From: Jim Evins Date: Mon, 9 May 2005 04:35:42 +0000 (+0000) Subject: 2005-05-09 Jim Evins X-Git-Tag: glabels-2_3_0~420 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6f2f4ee62487d346746d5fe8b8ed2801a72ce90b;p=glabels 2005-05-09 Jim Evins Replaced libbonoboui with GtkUIManager for creation of basic user interface menus and toolbars. * configure.in: * glabels.spec.in: Removed dependencies on libbonoboui. * data/Makefile.am: * data/ui/Makefile.am: * data/ui/glabels-ui.xml: Removed data/ui directory. * data/glade/Makefile.am: * data/property-bar.glade: Added glade description of property-bar for new libglade implementation of glUIPropertyBar. * src/Makefile.am: * src/commands.h: * src/commands.c: * src/tools.h: * src/tools.c: * src/ui-commands.h: * src/ui-commands.c: Replaced commands.[ch] and tools.[ch] with the single ui-commands.[ch] module since the distinction between "commands" and "tools" is no longer that clear. * src/file.h: * src/file.c: Modified to expect glWindow instead of GtkWindow. gl_file_open_recent() no longer has knowledge of eggRecent*. * src/glabels.c: (main): Removed libbonobo initialization and replaced bonobo_main loop with gtk_main loop. * src/object-editor.c: (gl_object_editor_init): Make sure notebook does not respond to a "show_all" on the parent. * src/recent-files/Makefile.am: * src/recent-files/*.[ch] Updated from latest version of libegg which now has a view based on GtkUIManager. Removed unused bonobo and gtk views. * src/ui-property-bar.h: * src/ui-property-bar.c: New implementation based on libglade. * src/ui-sidebar.h: * src/ui-sidebar.c: Sidebar is now simply a GtkWidget and does not expect to be a part of a libbonoboui interface. * src/ui-util.h: * src/ui-util.c: * src/ui.h: * src/ui.c: Converted for use with GtkUIManager. * src/window.h: * src/window.c: Now derived from GtkWindow instead of BonoboWindow and uses GtkUIManager to create menus and toolbars. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@529 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 2d012eca..9a52da82 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,58 @@ +2005-05-09 Jim Evins + + Replaced libbonoboui with GtkUIManager for creation of basic user interface menus + and toolbars. + + * configure.in: + * glabels.spec.in: + Removed dependencies on libbonoboui. + * data/Makefile.am: + * data/ui/Makefile.am: + * data/ui/glabels-ui.xml: + Removed data/ui directory. + * data/glade/Makefile.am: + * data/property-bar.glade: + Added glade description of property-bar for new libglade implementation + of glUIPropertyBar. + * src/Makefile.am: + * src/commands.h: + * src/commands.c: + * src/tools.h: + * src/tools.c: + * src/ui-commands.h: + * src/ui-commands.c: + Replaced commands.[ch] and tools.[ch] with the single ui-commands.[ch] module + since the distinction between "commands" and "tools" is no longer that clear. + * src/file.h: + * src/file.c: + Modified to expect glWindow instead of GtkWindow. gl_file_open_recent() + no longer has knowledge of eggRecent*. + * src/glabels.c: (main): + Removed libbonobo initialization and replaced bonobo_main loop with gtk_main + loop. + * src/object-editor.c: (gl_object_editor_init): + Make sure notebook does not respond to a "show_all" on the parent. + * src/recent-files/Makefile.am: + * src/recent-files/*.[ch] + Updated from latest version of libegg which now has a view based on + GtkUIManager. Removed unused bonobo and gtk views. + * src/ui-property-bar.h: + * src/ui-property-bar.c: + New implementation based on libglade. + * src/ui-sidebar.h: + * src/ui-sidebar.c: + Sidebar is now simply a GtkWidget and does not expect to be a part of + a libbonoboui interface. + * src/ui-util.h: + * src/ui-util.c: + * src/ui.h: + * src/ui.c: + Converted for use with GtkUIManager. + * src/window.h: + * src/window.c: + Now derived from GtkWindow instead of BonoboWindow and uses GtkUIManager + to create menus and toolbars. + 2005-04-25 Jim Evins * data/templates/misc-iso-templates.xml: diff --git a/glabels2/configure.in b/glabels2/configure.in index 08e3bd05..35375406 100644 --- a/glabels2/configure.in +++ b/glabels2/configure.in @@ -54,8 +54,6 @@ GLIB_REQUIRED=2.6.0 GTK_REQUIRED=2.6.0 LIBGNOME_REQUIRED=2.10.0 LIBGNOMEUI_REQUIRED=2.10.0 -LIBBONOBO_REQUIRED=2.8.0 -LIBBONOBOUI_REQUIRED=2.8.0 LIBXML_REQUIRED=2.6.0 LIBGNOMEPRINT_REQUIRED=2.10.0 LIBGNOMEPRINTUI_REQUIRED=2.10.0 @@ -67,8 +65,6 @@ AC_SUBST(GLIB_REQUIRED) AC_SUBST(GTK_REQUIRED) AC_SUBST(LIBGNOME_REQUIRED) AC_SUBST(LIBGNOMEUI_REQUIRED) -AC_SUBST(LIBBONOBO_REQUIRED) -AC_SUBST(LIBBONOBOUI_REQUIRED) AC_SUBST(LIBXML_REQUIRED) AC_SUBST(LIBGNOMEPRINT_REQUIRED) AC_SUBST(LIBGNOMEPRINTUI_REQUIRED) @@ -84,8 +80,6 @@ glib-2.0 >= $GLIB_REQUIRED \ gtk+-2.0 >= $GTK_REQUIRED \ libgnome-2.0 >= $LIBGNOME_REQUIRED \ libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED \ -libbonobo-2.0 >= $LIBBONOBO_REQUIRED \ -libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED \ libxml-2.0 >= $LIBXML_REQUIRED \ libgnomeprint-2.2 >= $LIBGNOMEPRINT_REQUIRED \ libgnomeprintui-2.2 >= $LIBGNOMEPRINTUI_REQUIRED \ @@ -167,7 +161,6 @@ data/Makefile data/templates/Makefile data/pixmaps/Makefile data/mime/Makefile -data/ui/Makefile data/glade/Makefile data/desktop/Makefile data/dtd/Makefile diff --git a/glabels2/data/Makefile.am b/glabels2/data/Makefile.am index 61130e8d..6b00c464 100644 --- a/glabels2/data/Makefile.am +++ b/glabels2/data/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = desktop dtd glade man mime pixmaps templates ui +SUBDIRS = desktop dtd glade man mime pixmaps templates diff --git a/glabels2/data/glade/Makefile.am b/glabels2/data/glade/Makefile.am index 5572e385..2a64fef8 100644 --- a/glabels2/data/glade/Makefile.am +++ b/glabels2/data/glade/Makefile.am @@ -6,7 +6,8 @@ glade_DATA = \ object-editor.glade \ prefs-dialog.glade \ template-designer.glade \ - merge-properties-dialog.glade + merge-properties-dialog.glade \ + property-bar.glade EXTRA_DIST = $(glade_DATA) diff --git a/glabels2/data/glade/property-bar.glade b/glabels2/data/glade/property-bar.glade new file mode 100644 index 00000000..53db5b71 --- /dev/null +++ b/glabels2/data/glade/property-bar.glade @@ -0,0 +1,376 @@ + + + + + + + True + window1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + True + + + + True + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_ICONS + True + False + + + + True + True + True + False + + + + True + Font family + True + False + + + + True + Font family + False + False + + + + + + + False + False + + + + + + True + True + True + False + + + + True + 0.5 + 0.5 + 1 + 1 + 0 + 0 + 6 + 0 + + + + True + Font size + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 1 250 1 10 10 + + + + + + + False + False + + + + + + True + True + True + True + + + False + False + + + + + + True + Bold + + True + gtk-bold + True + True + False + False + + + False + True + + + + + + True + Italic + + True + gtk-italic + True + True + False + False + + + False + True + + + + + + True + True + True + True + + + False + False + + + + + + True + Left align + + True + gtk-justify-left + True + True + False + False + + + False + True + + + + + + True + Center align + + True + gtk-justify-center + True + True + False + False + text_align_left_radio + + + False + True + + + + + + True + Right align + + True + gtk-justify-right + True + True + False + False + text_align_left_radio + + + False + True + + + + + + True + True + True + True + + + False + False + + + + + + True + True + True + False + + + + True + Text Color + True + False + + + + True + Text color + gl_ui_property_bar_construct_color_combo + 0 + 0 + Sun, 01 May 2005 15:21:11 GMT + + + + + + + False + False + + + + + + True + True + True + False + + + + True + Fill color + True + False + + + + True + Fill color + gl_ui_property_bar_construct_color_combo + 1 + 0 + Sun, 01 May 2005 15:21:18 GMT + + + + + + + False + False + + + + + + True + True + True + False + + + + True + Line color + True + False + + + + True + Line color + gl_ui_property_bar_construct_color_combo + 2 + 0 + Sun, 01 May 2005 15:21:24 GMT + + + + + + + False + False + + + + + + True + True + True + True + + + False + False + + + + + + True + True + True + False + + + + True + Line width + True + 1 + 2 + False + GTK_UPDATE_ALWAYS + False + False + 1 0.25 4 0.25 1 1 + + + + + False + False + + + + + + + diff --git a/glabels2/data/ui/Makefile.am b/glabels2/data/ui/Makefile.am deleted file mode 100644 index 1650d0c7..00000000 --- a/glabels2/data/ui/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -## Process this file with automake to produce Makefile.in - -uidir = $(datadir)/glabels/ui/ - -ui_DATA = glabels-ui.xml - -EXTRA_DIST = $(ui_DATA) diff --git a/glabels2/data/ui/glabels-ui.xml b/glabels2/data/ui/glabels-ui.xml deleted file mode 100644 index 1c5561af..00000000 --- a/glabels2/data/ui/glabels-ui.xml +++ /dev/null @@ -1,1040 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/glabels2/glabels.spec.in b/glabels2/glabels.spec.in index a7949d58..f454d0d9 100644 --- a/glabels2/glabels.spec.in +++ b/glabels2/glabels.spec.in @@ -13,7 +13,6 @@ Prefix: %{_prefix} BuildRequires: gtk2-devel >= @GTK_REQUIRED@ BuildRequires: libxml2-devel >= @LIBXML_REQUIRED@ BuildRequires: libgnomeui-devel >= @LIBGNOMEUI_REQUIRED@ -BuildRequires: libbonoboui-devel >= @LIBBONOBOUI_REQUIRED@ BuildRequires: libgnomecanvas-devel >= @LIBGNOMECANVAS_REQUIRED@ BuildRequires: libgnomeprintui22-devel >= @LIBGNOMEPRINT_REQUIRED@ BuildRequires: libglade2-devel >= @LIBGLADE_REQUIRED@ @@ -21,7 +20,6 @@ BuildRequires: libglade2-devel >= @LIBGLADE_REQUIRED@ Requires: gtk2 >= @GTK_REQUIRED@ Requires: libxml2 >= @LIBXML_REQUIRED@ Requires: libgnomeui >= @LIBGNOMEUI_REQUIRED@ -Requires: libbonoboui >= @LIBBONOBOUI_REQUIRED@ Requires: libgnomecanvas >= @LIBGNOMECANVAS_REQUIRED@ Requires: libgnomeprintui22 >= @LIBGNOMEPRINT_REQUIRED@ Requires: libglade2 >= @LIBGLADE_REQUIRED@ diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 106d39b2..5833c8ee 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -52,20 +52,18 @@ glabels_SOURCES = \ stock.h \ ui.h \ ui.c \ + ui-util.h \ + ui-util.c \ + ui-commands.h \ + ui-commands.c \ ui-property-bar.h \ ui-property-bar.c \ ui-sidebar.h \ ui-sidebar.c \ - ui-util.h \ - ui-util.c \ - commands.h \ - commands.c \ file.h \ file.c \ recent.h \ recent.c \ - tools.h \ - tools.c \ prefs.c \ prefs.h \ prefs-model.c \ diff --git a/glabels2/src/commands.c b/glabels2/src/commands.c deleted file mode 100644 index d8558fe9..00000000 --- a/glabels2/src/commands.c +++ /dev/null @@ -1,482 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * commands.c: GLabels commands module - * - * Copyright (C) 2001-2003 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "commands.h" - -#include -#include -#include -#include -#include - -#include "view.h" -#include "file.h" -#include "template-designer.h" -#include "print-dialog.h" -#include "prefs.h" -#include "prefs-dialog.h" -#include "debug.h" - -#define LOGO_PIXMAP gnome_program_locate_file (NULL,\ - GNOME_FILE_DOMAIN_APP_PIXMAP,\ - "glabels/glabels-about-logo.png",\ - FALSE, NULL) - - -/****************************************************************************/ -/* File->New command. */ -/****************************************************************************/ -void -gl_cmd_file_new (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - gl_file_new (GTK_WINDOW(window)); -} - -/****************************************************************************/ -/* File->Properties command. */ -/****************************************************************************/ -void -gl_cmd_file_properties (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - gl_file_properties (GL_VIEW(window->view)->label, GTK_WINDOW(window)); -} - -/****************************************************************************/ -/* File->Template Designer command. */ -/****************************************************************************/ -void -gl_cmd_file_template_designer (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - GtkWidget *dialog; - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - dialog = gl_template_designer_new (GTK_WINDOW(window)); - - gtk_widget_show (dialog); -} - -/****************************************************************************/ -/* File->Open command. */ -/****************************************************************************/ -void -gl_cmd_file_open (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_file_open (GTK_WINDOW(window)); -} - -/****************************************************************************/ -/* File->Save command. */ -/****************************************************************************/ -void -gl_cmd_file_save (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_file_save (GL_VIEW(window->view)->label, GTK_WINDOW(window)); -} - -/****************************************************************************/ -/* File->Save_as command. */ -/****************************************************************************/ -void -gl_cmd_file_save_as (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_file_save_as (GL_VIEW(window->view)->label, GTK_WINDOW(window)); -} - -/****************************************************************************/ -/* File->Print command. */ -/****************************************************************************/ -void -gl_cmd_file_print (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - if (GL_VIEW(window->view)->print_dialog) { - - gtk_window_present (GTK_WINDOW(GL_VIEW(window->view)->print_dialog)); - - } else { - - GL_VIEW(window->view)->print_dialog = - g_object_ref ( - gl_print_dialog_new (GL_VIEW(window->view)->label, - BONOBO_WINDOW(window)) ); - - gtk_widget_show (GL_VIEW(window->view)->print_dialog); - } - -} - -/****************************************************************************/ -/* File->Close command. */ -/****************************************************************************/ -void -gl_cmd_file_close (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_file_close (window); -} - -/****************************************************************************/ -/* File->Exit command. */ -/****************************************************************************/ -void -gl_cmd_file_exit (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_file_exit (); -} - - -/****************************************************************************/ -/* Edit->Cut command. */ -/****************************************************************************/ -void -gl_cmd_edit_cut (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_view_cut (GL_VIEW(window->view)); -} - -/****************************************************************************/ -/* Edit->Copy command. */ -/****************************************************************************/ -void -gl_cmd_edit_copy (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_view_copy (GL_VIEW(window->view)); -} - -/****************************************************************************/ -/* Edit->Paste command. */ -/****************************************************************************/ -void -gl_cmd_edit_paste (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_view_paste (GL_VIEW(window->view)); -} - - -/****************************************************************************/ -/* Edit->Delete command. */ -/****************************************************************************/ -void -gl_cmd_edit_delete (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_view_delete_selection (GL_VIEW(window->view)); -} - - -/****************************************************************************/ -/* Edit->Select_all command. */ -/****************************************************************************/ -void -gl_cmd_edit_select_all (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_view_select_all (GL_VIEW(window->view)); -} - -/****************************************************************************/ -/* Edit->Select_all command. */ -/****************************************************************************/ -void -gl_cmd_edit_unselect_all (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gl_view_unselect_all (GL_VIEW(window->view)); -} - -/****************************************************************************/ -/* Settings->Preferences command. */ -/****************************************************************************/ -void -gl_cmd_settings_preferences (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - static GtkWidget *dlg = NULL; - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - if (dlg != NULL) - { - gtk_window_present (GTK_WINDOW (dlg)); - gtk_window_set_transient_for (GTK_WINDOW (dlg), - GTK_WINDOW(window)); - - return; - } - - dlg = gl_prefs_dialog_new (GTK_WINDOW(window)); - - g_signal_connect (G_OBJECT (dlg), "destroy", - G_CALLBACK (gtk_widget_destroyed), &dlg); - - gtk_widget_show (dlg); -} - -/****************************************************************************/ -/* Help->Contents command. */ -/****************************************************************************/ -void -gl_cmd_help_contents (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - GError *error = NULL; - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error); - - if (error != NULL) - { - g_warning (error->message); - - g_error_free (error); - } -} - -/*--------------------------------------------------------------------------*/ -/* Private: URL handler. */ -/*--------------------------------------------------------------------------*/ -static void -activate_url (GtkAboutDialog *about, const gchar *url, gpointer data) -{ - gnome_url_show (url, NULL); -} - - -/****************************************************************************/ -/* Help->About command. */ -/****************************************************************************/ -void -gl_cmd_help_about (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window = GL_WINDOW (user_data); - - static GtkWidget *about = NULL; - - GdkPixbuf *pixbuf = NULL; - - const gchar *authors[] = { - "Jim Evins ", - " ", - "Frederic Ruaudel ", - "Wayne Schuller ", - "Emmanuel Pacaud ", - " ", - _("See the file AUTHORS for additional credits,"), - _("or visit http://glabels.sourceforge.net/"), - NULL - }; - - const gchar *artists[] = { - "Nestor Di ", - "Jim Evins ", - NULL - }; - - const gchar *copy_text = "Copyright \xc2\xa9 2001-2005 Jim Evins"; - - const gchar *about_text = _("A label and business card creation program.\n"); - - const gchar *url = "http://glabels.sourceforge.net"; - - const gchar *translator_credits = _("translator-credits"); - - const gchar *license = _( - "Glabels is free software; you can redistribute it and/or modify it\n" - "under the terms of the GNU General Public License as published by\n" - "the Free Software Foundation; either version 2 of the License, or\n" - "(at your option) any later version.\n" "\n" - "This program is distributed in the hope that it will be useful, but\n" - "WITHOUT ANY WARRANTY; without even the implied warranty of\n" - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See\n" - "the GNU General Public License for more details.\n"); - - gl_debug (DEBUG_COMMANDS, ""); - - g_return_if_fail (window && GL_IS_WINDOW(window)); - - if (about != NULL) - { - gtk_window_set_transient_for (GTK_WINDOW (about), - GTK_WINDOW (window)); - gtk_window_present (GTK_WINDOW (about)); - return; - } - - pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL); - - gtk_about_dialog_set_url_hook (activate_url, NULL, NULL); - - about = gtk_about_dialog_new (); - gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about), _("glabels")); - gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about), VERSION); - gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about), copy_text); - gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about), about_text); - gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), url); - gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG(about), pixbuf); - - gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors); - gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG(about), artists); - gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about), - translator_credits); - gtk_about_dialog_set_license (GTK_ABOUT_DIALOG(about), license); - - gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE); - - g_signal_connect (G_OBJECT (about), "response", - G_CALLBACK (gtk_widget_destroy), NULL); - g_signal_connect (G_OBJECT (about), "destroy", - G_CALLBACK (gtk_widget_destroyed), &about); - - gtk_window_set_transient_for (GTK_WINDOW (about), - GTK_WINDOW (window)); - - gtk_window_present (GTK_WINDOW (about)); - - if (pixbuf != NULL) - g_object_unref (pixbuf); - - -} - - diff --git a/glabels2/src/commands.h b/glabels2/src/commands.h deleted file mode 100644 index 1d199ca1..00000000 --- a/glabels2/src/commands.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * commands.h: GLabels commands module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __COMMANDS_H__ -#define __COMMANDS_H__ - -#include - -G_BEGIN_DECLS - -void gl_cmd_file_new (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_properties (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_template_designer (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_open (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_save (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_save_as (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_print (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_print_preview (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_close (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_file_exit (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - - -void gl_cmd_edit_undo (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_redo (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_cut (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_copy (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_paste (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_delete (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_select_all (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_edit_unselect_all (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - - -void gl_cmd_settings_preferences (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - - -void gl_cmd_help_contents (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_cmd_help_about (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); -G_END_DECLS - -#endif /* __COMMANDS_H__ */ diff --git a/glabels2/src/file.c b/glabels2/src/file.c index 958d66b1..56494e9d 100644 --- a/glabels2/src/file.c +++ b/glabels2/src/file.c @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * @@ -71,7 +73,7 @@ static void properties_response (GtkDialog *dlg, static void open_response (GtkDialog *chooser, gint response, - GtkWindow *window); + glWindow *window); static void save_as_response (GtkDialog *chooser, gint response, glLabel *label); @@ -81,7 +83,7 @@ static void save_as_response (GtkDialog *chooser, /* "New" menu callback. */ /*****************************************************************************/ void -gl_file_new (GtkWindow *window) +gl_file_new (glWindow *window) { GtkWidget *dlg; @@ -90,7 +92,7 @@ gl_file_new (GtkWindow *window) g_return_if_fail (window != NULL); dlg = gl_hig_dialog_new_with_buttons (_("New Label or Card"), - window, + GTK_WINDOW (window), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, @@ -249,7 +251,7 @@ new_response (GtkDialog *dlg, /*****************************************************************************/ void gl_file_properties (glLabel *label, - GtkWindow *window) + glWindow *window) { GtkWidget *dlg; @@ -259,7 +261,7 @@ gl_file_properties (glLabel *label, g_return_if_fail (window && GTK_IS_WINDOW (window)); dlg = gl_hig_dialog_new_with_buttons (_("Label properties"), - window, + GTK_WINDOW (window), GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, @@ -415,7 +417,7 @@ properties_response (GtkDialog *dlg, /* "Open" menu callback. */ /*****************************************************************************/ void -gl_file_open (GtkWindow *window) +gl_file_open (glWindow *window) { GtkWidget *chooser; GtkFileFilter *filter; @@ -425,7 +427,7 @@ gl_file_open (GtkWindow *window) g_return_if_fail (window != NULL); chooser = gtk_file_chooser_dialog_new ("Open label", - window, + GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, @@ -464,7 +466,7 @@ gl_file_open (GtkWindow *window) static void open_response (GtkDialog *chooser, gint response, - GtkWindow *window) + glWindow *window) { gchar *raw_filename; gchar *filename; @@ -540,26 +542,17 @@ open_response (GtkDialog *chooser, /*****************************************************************************/ /* "Open recent" menu callback. */ /*****************************************************************************/ -gboolean -gl_file_open_recent (EggRecentView *view, - EggRecentItem *item, - GtkWindow *window) +void +gl_file_open_recent (const gchar *filename, + glWindow *window) { - gboolean result = FALSE; - gchar *filename; - gl_debug (DEBUG_FILE, ""); - filename = gl_recent_get_filename (item); - if (filename) { gl_debug (DEBUG_FILE, "open recent: %s", filename); - result = gl_file_open_real (filename, window); - g_free (filename); + gl_file_open_real (filename, window); } - - return result; } /*---------------------------------------------------------------------------*/ @@ -567,7 +560,7 @@ gl_file_open_recent (EggRecentView *view, /*---------------------------------------------------------------------------*/ gboolean gl_file_open_real (const gchar *filename, - GtkWindow *window) + glWindow *window) { gchar *abs_filename; glLabel *label; @@ -589,7 +582,7 @@ gl_file_open_real (const gchar *filename, primary_msg = g_strdup_printf (_("Could not open file \"%s\""), filename); - dlg = gl_hig_alert_new (window, + dlg = gl_hig_alert_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -635,7 +628,7 @@ gl_file_open_real (const gchar *filename, /*****************************************************************************/ gboolean gl_file_save (glLabel *label, - GtkWindow *window) + glWindow *window) { glXMLLabelStatus status; GError *error = NULL; @@ -675,7 +668,7 @@ gl_file_save (glLabel *label, primary_msg = g_strdup_printf (_("Could not save file \"%s\""), filename); - dialog = gl_hig_alert_new (window, + dialog = gl_hig_alert_new (GTK_WINDOW (window), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, @@ -708,7 +701,7 @@ gl_file_save (glLabel *label, /*****************************************************************************/ gboolean gl_file_save_as (glLabel *label, - GtkWindow *window) + glWindow *window) { GtkWidget *chooser; GtkFileFilter *filter; @@ -718,14 +711,14 @@ gl_file_save_as (glLabel *label, gl_debug (DEBUG_FILE, "START"); g_return_val_if_fail (label && GL_IS_LABEL(label), FALSE); - g_return_val_if_fail (window && GTK_IS_WINDOW(window), FALSE); + g_return_val_if_fail (window && GL_IS_WINDOW(window), FALSE); name = gl_label_get_short_name (label); title = g_strdup_printf (_("Save \"%s\" as"), name); g_free (name); chooser = gtk_file_chooser_dialog_new (title, - window, + GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, @@ -963,8 +956,7 @@ gl_file_close (glWindow *window) switch (ret) { case GTK_RESPONSE_YES: - close = gl_file_save (label, - GTK_WINDOW(window)); + close = gl_file_save (label, window); break; case GTK_RESPONSE_NO: close = TRUE; @@ -985,7 +977,7 @@ gl_file_close (glWindow *window) gl_debug (DEBUG_FILE, "All windows closed."); - bonobo_main_quit (); + gtk_main_quit (); } } diff --git a/glabels2/src/file.h b/glabels2/src/file.h index 01c5d86e..7d5fb7a0 100644 --- a/glabels2/src/file.h +++ b/glabels2/src/file.h @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * @@ -23,7 +25,6 @@ #ifndef __FILE_H__ #define __FILE_H__ -#include "recent-files/egg-recent-view.h" #include #include "label.h" @@ -31,29 +32,28 @@ G_BEGIN_DECLS -void gl_file_new (GtkWindow *window); +void gl_file_new (glWindow *window); void gl_file_properties (glLabel *label, - GtkWindow *window); + glWindow *window); -void gl_file_open (GtkWindow *window); +void gl_file_open (glWindow *window); -gboolean gl_file_open_recent (EggRecentView *view, - EggRecentItem *filename, - GtkWindow *window);; +void gl_file_open_recent (const gchar *filename, + glWindow *window); gboolean gl_file_open_real (const gchar *filename, - GtkWindow *window); + glWindow *window); gboolean gl_file_save (glLabel *label, - GtkWindow *window); + glWindow *window); gboolean gl_file_save_as (glLabel *label, - GtkWindow *window); + glWindow *window); gboolean gl_file_close (glWindow *window); diff --git a/glabels2/src/glabels.c b/glabels2/src/glabels.c index f241841e..7461047c 100644 --- a/glabels2/src/glabels.c +++ b/glabels2/src/glabels.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * glabels.c: GLabels main module @@ -26,7 +28,6 @@ #include #include #include -#include #include "splash.h" #include "stock.h" @@ -113,10 +114,6 @@ main (int argc, char **argv) gl_merge_init (); gl_recent_init (); - if (!bonobo_ui_init ("glabels", VERSION, &argc, argv)) { - g_error (_("Could not initialize Bonobo!\n")); - } - client = gnome_master_client(); g_signal_connect (G_OBJECT (client), "save_yourself", @@ -154,7 +151,7 @@ main (int argc, char **argv) /* Begin main loop */ - bonobo_main(); + gtk_main(); return 0; } diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index cfc67c75..d9eb2989 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * object-editor.c: object properties editor module @@ -171,6 +173,7 @@ gl_object_editor_init (glObjectEditor *editor) /* Hide all notebook pages to start with. */ gtk_widget_hide_all (editor->priv->notebook); + gtk_widget_set_no_show_all (editor->priv->notebook, TRUE); gl_debug (DEBUG_EDITOR, "END"); } diff --git a/glabels2/src/recent-files/Makefile.am b/glabels2/src/recent-files/Makefile.am index fc33632b..bb0cec19 100644 --- a/glabels2/src/recent-files/Makefile.am +++ b/glabels2/src/recent-files/Makefile.am @@ -10,12 +10,10 @@ EGG_FILES = \ egg-recent-model.h \ egg-recent-util.c \ egg-recent-util.h \ - egg-recent-view-bonobo.c \ - egg-recent-view-bonobo.h \ egg-recent-view.c \ egg-recent-view.h \ - egg-recent-view-gtk.c \ - egg-recent-view-gtk.h + egg-recent-view-uimanager.c \ + egg-recent-view-uimanager.h noinst_LTLIBRARIES = librecent.la diff --git a/glabels2/src/recent-files/egg-recent-item.c b/glabels2/src/recent-files/egg-recent-item.c index e61c1f81..535e2227 100644 --- a/glabels2/src/recent-files/egg-recent-item.c +++ b/glabels2/src/recent-files/egg-recent-item.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** +/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the @@ -39,6 +39,7 @@ egg_recent_item_new (void) item->private_data = FALSE; item->uri = NULL; item->mime_type = NULL; + item->mime_type_is_explicit = FALSE; item->refcount = 1; @@ -97,11 +98,6 @@ egg_recent_item_new_from_uri (const gchar *uri) return NULL; } - item->mime_type = gnome_vfs_get_mime_type (item->uri); - - if (!item->mime_type) - item->mime_type = g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN); - return item; } @@ -132,6 +128,7 @@ egg_recent_item_copy (const EggRecentItem *item) newitem->uri = g_strdup (item->uri); if (item->mime_type) newitem->mime_type = g_strdup (item->mime_type); + newitem->mime_type_is_explicit = item->mime_type_is_explicit newitem->timestamp = item->timestamp; newitem->private_data = item->private_data; newitem->groups = egg_recent_item_copy_groups (item->groups); @@ -182,6 +179,21 @@ egg_recent_item_new_valist (const gchar *uri, va_list args) } */ +static void +egg_recent_item_update_mime_type (EggRecentItem *item) +{ + if (!item->mime_type_is_explicit) { + g_free (item->mime_type); + item->mime_type = NULL; + + if (item->uri) + item->mime_type = gnome_vfs_get_mime_type (item->uri); + + if (!item->mime_type) + item->mime_type = g_strdup (GNOME_VFS_MIME_TYPE_UNKNOWN); + } +} + gboolean egg_recent_item_set_uri (EggRecentItem *item, const gchar *uri) { @@ -248,7 +260,7 @@ make_valid_utf8 (const char *name) string = NULL; remainder = name; - remaining_bytes = strlen (name); + remaining_bytes = name ? strlen (name) : 0; while (remaining_bytes != 0) { if (g_utf8_validate (remainder, remaining_bytes, &invalid)) @@ -300,7 +312,8 @@ egg_recent_item_get_short_name (const EggRecentItem *item) return NULL; uri = gnome_vfs_uri_new (item->uri); - g_assert (uri != NULL); /* We already checked this in egg_recent_item_set_uri() */ + if (uri == NULL) + return NULL; short_name = gnome_vfs_uri_extract_short_name (uri); valid = FALSE; @@ -325,7 +338,7 @@ egg_recent_item_get_short_name (const EggRecentItem *item) short_name = tmp; } - g_free (uri); + gnome_vfs_uri_unref (uri); return short_name; } @@ -333,12 +346,22 @@ egg_recent_item_get_short_name (const EggRecentItem *item) void egg_recent_item_set_mime_type (EggRecentItem *item, const gchar *mime) { - item->mime_type = g_strdup (mime); + g_free (item->mime_type); + item->mime_type = NULL; + + if (mime && mime[0]) { + item->mime_type_is_explicit = TRUE; + item->mime_type = g_strdup (mime); + } else { + item->mime_type_is_explicit = FALSE; + } } gchar * -egg_recent_item_get_mime_type (const EggRecentItem *item) +egg_recent_item_get_mime_type (EggRecentItem *item) { + egg_recent_item_update_mime_type (item); + return g_strdup (item->mime_type); } diff --git a/glabels2/src/recent-files/egg-recent-item.h b/glabels2/src/recent-files/egg-recent-item.h index 5b3b405c..00f8fb84 100644 --- a/glabels2/src/recent-files/egg-recent-item.h +++ b/glabels2/src/recent-files/egg-recent-item.h @@ -27,6 +27,8 @@ struct _EggRecentItem { GList *groups; int refcount; + + guint mime_type_is_explicit : 1; }; GType egg_recent_item_get_type (void) G_GNUC_CONST; @@ -47,7 +49,7 @@ gchar * egg_recent_item_get_uri_for_display (const EggRecentItem *item); gchar * egg_recent_item_get_short_name (const EggRecentItem *item); void egg_recent_item_set_mime_type (EggRecentItem *item, const gchar *mime); -gchar * egg_recent_item_get_mime_type (const EggRecentItem *item); +gchar * egg_recent_item_get_mime_type (EggRecentItem *item); void egg_recent_item_set_timestamp (EggRecentItem *item, time_t timestamp); time_t egg_recent_item_get_timestamp (const EggRecentItem *item); diff --git a/glabels2/src/recent-files/egg-recent-model.c b/glabels2/src/recent-files/egg-recent-model.c index d5079492..201aec00 100644 --- a/glabels2/src/recent-files/egg-recent-model.c +++ b/glabels2/src/recent-files/egg-recent-model.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** +/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the @@ -677,12 +677,17 @@ static void egg_recent_model_monitor (EggRecentModel *model, gboolean should_monitor) { if (should_monitor && model->priv->monitor == NULL) { + char *uri; + + uri = gnome_vfs_get_uri_from_local_path (model->priv->path); gnome_vfs_monitor_add (&model->priv->monitor, - model->priv->path, - GNOME_VFS_MONITOR_FILE, - egg_recent_model_monitor_cb, - model); + uri, + GNOME_VFS_MONITOR_FILE, + egg_recent_model_monitor_cb, + model); + + g_free (uri); /* if the above fails, don't worry about it. * local notifications will still happen @@ -857,14 +862,17 @@ static FILE * egg_recent_model_open_file (EggRecentModel *model) { FILE *file; + mode_t prev_umask; file = fopen (model->priv->path, "r+"); if (file == NULL) { /* be paranoid */ - umask (077); + prev_umask = umask (077); file = fopen (model->priv->path, "w+"); + umask (prev_umask); + g_return_val_if_fail (file != NULL, NULL); } @@ -1283,6 +1291,7 @@ egg_recent_model_add_full (EggRecentModel * model, EggRecentItem *item) ret = TRUE; } else { g_warning ("Failed to lock: %s", strerror (errno)); + fclose (file); return FALSE; } diff --git a/glabels2/src/recent-files/egg-recent-util.c b/glabels2/src/recent-files/egg-recent-util.c index cb30e053..6780cd1e 100644 --- a/glabels2/src/recent-files/egg-recent-util.c +++ b/glabels2/src/recent-files/egg-recent-util.c @@ -54,51 +54,32 @@ egg_recent_util_escape_underlines (const gchar* text) } #ifndef USE_STABLE_LIBGNOMEUI -static GdkPixbuf * -scale_icon (GdkPixbuf *pixbuf, - double *scale) -{ - guint width, height; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - - width = floor (width * *scale + 0.5); - height = floor (height * *scale + 0.5); - - return gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR); -} - static GdkPixbuf * load_icon_file (char *filename, - guint base_size, guint nominal_size) { GdkPixbuf *pixbuf, *scaled_pixbuf; - guint width, height, size; - double scale; + guint width, height; - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + pixbuf = gdk_pixbuf_new_from_file_at_size (filename, nominal_size, nominal_size, NULL); if (pixbuf == NULL) { return NULL; } - if (base_size == 0) { - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - size = MAX (width, height); - if (size > nominal_size) { - base_size = size; + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + /* if the icon is larger than the nominal size, scale down */ + if (MAX (width, height) > nominal_size) { + if (width > height) { + height = height * nominal_size / width; + width = nominal_size; } else { - /* Don't scale up small icons */ - base_size = nominal_size; + width = width * nominal_size / height; + height = nominal_size; } - } - - if (base_size != nominal_size) { - scale = (double)nominal_size/base_size; - scaled_pixbuf = scale_icon (pixbuf, &scale); + scaled_pixbuf = gdk_pixbuf_scale_simple + (pixbuf, width, height, GDK_INTERP_BILINEAR); g_object_unref (pixbuf); pixbuf = scaled_pixbuf; } @@ -113,7 +94,6 @@ egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri, gchar *icon; gchar *filename; const GnomeIconData *icon_data; - int base_size; GdkPixbuf *pixbuf; icon = gnome_icon_lookup (theme, NULL, uri, NULL, NULL, @@ -125,14 +105,14 @@ egg_recent_util_get_icon (GnomeIconTheme *theme, const gchar *uri, filename = gnome_icon_theme_lookup_icon (theme, icon, size, &icon_data, - &base_size); + NULL); g_free (icon); if (filename == NULL) { return NULL; } - pixbuf = load_icon_file (filename, base_size, size); + pixbuf = load_icon_file (filename, size); g_free (filename); diff --git a/glabels2/src/recent-files/egg-recent-view-bonobo.c b/glabels2/src/recent-files/egg-recent-view-bonobo.c deleted file mode 100644 index e728e702..00000000 --- a/glabels2/src/recent-files/egg-recent-view-bonobo.c +++ /dev/null @@ -1,714 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - * - * Authors: - * James Willcox - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#ifndef USE_STABLE_LIBGNOMEUI -#include -#endif -#include -#include "egg-recent-model.h" -#include "egg-recent-view.h" -#include "egg-recent-view-bonobo.h" -#include "egg-recent-util.h" -#include "egg-recent-item.h" - -struct _EggRecentViewBonobo { - GObject parent_instance; /* We emit signals */ - - BonoboUIComponent *uic; - gchar *path; /* The menu path where our stuff - * will go - */ - - gulong changed_cb_id; - - gchar *uid; /* unique id used for the verb name */ - - gboolean show_icons; - gboolean show_numbers; -#ifndef USE_STABLE_LIBGNOMEUI - GnomeIconTheme *theme; -#endif - EggRecentViewBonoboTooltipFunc tooltip_func; - gpointer tooltip_func_data; - - EggRecentModel *model; - GConfClient *client; - GtkIconSize icon_size; -}; - - -struct _EggRecentViewBonoboMenuData { - EggRecentViewBonobo *view; - EggRecentItem *item; -}; - -typedef struct _EggRecentViewBonoboMenuData EggRecentViewBonoboMenuData; - -enum { - ACTIVATE, - LAST_SIGNAL -}; - -/* GObject properties */ -enum { - PROP_BOGUS, - PROP_UI_COMPONENT, - PROP_MENU_PATH, - PROP_SHOW_ICONS, - PROP_SHOW_NUMBERS -}; - -static guint egg_recent_view_bonobo_signals[LAST_SIGNAL] = { 0 }; - -static void -egg_recent_view_bonobo_clear (EggRecentViewBonobo *view) -{ - gint i=1; - gboolean done=FALSE; - EggRecentModel *model; - - g_return_if_fail (view->uic); - - model = egg_recent_view_get_model (EGG_RECENT_VIEW (view)); - - while (!done) - { - gchar *verb_name = g_strdup_printf ("%s-%d", view->uid, i); - gchar *item_path = g_strconcat (view->path, "/", verb_name, NULL); - if (bonobo_ui_component_path_exists (view->uic, item_path, NULL)) - bonobo_ui_component_rm (view->uic, item_path, NULL); - else - done=TRUE; - - g_free (item_path); - g_free (verb_name); - - i++; - } -} - -static void -egg_recent_view_bonobo_menu_cb (BonoboUIComponent *uic, gpointer data, const char *cname) -{ - EggRecentViewBonoboMenuData *md = (EggRecentViewBonoboMenuData *) data; - EggRecentItem *item; - - g_return_if_fail (md); - g_return_if_fail (md->item); - g_return_if_fail (md->view); - g_return_if_fail (EGG_IS_RECENT_VIEW_BONOBO (md->view)); - - item = md->item; - egg_recent_item_ref (item); - - g_signal_emit (G_OBJECT(md->view), - egg_recent_view_bonobo_signals[ACTIVATE], 0, - item); - - egg_recent_item_unref (item); -} - -static void -egg_recent_view_bonobo_menu_data_destroy_cb (gpointer data, GClosure *closure) -{ - EggRecentViewBonoboMenuData *md = data; - - egg_recent_item_unref (md->item); - g_free (md); -} - - -static void -egg_recent_view_bonobo_set_list (EggRecentViewBonobo *view, GList *list) -{ - BonoboUIComponent* ui_component; - unsigned int i; - gchar *label = NULL; - gchar *verb_name = NULL; - gchar *tip = NULL; - gchar *escaped_name = NULL; - gchar *item_path = NULL; - gchar *base_uri; - gchar *utf8_uri; - gchar *cmd; - gchar *xml_escaped_name; - EggRecentViewBonoboMenuData *md; - EggRecentModel *model; - GClosure *closure; - - g_return_if_fail (view); - - ui_component = view->uic; - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - - model = egg_recent_view_get_model (EGG_RECENT_VIEW (view)); - - egg_recent_view_bonobo_clear (view); - - - bonobo_ui_component_freeze (ui_component, NULL); - - for (i = 1; i <= g_list_length (list); ++i) - { - EggRecentItem *item = (EggRecentItem *)g_list_nth_data (list, i-1); - - utf8_uri = egg_recent_item_get_uri_for_display (item); - if (utf8_uri == NULL) - continue; - - /* this is what gets passed to our private "activate" callback */ - md = (EggRecentViewBonoboMenuData *)g_malloc (sizeof (EggRecentViewBonoboMenuData)); - md->view = view; - md->item = item; - - egg_recent_item_ref (md->item); - - base_uri = g_path_get_basename (utf8_uri); - xml_escaped_name = g_markup_escape_text (base_uri, - strlen (base_uri)); - - escaped_name = egg_recent_util_escape_underlines (xml_escaped_name); - g_free (xml_escaped_name); - - tip = NULL; - if (view->tooltip_func != NULL) { - gchar *tmp_tip; - tip = view->tooltip_func (item, - view->tooltip_func_data); - tmp_tip = g_markup_escape_text (tip, strlen (tip)); - g_free (tip); - tip = tmp_tip; - } - - if (tip == NULL) - tip = g_strdup (""); - - verb_name = g_strdup_printf ("%s-%d", view->uid, i); - - if (view->show_icons) { - GdkPixbuf *pixbuf; - gchar *mime_type; - gchar *uri; - - mime_type = egg_recent_item_get_mime_type (item); - uri = egg_recent_item_get_uri (item); -#ifndef USE_STABLE_LIBGNOMEUI - { - int width, height; - - gtk_icon_size_lookup_for_settings - (gtk_settings_get_default (), - view->icon_size, - &width, &height); - pixbuf = egg_recent_util_get_icon - (view->theme, - uri, mime_type, - height); - } -#else - pixbuf = NULL; -#endif - - - if (pixbuf != NULL) { - gchar *pixbuf_xml; - - /* Riiiiight.... */ - pixbuf_xml = bonobo_ui_util_pixbuf_to_xml (pixbuf); - - cmd = g_strdup_printf ("", verb_name, pixbuf_xml); - - g_free (pixbuf_xml); - g_object_unref (pixbuf); - } else { - cmd = g_strdup_printf (" ", - verb_name); - } - - g_free (mime_type); - g_free (uri); - } else - cmd = g_strdup_printf (" ", - verb_name); - bonobo_ui_component_set_translate (ui_component, "/commands/", cmd, NULL); - - closure = g_cclosure_new (G_CALLBACK (egg_recent_view_bonobo_menu_cb), - md, egg_recent_view_bonobo_menu_data_destroy_cb); - - bonobo_ui_component_add_verb_full (ui_component, verb_name, - closure); - - if (view->show_numbers) { - if (i < 10) - label = g_strdup_printf ("_%d. %s", i, - escaped_name); - else - label = g_strdup_printf ("%d. %s", i, escaped_name); - } else { - label = g_strdup (escaped_name); - } - - - - item_path = g_strconcat (view->path, "/", verb_name, NULL); - - if (bonobo_ui_component_path_exists (ui_component, item_path, NULL)) - { - bonobo_ui_component_set_prop (ui_component, item_path, - "label", label, NULL); - - bonobo_ui_component_set_prop (ui_component, item_path, - "tip", tip, NULL); - } - else - { - gchar *xml; - - xml = g_strdup_printf ("", - verb_name, verb_name, label, - tip); - - bonobo_ui_component_set_translate (ui_component, view->path, xml, NULL); - - g_free (xml); - } - - g_free (label); - g_free (verb_name); - g_free (tip); - g_free (escaped_name); - g_free (item_path); - g_free (utf8_uri); - g_free (base_uri); - g_free (cmd); - - } - - - bonobo_ui_component_thaw (ui_component, NULL); -} - -static void -model_changed_cb (EggRecentModel *model, GList *list, EggRecentViewBonobo *view) -{ - if (list != NULL) - egg_recent_view_bonobo_set_list (view, list); - else - egg_recent_view_bonobo_clear (view); -} - - -static EggRecentModel * -egg_recent_view_bonobo_get_model (EggRecentView *view_parent) -{ - EggRecentViewBonobo *view; - - g_return_val_if_fail (view_parent, NULL); - view = EGG_RECENT_VIEW_BONOBO (view_parent); - - return view->model; -} - -static void -egg_recent_view_bonobo_set_model (EggRecentView *view_parent, EggRecentModel *model) -{ - EggRecentViewBonobo *view; - - g_return_if_fail (view_parent); - view = EGG_RECENT_VIEW_BONOBO (view_parent); - - if (view->model) - g_signal_handler_disconnect (G_OBJECT (view->model), - view->changed_cb_id); - - view->model = model; - g_object_ref (view->model); - view->changed_cb_id = g_signal_connect_object (G_OBJECT (model), - "changed", - G_CALLBACK (model_changed_cb), - view, 0); - - egg_recent_model_changed (view->model); -} - -static void -egg_recent_view_bonobo_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EggRecentViewBonobo *view = EGG_RECENT_VIEW_BONOBO (object); - - switch (prop_id) - { - case PROP_UI_COMPONENT: - egg_recent_view_bonobo_set_ui_component (EGG_RECENT_VIEW_BONOBO (view), - BONOBO_UI_COMPONENT (g_value_get_object (value))); - break; - case PROP_MENU_PATH: - view->path = g_strdup (g_value_get_string (value)); - break; - case PROP_SHOW_ICONS: - egg_recent_view_bonobo_show_icons (view, - g_value_get_boolean (value)); - default: - case PROP_SHOW_NUMBERS: - egg_recent_view_bonobo_show_numbers (view, - g_value_get_boolean (value)); - break; - break; - } -} - -static void -egg_recent_view_bonobo_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EggRecentViewBonobo *view = EGG_RECENT_VIEW_BONOBO (object); - - switch (prop_id) - { - case PROP_UI_COMPONENT: - g_value_set_pointer (value, view->uic); - break; - case PROP_MENU_PATH: - g_value_set_string (value, g_strdup (view->path)); - break; - case PROP_SHOW_ICONS: - g_value_set_boolean (value, view->show_icons); - break; - case PROP_SHOW_NUMBERS: - g_value_set_boolean (value, view->show_numbers); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -egg_recent_view_bonobo_finalize (GObject *object) -{ - EggRecentViewBonobo *view = EGG_RECENT_VIEW_BONOBO (object); - - g_free (view->path); - g_free (view->uid); - - g_object_unref (view->model); - g_object_unref (view->uic); -#ifndef USE_STABLE_LIBGNOMEUI - g_object_unref (view->theme); -#endif - g_object_unref (view->client); -} - -static void -egg_recent_view_bonobo_class_init (EggRecentViewBonoboClass * klass) -{ - GObjectClass *object_class; - - - object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = egg_recent_view_bonobo_set_property; - object_class->get_property = egg_recent_view_bonobo_get_property; - object_class->finalize = egg_recent_view_bonobo_finalize; - - egg_recent_view_bonobo_signals[ACTIVATE] = g_signal_new ("activate", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggRecentViewBonoboClass, activate), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - EGG_TYPE_RECENT_ITEM); - - g_object_class_install_property (object_class, - PROP_UI_COMPONENT, - g_param_spec_object ("ui-component", - "UI Component", - "BonoboUIComponent for menus.", - bonobo_ui_component_get_type(), - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_MENU_PATH, - g_param_spec_string ("ui-path", - "Path", - "The path to put the menu items.", - "/menus/File/EggRecentDocuments", - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_SHOW_ICONS, - g_param_spec_boolean ("show-icons", - "Show Icons", - "Whether or not to show icons", - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_SHOW_NUMBERS, - g_param_spec_boolean ("show-numbers", - "Show Numbers", - "Whether or not to show numbers", - TRUE, - G_PARAM_READWRITE)); - - - - klass->activate = NULL; -} - -static void -egg_recent_view_init (EggRecentViewClass *iface) -{ - iface->do_get_model = egg_recent_view_bonobo_get_model; - iface->do_set_model = egg_recent_view_bonobo_set_model; -} - -static void -show_menus_changed_cb (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EggRecentViewBonobo *view) -{ - GConfValue *value; - - value = gconf_entry_get_value (entry); - - g_return_if_fail (value->type == GCONF_VALUE_BOOL); - - egg_recent_view_bonobo_show_icons (view, - gconf_value_get_bool (value)); - -} - -#ifndef USE_STABLE_LIBGNOMEUI -static void -theme_changed_cb (GnomeIconTheme *theme, EggRecentViewBonobo *view) -{ - if (view->model != NULL) - egg_recent_model_changed (view->model); -} -#endif - -static void -egg_recent_view_bonobo_init (EggRecentViewBonobo *view) -{ - view->uid = egg_recent_util_get_unique_id (); -#ifndef USE_STABLE_LIBGNOMEUI - view->theme = gnome_icon_theme_new (); - gnome_icon_theme_set_allow_svg (view->theme, TRUE); - g_signal_connect_object (view->theme, "changed", - G_CALLBACK (theme_changed_cb), view, 0); -#endif - - view->client = gconf_client_get_default (); - view->show_icons = - gconf_client_get_bool (view->client, - "/desktop/gnome/interface/menus_have_icons", - NULL); - - gconf_client_add_dir (view->client, "/desktop/gnome/interface", - GCONF_CLIENT_PRELOAD_NONE, - NULL); - gconf_client_notify_add (view->client, - "/desktop/gnome/interface/menus_have_icons", - (GConfClientNotifyFunc)show_menus_changed_cb, - view, NULL, NULL); - - view->tooltip_func = NULL; - view->tooltip_func_data = NULL; - - view->icon_size = GTK_ICON_SIZE_MENU; -} - -void -egg_recent_view_bonobo_set_icon_size (EggRecentViewBonobo *view, - GtkIconSize icon_size) -{ - if (view->icon_size != icon_size) { - view->icon_size = icon_size; - egg_recent_model_changed (view->model); - } else { - view->icon_size = icon_size; - } -} - -GtkIconSize -egg_recent_view_bonobo_get_icon_size (EggRecentViewBonobo *view) -{ - return view->icon_size; -} - -void -egg_recent_view_bonobo_show_icons (EggRecentViewBonobo *view, gboolean show) -{ - view->show_icons = show; - - if (view->model) - egg_recent_model_changed (view->model); -} - -void -egg_recent_view_bonobo_show_numbers (EggRecentViewBonobo *view, gboolean show) -{ - view->show_numbers = show; - - if (view->model) - egg_recent_model_changed (view->model); -} - -void -egg_recent_view_bonobo_set_ui_component (EggRecentViewBonobo *view, BonoboUIComponent *uic) -{ - g_return_if_fail (view); - g_return_if_fail (uic); - - view->uic = uic; - - g_object_ref (view->uic); -} - -void -egg_recent_view_bonobo_set_ui_path (EggRecentViewBonobo *view, const gchar *path) -{ - g_return_if_fail (view); - g_return_if_fail (path); - - view->path = g_strdup (path); -} - -const BonoboUIComponent * -egg_recent_view_bonobo_get_ui_component (EggRecentViewBonobo *view) -{ - g_return_val_if_fail (view, NULL); - - return view->uic; -} - -gchar * -egg_recent_view_bonobo_get_ui_path (EggRecentViewBonobo *view) -{ - g_return_val_if_fail (view, NULL); - - return g_strdup (view->path); -} - -void -egg_recent_view_bonobo_set_tooltip_func (EggRecentViewBonobo *view, - EggRecentViewBonoboTooltipFunc func, - gpointer user_data) -{ - view->tooltip_func = func; - view->tooltip_func_data = user_data; - - if (view->model) - egg_recent_model_changed (view->model); -} - -/** - * egg_recent_view_bonobo_new: - * @appname: The name of your application. - * @limit: The maximum number of items allowed. - * - * This creates a new EggRecentViewBonobo object. - * - * Returns: a EggRecentViewBonobo object - */ -EggRecentViewBonobo * -egg_recent_view_bonobo_new (BonoboUIComponent *uic, const gchar *path) -{ - EggRecentViewBonobo *view; - - g_return_val_if_fail (uic, NULL); - g_return_val_if_fail (path, NULL); - - view = EGG_RECENT_VIEW_BONOBO (g_object_new (egg_recent_view_bonobo_get_type (), - "ui-path", path, - "ui-component", uic, - "show-icons", FALSE, - "show-numbers", TRUE, NULL)); - - g_return_val_if_fail (view, NULL); - - return view; -} - -/** - * egg_recent_view_bonobo_get_type: - * @: - * - * This returns a GType representing a EggRecentViewBonobo object. - * - * Returns: a GType - */ -GType -egg_recent_view_bonobo_get_type (void) -{ - static GType egg_recent_view_bonobo_type = 0; - - if(!egg_recent_view_bonobo_type) { - static const GTypeInfo egg_recent_view_bonobo_info = { - sizeof (EggRecentViewBonoboClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc)egg_recent_view_bonobo_class_init, /* class init */ - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EggRecentViewBonobo), - 0, - (GInstanceInitFunc) egg_recent_view_bonobo_init - }; - - static const GInterfaceInfo view_info = - { - (GInterfaceInitFunc) egg_recent_view_init, - NULL, - NULL - }; - - egg_recent_view_bonobo_type = g_type_register_static (G_TYPE_OBJECT, - "EggRecentViewBonobo", - &egg_recent_view_bonobo_info, 0); - g_type_add_interface_static (egg_recent_view_bonobo_type, - EGG_TYPE_RECENT_VIEW, - &view_info); - } - - return egg_recent_view_bonobo_type; -} - diff --git a/glabels2/src/recent-files/egg-recent-view-bonobo.h b/glabels2/src/recent-files/egg-recent-view-bonobo.h deleted file mode 100644 index 0b283ef7..00000000 --- a/glabels2/src/recent-files/egg-recent-view-bonobo.h +++ /dev/null @@ -1,58 +0,0 @@ -/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef __EGG_RECENT_VIEW_BONOBO_H__ -#define __EGG_RECENT_VIEW_BONOBO_H__ - -#include - -G_BEGIN_DECLS - -#define EGG_RECENT_VIEW_BONOBO(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, egg_recent_view_bonobo_get_type (), EggRecentViewBonobo) -#define EGG_RECENT_VIEW_BONOBO_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, egg_recent_view_bonobo_get_type (), EggRecentViewBonoboClass) -#define EGG_IS_RECENT_VIEW_BONOBO(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, egg_recent_view_bonobo_get_type ()) - -typedef char *(*EggRecentViewBonoboTooltipFunc) (EggRecentItem *item, - gpointer user_data); - -typedef struct _EggRecentViewBonobo EggRecentViewBonobo; - -typedef struct _EggRecentViewBonoboClass EggRecentViewBonoboClass; - -struct _EggRecentViewBonoboClass { - GObjectClass parent_class; - - void (*activate) (EggRecentViewBonobo *view, EggRecentItem *item); -}; - -GType egg_recent_view_bonobo_get_type (void); - -EggRecentViewBonobo * egg_recent_view_bonobo_new (BonoboUIComponent *uic, - const gchar *path); - - -void egg_recent_view_bonobo_set_ui_component (EggRecentViewBonobo *view, - BonoboUIComponent *uic); - -void egg_recent_view_bonobo_set_ui_path (EggRecentViewBonobo *view, - const gchar *path); - -gchar * egg_recent_view_bonobo_get_ui_path (EggRecentViewBonobo *view); -const BonoboUIComponent *egg_recent_view_bonobo_get_ui_component (EggRecentViewBonobo *view); - -void egg_recent_view_bonobo_show_icons (EggRecentViewBonobo *view, - gboolean show); - -void egg_recent_view_bonobo_show_numbers (EggRecentViewBonobo *view, - gboolean show); - -void egg_recent_view_bonobo_set_tooltip_func (EggRecentViewBonobo *view, - EggRecentViewBonoboTooltipFunc func, - gpointer user_data); - -void egg_recent_view_bonobo_set_icon_size (EggRecentViewBonobo *view, - GtkIconSize icon_size); - -GtkIconSize egg_recent_view_bonobo_get_icon_size (EggRecentViewBonobo *view); - -G_END_DECLS - -#endif /* __EGG_RECENT_VIEW_BONOBO_H__ */ diff --git a/glabels2/src/recent-files/egg-recent-view-gtk.c b/glabels2/src/recent-files/egg-recent-view-gtk.c deleted file mode 100644 index 6e6bac0a..00000000 --- a/glabels2/src/recent-files/egg-recent-view-gtk.c +++ /dev/null @@ -1,800 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. - * - * Authors: - * James Willcox - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include -#include -#include -#ifndef USE_STABLE_LIBGNOMEUI -#include -#endif -#include -#include "egg-recent-model.h" -#include "egg-recent-view.h" -#include "egg-recent-view-gtk.h" -#include "egg-recent-util.h" -#include "egg-recent-item.h" - -struct _EggRecentViewGtk { - GObject parent_instance; /* We emit signals */ - - GtkWidget *menu; - GtkWidget *start_menu_item; - - gboolean leading_sep; - gboolean trailing_sep; - - gulong changed_cb_id; - - gchar *uid; - - gboolean show_icons; - gboolean show_numbers; -#ifndef USE_STABLE_LIBGNOMEUI - GnomeIconTheme *theme; -#endif - - GtkTooltips *tooltips; - EggRecentViewGtkTooltipFunc tooltip_func; - gpointer tooltip_func_data; - - EggRecentModel *model; - GConfClient *client; - GtkIconSize icon_size; -}; - - - -struct _EggRecentViewGtkMenuData { - EggRecentViewGtk *view; - EggRecentItem *item; -}; - -typedef struct _EggRecentViewGtkMenuData EggRecentViewGtkMenuData; - -enum { - ACTIVATE, - LAST_SIGNAL -}; - -/* GObject properties */ -enum { - PROP_BOGUS, - PROP_MENU, - PROP_START_MENU_ITEM, - PROP_SHOW_ICONS, - PROP_SHOW_NUMBERS -}; - -static guint view_signals[LAST_SIGNAL] = { 0 }; - - -static void -egg_recent_view_gtk_clear (EggRecentViewGtk *view) -{ - GList *menu_children; - GList *p; - GObject *menu_item; - gint *menu_data=NULL; - - g_return_if_fail (view->menu != NULL); - - menu_children = gtk_container_get_children (GTK_CONTAINER (view->menu)); - - p = menu_children; - while (p != NULL) { - menu_item = (GObject *)p->data; - - menu_data = (gint *)g_object_get_data (menu_item, - view->uid); - - if (menu_data) { - gtk_container_remove (GTK_CONTAINER (view->menu), - GTK_WIDGET (menu_item)); - - } - - p = p->next; - } -} - - -static gint -egg_recent_view_gtk_find_menu_offset (EggRecentViewGtk *view) -{ - gint i; - GList *menu_children; - GList *p; - GtkWidget *menu_item; - gint menu_loc=-1; - - g_return_val_if_fail (view, 0); - - menu_children = GTK_MENU_SHELL (view->menu)->children; - - i = 0; - p = menu_children; - while (p != NULL) { - menu_item = (GtkWidget *)p->data; - - if (menu_item == view->start_menu_item) { - menu_loc = i; - break; - } - - p = p->next; - i++; - } - - return menu_loc; -} - -static void -egg_recent_view_gtk_menu_cb (GtkWidget *menu, gpointer data) -{ - EggRecentViewGtkMenuData *md = (EggRecentViewGtkMenuData *) data; - EggRecentItem *item; - - g_return_if_fail (md); - g_return_if_fail (md->item); - g_return_if_fail (md->view); - g_return_if_fail (EGG_IS_RECENT_VIEW_GTK (md->view)); - - item = md->item; - - egg_recent_item_ref (item); - - g_signal_emit (G_OBJECT(md->view), view_signals[ACTIVATE], 0, - item); - - egg_recent_item_unref (item); -} - -static void -egg_recent_view_gtk_destroy_cb (gpointer data, GClosure *closure) -{ - EggRecentViewGtkMenuData *md = data; - - egg_recent_item_unref (md->item); - g_free (md); -} - -static GtkWidget * -egg_recent_view_gtk_new_menu_item (EggRecentViewGtk *view, - EggRecentItem *item, - gint index) -{ - GtkWidget *menu_item; - EggRecentViewGtkMenuData *md=(EggRecentViewGtkMenuData *)g_malloc (sizeof (EggRecentViewGtkMenuData)); - - g_return_val_if_fail (view, NULL); - - if (item != NULL) { - gchar *mime_type; - GtkWidget *image; - GdkPixbuf *pixbuf; - gchar *text; - gchar *short_name; - gchar *escaped; - - short_name = egg_recent_item_get_short_name (item); - escaped = egg_recent_util_escape_underlines (short_name); - g_free (short_name); - - if (view->show_numbers) { - /* avoid having conflicting mnemonics */ - if (index >= 10) - text = g_strdup_printf ("%d. %s", index, - escaped); - else - text = g_strdup_printf ("_%d. %s", index, - escaped); - g_free (escaped); - } else { - text = escaped; - } - - - mime_type = egg_recent_item_get_mime_type (item); -#ifndef USE_STABLE_LIBGNOMEUI - { - int width, height; - gchar *uri; - - gtk_icon_size_lookup_for_settings - (gtk_widget_get_settings (view->menu), - view->icon_size, - &width, &height); - - uri = egg_recent_item_get_uri (item); - pixbuf = egg_recent_util_get_icon (view->theme, uri, - mime_type, - height); - g_free (uri); - } -#else - pixbuf = NULL; -#endif - image = gtk_image_new_from_pixbuf (pixbuf); - if (pixbuf) - g_object_unref (pixbuf); - - if (view->show_icons) - gtk_widget_show (image); - - menu_item = gtk_image_menu_item_new_with_mnemonic (text); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), - image); - - md->view = view; - md->item = item; - - egg_recent_item_ref (md->item); - - g_signal_connect_data (G_OBJECT (menu_item), "activate", - G_CALLBACK (egg_recent_view_gtk_menu_cb), - md, - (GClosureNotify)egg_recent_view_gtk_destroy_cb, - 0); - - g_free (mime_type); - g_free (text); - } - else { - menu_item = gtk_separator_menu_item_new (); - } - - g_return_val_if_fail (menu_item, NULL); - - /** - * this is a tag so we can distinguish our menu items - * from others that may be in the menu. - */ - g_object_set_data (G_OBJECT (menu_item), - view->uid, - GINT_TO_POINTER (1)); - - - gtk_widget_show (menu_item); - - return menu_item; -} - -static void -egg_recent_view_gtk_add_to_menu (EggRecentViewGtk *view, - EggRecentItem *item, - gint display, - gint index) -{ - GtkWidget *menu_item; - gint menu_offset; - - g_return_if_fail (view); - g_return_if_fail (view->menu); - - menu_offset = egg_recent_view_gtk_find_menu_offset (view); - - menu_item = egg_recent_view_gtk_new_menu_item (view, item, display); - - if (view->tooltip_func != NULL && menu_item != NULL) { - view->tooltip_func (view->tooltips, menu_item, - item, view->tooltip_func_data); - } - - if (menu_item) - gtk_menu_shell_insert (GTK_MENU_SHELL (view->menu), menu_item, - menu_offset+index); -} - - - - -static void -egg_recent_view_gtk_set_list (EggRecentViewGtk *view, GList *list) -{ - EggRecentItem *item; - GList *p; - gint display=1; - gint index=1; - - g_return_if_fail (view); - - egg_recent_view_gtk_clear (view); - - if (view->leading_sep) { - egg_recent_view_gtk_add_to_menu (view, NULL, display, index); - index++; - } - - p = list; - while (p != NULL) { - item = (EggRecentItem *)p->data; - - egg_recent_view_gtk_add_to_menu (view, item, display, index); - - p = p->next; - display++; - index++; - } - - if (view->trailing_sep) - egg_recent_view_gtk_add_to_menu (view, NULL, display, index); -} - -static void -model_changed_cb (EggRecentModel *model, GList *list, EggRecentViewGtk *view) -{ - if (list != NULL) - egg_recent_view_gtk_set_list (view, list); - else - egg_recent_view_gtk_clear (view); -} - -static EggRecentModel * -egg_recent_view_gtk_get_model (EggRecentView *view_parent) -{ - EggRecentViewGtk *view; - - g_return_val_if_fail (view_parent != NULL, NULL); - view = EGG_RECENT_VIEW_GTK (view_parent); - return view->model; -} - -static void -egg_recent_view_gtk_set_model (EggRecentView *view_parent, - EggRecentModel *model) -{ - EggRecentViewGtk *view; - - g_return_if_fail (view_parent != NULL); - view = EGG_RECENT_VIEW_GTK (view_parent); - - if (view->model != NULL) { - g_object_unref (view->model); - g_signal_handler_disconnect (G_OBJECT (model), - view->changed_cb_id); - } - - view->model = model; - g_object_ref (view->model); - - view->changed_cb_id = g_signal_connect_object (G_OBJECT (model), - "changed", - G_CALLBACK (model_changed_cb), - view, 0); - - egg_recent_model_changed (view->model); -} - -void -egg_recent_view_gtk_set_leading_sep (EggRecentViewGtk *view, gboolean val) -{ - view->leading_sep = val; - - egg_recent_view_gtk_clear (view); - - if (view->model) - egg_recent_model_changed (view->model); -} - -void -egg_recent_view_gtk_set_trailing_sep (EggRecentViewGtk *view, gboolean val) -{ - view->trailing_sep = val; - - egg_recent_view_gtk_clear (view); - - if (view->model) - egg_recent_model_changed (view->model); -} - -static void -egg_recent_view_gtk_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EggRecentViewGtk *view = EGG_RECENT_VIEW_GTK (object); - - switch (prop_id) - { - case PROP_MENU: - egg_recent_view_gtk_set_menu (view, - GTK_WIDGET (g_value_get_object (value))); - break; - case PROP_START_MENU_ITEM: - egg_recent_view_gtk_set_start_menu_item (view, - g_value_get_object (value)); - break; - case PROP_SHOW_ICONS: - egg_recent_view_gtk_show_icons (view, - g_value_get_boolean (value)); - break; - case PROP_SHOW_NUMBERS: - egg_recent_view_gtk_show_numbers (view, - g_value_get_boolean (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -egg_recent_view_gtk_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EggRecentViewGtk *view = EGG_RECENT_VIEW_GTK (object); - - switch (prop_id) - { - case PROP_MENU: - g_value_set_object (value, view->menu); - break; - case PROP_START_MENU_ITEM: - g_value_set_object (value, view->start_menu_item); - break; - case PROP_SHOW_ICONS: - g_value_set_boolean (value, view->show_icons); - break; - case PROP_SHOW_NUMBERS: - g_value_set_boolean (value, view->show_numbers); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -egg_recent_view_gtk_finalize (GObject *object) -{ - EggRecentViewGtk *view = EGG_RECENT_VIEW_GTK (object); - - g_signal_handler_disconnect (G_OBJECT (view->model), - view->changed_cb_id); - - g_free (view->uid); - - g_object_unref (view->menu); - g_object_unref (view->model); -#ifndef USE_STABLE_LIBGNOMEUI - g_object_unref (view->theme); -#endif - g_object_unref (view->client); - - g_object_unref (view->tooltips); -} - -static void -egg_recent_view_gtk_class_init (EggRecentViewGtkClass * klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - object_class->set_property = egg_recent_view_gtk_set_property; - object_class->get_property = egg_recent_view_gtk_get_property; - object_class->finalize = egg_recent_view_gtk_finalize; - - view_signals[ACTIVATE] = g_signal_new ("activate", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EggRecentViewGtkClass, activate), - NULL, NULL, - g_cclosure_marshal_VOID__BOXED, - G_TYPE_NONE, 1, - EGG_TYPE_RECENT_ITEM); - - g_object_class_install_property (object_class, - PROP_MENU, - g_param_spec_object ("menu", - "Menu", - "The GtkMenuShell this object will update.", - gtk_menu_get_type(), - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_START_MENU_ITEM, - g_param_spec_object ("start-menu-item", - "Start Menu Item", - "The menu item that precedes where are menu items will go", - gtk_menu_item_get_type (), - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_SHOW_ICONS, - g_param_spec_boolean ("show-icons", - "Show Icons", - "Whether or not to show icons", - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_SHOW_NUMBERS, - g_param_spec_boolean ("show-numbers", - "Show Numbers", - "Whether or not to show numbers", - TRUE, - G_PARAM_READWRITE)); - - klass->activate = NULL; -} - -static void -egg_recent_view_init (EggRecentViewClass *iface) -{ - iface->do_get_model = egg_recent_view_gtk_get_model; - iface->do_set_model = egg_recent_view_gtk_set_model; -} - -static void -show_menus_changed_cb (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, - EggRecentViewGtk *view) -{ - GConfValue *value; - - value = gconf_entry_get_value (entry); - - g_return_if_fail (value->type == GCONF_VALUE_BOOL); - - egg_recent_view_gtk_show_icons (view, - gconf_value_get_bool (value)); - -} - -#ifndef USE_STABLE_LIBGNOMEUI -static void -theme_changed_cb (GnomeIconTheme *theme, EggRecentViewGtk *view) -{ - if (view->model != NULL) - egg_recent_model_changed (view->model); -} -#endif - -static void -egg_recent_view_gtk_init (EggRecentViewGtk * view) -{ - view->client = gconf_client_get_default (); - - view->show_icons = - gconf_client_get_bool (view->client, - "/desktop/gnome/interface/menus_have_icons", - NULL); - - gconf_client_add_dir (view->client, "/desktop/gnome/interface", - GCONF_CLIENT_PRELOAD_NONE, - NULL); - gconf_client_notify_add (view->client, - "/desktop/gnome/interface/menus_have_icons", - (GConfClientNotifyFunc)show_menus_changed_cb, - view, NULL, NULL); - - - view->leading_sep = FALSE; - view->trailing_sep = FALSE; - - view->uid = egg_recent_util_get_unique_id (); -#ifndef USE_STABLE_LIBGNOMEUI - view->theme = gnome_icon_theme_new (); - gnome_icon_theme_set_allow_svg (view->theme, TRUE); - g_signal_connect_object (view->theme, "changed", - G_CALLBACK (theme_changed_cb), view, 0); -#endif - view->tooltips = gtk_tooltips_new (); - g_object_ref (view->tooltips); - gtk_object_sink (GTK_OBJECT (view->tooltips)); - view->tooltip_func = NULL; - view->tooltip_func_data = NULL; - - view->icon_size = GTK_ICON_SIZE_MENU; -} - -void -egg_recent_view_gtk_set_icon_size (EggRecentViewGtk *view, - GtkIconSize icon_size) -{ - if (view->icon_size != icon_size) { - view->icon_size = icon_size; - egg_recent_model_changed (view->model); - } else { - view->icon_size = icon_size; - } -} - -GtkIconSize -egg_recent_view_gtk_get_icon_size (EggRecentViewGtk *view) -{ - return view->icon_size; -} - -void -egg_recent_view_gtk_show_icons (EggRecentViewGtk *view, gboolean show) -{ - view->show_icons = show; - - if (view->model) - egg_recent_model_changed (view->model); -} - -void -egg_recent_view_gtk_show_numbers (EggRecentViewGtk *view, gboolean show) -{ - view->show_numbers = show; - - if (view->model) - egg_recent_model_changed (view->model); -} - -void -egg_recent_view_gtk_set_tooltip_func (EggRecentViewGtk *view, - EggRecentViewGtkTooltipFunc func, - gpointer user_data) -{ - view->tooltip_func = func; - view->tooltip_func_data = user_data; - - if (view->model) - egg_recent_model_changed (view->model); -} - -/** - * egg_recent_view_gtk_set_menu: - * @view: A EggRecentViewGtk object. - * @menu: The GtkMenuShell to put the menu items in. - * - * Use this function to change the GtkMenuShell that the recent - * documents appear in. - * - */ -void -egg_recent_view_gtk_set_menu (EggRecentViewGtk *view, - GtkWidget *menu) -{ - g_return_if_fail (view); - g_return_if_fail (EGG_IS_RECENT_VIEW_GTK (view)); - g_return_if_fail (menu); - - if (view->menu != NULL) - g_object_unref (view->menu); - - view->menu = menu; - g_object_ref (view->menu); -} - -/** - * egg_recent_view_gtk_set_start_menu_item: - * @view: A EggRecentViewGtk object. - * @start_menu_item: The menu item that appears just before where our menu - * items should appear - * - */ -void -egg_recent_view_gtk_set_start_menu_item (EggRecentViewGtk *view, - GtkWidget *menu_item) -{ - g_return_if_fail (view); - g_return_if_fail (EGG_IS_RECENT_VIEW_GTK (view)); - - view->start_menu_item = menu_item; -} - -/** - * egg_recent_view_gtk_get_menu: - * @view: A EggRecentViewGtk object. - * - */ -GtkWidget * -egg_recent_view_gtk_get_menu (EggRecentViewGtk *view) -{ - return view->menu; -} - -/** - * egg_recent_view_gtk_get_start_menu_item - * @view: A EggRecentViewGtk object. - * - */ -GtkWidget * -egg_recent_view_gtk_get_start_menu_item (EggRecentViewGtk *view) -{ - return view->start_menu_item; -} - - -/** - * egg_recent_view_gtk_new: - * @appname: The name of your application. - * @limit: The maximum number of items allowed. - * - * This creates a new EggRecentViewGtk object. - * - * Returns: a EggRecentViewGtk object - */ -EggRecentViewGtk * -egg_recent_view_gtk_new (GtkWidget *menu, GtkWidget *start_menu_item) -{ - EggRecentViewGtk *view; - - g_return_val_if_fail (menu, NULL); - - view = EGG_RECENT_VIEW_GTK (g_object_new (egg_recent_view_gtk_get_type (), - "start-menu-item", - start_menu_item, - "menu", menu, - "show-numbers", TRUE, NULL)); - - g_return_val_if_fail (view, NULL); - - return view; -} - -/** - * egg_recent_view_gtk_get_type: - * @: - * - * This returns a GType representing a EggRecentViewGtk object. - * - * Returns: a GType - */ -GType -egg_recent_view_gtk_get_type (void) -{ - static GType egg_recent_view_gtk_type = 0; - - if(!egg_recent_view_gtk_type) { - static const GTypeInfo egg_recent_view_gtk_info = { - sizeof (EggRecentViewGtkClass), - NULL, /* base init */ - NULL, /* base finalize */ - (GClassInitFunc)egg_recent_view_gtk_class_init, /* class init */ - NULL, /* class finalize */ - NULL, /* class data */ - sizeof (EggRecentViewGtk), - 0, - (GInstanceInitFunc) egg_recent_view_gtk_init - }; - - static const GInterfaceInfo view_info = - { - (GInterfaceInitFunc) egg_recent_view_init, - NULL, - NULL - }; - - egg_recent_view_gtk_type = g_type_register_static (G_TYPE_OBJECT, - "EggRecentViewGtk", - &egg_recent_view_gtk_info, 0); - g_type_add_interface_static (egg_recent_view_gtk_type, - EGG_TYPE_RECENT_VIEW, - &view_info); - } - - return egg_recent_view_gtk_type; -} - diff --git a/glabels2/src/recent-files/egg-recent-view-gtk.h b/glabels2/src/recent-files/egg-recent-view-gtk.h deleted file mode 100644 index 7e56bafe..00000000 --- a/glabels2/src/recent-files/egg-recent-view-gtk.h +++ /dev/null @@ -1,64 +0,0 @@ -/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef __EGG_RECENT_VIEW_GTK_H__ -#define __EGG_RECENT_VIEW_GTK_H__ - -G_BEGIN_DECLS - -#include -#include "egg-recent-item.h" - -#define EGG_RECENT_VIEW_GTK(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, egg_recent_view_gtk_get_type (), EggRecentViewGtk) -#define EGG_RECENT_VIEW_GTK_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, egg_recent_view_gtk_get_type (), EggRecentViewGtkClass) -#define EGG_IS_RECENT_VIEW_GTK(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, egg_recent_view_gtk_get_type ()) - -typedef void (*EggRecentViewGtkTooltipFunc) (GtkTooltips *tooltips, - GtkWidget *menu, - EggRecentItem *item, - gpointer user_data); - -typedef struct _EggRecentViewGtk EggRecentViewGtk; - -typedef struct _EggRecentViewGtkClass EggRecentViewGtkClass; - -struct _EggRecentViewGtkClass { - GObjectClass parent_class; - - void (*activate) (EggRecentViewGtk *view, EggRecentItem *item); -}; - -GType egg_recent_view_gtk_get_type (void); - -EggRecentViewGtk * egg_recent_view_gtk_new (GtkWidget *menu, - GtkWidget *start_menu_item); - -void egg_recent_view_gtk_set_menu (EggRecentViewGtk *view, - GtkWidget *menu); -GtkWidget * egg_recent_view_gtk_get_menu (EggRecentViewGtk *view); - - -void egg_recent_view_gtk_set_start_menu_item (EggRecentViewGtk *view, - GtkWidget *menu_item); -GtkWidget *egg_recent_view_gtk_get_start_menu_item (EggRecentViewGtk *view); - -void egg_recent_view_gtk_set_leading_sep (EggRecentViewGtk *view, - gboolean val); - -void egg_recent_view_gtk_set_trailing_sep (EggRecentViewGtk *view, - gboolean val); - -void egg_recent_view_gtk_show_icons (EggRecentViewGtk *view, - gboolean show); -void egg_recent_view_gtk_show_numbers (EggRecentViewGtk *view, - gboolean show); - -void egg_recent_view_gtk_set_tooltip_func (EggRecentViewGtk *view, - EggRecentViewGtkTooltipFunc func, - gpointer user_data); - -void egg_recent_view_gtk_set_icon_size (EggRecentViewGtk *view, - GtkIconSize icon_size); -GtkIconSize egg_recent_view_gtk_get_icon_size (EggRecentViewGtk *view); - -G_END_DECLS - -#endif /* __EGG_RECENT_VIEW_GTK_H__ */ diff --git a/glabels2/src/recent-files/egg-recent-view-uimanager.c b/glabels2/src/recent-files/egg-recent-view-uimanager.c new file mode 100644 index 00000000..eac90813 --- /dev/null +++ b/glabels2/src/recent-files/egg-recent-view-uimanager.c @@ -0,0 +1,738 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + * + * Authors: + * James Willcox + * Paolo Bacchilega + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#ifndef USE_STABLE_LIBGNOMEUI +#include +#endif +#include +#include "egg-recent-model.h" +#include "egg-recent-view.h" +#include "egg-recent-view-uimanager.h" +#include "egg-recent-util.h" +#include "egg-recent-item.h" + +#define EGG_RECENT_NAME_PREFIX "EggRecentAction" +#define EGG_RECENT_ACTION "EggRecentFile" +#define EGG_RECENT_SEPARATOR (NULL) + +struct _EggRecentViewUIManager { + GObject parent_instance; + + GCallback action_callback; + gpointer action_user_data; + + gboolean leading_sep; + gboolean trailing_sep; + + GtkUIManager *uimanager; + GtkActionGroup *action_group; + guint merge_id; + gulong changed_cb_id; + + gchar *path; + + gboolean show_icons; + gboolean show_numbers; +#ifndef USE_STABLE_LIBGNOMEUI + GnomeIconTheme *theme; +#endif + + EggUIManagerTooltipFunc tooltip_func; + gpointer tooltip_func_data; + + EggRecentModel *model; + GConfClient *client; + GtkIconSize icon_size; +}; + + +struct _EggRecentViewUIManagerMenuData { + EggRecentViewUIManager *view; + EggRecentItem *item; +}; + +typedef struct _EggRecentViewUIManagerMenuData EggRecentViewUIManagerMenuData; + +enum { + ACTIVATE, + LAST_SIGNAL +}; + +/* GObject properties */ +enum { + PROP_BOGUS, + PROP_UIMANAGER, + PROP_PATH, + PROP_SHOW_ICONS, + PROP_SHOW_NUMBERS +}; + +static guint view_signals[LAST_SIGNAL] = { 0 }; + +static void +egg_recent_view_uimanager_clear (EggRecentViewUIManager *view) +{ + if (view->merge_id != 0) { + gtk_ui_manager_remove_ui (view->uimanager, view->merge_id); + view->merge_id = 0; + } + + if (view->action_group != NULL) { + gtk_ui_manager_remove_action_group (view->uimanager, view->action_group); + g_object_unref (view->action_group); + view->action_group = NULL; + } + + gtk_ui_manager_ensure_update (view->uimanager); +} + +static void +egg_recent_view_uimanager_set_list (EggRecentViewUIManager *view, GList *list) +{ + GList *scan; + guint index = 1; + + g_return_if_fail (view); + + egg_recent_view_uimanager_clear (view); + + if (view->merge_id == 0) + view->merge_id = gtk_ui_manager_new_merge_id (view->uimanager); + + if (view->action_group == NULL) { + gchar *group = g_strdup_printf ("EggRecentActions%u", + view->merge_id); + view->action_group = gtk_action_group_new (group); + gtk_ui_manager_insert_action_group (view->uimanager, view->action_group, 0); + g_free (group); + } + + if (view->leading_sep) { + gchar *action = g_strdup_printf ("EggRecentLeadingSeparator%u", + view->merge_id); + gtk_ui_manager_add_ui (view->uimanager, + view->merge_id, + view->path, + action, + EGG_RECENT_SEPARATOR, + GTK_UI_MANAGER_AUTO, + FALSE); + g_free (action); + } + + for (scan = list; scan; scan = scan->next, index++) { + EggRecentItem *item = scan->data; + GtkAction *action; + gchar *name; + gchar *uri; + gchar *basename; + gchar *escaped; + gchar *label; + gchar *tooltip = NULL; + + uri = egg_recent_item_get_uri_for_display (item); + if (uri == NULL) + continue; + + name = g_strdup_printf (EGG_RECENT_NAME_PREFIX"%u-%u", + view->merge_id, + index); + + if (view->tooltip_func != NULL) + tooltip = (*view->tooltip_func) (item, view->tooltip_func_data); + + basename = g_path_get_basename (uri); + escaped = egg_recent_util_escape_underlines (basename); + g_free (basename); + g_free (uri); + + if (view->show_numbers) { + if (index >= 10) + label = g_strdup_printf ("%d. %s", + index, + escaped); + else + label = g_strdup_printf ("_%d. %s", + index, + escaped); + g_free (escaped); + } else + label = escaped; + + action = g_object_new (GTK_TYPE_ACTION, + "name", name, + "label", label, + (view->show_icons)? "stock_id": NULL, + GTK_STOCK_OPEN, + NULL); + if (tooltip != NULL) { + g_object_set (action, "tooltip", tooltip, NULL); + g_free (tooltip); + } + egg_recent_item_ref (item); + g_object_set_data_full (G_OBJECT (action), + "egg_recent_uri", + item, + (GFreeFunc) egg_recent_item_unref); + + if (view->action_callback != NULL) { + GClosure *closure; + closure = g_cclosure_new (view->action_callback, view->action_user_data, NULL); + g_signal_connect_closure (action, "activate", closure, FALSE); + } + + gtk_action_group_add_action (view->action_group, action); + g_object_unref (action); + + gtk_ui_manager_add_ui (view->uimanager, + view->merge_id, + view->path, + name, + name, + GTK_UI_MANAGER_AUTO, + FALSE); + + g_free (name); + g_free (label); + } + + if (view->trailing_sep) { + gchar *action = g_strdup_printf ("EggRecentTrailingSeparator%u", + view->merge_id); + gtk_ui_manager_add_ui (view->uimanager, + view->merge_id, + view->path, + action, + EGG_RECENT_SEPARATOR, + GTK_UI_MANAGER_AUTO, + FALSE); + g_free (action); + } +} + +static void +model_changed_cb (EggRecentModel *model, + GList *list, + EggRecentViewUIManager *view) +{ + if (list != NULL) + egg_recent_view_uimanager_set_list (view, list); + else + egg_recent_view_uimanager_clear (view); + gtk_ui_manager_ensure_update (view->uimanager); +} + +static EggRecentModel * +egg_recent_view_uimanager_get_model (EggRecentView *view_parent) +{ + EggRecentViewUIManager *view; + + g_return_val_if_fail (view_parent != NULL, NULL); + view = EGG_RECENT_VIEW_UIMANAGER (view_parent); + return view->model; +} + +static void +egg_recent_view_uimanager_set_model (EggRecentView *view_parent, + EggRecentModel *model) +{ + EggRecentViewUIManager *view; + + g_return_if_fail (view_parent != NULL); + view = EGG_RECENT_VIEW_UIMANAGER (view_parent); + + if (view->model != NULL) { + if (view->changed_cb_id != 0) + g_signal_handler_disconnect (G_OBJECT (view->model), + view->changed_cb_id); + g_object_unref (view->model); + } + + view->model = model; + g_object_ref (view->model); + + view->changed_cb_id = g_signal_connect_object (G_OBJECT (model), + "changed", + G_CALLBACK (model_changed_cb), + view, 0); + + egg_recent_model_changed (view->model); +} + +void +egg_recent_view_uimanager_set_leading_sep (EggRecentViewUIManager *view, + gboolean val) +{ + view->leading_sep = val; + egg_recent_view_uimanager_clear (view); + if (view->model) + egg_recent_model_changed (view->model); +} + +void +egg_recent_view_uimanager_set_trailing_sep (EggRecentViewUIManager *view, + gboolean val) +{ + view->trailing_sep = val; + egg_recent_view_uimanager_clear (view); + if (view->model) + egg_recent_model_changed (view->model); +} + +static void +egg_recent_view_uimanager_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + EggRecentViewUIManager *view = EGG_RECENT_VIEW_UIMANAGER (object); + + switch (prop_id) { + case PROP_UIMANAGER: + egg_recent_view_uimanager_set_uimanager (view, (GtkUIManager*)g_value_get_object (value)); + break; + case PROP_PATH: + egg_recent_view_uimanager_set_path (view, g_value_get_string (value)); + break; + case PROP_SHOW_ICONS: + egg_recent_view_uimanager_show_icons (view, g_value_get_boolean (value)); + break; + case PROP_SHOW_NUMBERS: + egg_recent_view_uimanager_show_numbers (view, g_value_get_boolean (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +egg_recent_view_uimanager_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EggRecentViewUIManager *view = EGG_RECENT_VIEW_UIMANAGER (object); + + switch (prop_id) { + case PROP_UIMANAGER: + g_value_set_object (value, view->uimanager); + break; + case PROP_PATH: + g_value_set_string (value, view->path); + break; + case PROP_SHOW_ICONS: + g_value_set_boolean (value, view->show_icons); + break; + case PROP_SHOW_NUMBERS: + g_value_set_boolean (value, view->show_numbers); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +egg_recent_view_uimanager_finalize (GObject *object) +{ + EggRecentViewUIManager *view = EGG_RECENT_VIEW_UIMANAGER (object); + + if (view->changed_cb_id != 0) { + g_signal_handler_disconnect (G_OBJECT (view->model), + view->changed_cb_id); + view->changed_cb_id = 0; + } + + g_free (view->path); + + egg_recent_view_uimanager_clear (view); + + if (view->action_group != NULL) { + g_object_unref (view->action_group); + view->action_group = NULL; + } + + if (view->uimanager != NULL) { + g_object_unref (view->uimanager); + view->uimanager = NULL; + } + + if (view->model != NULL) { + g_object_unref (view->model); + view->model = NULL; + } + +#ifndef USE_STABLE_LIBGNOMEUI + if (view->theme != NULL) { + g_object_unref (view->theme); + view->theme = NULL; + } +#endif + + if (view->client != NULL) { + g_object_unref (view->client); + view->client = NULL; + } +} + +static void +egg_recent_view_uimanager_class_init (EggRecentViewUIManagerClass * klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = egg_recent_view_uimanager_set_property; + object_class->get_property = egg_recent_view_uimanager_get_property; + object_class->finalize = egg_recent_view_uimanager_finalize; + + view_signals[ACTIVATE] = g_signal_new ("activate", + G_OBJECT_CLASS_TYPE (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EggRecentViewUIManagerClass, activate), + NULL, NULL, + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + EGG_TYPE_RECENT_ITEM); + + g_object_class_install_property (object_class, + PROP_UIMANAGER, + g_param_spec_object ("uimanager", + "UI Manager", + "The UI manager this object will use to update.the UI", + GTK_TYPE_UI_MANAGER, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_PATH, + g_param_spec_string ("path", + "Path", + "The UI path this object will update.", + NULL, + G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_SHOW_ICONS, + g_param_spec_boolean ("show-icons", + "Show Icons", + "Whether or not to show icons", + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_SHOW_NUMBERS, + g_param_spec_boolean ("show-numbers", + "Show Numbers", + "Whether or not to show numbers", + TRUE, + G_PARAM_READWRITE)); + + klass->activate = NULL; +} + +static void +egg_recent_view_init (EggRecentViewClass *iface) +{ + iface->do_get_model = egg_recent_view_uimanager_get_model; + iface->do_set_model = egg_recent_view_uimanager_set_model; +} + +static void +show_menus_changed_cb (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EggRecentViewUIManager *view) +{ + GConfValue *value; + + value = gconf_entry_get_value (entry); + g_return_if_fail (value->type == GCONF_VALUE_BOOL); + + egg_recent_view_uimanager_show_icons (view, gconf_value_get_bool (value)); +} + +#ifndef USE_STABLE_LIBGNOMEUI +static void +theme_changed_cb (GnomeIconTheme *theme, + EggRecentViewUIManager *view) +{ + if (view->model != NULL) + egg_recent_model_changed (view->model); +} +#endif + +static void +egg_recent_view_uimanager_init (EggRecentViewUIManager * view) +{ + view->client = gconf_client_get_default (); + + view->show_icons = gconf_client_get_bool (view->client, + "/desktop/gnome/interface/menus_have_icons", + NULL); + + gconf_client_add_dir (view->client, "/desktop/gnome/interface", + GCONF_CLIENT_PRELOAD_NONE, + NULL); + gconf_client_notify_add (view->client, + "/desktop/gnome/interface/menus_have_icons", + (GConfClientNotifyFunc)show_menus_changed_cb, + view, NULL, NULL); + + + view->leading_sep = FALSE; + view->trailing_sep = FALSE; + view->show_numbers = TRUE; + + view->uimanager = NULL; + view->action_group = NULL; + view->merge_id = 0; + view->changed_cb_id = 0; + + view->path = NULL; + +#ifndef USE_STABLE_LIBGNOMEUI + view->theme = gnome_icon_theme_new (); + gnome_icon_theme_set_allow_svg (view->theme, TRUE); + g_signal_connect_object (view->theme, "changed", + G_CALLBACK (theme_changed_cb), view, 0); +#endif + + view->tooltip_func = NULL; + view->tooltip_func_data = NULL; + + view->icon_size = GTK_ICON_SIZE_MENU; +} + +void +egg_recent_view_uimanager_set_icon_size (EggRecentViewUIManager *view, + GtkIconSize icon_size) +{ + if (view->icon_size != icon_size) { + view->icon_size = icon_size; + egg_recent_model_changed (view->model); + } else { + view->icon_size = icon_size; + } +} + +GtkIconSize +egg_recent_view_uimanager_get_icon_size (EggRecentViewUIManager *view) +{ + return view->icon_size; +} + +void +egg_recent_view_uimanager_show_icons (EggRecentViewUIManager *view, + gboolean show) +{ + view->show_icons = show; + if (view->model != NULL) + egg_recent_model_changed (view->model); +} + +void +egg_recent_view_uimanager_show_numbers (EggRecentViewUIManager *view, + gboolean show) +{ + view->show_numbers = show; + if (view->model != NULL) + egg_recent_model_changed (view->model); +} + +void +egg_recent_view_uimanager_set_tooltip_func (EggRecentViewUIManager *view, + EggUIManagerTooltipFunc func, + gpointer user_data) +{ + view->tooltip_func = func; + view->tooltip_func_data = user_data; + if (view->model) + egg_recent_model_changed (view->model); +} + +/** + * egg_recent_view_uimanager_set_uimanager: + * @view: A EggRecentViewUIManager object. + * @uimanager: The ui manager used to put the menu items in. + * + * Use this function to change the ui manager used to update the menu. + * + */ +void +egg_recent_view_uimanager_set_uimanager (EggRecentViewUIManager *view, + GtkUIManager *uimanager) +{ + g_return_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view)); + g_return_if_fail (uimanager != NULL); + + if (view->uimanager != NULL) + g_object_unref (view->uimanager); + view->uimanager = uimanager; + g_object_ref (view->uimanager); +} + +/** + * egg_recent_view_uimanager_get_uimanager: + * @view: A EggRecentViewUIManager object. + * + */ +GtkUIManager* +egg_recent_view_uimanager_get_uimanager (EggRecentViewUIManager *view) +{ + g_return_val_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view), NULL); + return view->uimanager; +} + +/** + * egg_recent_view_uimanager_set_path: + * @view: A EggRecentViewUIManager object. + * @path: The path to put the menu items in. + * + * Use this function to change the path where the recent + * documents appear in. + * + */ +void +egg_recent_view_uimanager_set_path (EggRecentViewUIManager *view, + const gchar *path) +{ + g_return_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view)); + g_return_if_fail (path); + + g_free (view->path); + view->path = g_strdup (path); +} + +/** + * egg_recent_view_uimanager_get_path: + * @view: A EggRecentViewUIManager object. + * + */ +G_CONST_RETURN gchar* +egg_recent_view_uimanager_get_path (EggRecentViewUIManager *view) +{ + g_return_val_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view), NULL); + return view->path; +} + +void +egg_recent_view_uimanager_set_action_func (EggRecentViewUIManager *view, + GCallback callback, + gpointer user_data) +{ + g_return_if_fail (EGG_IS_RECENT_VIEW_UIMANAGER (view)); + view->action_callback = callback; + view->action_user_data = user_data; +} + +/** + * egg_recent_view_uimanager_new: + * @appname: The name of your application. + * @limit: The maximum number of items allowed. + * + * This creates a new EggRecentViewUIManager object. + * + * Returns: a EggRecentViewUIManager object + */ +EggRecentViewUIManager * +egg_recent_view_uimanager_new (GtkUIManager *uimanager, + const gchar *path, + GCallback callback, + gpointer user_data) +{ + GObject *view; + + g_return_val_if_fail (uimanager, NULL); + g_return_val_if_fail (path, NULL); + + view = g_object_new (egg_recent_view_uimanager_get_type (), + "uimanager", uimanager, + "path", path, + NULL); + + g_return_val_if_fail (view, NULL); + + egg_recent_view_uimanager_set_action_func (EGG_RECENT_VIEW_UIMANAGER (view), + callback, + user_data); + + return EGG_RECENT_VIEW_UIMANAGER (view); +} + +/** + * egg_recent_view_uimanager_get_type: + * @: + * + * This returns a GType representing a EggRecentViewUIManager object. + * + * Returns: a GType + */ +GType +egg_recent_view_uimanager_get_type (void) +{ + static GType egg_recent_view_uimanager_type = 0; + + if(!egg_recent_view_uimanager_type) { + static const GTypeInfo egg_recent_view_uimanager_info = { + sizeof (EggRecentViewUIManagerClass), + NULL, /* base init */ + NULL, /* base finalize */ + (GClassInitFunc)egg_recent_view_uimanager_class_init, /* class init */ + NULL, /* class finalize */ + NULL, /* class data */ + sizeof (EggRecentViewUIManager), + 0, + (GInstanceInitFunc) egg_recent_view_uimanager_init + }; + + static const GInterfaceInfo view_info = + { + (GInterfaceInitFunc) egg_recent_view_init, + NULL, + NULL + }; + + egg_recent_view_uimanager_type = g_type_register_static (G_TYPE_OBJECT, + "EggRecentViewUIManager", + &egg_recent_view_uimanager_info, 0); + g_type_add_interface_static (egg_recent_view_uimanager_type, + EGG_TYPE_RECENT_VIEW, + &view_info); + } + + return egg_recent_view_uimanager_type; +} + +EggRecentItem* +egg_recent_view_uimanager_get_item (EggRecentViewUIManager *view, + GtkAction *action) +{ + return g_object_get_data (G_OBJECT(action), "egg_recent_uri"); +} diff --git a/glabels2/src/recent-files/egg-recent-view-uimanager.h b/glabels2/src/recent-files/egg-recent-view-uimanager.h new file mode 100644 index 00000000..b6eadfaf --- /dev/null +++ b/glabels2/src/recent-files/egg-recent-view-uimanager.h @@ -0,0 +1,60 @@ +/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef __EGG_RECENT_VIEW_UIMANAGER_H__ +#define __EGG_RECENT_VIEW_UIMANAGER_H__ + + +#include +#include "egg-recent-item.h" + +G_BEGIN_DECLS + +#define EGG_RECENT_VIEW_UIMANAGER(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, egg_recent_view_uimanager_get_type (), EggRecentViewUIManager) +#define EGG_RECENT_VIEW_UIMANAGER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, egg_recent_view_uimanager_get_type (), EggRecentViewUIManagerClass) +#define EGG_IS_RECENT_VIEW_UIMANAGER(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, egg_recent_view_uimanager_get_type ()) + +typedef char* (*EggUIManagerTooltipFunc) (EggRecentItem *item, + gpointer user_data); + +typedef struct _EggRecentViewUIManager EggRecentViewUIManager; +typedef struct _EggRecentViewUIManagerClass EggRecentViewUIManagerClass; + +struct _EggRecentViewUIManagerClass { + GObjectClass parent_class; + void (*activate) (EggRecentViewUIManager *view, EggRecentItem *item); +}; + +GType egg_recent_view_uimanager_get_type (void); +EggRecentViewUIManager *egg_recent_view_uimanager_new (GtkUIManager *uimanager, + const gchar *path, + GCallback callback, + gpointer user_data); +void egg_recent_view_uimanager_set_uimanager (EggRecentViewUIManager *view, + GtkUIManager *uimanager); +GtkUIManager* egg_recent_view_uimanager_get_uimanager (EggRecentViewUIManager *view); +void egg_recent_view_uimanager_set_path (EggRecentViewUIManager *view, + const gchar *path); +G_CONST_RETURN gchar *egg_recent_view_uimanager_get_path (EggRecentViewUIManager *view); +void egg_recent_view_uimanager_set_action_func (EggRecentViewUIManager *view, + GCallback callback, + gpointer user_data); +void egg_recent_view_uimanager_set_leading_sep (EggRecentViewUIManager *view, + gboolean val); +void egg_recent_view_uimanager_set_trailing_sep (EggRecentViewUIManager *view, + gboolean val); +void egg_recent_view_uimanager_show_icons (EggRecentViewUIManager *view, + gboolean show); +void egg_recent_view_uimanager_show_numbers (EggRecentViewUIManager *view, + gboolean show); +void egg_recent_view_uimanager_set_tooltip_func (EggRecentViewUIManager *view, + EggUIManagerTooltipFunc func, + gpointer user_data); +void egg_recent_view_uimanager_set_icon_size (EggRecentViewUIManager *view, + GtkIconSize icon_size); +GtkIconSize egg_recent_view_uimanager_get_icon_size (EggRecentViewUIManager *view); +EggRecentItem *egg_recent_view_uimanager_get_item (EggRecentViewUIManager *view, + GtkAction *action); + +G_END_DECLS + + +#endif /* __EGG_RECENT_VIEW_UIMANAGER_H__ */ diff --git a/glabels2/src/recent-files/egg-recent-view.c b/glabels2/src/recent-files/egg-recent-view.c index 0aa38b93..7794561d 100644 --- a/glabels2/src/recent-files/egg-recent-view.c +++ b/glabels2/src/recent-files/egg-recent-view.c @@ -1,5 +1,5 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/** +/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the diff --git a/glabels2/src/recent-files/egg-recent.h b/glabels2/src/recent-files/egg-recent.h index 686b91c3..8b8153ba 100644 --- a/glabels2/src/recent-files/egg-recent.h +++ b/glabels2/src/recent-files/egg-recent.h @@ -3,3 +3,4 @@ #include "egg-recent-view.h" #include "egg-recent-view-bonobo.h" #include "egg-recent-view-gtk.h" +#include "egg-recent-view-uimanager.h" diff --git a/glabels2/src/tools.c b/glabels2/src/tools.c deleted file mode 100644 index 98f23611..00000000 --- a/glabels2/src/tools.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * tools.c: implementation of drawing toolbar verbs - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#include "tools.h" - -#include "window.h" - -/*===========================================*/ -/* Private types. */ -/*===========================================*/ - -/*===========================================*/ -/* Private globals. */ -/*===========================================*/ - -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ - - - -/*****************************************************************************/ -/* arrow callback. */ -/*****************************************************************************/ -void -gl_tools_arrow (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_arrow_mode (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* text callback. */ -/*****************************************************************************/ -void -gl_tools_text (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_object_create_mode (GL_VIEW(window->view), - GL_LABEL_OBJECT_TEXT); - } -} - -/*****************************************************************************/ -/* box callback. */ -/*****************************************************************************/ -void -gl_tools_box (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_object_create_mode (GL_VIEW(window->view), - GL_LABEL_OBJECT_BOX); - } -} - -/*****************************************************************************/ -/* line callback. */ -/*****************************************************************************/ -void -gl_tools_line (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_object_create_mode (GL_VIEW(window->view), - GL_LABEL_OBJECT_LINE); - } -} - -/*****************************************************************************/ -/* ellipse callback. */ -/*****************************************************************************/ -void -gl_tools_ellipse (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_object_create_mode (GL_VIEW(window->view), - GL_LABEL_OBJECT_ELLIPSE); - } -} - -/*****************************************************************************/ -/* image callback. */ -/*****************************************************************************/ -void -gl_tools_image (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_object_create_mode (GL_VIEW(window->view), - GL_LABEL_OBJECT_IMAGE); - } -} - -/*****************************************************************************/ -/* barcode callback. */ -/*****************************************************************************/ -void -gl_tools_barcode (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_object_create_mode (GL_VIEW(window->view), - GL_LABEL_OBJECT_BARCODE); - } -} - -/*****************************************************************************/ -/* zoom in callback. */ -/*****************************************************************************/ -void -gl_tools_zoomin (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_zoom_in (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* zoom out callback. */ -/*****************************************************************************/ -void -gl_tools_zoomout (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_zoom_out (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* zoom 1:1 callback. */ -/*****************************************************************************/ -void -gl_tools_zoom1to1 (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_set_zoom (GL_VIEW(window->view), 1.0); - } -} - -/*****************************************************************************/ -/* zoom to fit callback. */ -/*****************************************************************************/ -void -gl_tools_zoom_to_fit (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_zoom_to_fit (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* edit merge properties callback. */ -/*****************************************************************************/ -void -gl_tools_merge_properties (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_edit_merge_props (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Raise objects to top callback. */ -/*****************************************************************************/ -void -gl_tools_raise_objects (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_raise_selection (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Lower objects to bottom callback. */ -/*****************************************************************************/ -void -gl_tools_lower_objects (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_lower_selection (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Rotate objects left 90 degrees. */ -/*****************************************************************************/ -void -gl_tools_rotate_objects_left (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_rotate_selection_left (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Rotate objects right 90 degrees. */ -/*****************************************************************************/ -void -gl_tools_rotate_objects_right (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_rotate_selection_right (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Flip objects horizontally callback. */ -/*****************************************************************************/ -void -gl_tools_flip_objects_horiz (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_flip_selection_horiz (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Flip objects vertically callback. */ -/*****************************************************************************/ -void -gl_tools_flip_objects_vert (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_flip_selection_vert (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Align objects left callback. */ -/*****************************************************************************/ -void -gl_tools_align_objects_left (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_align_selection_left (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Align objects right callback. */ -/*****************************************************************************/ -void -gl_tools_align_objects_right (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_align_selection_right (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Align objects horizontal center callback. */ -/*****************************************************************************/ -void -gl_tools_align_objects_hcenter (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_align_selection_hcenter (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Align objects top callback. */ -/*****************************************************************************/ -void -gl_tools_align_objects_top (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_align_selection_top (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Align objects bottom callback. */ -/*****************************************************************************/ -void -gl_tools_align_objects_bottom (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_align_selection_bottom (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Align objects vertical center callback. */ -/*****************************************************************************/ -void -gl_tools_align_objects_vcenter (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_align_selection_vcenter (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Center objects horizontally callback. */ -/*****************************************************************************/ -void -gl_tools_center_objects_horiz (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_center_selection_horiz (GL_VIEW(window->view)); - } -} - -/*****************************************************************************/ -/* Center objects vertically callback. */ -/*****************************************************************************/ -void -gl_tools_center_objects_vert (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) - -{ - glWindow *window; - - window = GL_WINDOW (user_data); - - if (window->view != NULL) { - gl_view_center_selection_vert (GL_VIEW(window->view)); - } -} - diff --git a/glabels2/src/tools.h b/glabels2/src/tools.h deleted file mode 100644 index f76ae950..00000000 --- a/glabels2/src/tools.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * tools.h: toolbar module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __TOOLS_H__ -#define __TOOLS_H__ - -#include - -G_BEGIN_DECLS - -void gl_tools_arrow (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_text (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_box (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_line (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_ellipse (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_image (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_barcode (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_zoomin (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_zoomout (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_zoom1to1 (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_zoom_to_fit (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_merge_properties (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_raise_objects (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_lower_objects (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_rotate_objects_left (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_rotate_objects_right (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_flip_objects_horiz (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_flip_objects_vert (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_align_objects_left (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_align_objects_right (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_align_objects_hcenter (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_align_objects_top (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_align_objects_bottom (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_align_objects_vcenter (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_center_objects_horiz (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -void gl_tools_center_objects_vert (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname); - -G_END_DECLS - -#endif diff --git a/glabels2/src/ui-commands.c b/glabels2/src/ui-commands.c new file mode 100644 index 00000000..1aae2b0a --- /dev/null +++ b/glabels2/src/ui-commands.c @@ -0,0 +1,1153 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** + * (GLABELS) Label and Business Card Creation program for GNOME + * + * ui-commands.c: GLabels UI commands module + * + * Copyright (C) 2001-2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include "ui-commands.h" + +#include +#include +#include +#include +#include +#include "recent-files/egg-recent-view.h" +#include "recent-files/egg-recent-view-uimanager.h" + +#include "view.h" +#include "file.h" +#include "template-designer.h" +#include "print-dialog.h" +#include "prefs.h" +#include "prefs-dialog.h" +#include "recent.h" +#include "debug.h" + +#define LOGO_PIXMAP gnome_program_locate_file (NULL,\ + GNOME_FILE_DOMAIN_APP_PIXMAP,\ + "glabels/glabels-about-logo.png",\ + FALSE, NULL) + + +/****************************************************************************/ +/** File/New command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_new (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_new (window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Properties command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_properties (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_properties (GL_VIEW(window->view)->label, window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Template-Designer command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_template_designer (GtkAction *action, + glWindow *window) +{ + GtkWidget *dialog; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + dialog = gl_template_designer_new (GTK_WINDOW(window)); + + gtk_widget_show (dialog); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Open command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_open (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_open (window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Open-Recent command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_open_recent (GtkAction *action, + glWindow *window) +{ + EggRecentItem *item; + gchar *utf8_filename; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + item = egg_recent_view_uimanager_get_item (window->recent_view, action); + utf8_filename = gl_recent_get_filename (item); + + gl_file_open_recent (utf8_filename, window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Save command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_save (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_save (GL_VIEW(window->view)->label, window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Save-as command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_save_as (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_save_as (GL_VIEW(window->view)->label, window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Print command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_print (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (GL_VIEW(window->view)->print_dialog) { + + gtk_window_present (GTK_WINDOW(GL_VIEW(window->view)->print_dialog)); + + } else { + + GL_VIEW(window->view)->print_dialog = + g_object_ref ( + gl_print_dialog_new (GL_VIEW(window->view)->label, + BONOBO_WINDOW(window)) ); + + gtk_widget_show (GL_VIEW(window->view)->print_dialog); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Close command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_close (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_close (window); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** File/Quit command. */ +/****************************************************************************/ +void +gl_ui_cmd_file_quit (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_file_exit (); + + gl_debug (DEBUG_COMMANDS, "END"); +} + + +/****************************************************************************/ +/** Edit/Cut command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_cut (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_view_cut (GL_VIEW(window->view)); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** Edit/Copy command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_copy (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_view_copy (GL_VIEW(window->view)); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** Edit/Paste command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_paste (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_view_paste (GL_VIEW(window->view)); + + gl_debug (DEBUG_COMMANDS, "END"); +} + + +/****************************************************************************/ +/** Edit/Delete command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_delete (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_view_delete_selection (GL_VIEW(window->view)); + + gl_debug (DEBUG_COMMANDS, "END"); +} + + +/****************************************************************************/ +/** Edit/Select-all command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_select_all (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_view_select_all (GL_VIEW(window->view)); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** Edit/Unselect-all command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_unselect_all (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gl_view_unselect_all (GL_VIEW(window->view)); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** Edit/Preferences command. */ +/****************************************************************************/ +void +gl_ui_cmd_edit_preferences (GtkAction *action, + glWindow *window) +{ + static GtkWidget *dlg = NULL; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (dlg != NULL) + { + gtk_window_present (GTK_WINDOW (dlg)); + gtk_window_set_transient_for (GTK_WINDOW (dlg), + GTK_WINDOW(window)); + + } else { + + dlg = gl_prefs_dialog_new (GTK_WINDOW(window)); + + g_signal_connect (G_OBJECT (dlg), "destroy", + G_CALLBACK (gtk_widget_destroyed), &dlg); + + gtk_widget_show (dlg); + + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Property-bar-toggle command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action, + glWindow *window) +{ + gboolean state; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + state = gtk_toggle_action_get_active (action); + + gl_prefs->property_toolbar_visible = state; + if (state) { + gtk_widget_show (GTK_WIDGET (window->property_bar)); + } else { + gtk_widget_hide (GTK_WIDGET (window->property_bar)); + } + gl_prefs_model_save_settings (gl_prefs); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Property-bar-tooltips-toggle command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_property_bar_tips_toggle (GtkToggleAction *action, + glWindow *window) +{ + gboolean state; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + state = gtk_toggle_action_get_active (action); + + gl_prefs->property_toolbar_view_tooltips = state; + gl_ui_property_bar_set_tooltips (window->property_bar, state); + gl_prefs_model_save_settings (gl_prefs); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Grid-toggle command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_grid_toggle (GtkToggleAction *action, + glWindow *window) +{ + gboolean state; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + state = gtk_toggle_action_get_active (action); + + gl_prefs->grid_visible = state; + if (state) { + gl_view_show_grid (GL_VIEW(window->view)); + } else { + gl_view_hide_grid (GL_VIEW(window->view)); + } + gl_prefs_model_save_settings (gl_prefs); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Markup-toggle command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_markup_toggle (GtkToggleAction *action, + glWindow *window) +{ + gboolean state; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + state = gtk_toggle_action_get_active (action); + + gl_prefs->markup_visible = state; + if (state) { + gl_view_show_markup (GL_VIEW(window->view)); + } else { + gl_view_hide_markup (GL_VIEW(window->view)); + } + gl_prefs_model_save_settings (gl_prefs); + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Zoom-in command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_zoomin (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_zoom_in (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Zoom-out command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_zoomout (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_zoom_out (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Zoom-1:1 command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_zoom1to1 (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_set_zoom (GL_VIEW(window->view), 1.0); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** View/Zoom-to-fit command. */ +/*****************************************************************************/ +void +gl_ui_cmd_view_zoom_to_fit (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_zoom_to_fit (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Arrow-mode command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_arrow_mode (GtkAction *action, + glWindow *window) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_arrow_mode (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Create-text object command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_create_text (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_object_create_mode (GL_VIEW(window->view), + GL_LABEL_OBJECT_TEXT); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Create-box object command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_create_box (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_object_create_mode (GL_VIEW(window->view), + GL_LABEL_OBJECT_BOX); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Create-line object command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_create_line (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_object_create_mode (GL_VIEW(window->view), + GL_LABEL_OBJECT_LINE); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Create-ellipse object command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_create_ellipse (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_object_create_mode (GL_VIEW(window->view), + GL_LABEL_OBJECT_ELLIPSE); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Create-image object command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_create_image (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_object_create_mode (GL_VIEW(window->view), + GL_LABEL_OBJECT_IMAGE); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Create-barcode object command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_create_barcode (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_object_create_mode (GL_VIEW(window->view), + GL_LABEL_OBJECT_BARCODE); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Raise command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_raise (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_raise_selection (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Lower command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_lower (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_lower_selection (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Rotate-left-90-degrees command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_rotate_left (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_rotate_selection_left (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Rotate-right-90-degrees command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_rotate_right (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_rotate_selection_right (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Flip-horizontally command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_flip_horiz (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_flip_selection_horiz (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Flip-vertically command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_flip_vert (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_flip_selection_vert (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Align-left command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_align_left (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_align_selection_left (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Align-right command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_align_right (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_align_selection_right (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Align-horizontal-center command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_align_hcenter (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_align_selection_hcenter (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Align-top command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_align_top (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_align_selection_top (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Align-bottom command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_align_bottom (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_align_selection_bottom (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Align-vertical center command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_align_vcenter (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_align_selection_vcenter (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Center-horizontally command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_center_horiz (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_center_selection_horiz (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Center-vertically command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_center_vert (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_center_selection_vert (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*****************************************************************************/ +/** Objects/Edit- merge-properties command. */ +/*****************************************************************************/ +void +gl_ui_cmd_objects_merge_properties (GtkAction *action, + glWindow *window) + +{ + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (window->view != NULL) { + gl_view_edit_merge_props (GL_VIEW(window->view)); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/****************************************************************************/ +/** Help/Contents command. */ +/****************************************************************************/ +void +gl_ui_cmd_help_contents (GtkAction *action, + glWindow *window) +{ + GError *error = NULL; + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error); + + if (error != NULL) + { + g_warning (error->message); + + g_error_free (error); + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + +/*--------------------------------------------------------------------------*/ +/** Private: URL handler. */ +/*--------------------------------------------------------------------------*/ +static void +activate_url (GtkAboutDialog *about, + const gchar *url, + gpointer data) +{ + gl_debug (DEBUG_COMMANDS, "START"); + + gnome_url_show (url, NULL); + + gl_debug (DEBUG_COMMANDS, "END"); +} + + +/****************************************************************************/ +/** Help/About command. */ +/****************************************************************************/ +void +gl_ui_cmd_help_about (GtkAction *action, + glWindow *window) +{ + static GtkWidget *about = NULL; + + GdkPixbuf *pixbuf = NULL; + + const gchar *authors[] = { + "Jim Evins ", + " ", + _("Glabels includes contributions from:"), + "Frederic Ruaudel ", + "Wayne Schuller ", + "Emmanuel Pacaud ", + " ", + _("See the file AUTHORS for additional credits,"), + _("or visit http://glabels.sourceforge.net/"), + NULL + }; + + const gchar *artists[] = { + "Nestor Di ", + "Jim Evins ", + NULL + }; + + const gchar *copy_text = "Copyright \xc2\xa9 2001-2005 Jim Evins"; + + const gchar *about_text = _("A label and business card creation program.\n"); + + const gchar *url = "http://glabels.sourceforge.net"; + + const gchar *translator_credits = _("translator-credits"); + + const gchar *license = _( + "Glabels is free software; you can redistribute it and/or modify it\n" + "under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 2 of the License, or\n" + "(at your option) any later version.\n" "\n" + "This program is distributed in the hope that it will be useful, but\n" + "WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See\n" + "the GNU General Public License for more details.\n"); + + gl_debug (DEBUG_COMMANDS, "START"); + + g_return_if_fail (action && GTK_IS_ACTION(action)); + g_return_if_fail (window && GL_IS_WINDOW(window)); + + if (about != NULL) + { + + gtk_window_set_transient_for (GTK_WINDOW (about), + GTK_WINDOW (window)); + gtk_window_present (GTK_WINDOW (about)); + + } else { + + pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL); + + gtk_about_dialog_set_url_hook (activate_url, NULL, NULL); + + about = gtk_about_dialog_new (); + gtk_about_dialog_set_name (GTK_ABOUT_DIALOG(about), _("glabels")); + gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about), VERSION); + gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about), copy_text); + gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about), about_text); + gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), url); + gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG(about), pixbuf); + + gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors); + gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG(about), artists); + gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about), + translator_credits); + gtk_about_dialog_set_license (GTK_ABOUT_DIALOG(about), license); + + gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE); + + g_signal_connect (G_OBJECT (about), "response", + G_CALLBACK (gtk_widget_destroy), NULL); + g_signal_connect (G_OBJECT (about), "destroy", + G_CALLBACK (gtk_widget_destroyed), &about); + + gtk_window_set_transient_for (GTK_WINDOW (about), + GTK_WINDOW (window)); + + gtk_window_present (GTK_WINDOW (about)); + + if (pixbuf != NULL) + g_object_unref (pixbuf); + + } + + gl_debug (DEBUG_COMMANDS, "END"); +} + diff --git a/glabels2/src/ui-commands.h b/glabels2/src/ui-commands.h new file mode 100644 index 00000000..51ce39f2 --- /dev/null +++ b/glabels2/src/ui-commands.h @@ -0,0 +1,202 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** + * (GLABELS) Label and Business Card Creation program for GNOME + * + * ui-commands.h: GLabels UI commands module header file + * + * Copyright (C) 2001-2005 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __COMMANDS_H__ +#define __COMMANDS_H__ + +#include +#include +#include "window.h" + +G_BEGIN_DECLS + +void gl_ui_cmd_file_new (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_properties (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_template_designer (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_open (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_open_recent (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_save (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_save_as (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_print (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_print_preview (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_close (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_file_quit (GtkAction *action, + glWindow *window); + + + +void gl_ui_cmd_edit_undo (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_redo (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_cut (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_copy (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_paste (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_delete (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_select_all (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_unselect_all (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_edit_preferences (GtkAction *action, + glWindow *window); + + + +void gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action, + glWindow *window); + +void gl_ui_cmd_view_property_bar_tips_toggle (GtkToggleAction *action, + glWindow *window); + +void gl_ui_cmd_view_grid_toggle (GtkToggleAction *action, + glWindow *window); + +void gl_ui_cmd_view_markup_toggle (GtkToggleAction *action, + glWindow *window); + + + +void gl_ui_cmd_view_zoomin (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_view_zoomout (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_view_zoom1to1 (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_view_zoom_to_fit (GtkAction *action, + glWindow *window); + + + +void gl_ui_cmd_objects_arrow_mode (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_create_text (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_create_box (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_create_line (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_create_ellipse (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_create_image (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_create_barcode (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_raise (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_lower (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_rotate_left (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_rotate_right (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_flip_horiz (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_flip_vert (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_align_left (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_align_right (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_align_hcenter (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_align_top (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_align_bottom (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_align_vcenter (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_center_horiz (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_center_vert (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_objects_merge_properties (GtkAction *action, + glWindow *window); + + + +void gl_ui_cmd_help_contents (GtkAction *action, + glWindow *window); + +void gl_ui_cmd_help_about (GtkAction *action, + glWindow *window); + +G_END_DECLS + +#endif /* __COMMANDS_H__ */ diff --git a/glabels2/src/ui-property-bar.c b/glabels2/src/ui-property-bar.c index 64cac185..2a5a50b4 100644 --- a/glabels2/src/ui-property-bar.c +++ b/glabels2/src/ui-property-bar.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * property-bar.c: gLabels property bar @@ -25,11 +27,15 @@ #include "ui-property-bar.h" #include +#include #include #include +#include +#include #include +#include -#include "ui-util.h" +#include "util.h" #include "mygal/widget-color-combo.h" #include "stock-pixmaps/stockpixbufs.h" #include "prefs.h" @@ -42,59 +48,47 @@ /*============================================================================*/ /*============================================================================*/ -/* Private globals */ +/* Private data types */ /*============================================================================*/ -static GObjectClass *parent_class; - -static gchar* doc_verbs [] = { - "/commands/PropFontName", - "/commands/PropFontSize", - "/commands/PropFontBold", - "/commands/PropFontItalic", - "/commands/PropTextAlignLeft", - "/commands/PropTextAlignCenter", - "/commands/PropTextAlignRight", - "/commands/PropFillColor", - "/commands/PropLineColor", - "/commands/PropTextColor", - "/commands/PropLineWidth", - - NULL -}; +struct _glUIPropertyBarPrivate { -static gchar* text_verbs [] = { - "/commands/PropFontName", - "/commands/PropFontSize", - "/commands/PropFontBold", - "/commands/PropFontItalic", - "/commands/PropTextAlignLeft", - "/commands/PropTextAlignCenter", - "/commands/PropTextAlignRight", - "/commands/PropTextColor", - - NULL -}; + glView *view; -static gchar* fill_verbs [] = { - "/commands/PropFillColor", + GladeXML *gui; - NULL -}; + GtkWidget *tool_bar; -static gchar* line_color_verbs [] = { - "/commands/PropLineColor", + /* Font selection */ + GtkWidget *font_family_combo; + GtkWidget *font_size_spin; + GtkWidget *font_bold_toggle; + GtkWidget *font_italic_toggle; - NULL -}; + /* Text alignemnt radios */ + GtkWidget *text_align_left_radio; + GtkWidget *text_align_center_radio; + GtkWidget *text_align_right_radio; + + /* Color combos */ + GtkWidget *text_color_combo; + GtkWidget *fill_color_combo; + GtkWidget *line_color_combo; -static gchar* line_width_verbs [] = { - "/commands/PropLineWidth", + /* Line width */ + GtkWidget *line_width_spin; + + gboolean stop_signals; - NULL }; +/*============================================================================*/ +/* Private globals */ +/*============================================================================*/ + +static GtkHBoxClass *parent_class; + /*============================================================================*/ /* Local function prototypes */ /*============================================================================*/ @@ -103,8 +97,7 @@ static void gl_ui_property_bar_class_init (glUIPropertyBarClass *class); static void gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar); static void gl_ui_property_bar_finalize (GObject *object); -static void gl_ui_property_bar_construct (glUIPropertyBar *property_bar, - BonoboUIComponent *ui_component); +static void gl_ui_property_bar_construct (glUIPropertyBar *property_bar); static void selection_changed_cb (glUIPropertyBar *property_bar); @@ -138,17 +131,29 @@ static void line_color_changed_cb (ColorCombo *cc, static void line_width_changed_cb (GtkSpinButton *spin, glUIPropertyBar *property_bar); -static void prop_item_toggled_cb (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - glUIPropertyBar *property_bar); +static void font_bold_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *property_bar); + +static void font_italic_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *property_bar); + +static void text_align_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *property_bar); + +static void set_doc_items_sensitive (glUIPropertyBar *property_bar, + gboolean state); -static void null_cmd (BonoboUIComponent *ui_component, - gpointer user_data, - const gchar *verbname); +static void set_text_items_sensitive (glUIPropertyBar *property_bar, + gboolean state); +static void set_fill_items_sensitive (glUIPropertyBar *property_bar, + gboolean state); +static void set_line_color_items_sensitive (glUIPropertyBar *property_bar, + gboolean state); + +static void set_line_width_items_sensitive (glUIPropertyBar *property_bar, + gboolean state); /****************************************************************************/ @@ -173,7 +178,7 @@ gl_ui_property_bar_get_type (void) NULL }; - type = g_type_register_static (G_TYPE_OBJECT, + type = g_type_register_static (GTK_TYPE_HBOX, "glUIPropertyBar", &info, 0); } @@ -199,7 +204,16 @@ gl_ui_property_bar_instance_init (glUIPropertyBar *property_bar) { gl_debug (DEBUG_PROPERTY_BAR, "START"); - property_bar->view = NULL; + property_bar->priv = g_new0 (glUIPropertyBarPrivate, 1); + + property_bar->priv->gui = glade_xml_new (GLABELS_GLADE_DIR "property-bar.glade", + "property_toolbar", + NULL); + + if (!property_bar->priv->gui) { + g_warning ("Could not open property-bar.glade, reinstall glabels!"); + return; + } gl_debug (DEBUG_PROPERTY_BAR, "END"); } @@ -216,186 +230,165 @@ gl_ui_property_bar_finalize (GObject *object) property_bar = GL_UI_PROPERTY_BAR (object); - if (property_bar->view) { - g_object_unref (G_OBJECT(property_bar->view)); - property_bar = NULL; + if (property_bar->priv->view) { + g_object_unref (G_OBJECT(property_bar->priv->view)); } G_OBJECT_CLASS (parent_class)->finalize (object); + g_free (property_bar->priv); + gl_debug (DEBUG_PROPERTY_BAR, "END"); } /****************************************************************************/ /* Create a NEW property_bar. */ /****************************************************************************/ -GObject * -gl_ui_property_bar_new (BonoboUIComponent *ui_component) +GtkWidget * +gl_ui_property_bar_new (void) { glUIPropertyBar *property_bar; gl_debug (DEBUG_PROPERTY_BAR, "START"); - property_bar = g_object_new (gl_ui_property_bar_get_type (), NULL); + property_bar = g_object_new (GL_TYPE_UI_PROPERTY_BAR, NULL); - gl_ui_property_bar_construct (property_bar, ui_component); + gl_ui_property_bar_construct (property_bar); gl_debug (DEBUG_PROPERTY_BAR, "END"); - return G_OBJECT(property_bar); + return GTK_WIDGET (property_bar); } /******************************************************************************/ /* Initialize property toolbar. */ /******************************************************************************/ static void -gl_ui_property_bar_construct (glUIPropertyBar *property_bar, - BonoboUIComponent *ui_component) +gl_ui_property_bar_construct (glUIPropertyBar *property_bar) { - GtkWidget *wcombo; GList *family_names = NULL; GList *family_node; - GtkObject *adjust; - ColorGroup *cg; - GdkPixbuf *pixbuf; GdkColor *gdk_color; gl_debug (DEBUG_PROPERTY_BAR, "START"); - property_bar->stop_signals = TRUE; - property_bar->ui_component = ui_component; + property_bar->priv->stop_signals = TRUE; + + property_bar->priv->tool_bar = glade_xml_get_widget (property_bar->priv->gui, + "property_toolbar"); + gtk_container_add (GTK_CONTAINER (property_bar), property_bar->priv->tool_bar); + + property_bar->priv->font_family_combo = + glade_xml_get_widget (property_bar->priv->gui, "font_family_combo"); + property_bar->priv->font_size_spin = + glade_xml_get_widget (property_bar->priv->gui, "font_size_spin"); + property_bar->priv->font_bold_toggle = + glade_xml_get_widget (property_bar->priv->gui, "font_bold_toggle"); + property_bar->priv->font_italic_toggle = + glade_xml_get_widget (property_bar->priv->gui, "font_italic_toggle"); + property_bar->priv->text_align_left_radio = + glade_xml_get_widget (property_bar->priv->gui, "text_align_left_radio"); + property_bar->priv->text_align_center_radio = + glade_xml_get_widget (property_bar->priv->gui, "text_align_center_radio"); + property_bar->priv->text_align_right_radio = + glade_xml_get_widget (property_bar->priv->gui, "text_align_right_radio"); + property_bar->priv->text_color_combo = + glade_xml_get_widget (property_bar->priv->gui, "text_color_combo"); + property_bar->priv->fill_color_combo = + glade_xml_get_widget (property_bar->priv->gui, "fill_color_combo"); + property_bar->priv->line_color_combo = + glade_xml_get_widget (property_bar->priv->gui, "line_color_combo"); + property_bar->priv->line_width_spin = + glade_xml_get_widget (property_bar->priv->gui, "line_width_spin"); + + set_doc_items_sensitive (property_bar, FALSE); /* Font family entry widget */ - wcombo = gtk_combo_box_new_text (); + gl_util_combo_box_add_text_model (GTK_COMBO_BOX (property_bar->priv->font_family_combo)); family_names = gnome_font_family_list (); - gl_util_combo_box_set_strings (GTK_COMBO_BOX (wcombo), family_names); - property_bar->font_family_combo = wcombo; - gtk_widget_set_size_request (wcombo, 200, -1); + gl_util_combo_box_set_strings (GTK_COMBO_BOX (property_bar->priv->font_family_combo), + family_names); + gtk_widget_set_size_request (property_bar->priv->font_family_combo, 200, -1); /* Make sure we have a valid font. if not provide a good default. */ family_node = g_list_find_custom (family_names, gl_prefs->default_font_family, (GCompareFunc)g_utf8_collate); if (family_node) { - gtk_combo_box_set_active (GTK_COMBO_BOX (wcombo), + gtk_combo_box_set_active (GTK_COMBO_BOX (property_bar->priv->font_family_combo), g_list_position (family_names, family_node)); } else { - gtk_combo_box_set_active (GTK_COMBO_BOX (wcombo), 0); + gtk_combo_box_set_active (GTK_COMBO_BOX (property_bar->priv->font_family_combo), 0); } gnome_font_family_list_free (family_names); - g_signal_connect (G_OBJECT (property_bar->font_family_combo), + g_signal_connect (G_OBJECT (property_bar->priv->font_family_combo), "changed", G_CALLBACK (font_family_changed_cb), property_bar); - gl_ui_util_insert_widget (ui_component, wcombo, "/PropertyToolbar/PropFontName"); - /* Font size entry widget */ - adjust = gtk_adjustment_new (1.0, 1.0, 250.0, 1.0, 10.0, 10.0); - property_bar->font_size_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin), + gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->font_size_spin), gl_prefs->default_font_size); - g_signal_connect (G_OBJECT (property_bar->font_size_spin), + g_signal_connect (G_OBJECT (property_bar->priv->font_size_spin), "changed", G_CALLBACK (font_size_changed_cb), property_bar); - gl_ui_util_insert_widget (ui_component, property_bar->font_size_spin, - "/PropertyToolbar/PropFontSize"); /* Bold and Italic toggles */ - bonobo_ui_component_add_verb (ui_component, "PropFontBold", null_cmd, NULL); - gl_ui_util_set_verb_state (ui_component, "/commands/PropFontBold", - (gl_prefs->default_font_weight == GNOME_FONT_BOLD)); - bonobo_ui_component_add_listener (ui_component, "PropFontBold", - (BonoboUIListenerFn)prop_item_toggled_cb, - (gpointer)property_bar); - bonobo_ui_component_add_verb (ui_component, "PropFontItalic", null_cmd, NULL); - gl_ui_util_set_verb_state (ui_component, "/commands/PropFontItalic", - gl_prefs->default_font_italic_flag); - bonobo_ui_component_add_listener (ui_component, "PropFontItalic", - (BonoboUIListenerFn)prop_item_toggled_cb, - (gpointer)property_bar); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle), + (gl_prefs->default_font_weight == GNOME_FONT_BOLD)); + g_signal_connect (G_OBJECT (property_bar->priv->font_bold_toggle), + "toggled", G_CALLBACK (font_bold_toggled_cb), property_bar); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle), + gl_prefs->default_font_italic_flag); + g_signal_connect (G_OBJECT (property_bar->priv->font_italic_toggle), + "toggled", G_CALLBACK (font_italic_toggled_cb), property_bar); + /* Text alignment radio group */ - bonobo_ui_component_add_verb (ui_component, "PropTextAlignLeft", null_cmd, NULL); - gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignLeft", - (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT)); - bonobo_ui_component_add_listener (ui_component, "PropTextAlignLeft", - (BonoboUIListenerFn)prop_item_toggled_cb, - (gpointer)property_bar); - bonobo_ui_component_add_verb (ui_component, "PropTextAlignCenter", null_cmd, NULL); - gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignCenter", - (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER)); - bonobo_ui_component_add_listener (ui_component, "PropTextAlignCenter", - (BonoboUIListenerFn)prop_item_toggled_cb, - (gpointer)property_bar); - bonobo_ui_component_add_verb (ui_component, "PropTextAlignRight", null_cmd, NULL); - gl_ui_util_set_verb_state (ui_component, "/commands/PropTextAlignRight", - (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT)); - bonobo_ui_component_add_listener (ui_component, "PropTextAlignRight", - (BonoboUIListenerFn)prop_item_toggled_cb, - (gpointer)property_bar); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio), + (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT)); + g_signal_connect (G_OBJECT (property_bar->priv->text_align_left_radio), + "toggled", G_CALLBACK (text_align_toggled_cb), property_bar); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio), + (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER)); + g_signal_connect (G_OBJECT (property_bar->priv->text_align_center_radio), + "toggled", G_CALLBACK (text_align_toggled_cb), property_bar); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio), + (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT)); + g_signal_connect (G_OBJECT (property_bar->priv->text_align_right_radio), + "toggled", G_CALLBACK (text_align_toggled_cb), property_bar); /* Text color widget */ - cg = color_group_fetch ("text_color_group", NULL); - pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL); gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color); - property_bar->text_color_combo = color_combo_new (pixbuf, _("Default"), - gdk_color, cg); + color_combo_set_color (COLOR_COMBO (property_bar->priv->text_color_combo), gdk_color); g_free (gdk_color); - - g_signal_connect (G_OBJECT (property_bar->text_color_combo), + g_signal_connect (G_OBJECT (property_bar->priv->text_color_combo), "color_changed", G_CALLBACK (text_color_changed_cb), property_bar); - gl_ui_util_insert_widget (ui_component, property_bar->text_color_combo, - "/PropertyToolbar/PropTextColor"); - /* Fill color widget */ - cg = color_group_fetch ("fill_color_group", NULL); - pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL); gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color); - property_bar->fill_color_combo = color_combo_new (pixbuf, _("No fill"), - gdk_color, cg); + color_combo_set_color (COLOR_COMBO (property_bar->priv->fill_color_combo), gdk_color); g_free (gdk_color); - - g_signal_connect (G_OBJECT (property_bar->fill_color_combo), + g_signal_connect (G_OBJECT (property_bar->priv->fill_color_combo), "color_changed", G_CALLBACK (fill_color_changed_cb), property_bar); - gl_ui_util_insert_widget (ui_component, property_bar->fill_color_combo, - "/PropertyToolbar/PropFillColor"); - /* Line color widget */ - cg = color_group_fetch ("line_color_group", NULL); - pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL); gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); - property_bar->line_color_combo = color_combo_new (pixbuf, _("No line"), - gdk_color, cg); + color_combo_set_color (COLOR_COMBO (property_bar->priv->line_color_combo), gdk_color); g_free (gdk_color); - - g_signal_connect (G_OBJECT (property_bar->line_color_combo), + g_signal_connect (G_OBJECT (property_bar->priv->line_color_combo), "color_changed", G_CALLBACK (line_color_changed_cb), property_bar); - gl_ui_util_insert_widget (ui_component, property_bar->line_color_combo, - "/PropertyToolbar/PropLineColor"); - /* Line width entry widget */ - adjust = gtk_adjustment_new (1.0, 0.25, 4.0, 0.25, 1.0, 1.0); - property_bar->line_width_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 0.25, 2); - - g_signal_connect (G_OBJECT (property_bar->line_width_spin), + g_signal_connect (G_OBJECT (property_bar->priv->line_width_spin), "changed", G_CALLBACK (line_width_changed_cb), property_bar); - gl_ui_util_insert_widget (ui_component, property_bar->line_width_spin, - "/PropertyToolbar/PropLineWidth"); - - gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE); - - property_bar->stop_signals = FALSE; + property_bar->priv->stop_signals = FALSE; gl_debug (DEBUG_PROPERTY_BAR, "END"); } @@ -424,43 +417,38 @@ reset_to_default_properties (glView *view, good_font_family = NULL; } } - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->font_family_combo), + gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo), good_font_family); g_free (good_font_family); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->font_size_spin), + gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->font_size_spin), view->default_font_size); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropFontBold", - (view->default_font_weight == GNOME_FONT_BOLD)); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropFontItalic", - view->default_font_italic_flag); - - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropTextAlignLeft", - (view->default_text_alignment == GTK_JUSTIFY_LEFT)); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropTextAlignCenter", - (view->default_text_alignment == GTK_JUSTIFY_CENTER)); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropTextAlignRight", - (view->default_text_alignment == GTK_JUSTIFY_RIGHT)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle), + (view->default_font_weight == GNOME_FONT_BOLD)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle), + view->default_font_italic_flag); + + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio), + (view->default_text_alignment == GTK_JUSTIFY_LEFT)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio), + (view->default_text_alignment == GTK_JUSTIFY_CENTER)); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio), + (view->default_text_alignment == GTK_JUSTIFY_RIGHT)); gdk_color = gl_color_to_gdk_color (view->default_text_color); - color_combo_set_color (COLOR_COMBO(property_bar->text_color_combo), gdk_color); + color_combo_set_color (COLOR_COMBO(property_bar->priv->text_color_combo), gdk_color); g_free (gdk_color); gdk_color = gl_color_to_gdk_color (view->default_fill_color); - color_combo_set_color (COLOR_COMBO(property_bar->fill_color_combo), gdk_color); + color_combo_set_color (COLOR_COMBO(property_bar->priv->fill_color_combo), gdk_color); g_free (gdk_color); gdk_color = gl_color_to_gdk_color (view->default_line_color); - color_combo_set_color (COLOR_COMBO(property_bar->line_color_combo), gdk_color); + color_combo_set_color (COLOR_COMBO(property_bar->priv->line_color_combo), gdk_color); g_free (gdk_color); - gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->line_width_spin), + gtk_spin_button_set_value (GTK_SPIN_BUTTON(property_bar->priv->line_width_spin), view->default_line_width); } @@ -479,9 +467,9 @@ gl_ui_property_bar_set_view (glUIPropertyBar *property_bar, label = view->label; g_return_if_fail (label && GL_IS_LABEL (label)); - gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, doc_verbs, TRUE); + set_doc_items_sensitive (property_bar, TRUE); - property_bar->view = GL_VIEW (g_object_ref (G_OBJECT (view))); + property_bar->priv->view = GL_VIEW (g_object_ref (G_OBJECT (view))); reset_to_default_properties (view, property_bar); @@ -494,10 +482,35 @@ gl_ui_property_bar_set_view (glUIPropertyBar *property_bar, gl_debug (DEBUG_PROPERTY_BAR, "END"); } +/****************************************************************************/ +/** Set visiblity of property bar's tooltips. */ +/****************************************************************************/ +void +gl_ui_property_bar_set_tooltips (glUIPropertyBar *property_bar, + gboolean state) +{ + GtkTooltipsData *data; + + gl_debug (DEBUG_PROPERTY_BAR, "START"); + + g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR(property_bar)); + + /* HACK: peek into one of our widgets to get the tooltips group created by libglade. */ + data = gtk_tooltips_data_get (property_bar->priv->font_size_spin); + g_return_if_fail (data); + + if (state) { + gtk_tooltips_enable (data->tooltips); + } else { + gtk_tooltips_disable (data->tooltips); + } + + gl_debug (DEBUG_PROPERTY_BAR, "END"); +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. View "selection state changed" callback. */ /*---------------------------------------------------------------------------*/ - static void update_text_properties (glView *view, glUIPropertyBar *property_bar) @@ -518,9 +531,8 @@ update_text_properties (glView *view, GdkColor *gdk_color; can_text = gl_view_can_selection_text (view); - gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, - text_verbs, - can_text); + set_text_items_sensitive (property_bar, can_text); + if (!can_text) return; @@ -590,23 +602,23 @@ update_text_properties (glView *view, if (is_same_font_family && (selection_font_family != NULL)) gl_debug (DEBUG_PROPERTY_BAR, "same font family = %s", selection_font_family); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->font_family_combo), + gl_util_combo_box_set_active_text (GTK_COMBO_BOX (property_bar->priv->font_family_combo), is_same_font_family?selection_font_family:""); g_free (selection_font_family); if (is_same_font_size) { gl_debug (DEBUG_PROPERTY_BAR, "same font size = %g", selection_font_size); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->font_size_spin), + gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->priv->font_size_spin), selection_font_size); } else { - gtk_entry_set_text (GTK_ENTRY (property_bar->font_size_spin), ""); + gtk_entry_set_text (GTK_ENTRY (property_bar->priv->font_size_spin), ""); } if (is_same_text_color) { gl_debug (DEBUG_PROPERTY_BAR, "same text color = %08x", selection_text_color); gdk_color = gl_color_to_gdk_color (selection_text_color); - color_combo_set_color (COLOR_COMBO (property_bar->text_color_combo), + color_combo_set_color (COLOR_COMBO (property_bar->priv->text_color_combo), gdk_color); g_free (gdk_color); } @@ -614,31 +626,26 @@ update_text_properties (glView *view, if (is_same_is_italic) gl_debug (DEBUG_PROPERTY_BAR, "same italic flag = %d", selection_is_italic); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropFontItalic", - selection_is_italic && is_same_is_italic); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_italic_toggle), + selection_is_italic && is_same_is_italic); if (is_same_is_bold) gl_debug (DEBUG_PROPERTY_BAR, "same bold flag = %d", selection_is_bold); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropFontBold", - selection_is_bold && is_same_is_bold); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->font_bold_toggle), + selection_is_bold && is_same_is_bold); if (is_same_justification) gl_debug (DEBUG_PROPERTY_BAR, "same justification"); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropTextAlignRight", - (selection_justification == GTK_JUSTIFY_RIGHT) && - is_same_justification); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropTextAlignLeft", - (selection_justification == GTK_JUSTIFY_LEFT) && - is_same_justification); - gl_ui_util_set_verb_state (property_bar->ui_component, - "/commands/PropTextAlignCenter", - (selection_justification == GTK_JUSTIFY_CENTER) && - is_same_justification); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio), + (selection_justification == GTK_JUSTIFY_LEFT) && + is_same_justification); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio), + (selection_justification == GTK_JUSTIFY_CENTER) && + is_same_justification); + gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio), + (selection_justification == GTK_JUSTIFY_RIGHT) && + is_same_justification); } static void @@ -654,9 +661,8 @@ update_fill_color (glView *view, glColorNode *fill_color_node; can = gl_view_can_selection_fill (view); - gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, - fill_verbs, - can); + set_fill_items_sensitive (property_bar, can); + if (!can) return; @@ -691,7 +697,7 @@ update_fill_color (glView *view, if (is_same_fill_color) { gl_debug (DEBUG_PROPERTY_BAR, "same fill color = %08x", selection_fill_color); gdk_color = gl_color_to_gdk_color (selection_fill_color); - color_combo_set_color (COLOR_COMBO (property_bar->fill_color_combo), + color_combo_set_color (COLOR_COMBO (property_bar->priv->fill_color_combo), gdk_color); g_free (gdk_color); } @@ -710,9 +716,8 @@ update_line_color (glView *view, GdkColor *gdk_color; can = gl_view_can_selection_line_color (view); - gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, - line_color_verbs, - can); + set_line_color_items_sensitive (property_bar, can); + if (!can) return; @@ -747,7 +752,7 @@ update_line_color (glView *view, if (is_same_line_color) { gl_debug (DEBUG_PROPERTY_BAR, "same line color = %08x", selection_line_color); gdk_color = gl_color_to_gdk_color (selection_line_color); - color_combo_set_color (COLOR_COMBO (property_bar->line_color_combo), + color_combo_set_color (COLOR_COMBO (property_bar->priv->line_color_combo), gdk_color); g_free (gdk_color); } @@ -764,9 +769,8 @@ update_line_width (glView *view, gdouble selection_line_width, line_width; can = gl_view_can_selection_line_width (view); - gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, - line_width_verbs, - can); + set_line_width_items_sensitive (property_bar, can); + if (!can) return; @@ -792,31 +796,30 @@ update_line_width (glView *view, if (is_same_line_width) { gl_debug (DEBUG_PROPERTY_BAR, "same line width = %g", selection_line_width); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->line_width_spin), + gtk_spin_button_set_value (GTK_SPIN_BUTTON (property_bar->priv->line_width_spin), selection_line_width); } else { - gtk_entry_set_text (GTK_ENTRY (property_bar->line_width_spin), ""); + gtk_entry_set_text (GTK_ENTRY (property_bar->priv->line_width_spin), ""); } } static void selection_changed_cb (glUIPropertyBar *property_bar) { - glView *view = property_bar->view; + glView *view = property_bar->priv->view; gl_debug (DEBUG_PROPERTY_BAR, "START"); g_return_if_fail (view && GL_IS_VIEW (view)); g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar)); - property_bar->stop_signals = TRUE; + property_bar->priv->stop_signals = TRUE; if (gl_view_is_selection_empty (view)) { /* No selection: make all controls active. */ reset_to_default_properties (view, property_bar); - gl_ui_util_set_verb_list_sensitive (property_bar->ui_component, - doc_verbs, TRUE); + set_doc_items_sensitive (property_bar, TRUE); } else { @@ -827,7 +830,7 @@ selection_changed_cb (glUIPropertyBar *property_bar) } - property_bar->stop_signals = FALSE; + property_bar->priv->stop_signals = FALSE; gl_debug (DEBUG_PROPERTY_BAR, "END"); } @@ -841,25 +844,25 @@ font_family_changed_cb (GtkComboBox *combo, { gchar *font_family; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); font_family = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo)); if ( strlen(font_family) ) { - gl_view_set_selection_font_family (property_bar->view, + gl_view_set_selection_font_family (property_bar->priv->view, font_family); - gl_view_set_default_font_family (property_bar->view, + gl_view_set_default_font_family (property_bar->priv->view, font_family); } g_free (font_family); - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -875,23 +878,23 @@ font_size_changed_cb (GtkSpinButton *spin, { gdouble font_size; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); font_size = gtk_spin_button_get_value (spin); - gl_view_set_selection_font_size (property_bar->view, + gl_view_set_selection_font_size (property_bar->priv->view, font_size); - gl_view_set_default_font_size (property_bar->view, + gl_view_set_default_font_size (property_bar->priv->view, font_size); - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -911,14 +914,14 @@ text_color_changed_cb (ColorCombo *cc, { glColorNode *text_color_node; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar)); gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -930,23 +933,23 @@ text_color_changed_cb (ColorCombo *cc, if (is_default) { text_color_node->color = gl_prefs->default_text_color; - gl_view_set_selection_text_color (property_bar->view, + gl_view_set_selection_text_color (property_bar->priv->view, text_color_node); - gl_view_set_default_text_color (property_bar->view, + gl_view_set_default_text_color (property_bar->priv->view, gl_prefs->default_text_color); } else { - gl_view_set_selection_text_color (property_bar->view, + gl_view_set_selection_text_color (property_bar->priv->view, text_color_node); - gl_view_set_default_text_color (property_bar->view, + gl_view_set_default_text_color (property_bar->priv->view, text_color_node->color); } gl_color_node_free (&text_color_node); - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -966,14 +969,14 @@ fill_color_changed_cb (ColorCombo *cc, { glColorNode *fill_color_node; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar)); gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -987,22 +990,22 @@ fill_color_changed_cb (ColorCombo *cc, if (is_default) { fill_color_node->color = GL_COLOR_NONE; - gl_view_set_selection_fill_color (property_bar->view, + gl_view_set_selection_fill_color (property_bar->priv->view, fill_color_node); - gl_view_set_default_fill_color (property_bar->view, + gl_view_set_default_fill_color (property_bar->priv->view, fill_color_node->color); } else { - gl_view_set_selection_fill_color (property_bar->view, + gl_view_set_selection_fill_color (property_bar->priv->view, fill_color_node); - gl_view_set_default_fill_color (property_bar->view, + gl_view_set_default_fill_color (property_bar->priv->view, fill_color_node->color); } gl_color_node_free (&fill_color_node); - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -1022,14 +1025,14 @@ line_color_changed_cb (ColorCombo *cc, { glColorNode *line_color_node; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; g_return_if_fail (property_bar && GL_IS_UI_PROPERTY_BAR (property_bar)); gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -1041,22 +1044,22 @@ line_color_changed_cb (ColorCombo *cc, if (is_default) { line_color_node->color = GL_COLOR_NONE; - gl_view_set_selection_line_color (property_bar->view, + gl_view_set_selection_line_color (property_bar->priv->view, line_color_node); - gl_view_set_default_line_color (property_bar->view, + gl_view_set_default_line_color (property_bar->priv->view, line_color_node->color); } else { - gl_view_set_selection_line_color (property_bar->view, + gl_view_set_selection_line_color (property_bar->priv->view, line_color_node); - gl_view_set_default_line_color (property_bar->view, + gl_view_set_default_line_color (property_bar->priv->view, line_color_node->color); } gl_color_node_free (&line_color_node); - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); @@ -1072,133 +1075,264 @@ line_width_changed_cb (GtkSpinButton *spin, { gdouble line_width; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + if (property_bar->priv->view) { + + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), + selection_changed_cb, + property_bar); + + line_width = gtk_spin_button_get_value (spin); + + gl_view_set_selection_line_width (property_bar->priv->view, + line_width); + gl_view_set_default_line_width (property_bar->priv->view, + line_width); + + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), + selection_changed_cb, + property_bar); + + } + + gl_debug (DEBUG_PROPERTY_BAR, "END"); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Font bold toggled callback. */ +/*---------------------------------------------------------------------------*/ +static void +font_bold_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *property_bar) +{ + gboolean state; + GnomeFontWeight weight; + + + if (property_bar->priv->stop_signals) + return; + + gl_debug (DEBUG_PROPERTY_BAR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); - line_width = gtk_spin_button_get_value (spin); + state = gtk_toggle_tool_button_get_active (toggle); - gl_view_set_selection_line_width (property_bar->view, - line_width); - gl_view_set_default_line_width (property_bar->view, - line_width); + weight = state ? GNOME_FONT_BOLD : GNOME_FONT_BOOK; - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + gl_view_set_selection_font_weight (property_bar->priv->view, weight); + gl_view_set_default_font_weight (property_bar->priv->view, weight); + + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); gl_debug (DEBUG_PROPERTY_BAR, "END"); } - + /*---------------------------------------------------------------------------*/ -/* PRIVATE. Property bar item toggled callback. */ +/* PRIVATE. Font italic toggled callback. */ /*---------------------------------------------------------------------------*/ static void -prop_item_toggled_cb (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - glUIPropertyBar *property_bar) +font_italic_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *property_bar) { - gboolean s; + gboolean state; - if (property_bar->stop_signals) + if (property_bar->priv->stop_signals) return; - gl_debug (DEBUG_PROPERTY_BAR, ""); + gl_debug (DEBUG_PROPERTY_BAR, "START"); - g_signal_handlers_block_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); - s = (strcmp (state, "1") == 0); + state = gtk_toggle_tool_button_get_active (toggle); - /* - * Font properties: Bold & Italic - */ - if (strcmp (path, "PropFontBold") == 0) - { - GnomeFontWeight weight = s ? GNOME_FONT_BOLD : GNOME_FONT_BOOK; + gl_view_set_selection_font_italic_flag (property_bar->priv->view, state); + gl_view_set_default_font_italic_flag (property_bar->priv->view, state); - gl_view_set_selection_font_weight (property_bar->view, weight); - gl_view_set_default_font_weight (property_bar->view, weight); - } + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), + selection_changed_cb, + property_bar); - if (strcmp (path, "PropFontItalic") == 0) - { - gl_view_set_selection_font_italic_flag (property_bar->view, s); - gl_view_set_default_font_italic_flag (property_bar->view, s); - } + gl_debug (DEBUG_PROPERTY_BAR, "END"); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Text align toggled callback. */ +/*---------------------------------------------------------------------------*/ +static void +text_align_toggled_cb (GtkToggleToolButton *toggle, + glUIPropertyBar *property_bar) +{ + if (property_bar->priv->stop_signals) + return; + gl_debug (DEBUG_PROPERTY_BAR, "START"); - /* - * Text alignment group - */ - if (s && (strcmp (path, "PropTextAlignLeft") == 0)) + g_signal_handlers_block_by_func (G_OBJECT(property_bar->priv->view->label), + selection_changed_cb, + property_bar); + + if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_left_radio))) { - gl_view_set_selection_text_alignment (property_bar->view, + gl_view_set_selection_text_alignment (property_bar->priv->view, GTK_JUSTIFY_LEFT); - gl_view_set_default_text_alignment (property_bar->view, + gl_view_set_default_text_alignment (property_bar->priv->view, GTK_JUSTIFY_LEFT); - - /* Adjust state of siblings */ - gl_ui_util_set_verb_state (ui_component, - "/commands/PropTextAlignCenter", - FALSE); - gl_ui_util_set_verb_state (ui_component, - "/commands/PropTextAlignRight", - FALSE); } - if (s && (strcmp (path, "PropTextAlignCenter") == 0)) + if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_center_radio))) { - gl_view_set_selection_text_alignment (property_bar->view, + gl_view_set_selection_text_alignment (property_bar->priv->view, GTK_JUSTIFY_CENTER); - gl_view_set_default_text_alignment (property_bar->view, + gl_view_set_default_text_alignment (property_bar->priv->view, GTK_JUSTIFY_CENTER); - - /* Adjust state of siblings */ - gl_ui_util_set_verb_state (ui_component, - "/commands/PropTextAlignLeft", - FALSE); - gl_ui_util_set_verb_state (ui_component, - "/commands/PropTextAlignRight", - FALSE); } - if (s && (strcmp (path, "PropTextAlignRight") == 0)) - { - gl_view_set_selection_text_alignment (property_bar->view, + if (gtk_toggle_tool_button_get_active (GTK_TOGGLE_TOOL_BUTTON (property_bar->priv->text_align_right_radio))) + { + gl_view_set_selection_text_alignment (property_bar->priv->view, GTK_JUSTIFY_RIGHT); - gl_view_set_default_text_alignment (property_bar->view, + gl_view_set_default_text_alignment (property_bar->priv->view, GTK_JUSTIFY_RIGHT); - - /* Adjust state of siblings */ - gl_ui_util_set_verb_state (ui_component, - "/commands/PropTextAlignLeft", - FALSE); - gl_ui_util_set_verb_state (ui_component, - "/commands/PropTextAlignCenter", - FALSE); } - g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->view->label), + g_signal_handlers_unblock_by_func (G_OBJECT(property_bar->priv->view->label), selection_changed_cb, property_bar); + gl_debug (DEBUG_PROPERTY_BAR, "END"); +} + + +/*****************************************************************************/ +/* Construct color combo "Custom widget". */ +/*****************************************************************************/ +GtkWidget * +gl_ui_property_bar_construct_color_combo (gchar *name, + gchar *string1, + gchar *string2, + gint int1, + gint int2) +{ + GtkWidget *color_combo; + ColorGroup *cg; + gchar *cg_name; + guint color; + GdkColor *gdk_color; + gchar *no_color; + GdkPixbuf *pixbuf = NULL; + + switch (int1) { + + case 0: + cg_name = "text_color_group"; + color = gl_prefs->default_text_color; + no_color = _("Default"); + pixbuf = gdk_pixbuf_new_from_inline (-1, stock_text_24, FALSE, NULL); + break; + + case 2: + cg_name = "line_color_group"; + color = gl_prefs->default_line_color; + no_color = _("No line"); + pixbuf = gdk_pixbuf_new_from_inline (-1, stock_pencil_24, FALSE, NULL); + break; + + case 1: + default: + cg_name = "fill_color_group"; + color = gl_prefs->default_fill_color; + no_color = _("No fill"); + pixbuf = gdk_pixbuf_new_from_inline (-1, stock_bucket_fill_24, FALSE, NULL); + break; + + } + + cg = color_group_fetch (cg_name, NULL); + gdk_color = gl_color_to_gdk_color (color); + color_combo = color_combo_new (pixbuf, no_color, gdk_color, cg); + g_free (gdk_color); + + color_combo_box_set_preview_relief (COLOR_COMBO(color_combo), GTK_RELIEF_NORMAL); + + return color_combo; +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Set sensitivity of doc controls. */ +/*---------------------------------------------------------------------------*/ +static void +set_doc_items_sensitive (glUIPropertyBar *property_bar, + gboolean state) +{ + gtk_widget_set_sensitive (property_bar->priv->font_family_combo, state); + gtk_widget_set_sensitive (property_bar->priv->font_size_spin, state); + gtk_widget_set_sensitive (property_bar->priv->font_bold_toggle, state); + gtk_widget_set_sensitive (property_bar->priv->font_italic_toggle, state); + gtk_widget_set_sensitive (property_bar->priv->text_align_left_radio, state); + gtk_widget_set_sensitive (property_bar->priv->text_align_center_radio, state); + gtk_widget_set_sensitive (property_bar->priv->text_align_right_radio, state); + gtk_widget_set_sensitive (property_bar->priv->text_color_combo, state); + gtk_widget_set_sensitive (property_bar->priv->fill_color_combo, state); + gtk_widget_set_sensitive (property_bar->priv->line_color_combo, state); + gtk_widget_set_sensitive (property_bar->priv->line_width_spin, state); } -/*---------------------------------------------------------------------------------------*/ -/* NULL command handler -- hides bogus "verb not found" errors for toggle toolbar items. */ -/*---------------------------------------------------------------------------------------*/ +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Set sensitivity of text related controls. */ +/*---------------------------------------------------------------------------*/ static void -null_cmd (BonoboUIComponent *ui_component, - gpointer user_data, - const gchar *verbname) +set_text_items_sensitive (glUIPropertyBar *property_bar, + gboolean state) { + gtk_widget_set_sensitive (property_bar->priv->font_family_combo, state); + gtk_widget_set_sensitive (property_bar->priv->font_size_spin, state); + gtk_widget_set_sensitive (property_bar->priv->font_bold_toggle, state); + gtk_widget_set_sensitive (property_bar->priv->font_italic_toggle, state); + gtk_widget_set_sensitive (property_bar->priv->text_align_left_radio, state); + gtk_widget_set_sensitive (property_bar->priv->text_align_center_radio, state); + gtk_widget_set_sensitive (property_bar->priv->text_align_right_radio, state); + gtk_widget_set_sensitive (property_bar->priv->text_color_combo, state); } + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Set sensitivity of fill related controls. */ +/*---------------------------------------------------------------------------*/ +static void +set_fill_items_sensitive (glUIPropertyBar *property_bar, + gboolean state) +{ + gtk_widget_set_sensitive (property_bar->priv->fill_color_combo, state); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Set sensitivity of line color related controls. */ +/*---------------------------------------------------------------------------*/ +static void +set_line_color_items_sensitive (glUIPropertyBar *property_bar, + gboolean state) +{ + gtk_widget_set_sensitive (property_bar->priv->line_color_combo, state); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Set sensitivity of line width related controls. */ +/*---------------------------------------------------------------------------*/ +static void +set_line_width_items_sensitive (glUIPropertyBar *property_bar, + gboolean state) +{ + gtk_widget_set_sensitive (property_bar->priv->line_width_spin, state); +} + + diff --git a/glabels2/src/ui-property-bar.h b/glabels2/src/ui-property-bar.h index 73aa1e66..6d3287fb 100644 --- a/glabels2/src/ui-property-bar.h +++ b/glabels2/src/ui-property-bar.h @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui-property-bar.h: Property toolbar header file @@ -23,9 +25,7 @@ #ifndef __UI_PROPERTY_BAR_H__ #define __UI_PROPERTY_BAR_H__ -#include -#include -#include +#include #include "view.h" @@ -41,39 +41,33 @@ G_BEGIN_DECLS #define GL_IS_UI_PROPERTY_BAR_CLASS(klass) \ (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_UI_PROPERTY_BAR)) -typedef struct _glUIPropertyBar glUIPropertyBar; -typedef struct _glUIPropertyBarClass glUIPropertyBarClass; - -struct _glUIPropertyBar { - GObject parent_widget; - - BonoboUIComponent *ui_component; +typedef struct _glUIPropertyBar glUIPropertyBar; +typedef struct _glUIPropertyBarClass glUIPropertyBarClass; - glView *view; +typedef struct _glUIPropertyBarPrivate glUIPropertyBarPrivate; - GtkWidget *font_family_combo; - GtkWidget *font_size_spin; - GtkWidget *text_color_combo; - - GtkWidget *fill_color_combo; +struct _glUIPropertyBar { + GtkHBox parent_widget; - GtkWidget *line_color_combo; - GtkWidget *line_width_spin; + glUIPropertyBarPrivate *priv; - gboolean stop_signals; }; struct _glUIPropertyBarClass { - GObjectClass parent_class; + GtkHBoxClass parent_class; }; GType gl_ui_property_bar_get_type (void) G_GNUC_CONST; -GObject *gl_ui_property_bar_new (BonoboUIComponent *ui_component); +GtkWidget *gl_ui_property_bar_new (void); void gl_ui_property_bar_set_view (glUIPropertyBar *property_bar, glView *view); +void gl_ui_property_bar_set_tooltips (glUIPropertyBar *property_bar, + gboolean state); + + G_END_DECLS diff --git a/glabels2/src/ui-sidebar.c b/glabels2/src/ui-sidebar.c index 2549c1b1..6d59ec67 100644 --- a/glabels2/src/ui-sidebar.c +++ b/glabels2/src/ui-sidebar.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui-sidebar.c: Object property sidebar @@ -40,17 +42,23 @@ #define DEFAULT_SIDEBAR_WIDTH 340 /*============================================================================*/ -/* Private globals */ +/* Private data types */ /*============================================================================*/ -static GObjectClass *parent_class; +struct _glUISidebarPrivate { -static gchar* doc_verbs [] = { - "/commands/PropertyEditor", + glView *view; - NULL + GtkWidget *child; + GtkWidget *empty_child; }; +/*============================================================================*/ +/* Private globals */ +/*============================================================================*/ + +static GtkVBoxClass *parent_class; + /*============================================================================*/ /* Local function prototypes */ /*============================================================================*/ @@ -59,8 +67,7 @@ static void gl_ui_sidebar_class_init (glUISidebarClass *class); static void gl_ui_sidebar_instance_init (glUISidebar *sidebar); static void gl_ui_sidebar_finalize (GObject *object); -static void gl_ui_sidebar_construct (glUISidebar *sidebar, - BonoboUIComponent *ui_component); +static void gl_ui_sidebar_construct (glUISidebar *sidebar); static void selection_changed_cb (glView *view, glUISidebar *sidebar); @@ -115,7 +122,7 @@ gl_ui_sidebar_instance_init (glUISidebar *sidebar) { gl_debug (DEBUG_UI, "START"); - sidebar->view = NULL; + sidebar->priv = g_new0 (glUISidebarPrivate, 1); gl_debug (DEBUG_UI, "END"); } @@ -132,21 +139,22 @@ gl_ui_sidebar_finalize (GObject *object) sidebar = GL_UI_SIDEBAR (object); - if (sidebar->view) { - g_object_unref (G_OBJECT(sidebar->view)); - sidebar = NULL; + if (sidebar->priv->view) { + g_object_unref (G_OBJECT(sidebar->priv->view)); } G_OBJECT_CLASS (parent_class)->finalize (object); + g_free (sidebar->priv); + gl_debug (DEBUG_UI, "END"); } /****************************************************************************/ /* Create a NEW sidebar. */ /****************************************************************************/ -GObject * -gl_ui_sidebar_new (BonoboUIComponent *ui_component) +GtkWidget * +gl_ui_sidebar_new (void) { glUISidebar *sidebar; @@ -156,38 +164,31 @@ gl_ui_sidebar_new (BonoboUIComponent *ui_component) gtk_widget_set_size_request (GTK_WIDGET (sidebar), DEFAULT_SIDEBAR_WIDTH, -1); - gl_ui_sidebar_construct (sidebar, ui_component); + gl_ui_sidebar_construct (sidebar); gl_debug (DEBUG_UI, "END"); - return G_OBJECT(sidebar); + return GTK_WIDGET(sidebar); } /******************************************************************************/ /* Initialize property toolbar. */ /******************************************************************************/ static void -gl_ui_sidebar_construct (glUISidebar *sidebar, - BonoboUIComponent *ui_component) +gl_ui_sidebar_construct (glUISidebar *sidebar) { gl_debug (DEBUG_UI, "START"); - sidebar->ui_component = ui_component; - - gl_ui_util_insert_widget (ui_component, - GTK_WIDGET (sidebar), - "/PropertySidebar/PropertyEditor"); + sidebar->priv->empty_child = gl_object_editor_new (GL_STOCK_PROPERTIES, + _("Object properties"), + GL_OBJECT_EDITOR_EMPTY, + NULL); - sidebar->empty_child = gl_object_editor_new (GL_STOCK_PROPERTIES, - _("Object properties"), - GL_OBJECT_EDITOR_EMPTY, - NULL); + sidebar->priv->child = gtk_widget_ref (sidebar->priv->empty_child); + gtk_widget_show (sidebar->priv->child); + gtk_container_add (GTK_CONTAINER(sidebar), sidebar->priv->child); - sidebar->child = gtk_widget_ref (sidebar->empty_child); - gtk_widget_show (sidebar->child); - gtk_container_add (GTK_CONTAINER(sidebar), sidebar->child); - - gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE); + gtk_widget_set_sensitive (GTK_WIDGET (sidebar), FALSE); gl_debug (DEBUG_UI, "END"); } @@ -203,9 +204,9 @@ gl_ui_sidebar_set_view (glUISidebar *sidebar, g_return_if_fail (view && GL_IS_VIEW (view)); - gl_ui_util_set_verb_list_sensitive (sidebar->ui_component, doc_verbs, TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (sidebar), TRUE); - sidebar->view = GL_VIEW (g_object_ref (G_OBJECT (view))); + sidebar->priv->view = GL_VIEW (g_object_ref (G_OBJECT (view))); g_signal_connect (G_OBJECT(view), "selection_changed", G_CALLBACK(selection_changed_cb), sidebar); @@ -225,24 +226,21 @@ selection_changed_cb (glView *view, g_return_if_fail (view && GL_IS_VIEW (view)); g_return_if_fail (sidebar && GL_IS_UI_SIDEBAR (sidebar)); - gtk_container_remove (GTK_CONTAINER(sidebar), sidebar->child); + gtk_container_remove (GTK_CONTAINER(sidebar), sidebar->priv->child); if (gl_view_is_selection_empty (view) || !gl_view_is_selection_atomic (view)) { - sidebar->child = gtk_widget_ref (sidebar->empty_child); + sidebar->priv->child = gtk_widget_ref (sidebar->priv->empty_child); } else { - sidebar->child = gtk_widget_ref (gl_view_get_editor (view)); + sidebar->priv->child = gtk_widget_ref (gl_view_get_editor (view)); } - gtk_widget_show (sidebar->child); -#if 0 - gtk_container_add (GTK_CONTAINER(sidebar), sidebar->child); -#else - gtk_box_pack_start (GTK_BOX(sidebar), sidebar->child, TRUE, TRUE, 0); -#endif + gtk_widget_show (sidebar->priv->child); + + gtk_box_pack_start (GTK_BOX(sidebar), sidebar->priv->child, TRUE, TRUE, 0); gl_debug (DEBUG_UI, "END"); } diff --git a/glabels2/src/ui-sidebar.h b/glabels2/src/ui-sidebar.h index 37892e82..74eb599f 100644 --- a/glabels2/src/ui-sidebar.h +++ b/glabels2/src/ui-sidebar.h @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui-sidebar.h: Object property sidebar header file @@ -23,9 +25,7 @@ #ifndef __UI_SIDEBAR_H__ #define __UI_SIDEBAR_H__ -#include -#include -#include +#include #include "view.h" @@ -41,17 +41,15 @@ G_BEGIN_DECLS #define GL_IS_UI_SIDEBAR_CLASS(klass) \ (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_UI_SIDEBAR)) -typedef struct _glUISidebar glUISidebar; -typedef struct _glUISidebarClass glUISidebarClass; +typedef struct _glUISidebar glUISidebar; +typedef struct _glUISidebarClass glUISidebarClass; + +typedef struct _glUISidebarPrivate glUISidebarPrivate; struct _glUISidebar { GtkVBox parent_widget; - BonoboUIComponent *ui_component; - - glView *view; - GtkWidget *child; - GtkWidget *empty_child; + glUISidebarPrivate *priv; }; struct _glUISidebarClass { @@ -60,7 +58,7 @@ struct _glUISidebarClass { GType gl_ui_sidebar_get_type (void) G_GNUC_CONST; -GObject *gl_ui_sidebar_new (BonoboUIComponent *ui_component); +GtkWidget *gl_ui_sidebar_new (void); void gl_ui_sidebar_set_view (glUISidebar *sidebar, glView *view); diff --git a/glabels2/src/ui-util.c b/glabels2/src/ui-util.c index 0a1420cb..4bf12e05 100644 --- a/glabels2/src/ui-util.c +++ b/glabels2/src/ui-util.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui-util.c: GLabels ui utilities module @@ -23,7 +25,8 @@ #include "ui-util.h" -#include +#include +#include #include "debug.h" @@ -49,20 +52,23 @@ /* Set sensitivity of verb. */ /*****************************************************************************/ void -gl_ui_util_set_verb_sensitive (BonoboUIComponent *ui_component, - gchar *cname, - gboolean sensitive) +gl_ui_util_set_verb_sensitive (GtkUIManager *ui, + gchar *cname, + gboolean sensitive) { + GtkAction *action; + gl_debug (DEBUG_UI, "START"); g_return_if_fail (cname != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); + g_return_if_fail (GTK_IS_UI_MANAGER (ui)); - bonobo_ui_component_set_prop (ui_component, - cname, - "sensitive", - sensitive ? "1" : "0", - NULL); + action = gtk_ui_manager_get_action (ui, cname); + + if (action) { + gl_debug (DEBUG_UI, "Set action \"%s\" sensitive = %d", cname, sensitive); + gtk_action_set_sensitive (action, sensitive); + } gl_debug (DEBUG_UI, "END"); } @@ -71,22 +77,24 @@ gl_ui_util_set_verb_sensitive (BonoboUIComponent *ui_component, /* Set sensitivity of a list of verbs. */ /*****************************************************************************/ void -gl_ui_util_set_verb_list_sensitive (BonoboUIComponent *ui_component, - gchar **vlist, - gboolean sensitive) +gl_ui_util_set_verb_list_sensitive (GtkUIManager *ui, + gchar **vlist, + gboolean sensitive) { + GtkAction *action; + gl_debug (DEBUG_UI, "START"); g_return_if_fail (vlist != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); + g_return_if_fail (GTK_IS_UI_MANAGER (ui)); for ( ; *vlist; ++vlist) { - bonobo_ui_component_set_prop (ui_component, - *vlist, - "sensitive", - sensitive ? "1" : "0", - NULL); + action = gtk_ui_manager_get_action (ui, *vlist); + + if (action) { + gtk_action_set_sensitive (action, sensitive); + } } gl_debug (DEBUG_UI, "END"); @@ -96,44 +104,22 @@ gl_ui_util_set_verb_list_sensitive (BonoboUIComponent *ui_component, /* Set state of a verb. */ /*****************************************************************************/ void -gl_ui_util_set_verb_state (BonoboUIComponent *ui_component, - gchar *cname, - gboolean state) +gl_ui_util_set_verb_state (GtkUIManager *ui, + gchar *cname, + gboolean state) { + GtkToggleAction *action; + gl_debug (DEBUG_UI, "START"); g_return_if_fail (cname != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); - - bonobo_ui_component_set_prop (ui_component, - cname, - "state", - state ? "1" : "0", - NULL); - - gl_debug (DEBUG_UI, "END"); -} + g_return_if_fail (GTK_IS_UI_MANAGER (ui)); - -/*****************************************************************************/ -/* Insert widget at path. */ -/*****************************************************************************/ -void -gl_ui_util_insert_widget (BonoboUIComponent *ui_component, - GtkWidget *widget, - const char *path) -{ - BonoboControl *control; - - gl_debug (DEBUG_UI, "START"); + action = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (ui, cname)); - gtk_widget_show_all (widget); - control = bonobo_control_new (widget); - bonobo_ui_component_object_set (ui_component, - path, - BONOBO_OBJREF (control), - NULL); - bonobo_object_unref (BONOBO_OBJECT (control)); + if (action) { + gtk_toggle_action_set_active (action, state); + } gl_debug (DEBUG_UI, "END"); } diff --git a/glabels2/src/ui-util.h b/glabels2/src/ui-util.h index 5e89c4c1..4ebcae17 100644 --- a/glabels2/src/ui-util.h +++ b/glabels2/src/ui-util.h @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui-util.h: GLabels UI utilities module header file @@ -22,26 +24,21 @@ #ifndef __GL_UI_UTIL_H__ #define __GL_UI_UTIL_H__ -#include +#include G_BEGIN_DECLS -void gl_ui_util_set_verb_sensitive (BonoboUIComponent *ui_component, - gchar *cname, - gboolean sensitive); - -void gl_ui_util_set_verb_list_sensitive (BonoboUIComponent *ui_component, - gchar **vlist, - gboolean sensitive); - -void gl_ui_util_set_verb_state (BonoboUIComponent *ui_component, - gchar *cname, - gboolean state); +void gl_ui_util_set_verb_sensitive (GtkUIManager *ui, + gchar *cname, + gboolean sensitive); -void gl_ui_util_insert_widget (BonoboUIComponent *ui_component, - GtkWidget *widget, - const char *path); +void gl_ui_util_set_verb_list_sensitive (GtkUIManager *ui, + gchar **vlist, + gboolean sensitive); +void gl_ui_util_set_verb_state (GtkUIManager *ui, + gchar *cname, + gboolean state); G_END_DECLS diff --git a/glabels2/src/ui.c b/glabels2/src/ui.c index 47c69af8..9378193f 100644 --- a/glabels2/src/ui.c +++ b/glabels2/src/ui.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui.c: GLabels ui module @@ -23,158 +25,650 @@ #include "ui.h" -#include "recent-files/egg-recent-view.h" -#include "recent-files/egg-recent-view-bonobo.h" +#include #include #include "ui-util.h" -#include "commands.h" -#include "tools.h" -#include "recent.h" +#include "ui-commands.h" #include "file.h" #include "prefs.h" +#include "stock.h" +#include "window.h" #include "debug.h" /*==========================================================================*/ /* Private macros and constants. */ /*==========================================================================*/ -#define GLABELS_UI_XML GLABELS_UI_DIR "glabels-ui.xml" /*==========================================================================*/ /* Private types. */ /*==========================================================================*/ +/*==========================================================================*/ +/* Local function prototypes */ +/*==========================================================================*/ + +static void view_ui_item_toggled_cb (GtkToggleAction *action, + GtkUIManager *ui); + +static void set_app_main_toolbar_style (GtkUIManager *ui); + +static void set_app_drawing_toolbar_style (GtkUIManager *ui); + +static void set_view_style (GtkUIManager *ui); + /*==========================================================================*/ /* Private globals */ /*==========================================================================*/ -static BonoboUIVerb gl_ui_verbs [] = { - BONOBO_UI_VERB ("FileNew", gl_cmd_file_new), - BONOBO_UI_VERB ("FileProperties", gl_cmd_file_properties), - BONOBO_UI_VERB ("FileTemplateDesigner", gl_cmd_file_template_designer), - BONOBO_UI_VERB ("FileOpen", gl_cmd_file_open), - BONOBO_UI_VERB ("FileSave", gl_cmd_file_save), - BONOBO_UI_VERB ("FileSaveAs", gl_cmd_file_save_as), - BONOBO_UI_VERB ("FilePrint", gl_cmd_file_print), - BONOBO_UI_VERB ("FileClose", gl_cmd_file_close), - BONOBO_UI_VERB ("FileExit", gl_cmd_file_exit), - BONOBO_UI_VERB ("EditCut", gl_cmd_edit_cut), - BONOBO_UI_VERB ("EditCopy", gl_cmd_edit_copy), - BONOBO_UI_VERB ("EditPaste", gl_cmd_edit_paste), - BONOBO_UI_VERB ("EditDelete", gl_cmd_edit_delete), - BONOBO_UI_VERB ("EditSelectAll", gl_cmd_edit_select_all), - BONOBO_UI_VERB ("EditUnSelectAll", gl_cmd_edit_unselect_all), - BONOBO_UI_VERB ("ToolsArrow", gl_tools_arrow), - BONOBO_UI_VERB ("ToolsText", gl_tools_text), - BONOBO_UI_VERB ("ToolsBox", gl_tools_box), - BONOBO_UI_VERB ("ToolsLine", gl_tools_line), - BONOBO_UI_VERB ("ToolsEllipse", gl_tools_ellipse), - BONOBO_UI_VERB ("ToolsImage", gl_tools_image), - BONOBO_UI_VERB ("ToolsBarcode", gl_tools_barcode), - BONOBO_UI_VERB ("ToolsZoomIn", gl_tools_zoomin), - BONOBO_UI_VERB ("ToolsZoomOut", gl_tools_zoomout), - BONOBO_UI_VERB ("ToolsZoom1to1", gl_tools_zoom1to1), - BONOBO_UI_VERB ("ToolsZoomToFit", gl_tools_zoom_to_fit), - BONOBO_UI_VERB ("ToolsMergeProperties", gl_tools_merge_properties), - BONOBO_UI_VERB ("ToolsRaiseObjects", gl_tools_raise_objects), - BONOBO_UI_VERB ("ToolsLowerObjects", gl_tools_lower_objects), - BONOBO_UI_VERB ("ToolsRotateLeft", gl_tools_rotate_objects_left), - BONOBO_UI_VERB ("ToolsRotateRight", gl_tools_rotate_objects_right), - BONOBO_UI_VERB ("ToolsFlipHorizontal", gl_tools_flip_objects_horiz), - BONOBO_UI_VERB ("ToolsFlipVertical", gl_tools_flip_objects_vert), - BONOBO_UI_VERB ("ToolsAlignLeft", gl_tools_align_objects_left), - BONOBO_UI_VERB ("ToolsAlignRight", gl_tools_align_objects_right), - BONOBO_UI_VERB ("ToolsAlignHCenter", gl_tools_align_objects_hcenter), - BONOBO_UI_VERB ("ToolsAlignTop", gl_tools_align_objects_top), - BONOBO_UI_VERB ("ToolsAlignBottom", gl_tools_align_objects_bottom), - BONOBO_UI_VERB ("ToolsAlignVCenter", gl_tools_align_objects_vcenter), - BONOBO_UI_VERB ("ToolsCenterHorizontal", gl_tools_center_objects_horiz), - BONOBO_UI_VERB ("ToolsCenterVertical", gl_tools_center_objects_vert), - BONOBO_UI_VERB ("SettingsPreferences", gl_cmd_settings_preferences), - BONOBO_UI_VERB ("HelpContents", gl_cmd_help_contents), - BONOBO_UI_VERB ("About", gl_cmd_help_about), - - BONOBO_UI_VERB_END +static GtkActionEntry entries[] = { + + /* Menu entries. */ + { "FileMenu", NULL, "_File" }, + { "FileRecentsMenu", NULL, "Recent _Files" }, + { "EditMenu", NULL, "_Edit" }, + { "ViewMenu", NULL, "_View" }, + { "ViewMainToolBarMenu", NULL, "Customize Main Toolbar" }, + { "ViewDrawingToolBarMenu", NULL, "Customize Drawing Toolbar" }, + { "ViewPropertyToolBarMenu", NULL, "Customize Properties Toolbar" }, + { "ObjectsMenu", NULL, "_Objects" }, + { "ObjectsCreateMenu", NULL, "_Create" }, + { "ObjectsOrderMenu", NULL, "_Order" }, + { "ObjectsRotateFlipMenu", NULL, "_Rotate/Flip" }, + { "ObjectsAlignHorizMenu", NULL, "Align _Horizontal" }, + { "ObjectsAlignVertMenu", NULL, "Align _Vertical" }, + { "HelpMenu", NULL, "_Help" }, + + + /* File action entries. */ + { "FileNew", + GTK_STOCK_NEW, + "_New", + "N", + "Create a new file", + G_CALLBACK (gl_ui_cmd_file_new) }, + + { "FileOpen", + GTK_STOCK_OPEN, + "_Open...", + "O", + "Open a file", + G_CALLBACK (gl_ui_cmd_file_open) }, + + { "FileSave", + GTK_STOCK_SAVE, + "_Save", + "S", + "Save current file", + G_CALLBACK (gl_ui_cmd_file_save) }, + + { "FileSaveAs", + GTK_STOCK_SAVE, + "Save _As...", + "S", + "Save the current file to a different name", + G_CALLBACK (gl_ui_cmd_file_save_as) }, + + { "FilePrint", + GTK_STOCK_PRINT, + "_Print...", + "P", + "Print the current file", + G_CALLBACK (gl_ui_cmd_file_print) }, + + { "FileProperties", + GTK_STOCK_PROPERTIES, + "Properties...", + NULL, + "Modify document properties", + G_CALLBACK (gl_ui_cmd_file_properties) }, + + { "FileTemplateDesigner", + NULL, + "Template _Designer...", + NULL, + "Create a custom template", + G_CALLBACK (gl_ui_cmd_file_template_designer) }, + + { "FileClose", + GTK_STOCK_CLOSE, + "_Close", + "F4", + "Close the current file", + G_CALLBACK (gl_ui_cmd_file_close) }, + + { "FileQuit", + GTK_STOCK_QUIT, + "_Quit", + "Q", + "Quit the program", + G_CALLBACK (gl_ui_cmd_file_quit) }, + + + /* Edit action entries. */ + { "EditCut", + GTK_STOCK_CUT, + "Cut", + "X", + "Cut the selection", + G_CALLBACK (gl_ui_cmd_edit_cut) }, + + { "EditCopy", + GTK_STOCK_COPY, + "Copy", + "C", + "Copy the selection", + G_CALLBACK (gl_ui_cmd_edit_copy) }, + + { "EditPaste", + GTK_STOCK_PASTE, + "Paste", + "V", + "Paste the clipboard", + G_CALLBACK (gl_ui_cmd_edit_paste) }, + + { "EditDelete", + NULL, + "Delete", + NULL, + "Delete the selected objects", + G_CALLBACK (gl_ui_cmd_edit_delete) }, + + { "EditSelectAll", + NULL, + "Select All", + "A", + "Select all objects", + G_CALLBACK (gl_ui_cmd_edit_select_all) }, + + { "EditUnSelectAll", + NULL, + "Un-select All", + NULL, + "Remove all selections", + G_CALLBACK (gl_ui_cmd_edit_unselect_all) }, + + { "EditPreferences", + GTK_STOCK_PREFERENCES, + "Preferences", + NULL, + "Configure the application", + G_CALLBACK (gl_ui_cmd_edit_preferences) }, + + + /* View action entries. */ + { "ViewZoomIn", + GTK_STOCK_ZOOM_IN, + "Zoom in", + NULL, + "Increase magnification", + G_CALLBACK (gl_ui_cmd_view_zoomin) }, + + { "ViewZoomOut", + GTK_STOCK_ZOOM_OUT, + "Zoom out", + NULL, + "Decrease magnification", + G_CALLBACK (gl_ui_cmd_view_zoomout) }, + + { "ViewZoom1to1", + GTK_STOCK_ZOOM_100, + "Zoom 1 to 1", + NULL, + "Restore scale to 100%", + G_CALLBACK (gl_ui_cmd_view_zoom1to1) }, + + { "ViewZoomToFit", + GTK_STOCK_ZOOM_FIT, + "Zoom to fit", + NULL, + "Set scale to fit window", + G_CALLBACK (gl_ui_cmd_view_zoom_to_fit) }, + + + /* Objects action entries. */ + { "ObjectsArrowMode", + GL_STOCK_ARROW, + "Select Mode", + NULL, + "Select, move and modify objects", + G_CALLBACK (gl_ui_cmd_objects_arrow_mode) }, + + { "ObjectsCreateText", + GL_STOCK_TEXT, + "Text", + NULL, + "Create text object", + G_CALLBACK (gl_ui_cmd_objects_create_text) }, + + { "ObjectsCreateBox", + GL_STOCK_BOX, + "Box", + NULL, + "Create box/rectangle object", + G_CALLBACK (gl_ui_cmd_objects_create_box) }, + + { "ObjectsCreateLine", + GL_STOCK_LINE, + "Line", + NULL, + "Create line object", + G_CALLBACK (gl_ui_cmd_objects_create_line) }, + + { "ObjectsCreateEllipse", + GL_STOCK_ELLIPSE, + "Ellipse", + NULL, + "Create ellipse/circle object", + G_CALLBACK (gl_ui_cmd_objects_create_ellipse) }, + + { "ObjectsCreateImage", + GL_STOCK_IMAGE, + "Image", + NULL, + "Create image object", + G_CALLBACK (gl_ui_cmd_objects_create_image) }, + + { "ObjectsCreateBarcode", + GL_STOCK_BARCODE, + "Barcode", + NULL, + "Create barcode object", + G_CALLBACK (gl_ui_cmd_objects_create_barcode) }, + + { "ObjectsRaise", + GL_STOCK_ORDER_TOP, + "Bring to front", NULL, + "Raise object to top", + G_CALLBACK (gl_ui_cmd_objects_raise) }, + + { "ObjectsLower", + GL_STOCK_ORDER_BOTTOM, + "Send to back", + NULL, + "Lower object to bottom", + G_CALLBACK (gl_ui_cmd_objects_lower) }, + + { "ObjectsRotateLeft", + GL_STOCK_ROTATE_LEFT, + "Rotate left", + NULL, + "Rotate object 90 degrees counter-clockwise", + G_CALLBACK (gl_ui_cmd_objects_rotate_left) }, + + { "ObjectsRotateRight", + GL_STOCK_ROTATE_RIGHT, + "Rotate right", + NULL, + "Rotate object 90 degrees clockwise", + G_CALLBACK (gl_ui_cmd_objects_rotate_right) }, + + { "ObjectsFlipHorizontal", + GL_STOCK_FLIP_HORIZ, + "Flip horizontally", + NULL, + "Flip object horizontally", + G_CALLBACK (gl_ui_cmd_objects_flip_horiz) }, + + { "ObjectsFlipVertical", + GL_STOCK_FLIP_VERT, + "Flip vertically", + NULL, + "Flip object vertically", + G_CALLBACK (gl_ui_cmd_objects_flip_vert) }, + + { "ObjectsAlignLeft", + GL_STOCK_ALIGN_LEFT, + "Align left", + NULL, + "Align objects to left edges", + G_CALLBACK (gl_ui_cmd_objects_align_left) }, + + { "ObjectsAlignRight", + GL_STOCK_ALIGN_RIGHT, + "Align right", + NULL, + "Align objects to right edges", + G_CALLBACK (gl_ui_cmd_objects_align_right) }, + + { "ObjectsAlignHCenter", + GL_STOCK_ALIGN_HCENTER, + "Align horizontal center", + NULL, + "Align objects to horizontal centers", + G_CALLBACK (gl_ui_cmd_objects_align_hcenter) }, + + { "ObjectsAlignTop", + GL_STOCK_ALIGN_TOP, + "Align tops", + NULL, + "Align objects to top edges", + G_CALLBACK (gl_ui_cmd_objects_align_top) }, + + { "ObjectsAlignBottom", + GL_STOCK_ALIGN_BOTTOM, + "Align bottoms", + NULL, + "Align objects to bottom edges", + G_CALLBACK (gl_ui_cmd_objects_align_bottom) }, + + { "ObjectsAlignVCenter", + GL_STOCK_ALIGN_VCENTER, + "Align vertical center", + NULL, + "Align objects to vertical centers", + G_CALLBACK (gl_ui_cmd_objects_align_vcenter) }, + + { "ObjectsCenterHorizontal", + GL_STOCK_CENTER_HORIZ, + "Center horizontally", + NULL, + "Center objects to horizontal label center", + G_CALLBACK (gl_ui_cmd_objects_center_horiz) }, + + { "ObjectsCenterVertical", + GL_STOCK_CENTER_VERT, + "Center vertically", + NULL, + "Center objects to vertical label center", + G_CALLBACK (gl_ui_cmd_objects_center_vert) }, + + { "ObjectsMergeProperties", + GL_STOCK_MERGE, + "Merge properties", + NULL, + "Edit merge properties", + G_CALLBACK (gl_ui_cmd_objects_merge_properties) }, + + + /* Help actions entries. */ + { "HelpContents", + GTK_STOCK_HELP, + "Contents", + "F1", + "Open glabels manual", + G_CALLBACK (gl_ui_cmd_help_contents) }, + + { "HelpAbout", + GTK_STOCK_ABOUT, + "About...", + NULL, + "About glabels", + G_CALLBACK (gl_ui_cmd_help_about) }, + }; +static guint n_entries = G_N_ELEMENTS (entries); + +static GtkToggleActionEntry toggle_entries[] = { + + { "ViewPropertyToolBar", + NULL, + "Property toolbar", + NULL, + "Change the visibility of the property toolbar in the current window", + G_CALLBACK (gl_ui_cmd_view_property_bar_toggle), + TRUE }, + + { "ViewPropertyToolBarToolTips", + NULL, + "Show tooltips", + NULL, + "Show tooltips for property toolbar", + G_CALLBACK (gl_ui_cmd_view_property_bar_tips_toggle), + TRUE }, + + { "ViewGrid", + NULL, + "Grid", + NULL, + "Change the visibility of the grid in the current window", + G_CALLBACK (gl_ui_cmd_view_grid_toggle), + TRUE }, + + { "ViewMarkup", + NULL, + "Markup", + NULL, + "Change the visibility of markup lines in the current window", + G_CALLBACK (gl_ui_cmd_view_markup_toggle), + TRUE }, + +}; +static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries); + +static GtkToggleActionEntry ui_toggle_entries[] = { + + { "ViewMainToolBar", + NULL, + "Main toolbar", + NULL, + "Change the visibility of the main toolbar in the current window", + G_CALLBACK (view_ui_item_toggled_cb), + TRUE }, + + { "ViewDrawingToolBar", + NULL, + "Drawing toolbar", + NULL, + "Change the visibility of the drawing toolbar in the current window", + G_CALLBACK (view_ui_item_toggled_cb), + TRUE }, + + { "ViewMainToolBarToolTips", + NULL, + "Show tooltips", + NULL, + "Show tooltips for main toolbar", + G_CALLBACK (view_ui_item_toggled_cb), + TRUE }, + + { "ViewDrawingToolBarToolTips", + NULL, + "Show tooltips", + NULL, + "Show tooltips for drawing toolbar", + G_CALLBACK (view_ui_item_toggled_cb), + TRUE }, + +}; +static guint n_ui_toggle_entries = G_N_ELEMENTS (ui_toggle_entries); + +static const gchar *ui_info = +"" +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +"" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +"" +""; + static gchar* doc_verbs [] = { - "/commands/FileProperties", - "/commands/FileSave", - "/commands/FileSaveAs", - "/commands/FilePrint", - "/commands/FilePrintPreview", - "/commands/FileClose", - "/commands/FileCloseAll", - "/commands/EditUndo", - "/commands/EditRedo", - "/commands/EditCut", - "/commands/EditCopy", - "/commands/EditPaste", - "/commands/EditDelete", - "/commands/EditSelectAll", - "/commands/EditUnSelectAll", - "/commands/ToolsArrow", - "/commands/ToolsText", - "/commands/ToolsLine", - "/commands/ToolsBox", - "/commands/ToolsEllipse", - "/commands/ToolsImage", - "/commands/ToolsBarcode", - "/commands/ToolsZoomIn", - "/commands/ToolsZoomOut", - "/commands/ToolsZoom1to1", - "/commands/ToolsZoomToFit", - "/commands/ToolsMergeProperties", - "/commands/ToolsRaiseObjects", - "/commands/ToolsLowerObjects", - "/commands/ToolsRotateLeft", - "/commands/ToolsRotateRight", - "/commands/ToolsFlipHorizontal", - "/commands/ToolsFlipVertical", - "/commands/ToolsAlignLeft", - "/commands/ToolsAlignRight", - "/commands/ToolsAlignHCenter", - "/commands/ToolsAlignTop", - "/commands/ToolsAlignBottom", - "/commands/ToolsAlignVCenter", - "/commands/ToolsCenterHorizontal", - "/commands/ToolsCenterVertical", - "/menu/Objects/CreateObjects", - "/menu/Objects/Order", - "/menu/Objects/RotateFlip", - "/menu/Objects/AlignHoriz", - "/menu/Objects/AlignVert", - "/commands/ViewGrid", - "/commands/ViewMarkup", + "/ui/MenuBar/FileMenu/FileProperties", + "/ui/MenuBar/FileMenu/FileSave", + "/ui/MenuBar/FileMenu/FileSaveAs", + "/ui/MenuBar/FileMenu/FilePrint", + "/ui/MenuBar/FileMenu/FileClose", + "/ui/MenuBar/EditMenu/EditCut", + "/ui/MenuBar/EditMenu/EditCopy", + "/ui/MenuBar/EditMenu/EditPaste", + "/ui/MenuBar/EditMenu/EditDelete", + "/ui/MenuBar/EditMenu/EditSelectAll", + "/ui/MenuBar/EditMenu/EditUnSelectAll", + "/ui/MenuBar/ViewMenu/ViewZoomIn", + "/ui/MenuBar/ViewMenu/ViewZoomOut", + "/ui/MenuBar/ViewMenu/ViewZoom1to1", + "/ui/MenuBar/ViewMenu/ViewZoomToFit", + "/ui/MenuBar/ViewMenu/ViewGrid", + "/ui/MenuBar/ViewMenu/ViewMarkup", + "/ui/MenuBar/ObjectsMenu/ObjectsArrowMode", + "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateText", + "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateLine", + "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateBox", + "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateEllipse", + "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateImage", + "/ui/MenuBar/ObjectsMenu/ObjectsCreateMenu/ObjectsCreateBarcode", + "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsRaise", + "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsLower", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateLeft", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateRight", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipHorizontal", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipVertical", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignLeft", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignRight", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignHCenter", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsCenterHorizontal", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignTop", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignBottom", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignVCenter", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsCenterVertical", + "/ui/MenuBar/ObjectsMenu/ObjectsMergeProperties", NULL }; static gchar* doc_modified_verbs [] = { - "/commands/FileSave", + "/ui/MenuBar/FileMenu/Save", NULL }; static gchar* selection_verbs [] = { - "/commands/EditCut", - "/commands/EditCopy", - "/commands/EditDelete", - "/commands/EditUnSelectAll", - "/commands/ToolsRaiseObjects", - "/commands/ToolsLowerObjects", - "/commands/ToolsRotateLeft", - "/commands/ToolsRotateRight", - "/commands/ToolsFlipHorizontal", - "/commands/ToolsFlipVertical", - "/commands/ToolsCenterHorizontal", - "/commands/ToolsCenterVertical", - "/menu/Objects/Order", - "/menu/Objects/RotateFlip", - "/menu/Objects/AlignHoriz", - "/menu/Objects/AlignVert", + "/ui/MenuBar/EditMenu/EditCut", + "/ui/MenuBar/EditMenu/EditCopy", + "/ui/MenuBar/EditMenu/EditDelete", + "/ui/MenuBar/EditMenu/EditUnSelectAll", + "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsRaise", + "/ui/MenuBar/ObjectsMenu/ObjectsOrderMenu/ObjectsLower", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateLeft", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsRotateRight", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipHorizontal", + "/ui/MenuBar/ObjectsMenu/ObjectsRotateFlipMenu/ObjectsFlipVertical", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsCenterHorizontal", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsCenterVertical", NULL }; @@ -185,239 +679,118 @@ static gchar* atomic_selection_verbs [] = { }; static gchar* multi_selection_verbs [] = { - "/commands/ToolsAlignLeft", - "/commands/ToolsAlignRight", - "/commands/ToolsAlignHCenter", - "/commands/ToolsAlignTop", - "/commands/ToolsAlignBottom", - "/commands/ToolsAlignVCenter", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignLeft", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignRight", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignHorizMenu/ObjectsAlignHCenter", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignTop", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignBottom", + "/ui/MenuBar/ObjectsMenu/ObjectsAlignVertMenu/ObjectsAlignVCenter", NULL }; -/*==========================================================================*/ -/* Local function prototypes */ -/*==========================================================================*/ - -static void view_menu_item_toggled_cb (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - BonoboWindow *win); - -static void set_app_main_toolbar_style (BonoboUIComponent *ui_component); - -static void set_app_drawing_toolbar_style (BonoboUIComponent *ui_component); - -static void set_app_property_toolbar_style (BonoboUIComponent *ui_component); - -static void set_view_style (BonoboUIComponent *ui_component); - - - /*****************************************************************************/ /* Initialize UI component for given window. */ /*****************************************************************************/ -void -gl_ui_init (BonoboUIComponent *ui_component, - BonoboWindow *win, - GtkWidget *cursor_info_frame, - GtkWidget *zoom_info_frame) +GtkUIManager * +gl_ui_new (GtkWindow *window) { - EggRecentView *recent_view; - EggRecentModel *recent_model; - BonoboControl *control; + GtkUIManager *ui; + GtkActionGroup *actions; + GError *error = NULL; gl_debug (DEBUG_UI, "START"); - gl_debug (DEBUG_UI, "window = %p", win); + g_return_val_if_fail (window && GTK_IS_WINDOW (window), NULL); - g_return_if_fail (ui_component != NULL); + gl_debug (DEBUG_UI, "window = %p", window); - bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win), - "/glabels/UIConfig/kvps"); - gl_debug (DEBUG_UI, "Path set"); + ui = gtk_ui_manager_new (); - bonobo_ui_util_set_ui (ui_component, - "", GLABELS_UI_XML, "gLabels", NULL); - gl_debug (DEBUG_UI, "UI set"); + actions = gtk_action_group_new ("Actions"); + gtk_action_group_add_actions (actions, entries, n_entries, window); + gtk_action_group_add_toggle_actions (actions, + toggle_entries, n_toggle_entries, + window); + gtk_action_group_add_toggle_actions (actions, + ui_toggle_entries, n_ui_toggle_entries, + ui); - bonobo_ui_component_add_verb_list_with_data(ui_component, - gl_ui_verbs, win); - gl_debug (DEBUG_UI, "verb list added"); - - /* Set the toolbar style according to prefs */ - set_app_main_toolbar_style (ui_component); - - /* Add listener for the view menu */ - bonobo_ui_component_add_listener (ui_component, "ViewMainToolbar", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - - bonobo_ui_component_add_listener (ui_component, "MainToolbarSystem", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "MainToolbarIcon", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "MainToolbarIconText", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "MainToolbarTooltips", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - - /* Set the toolbar style according to prefs */ - set_app_drawing_toolbar_style (ui_component); - - /* Add listener for the view menu */ - bonobo_ui_component_add_listener (ui_component, "ViewDrawingToolbar", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - - bonobo_ui_component_add_listener (ui_component, "DrawingToolbarSystem", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "DrawingToolbarIcon", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "DrawingToolbarIconText", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "DrawingToolbarTooltips", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - - /* Set the toolbar style according to prefs */ - set_app_property_toolbar_style (ui_component); - - /* Add listener for the view menu */ - bonobo_ui_component_add_listener (ui_component, "ViewPropertyToolbar", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - - bonobo_ui_component_add_listener (ui_component, "PropertyToolbarTooltips", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); + gtk_ui_manager_insert_action_group (ui, actions, 0); + gtk_window_add_accel_group (window, gtk_ui_manager_get_accel_group (ui)); + if (!gtk_ui_manager_add_ui_from_string (ui, ui_info, strlen (ui_info), &error)) { + g_message ("building menus failed: %s", error->message); + g_error_free (error); + } + /* Set the toolbar styles according to prefs */ + set_app_main_toolbar_style (ui); + set_app_drawing_toolbar_style (ui); + /* Set view grid and markup visibility according to prefs */ - set_view_style (ui_component); + set_view_style (ui); - /* Add listener for the view grid & markup */ - bonobo_ui_component_add_listener (ui_component, "ViewGrid", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - bonobo_ui_component_add_listener (ui_component, "ViewMarkup", - (BonoboUIListenerFn)view_menu_item_toggled_cb, - (gpointer)win); - - gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE); - - /* Status bar */ - gl_debug (DEBUG_UI, "START Setup status bar."); - - bonobo_ui_component_set_prop (ui_component, - "/status", "hidden", "0", NULL); - - control = bonobo_control_new (cursor_info_frame); - bonobo_ui_component_object_set (ui_component, - "/status/Cursor", BONOBO_OBJREF (control), NULL); - bonobo_object_unref (BONOBO_OBJECT (control)); - bonobo_ui_component_set_prop (ui_component, - "/status/Cursor", "hidden", "0", NULL); - - control = bonobo_control_new (zoom_info_frame); - bonobo_ui_component_object_set (ui_component, - "/status/Zoom", BONOBO_OBJREF (control), NULL); - bonobo_object_unref (BONOBO_OBJECT (control)); - bonobo_ui_component_set_prop (ui_component, - "/status/Zoom", "hidden", "0", NULL); - - gl_debug (DEBUG_UI, "END Setup status bar."); - - - /* add an eggRecentView object */ - recent_model = gl_recent_get_model (); - recent_view = - EGG_RECENT_VIEW (egg_recent_view_bonobo_new (ui_component, - "/menu/File/Recents")); - egg_recent_view_set_model (recent_view, recent_model); - - g_signal_connect (G_OBJECT (recent_view), "activate", - G_CALLBACK (gl_file_open_recent), win); - - /* Squirrel away a copy to be unreferenced in gl_ui_unref() */ - g_object_set_data (G_OBJECT (ui_component), "recent-view", recent_view); + gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, FALSE); gl_debug (DEBUG_UI, "END"); + + return ui; } /*****************************************************************************/ /* Unref wrapper. */ /*****************************************************************************/ void -gl_ui_unref (BonoboUIComponent *ui_component) +gl_ui_unref (GtkUIManager *ui) { - EggRecentView *recent_view; + gl_debug (DEBUG_UI, "START"); - /* Pull out recent view to unreference. */ - recent_view = g_object_get_data (G_OBJECT(ui_component), "recent-view"); - if (recent_view) { - g_object_unref (recent_view); - } + g_object_unref(ui); - bonobo_object_unref(ui_component); + gl_debug (DEBUG_UI, "END"); } /*****************************************************************************/ /* Update all verbs of given UI component. */ /*****************************************************************************/ void -gl_ui_update_all (BonoboUIComponent *ui_component, - glView *view) +gl_ui_update_all (GtkUIManager *ui, + glView *view) { glLabel *label; gl_debug (DEBUG_UI, "START"); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, TRUE); + gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, TRUE); label = view->label; g_return_if_fail (label != NULL); - gl_ui_util_set_verb_sensitive (ui_component, "/commands/EditUndo", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditUndo", gl_label_can_undo (label)); - gl_ui_util_set_verb_sensitive (ui_component, "/commands/EditRedo", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditRedo", gl_label_can_redo (label)); - gl_ui_util_set_verb_list_sensitive (ui_component, - doc_modified_verbs, + gl_ui_util_set_verb_list_sensitive (ui, doc_modified_verbs, gl_label_is_modified (label)); - gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomIn", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomIn", !gl_view_is_zoom_max (view)); - gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomOut", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomOut", !gl_view_is_zoom_min (view)); - gl_ui_util_set_verb_list_sensitive (ui_component, - selection_verbs, + gl_ui_util_set_verb_list_sensitive (ui, selection_verbs, !gl_view_is_selection_empty (view)); - gl_ui_util_set_verb_list_sensitive (ui_component, - atomic_selection_verbs, + gl_ui_util_set_verb_list_sensitive (ui, atomic_selection_verbs, gl_view_is_selection_atomic (view)); - gl_ui_util_set_verb_list_sensitive (ui_component, - multi_selection_verbs, + gl_ui_util_set_verb_list_sensitive (ui, multi_selection_verbs, !gl_view_is_selection_empty (view) && !gl_view_is_selection_atomic (view)); - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -425,15 +798,11 @@ gl_ui_update_all (BonoboUIComponent *ui_component, /* Update all verbs of given UI component to "no document" state. */ /*****************************************************************************/ void -gl_ui_update_nodoc (BonoboUIComponent *ui_component) +gl_ui_update_nodoc (GtkUIManager *ui) { gl_debug (DEBUG_UI, "START"); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE); - - bonobo_ui_component_thaw (ui_component, NULL); + gl_ui_util_set_verb_list_sensitive (ui, doc_verbs, FALSE); gl_debug (DEBUG_UI, "END"); } @@ -442,19 +811,15 @@ gl_ui_update_nodoc (BonoboUIComponent *ui_component) /* Update label modified verbs of given UI component. */ /*****************************************************************************/ void -gl_ui_update_modified_verbs (BonoboUIComponent *ui_component, - glLabel *label) +gl_ui_update_modified_verbs (GtkUIManager *ui, + glLabel *label) { gl_debug (DEBUG_UI, "START"); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_list_sensitive (ui_component, + gl_ui_util_set_verb_list_sensitive (ui, doc_modified_verbs, gl_label_is_modified (label)); - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -462,28 +827,21 @@ gl_ui_update_modified_verbs (BonoboUIComponent *ui_component, /* Update verbs associated with selection state of given UI component. */ /*****************************************************************************/ void -gl_ui_update_selection_verbs (BonoboUIComponent *ui_component, - glView *view) +gl_ui_update_selection_verbs (GtkUIManager *ui, + glView *view) { gl_debug (DEBUG_UI, "START"); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_list_sensitive (ui_component, - selection_verbs, + gl_ui_util_set_verb_list_sensitive (ui, selection_verbs, !gl_view_is_selection_empty (view)); - gl_ui_util_set_verb_list_sensitive (ui_component, - atomic_selection_verbs, + gl_ui_util_set_verb_list_sensitive (ui, atomic_selection_verbs, gl_view_is_selection_atomic (view)); - gl_ui_util_set_verb_list_sensitive (ui_component, - multi_selection_verbs, + gl_ui_util_set_verb_list_sensitive (ui, multi_selection_verbs, !gl_view_is_selection_empty (view) && !gl_view_is_selection_atomic (view)); - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -491,20 +849,16 @@ gl_ui_update_selection_verbs (BonoboUIComponent *ui_component, /* Update verbs associated with zoom level of given UI component. */ /*****************************************************************************/ void -gl_ui_update_zoom_verbs (BonoboUIComponent *ui_component, - glView *view) +gl_ui_update_zoom_verbs (GtkUIManager *ui, + glView *view) { gl_debug (DEBUG_UI, "START"); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomIn", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomIn", !gl_view_is_zoom_max (view)); - gl_ui_util_set_verb_sensitive (ui_component, "/commands/ToolsZoomOut", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewZoomOut", !gl_view_is_zoom_min (view)); - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -512,23 +866,17 @@ gl_ui_update_zoom_verbs (BonoboUIComponent *ui_component, /* Update undo/redo verbs of given UI component. */ /*****************************************************************************/ void -gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component, - glLabel *label) +gl_ui_update_undo_redo_verbs (GtkUIManager *ui, + glLabel *label) { gl_debug (DEBUG_UI, "START"); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/EditUndo", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditUndo", gl_label_can_undo (label)); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/EditRedo", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/EditMenu/EditRedo", gl_label_can_redo (label)); - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -536,233 +884,86 @@ gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component, /* PRIVATE. View menu item toggled callback. */ /*---------------------------------------------------------------------------*/ static void -view_menu_item_toggled_cb (BonoboUIComponent *ui_component, - const char *path, - Bonobo_UIComponent_EventType type, - const char *state, - BonoboWindow *win) +view_ui_item_toggled_cb (GtkToggleAction *action, + GtkUIManager *ui) { - gboolean s; - - gl_debug (DEBUG_UI, ""); - - s = (strcmp (state, "1") == 0); - - if (strcmp (path, "ViewMainToolbar") == 0) - { - gl_prefs->main_toolbar_visible = s; - set_app_main_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); - - return; - } - - if (s && (strcmp (path, "MainToolbarSystem") == 0)) - { - gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_SYSTEM; - set_app_main_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); - - return; - } - - if (s && (strcmp (path, "MainToolbarIcon") == 0)) - { - gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS; - set_app_main_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); - - return; - } - - if (s && (strcmp (path, "MainToolbarIconText") == 0)) - { - gl_prefs->main_toolbar_buttons_style = GL_TOOLBAR_ICONS_AND_TEXT; - set_app_main_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); - - return; - } + const gchar *name; + gboolean state; - if (strcmp (path, "MainToolbarTooltips") == 0) - { - gl_prefs->main_toolbar_view_tooltips = s; - set_app_main_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); - - return; - } - - if (strcmp (path, "ViewDrawingToolbar") == 0) - { - gl_prefs->drawing_toolbar_visible = s; - set_app_drawing_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); + gl_debug (DEBUG_UI, "START"); - return; - } + g_return_if_fail (action && GTK_IS_TOGGLE_ACTION (action)); - if (strcmp (path, "DrawingToolbarTooltips") == 0) - { - gl_prefs->drawing_toolbar_view_tooltips = s; - set_app_drawing_toolbar_style (ui_component); - gl_prefs_model_save_settings (gl_prefs); + name = gtk_action_get_name (GTK_ACTION (action)); + state = gtk_toggle_action_get_active (action); - return; - } + gl_debug (DEBUG_UI, "Action = %s, State = %d", name, state); - if (strcmp (path, "ViewPropertyToolbar") == 0) + if (strcmp (name, "ViewMainToolBar") == 0) { - gl_prefs->property_toolbar_visible = s; - set_app_property_toolbar_style (ui_component); + gl_prefs->main_toolbar_visible = state; + set_app_main_toolbar_style (ui); gl_prefs_model_save_settings (gl_prefs); - - return; } - if (strcmp (path, "PropertyToolbarTooltips") == 0) + if (strcmp (name, "ViewMainToolBarToolTips") == 0) { - gl_prefs->property_toolbar_view_tooltips = s; - set_app_property_toolbar_style (ui_component); + gl_prefs->main_toolbar_view_tooltips = state; + set_app_main_toolbar_style (ui); gl_prefs_model_save_settings (gl_prefs); - - return; } - if (strcmp (path, "ViewGrid") == 0) + if (strcmp (name, "ViewDrawingToolBar") == 0) { - gl_prefs->grid_visible = s; - if (s) { - gl_view_show_grid (GL_VIEW(GL_WINDOW(win)->view)); - } else { - gl_view_hide_grid (GL_VIEW(GL_WINDOW(win)->view)); - } + gl_prefs->drawing_toolbar_visible = state; + set_app_drawing_toolbar_style (ui); gl_prefs_model_save_settings (gl_prefs); - - return; } - if (strcmp (path, "ViewMarkup") == 0) + if (strcmp (name, "ViewDrawingToolBarToolTips") == 0) { - gl_prefs->markup_visible = s; - if (s) { - gl_view_show_markup (GL_VIEW(GL_WINDOW(win)->view)); - } else { - gl_view_hide_markup (GL_VIEW(GL_WINDOW(win)->view)); - } + gl_prefs->drawing_toolbar_view_tooltips = state; + set_app_drawing_toolbar_style (ui); gl_prefs_model_save_settings (gl_prefs); - - return; } + gl_debug (DEBUG_UI, ""); } /*---------------------------------------------------------------------------*/ /* PRIVATE. Set main toolbar style. */ /*---------------------------------------------------------------------------*/ static void -set_app_main_toolbar_style (BonoboUIComponent *ui_component) +set_app_main_toolbar_style (GtkUIManager *ui) { - GConfClient *client; - gboolean labels; + GtkWidget *toolbar; gl_debug (DEBUG_UI, "START"); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component)); + g_return_if_fail (ui && GTK_IS_UI_MANAGER (ui)); - bonobo_ui_component_freeze (ui_component, NULL); - /* Updated view menu */ - gl_ui_util_set_verb_state (ui_component, - "/commands/ViewMainToolbar", + gl_ui_util_set_verb_state (ui, "/ui/ViewMenu/ViewMainToolBar", gl_prefs->main_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/MainToolbarSystem", + gl_ui_util_set_verb_sensitive (ui, "/ui/ViewMenu/ViewMainToolBarToolTips", gl_prefs->main_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/MainToolbarIcon", - gl_prefs->main_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/MainToolbarIconText", - gl_prefs->main_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/MainToolbarTooltips", - gl_prefs->main_toolbar_visible); - - gl_ui_util_set_verb_state (ui_component, - "/commands/MainToolbarSystem", - gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_SYSTEM); - - gl_ui_util_set_verb_state (ui_component, - "/commands/MainToolbarIcon", - gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS); - gl_ui_util_set_verb_state (ui_component, - "/commands/MainToolbarIconText", - gl_prefs->main_toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT); - - gl_ui_util_set_verb_state (ui_component, - "/commands/MainToolbarTooltips", + gl_ui_util_set_verb_state (ui, "/ui/ViewMenu/ViewMainToolBarToolTips", gl_prefs->main_toolbar_view_tooltips); - /* Actually update main_toolbar style */ - bonobo_ui_component_set_prop ( - ui_component, "/MainToolbar", - "tips", gl_prefs->main_toolbar_view_tooltips ? "1" : "0", - NULL); - - switch (gl_prefs->main_toolbar_buttons_style) - { - case GL_TOOLBAR_SYSTEM: - - client = gconf_client_get_default (); - if (client == NULL) - goto error; + toolbar = gtk_ui_manager_get_widget (ui, "/MainToolBar"); - labels = gconf_client_get_bool (client, - "/desktop/gnome/interface/toolbar-labels", NULL); + gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), + gl_prefs->main_toolbar_view_tooltips); - g_object_unref (G_OBJECT (client)); - - if (labels) - { - bonobo_ui_component_set_prop ( - ui_component, "/MainToolbar", "look", "both", NULL); - - } - else - { - bonobo_ui_component_set_prop ( - ui_component, "/MainToolbar", "look", "icons", NULL); - } - - break; - - case GL_TOOLBAR_ICONS: - bonobo_ui_component_set_prop ( - ui_component, "/MainToolbar", "look", "icon", NULL); - - break; - - case GL_TOOLBAR_ICONS_AND_TEXT: - bonobo_ui_component_set_prop ( - ui_component, "/MainToolbar", "look", "both", NULL); - - break; - default: - goto error; - break; + if (gl_prefs->main_toolbar_visible) { + gtk_widget_show_all (toolbar); + } else { + gtk_widget_hide (toolbar); } - bonobo_ui_component_set_prop ( - ui_component, "/MainToolbar", - "hidden", gl_prefs->main_toolbar_visible ? "0":"1", NULL); - - error: - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -771,97 +972,38 @@ set_app_main_toolbar_style (BonoboUIComponent *ui_component) /* PRIVATE. Set drawing toolbar style. */ /*---------------------------------------------------------------------------*/ static void -set_app_drawing_toolbar_style (BonoboUIComponent *ui_component) +set_app_drawing_toolbar_style (GtkUIManager *ui) { - GConfClient *client; - gboolean labels; + GtkWidget *toolbar; gl_debug (DEBUG_UI, "START"); - g_return_if_fail (BONOBO_IS_UI_COMPONENT(ui_component)); + g_return_if_fail (ui && GTK_IS_UI_MANAGER (ui)); - bonobo_ui_component_freeze (ui_component, NULL); - /* Updated view menu */ - gl_ui_util_set_verb_state (ui_component, - "/commands/ViewDrawingToolbar", + gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewDrawingToolBar", gl_prefs->drawing_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/DrawingToolbarSystem", - gl_prefs->drawing_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/DrawingToolbarIcon", - gl_prefs->drawing_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/DrawingToolbarIconText", - gl_prefs->drawing_toolbar_visible); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/DrawingToolbarTooltips", + gl_ui_util_set_verb_sensitive (ui, "/ui/MenuBar/ViewMenu/ViewDrawingToolBarToolTips", gl_prefs->drawing_toolbar_visible); - gl_ui_util_set_verb_state (ui_component, - "/commands/DrawingToolbarTooltips", - gl_prefs->drawing_toolbar_view_tooltips); + gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenuDrawingToolBarToolTips", + gl_prefs->drawing_toolbar_view_tooltips); - /* Actually update drawing_toolbar style */ - bonobo_ui_component_set_prop ( - ui_component, "/DrawingToolbar", - "tips", gl_prefs->drawing_toolbar_view_tooltips ? "1" : "0", - NULL); - - bonobo_ui_component_set_prop ( - ui_component, "/DrawingToolbar", - "hidden", gl_prefs->drawing_toolbar_visible ? "0":"1", NULL); - - error: - bonobo_ui_component_thaw (ui_component, NULL); - - gl_debug (DEBUG_UI, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Set property toolbar style. */ -/*---------------------------------------------------------------------------*/ -static void -set_app_property_toolbar_style (BonoboUIComponent *ui_component) -{ - GConfClient *client; - gboolean labels; - - gl_debug (DEBUG_UI, "START"); - - g_return_if_fail (BONOBO_IS_UI_COMPONENT(ui_component)); - - bonobo_ui_component_freeze (ui_component, NULL); - - /* Updated view menu */ - gl_ui_util_set_verb_state (ui_component, - "/commands/ViewPropertyToolbar", - gl_prefs->property_toolbar_visible); + toolbar = gtk_ui_manager_get_widget (ui, "/DrawingToolBar"); - gl_ui_util_set_verb_sensitive (ui_component, - "/commands/PropertyToolbarTooltips", - gl_prefs->property_toolbar_visible); + gtk_toolbar_set_tooltips (GTK_TOOLBAR (toolbar), + gl_prefs->drawing_toolbar_view_tooltips); - gl_ui_util_set_verb_state (ui_component, - "/commands/PropertyToolbarTooltips", - gl_prefs->property_toolbar_view_tooltips); + gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); + if (gl_prefs->drawing_toolbar_visible) { + gtk_widget_show_all (toolbar); + } else { + gtk_widget_hide (toolbar); + } - /* Actually update property_toolbar style */ - bonobo_ui_component_set_prop ( - ui_component, "/PropertyToolbar", - "tips", gl_prefs->property_toolbar_view_tooltips ? "1" : "0", - NULL); - - bonobo_ui_component_set_prop ( - ui_component, "/PropertyToolbar", - "hidden", gl_prefs->property_toolbar_visible ? "0":"1", NULL); - - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } @@ -869,29 +1011,18 @@ set_app_property_toolbar_style (BonoboUIComponent *ui_component) /* PRIVATE. Set visibility of grid and markup. */ /*---------------------------------------------------------------------------*/ static void -set_view_style (BonoboUIComponent *ui_component) +set_view_style (GtkUIManager *ui) { - GConfClient *client; - gboolean labels; - gl_debug (DEBUG_UI, "START"); - g_return_if_fail (BONOBO_IS_UI_COMPONENT(ui_component)); + g_return_if_fail (ui && GTK_IS_UI_MANAGER(ui)); - bonobo_ui_component_freeze (ui_component, NULL); - - gl_ui_util_set_verb_state (ui_component, - "/commands/ViewGrid", + gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewGrid", gl_prefs->grid_visible); - gl_ui_util_set_verb_state (ui_component, - "/commands/ViewMarkup", + gl_ui_util_set_verb_state (ui, "/ui/MenuBar/ViewMenu/ViewMarkup", gl_prefs->markup_visible); - error: - bonobo_ui_component_thaw (ui_component, NULL); - gl_debug (DEBUG_UI, "END"); } - diff --git a/glabels2/src/ui.h b/glabels2/src/ui.h index 3d326e94..c296b3a8 100644 --- a/glabels2/src/ui.h +++ b/glabels2/src/ui.h @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * ui.h: GLabels UI module header file @@ -22,37 +24,33 @@ #ifndef __GL_UI_H__ #define __GL_UI_H__ -#include -#include -#include +#include +#include #include "view.h" G_BEGIN_DECLS -void gl_ui_init (BonoboUIComponent *ui_component, - BonoboWindow *win, - GtkWidget *cursor_info_frame, - GtkWidget *zoom_info_frame); +GtkUIManager *gl_ui_new (GtkWindow *window); -void gl_ui_unref (BonoboUIComponent *ui_component); +void gl_ui_unref (GtkUIManager *ui); -void gl_ui_update_all (BonoboUIComponent *ui_component, - glView *view); +void gl_ui_update_all (GtkUIManager *ui, + glView *view); -void gl_ui_update_nodoc (BonoboUIComponent *ui_component); +void gl_ui_update_nodoc (GtkUIManager *ui); -void gl_ui_update_modified_verbs (BonoboUIComponent *ui_component, - glLabel *label); +void gl_ui_update_modified_verbs (GtkUIManager *ui, + glLabel *label); -void gl_ui_update_selection_verbs (BonoboUIComponent *ui_component, - glView *view); +void gl_ui_update_selection_verbs (GtkUIManager *ui, + glView *view); -void gl_ui_update_zoom_verbs (BonoboUIComponent *ui_component, - glView *view); +void gl_ui_update_zoom_verbs (GtkUIManager *ui, + glView *view); -void gl_ui_update_undo_redo_verbs (BonoboUIComponent *ui_component, - glLabel *label); +void gl_ui_update_undo_redo_verbs (GtkUIManager *ui, + glLabel *label); G_END_DECLS diff --git a/glabels2/src/window.c b/glabels2/src/window.c index 97b483b1..c5193676 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * window.c: a gLabels app window @@ -25,14 +27,18 @@ #include "window.h" #include +#include +#include #include #include #include "ui.h" +#include "ui-commands.h" #include "util.h" #include "xml-label.h" #include "prefs.h" #include "file.h" +#include "recent.h" #include "debug.h" @@ -49,7 +55,7 @@ /*============================================================================*/ /* Private globals */ /*============================================================================*/ -static BonoboWindowClass *parent_class; +static GtkWindowClass *parent_class; static GList *window_list = NULL; @@ -91,6 +97,9 @@ static void name_changed_cb (glLabel *label, static void modified_changed_cb (glLabel *label, glWindow *window); +static char *recent_tooltip_func (EggRecentItem *item, + gpointer user_data); + /****************************************************************************/ /* Boilerplate Object stuff. */ @@ -114,7 +123,7 @@ gl_window_get_type (void) NULL }; - type = g_type_register_static (BONOBO_TYPE_WINDOW, + type = g_type_register_static (GTK_TYPE_WINDOW, "glWindow", &info, 0); } @@ -141,23 +150,51 @@ gl_window_class_init (glWindowClass *class) static void gl_window_init (glWindow *window) { - BonoboUIContainer *ui_container; - BonoboUIComponent *ui_component; + GtkWidget *vbox1; + GtkUIManager *ui; + GtkWidget *status_hbox; gl_debug (DEBUG_WINDOW, "START"); - ui_container = bonobo_window_get_ui_container(BONOBO_WINDOW(window)); - ui_component = bonobo_ui_component_new_default (); - bonobo_ui_component_set_container (ui_component, - BONOBO_OBJREF (ui_container), - NULL); - - window->cursor_info = gtk_label_new (NULL); - gtk_widget_set_size_request (window->cursor_info, CURSOR_INFO_WIDTH, -1); - window->cursor_info_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME(window->cursor_info_frame), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER(window->cursor_info_frame), window->cursor_info); - gtk_widget_show_all (window->cursor_info_frame); + vbox1 = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), vbox1); + + window->ui = ui = gl_ui_new (GTK_WINDOW (window)); + gtk_box_pack_start (GTK_BOX (vbox1), + gtk_ui_manager_get_widget (ui, "/MenuBar"), + FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox1), + gtk_ui_manager_get_widget (ui, "/MainToolBar"), + FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox1), + gtk_ui_manager_get_widget (ui, "/DrawingToolBar"), + FALSE, FALSE, 0); + + /* add an eggRecentView */ + window->recent_view = + egg_recent_view_uimanager_new (ui, + "/ui/MenuBar/FileMenu/FileRecentsMenu/FileRecentsPlaceHolder", + G_CALLBACK (gl_ui_cmd_file_open_recent), + window); + egg_recent_view_uimanager_show_icons (window->recent_view, FALSE); + egg_recent_view_uimanager_set_tooltip_func (window->recent_view, + recent_tooltip_func, + NULL); + egg_recent_view_set_model (EGG_RECENT_VIEW (window->recent_view), + gl_recent_get_model ()); + + + window->hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox1), window->hbox, TRUE, TRUE, 0); + + window->sidebar = GL_UI_SIDEBAR (gl_ui_sidebar_new ()); + gtk_box_pack_end (GTK_BOX (window->hbox), GTK_WIDGET (window->sidebar), FALSE, FALSE, 0); + + window->property_bar = GL_UI_PROPERTY_BAR (gl_ui_property_bar_new ()); + gtk_box_pack_start (GTK_BOX (vbox1), GTK_WIDGET (window->property_bar), FALSE, FALSE, 0); + + status_hbox = gtk_hbox_new (FALSE, 0); + gtk_box_pack_start (GTK_BOX (vbox1), status_hbox, FALSE, FALSE, 0); window->zoom_info = gtk_label_new (NULL); gtk_widget_set_size_request (window->zoom_info, ZOOM_INFO_WIDTH, -1); @@ -165,16 +202,19 @@ gl_window_init (glWindow *window) gtk_frame_set_shadow_type (GTK_FRAME(window->zoom_info_frame), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER(window->zoom_info_frame), window->zoom_info); gtk_widget_show_all (window->zoom_info_frame); + gtk_box_pack_end (GTK_BOX (status_hbox), + window->zoom_info_frame, + FALSE, FALSE, 0); - gl_ui_init (ui_component, - BONOBO_WINDOW (window), - window->cursor_info_frame, - window->zoom_info_frame); - - window->property_bar = - GL_UI_PROPERTY_BAR(gl_ui_property_bar_new (ui_component)); - window->sidebar = - GL_UI_SIDEBAR(gl_ui_sidebar_new (ui_component)); + window->cursor_info = gtk_label_new (NULL); + gtk_widget_set_size_request (window->cursor_info, CURSOR_INFO_WIDTH, -1); + window->cursor_info_frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME(window->cursor_info_frame), GTK_SHADOW_IN); + gtk_container_add (GTK_CONTAINER(window->cursor_info_frame), window->cursor_info); + gtk_widget_show_all (window->cursor_info_frame); + gtk_box_pack_end (GTK_BOX (status_hbox), + window->cursor_info_frame, + FALSE, FALSE, 0); gtk_window_set_default_size (GTK_WINDOW (window), DEFAULT_WINDOW_WIDTH, @@ -183,7 +223,6 @@ gl_window_init (glWindow *window) g_signal_connect (G_OBJECT(window), "delete-event", G_CALLBACK(window_delete_event_cb), NULL); - window->uic = ui_component; window->view = NULL; window_list = g_list_append (window_list, window); @@ -221,9 +260,14 @@ gl_window_destroy (GtkObject *gtk_object) window = GL_WINDOW (gtk_object); window_list = g_list_remove (window_list, window); - if (window->uic) { - gl_ui_unref(window->uic); - window->uic = NULL; + if (window->recent_view) { + g_object_unref (window->recent_view); + window->recent_view = NULL; + } + + if (window->ui) { + gl_ui_unref(window->ui); + window->ui = NULL; } if (GTK_OBJECT_CLASS (parent_class)->destroy) { @@ -244,8 +288,7 @@ gl_window_new (void) gl_debug (DEBUG_WINDOW, "START"); - window = g_object_new (gl_window_get_type (), - "win_name", "glabels", + window = g_object_new (GL_TYPE_WINDOW, "title", _("(none) - gLabels"), NULL); @@ -338,7 +381,7 @@ gl_window_set_label (glWindow *window, } window->view = gl_view_new (label); - bonobo_window_set_contents (BONOBO_WINDOW(window), window->view); + gtk_box_pack_start (GTK_BOX (window->hbox), window->view,TRUE, TRUE, 0); gtk_widget_show_all (window->view); @@ -356,7 +399,7 @@ gl_window_set_label (glWindow *window, gl_view_hide_markup (GL_VIEW(window->view)); } - gl_ui_update_all (window->uic, GL_VIEW(window->view)); + gl_ui_update_all (window->ui, GL_VIEW(window->view)); gl_ui_property_bar_set_view (window->property_bar, GL_VIEW(window->view)); gl_ui_sidebar_set_view (window->sidebar, GL_VIEW(window->view)); @@ -460,7 +503,7 @@ selection_changed_cb (glView *view, g_return_if_fail (view && GL_IS_VIEW (view)); g_return_if_fail (window && GL_IS_WINDOW (window)); - gl_ui_update_selection_verbs (window->uic, view); + gl_ui_update_selection_verbs (window->ui, view); gl_debug (DEBUG_WINDOW, "END"); } @@ -484,7 +527,7 @@ zoom_changed_cb (glView *view, gtk_label_set_text (GTK_LABEL(window->zoom_info), string); g_free (string); - gl_ui_update_zoom_verbs (window->uic, view); + gl_ui_update_zoom_verbs (window->ui, view); gl_debug (DEBUG_WINDOW, "END"); } @@ -567,7 +610,28 @@ modified_changed_cb (glLabel *label, set_window_title (window, label); - gl_ui_update_modified_verbs (window->uic, label); + gl_ui_update_modified_verbs (window->ui, label); gl_debug (DEBUG_WINDOW, "END"); } + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. Tooltip function for recent file menu items. */ +/*---------------------------------------------------------------------------*/ +static char * +recent_tooltip_func (EggRecentItem *item, gpointer user_data) +{ + char *tip; + char *uri_for_display; + + uri_for_display = egg_recent_item_get_uri_for_display (item); + g_return_val_if_fail (uri_for_display != NULL, NULL); + + tip = g_strdup_printf (_("Open '%s'"), uri_for_display); + + g_free (uri_for_display); + + return tip; +} + + diff --git a/glabels2/src/window.h b/glabels2/src/window.h index 2b855a3d..b362d03c 100644 --- a/glabels2/src/window.h +++ b/glabels2/src/window.h @@ -1,4 +1,6 @@ -/* +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/** * (GLABELS) Label and Business Card Creation program for GNOME * * window.h: a gLabels app window @@ -23,8 +25,10 @@ #ifndef __WINDOW_H__ #define __WINDOW_H__ -#include -#include +#include +#include +#include "recent-files/egg-recent-view.h" +#include "recent-files/egg-recent-view-uimanager.h" #include "view.h" #include "label.h" @@ -48,23 +52,27 @@ typedef struct _glWindow glWindow; typedef struct _glWindowClass glWindowClass; struct _glWindow { - BonoboWindow parent_widget; + GtkWindow parent_widget; + + GtkUIManager *ui; + + GtkWidget *view; - BonoboUIComponent *uic; + GtkWidget *hbox; - GtkWidget *view; + glUIPropertyBar *property_bar; + glUISidebar *sidebar; - glUIPropertyBar *property_bar; - glUISidebar *sidebar; + EggRecentViewUIManager *recent_view; - GtkWidget *cursor_info; - GtkWidget *cursor_info_frame; - GtkWidget *zoom_info; - GtkWidget *zoom_info_frame; + GtkWidget *cursor_info; + GtkWidget *cursor_info_frame; + GtkWidget *zoom_info; + GtkWidget *zoom_info_frame; }; struct _glWindowClass { - BonoboWindowClass parent_class; + GtkWindowClass parent_class; }; GType gl_window_get_type (void) G_GNUC_CONST;