]> git.sur5r.net Git - glabels/commitdiff
Renamed menus module to ui.
authorJim Evins <evins@snaught.com>
Fri, 6 Sep 2002 05:09:59 +0000 (05:09 +0000)
committerJim Evins <evins@snaught.com>
Fri, 6 Sep 2002 05:09:59 +0000 (05:09 +0000)
Added "selection_changed" signal to view.
Added adjustments to sensitivity of menu items based on selection state.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@94 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/po/POTFILES.in
glabels2/src/Makefile.am
glabels2/src/mdi.c
glabels2/src/menus.c [deleted file]
glabels2/src/menus.h [deleted file]
glabels2/src/ui.c [new file with mode: 0644]
glabels2/src/ui.h [new file with mode: 0644]
glabels2/src/view.c

index b8378228d59dfa1db1ac747078a48ed7dc4bbb21..0dd680ee2ee5321c67c7b57da73df40b03842a05 100644 (file)
@@ -12,8 +12,8 @@ src/mdi-child.c
 src/mdi-child.h
 src/stock.c
 src/stock.h
-src/menus.h
-src/menus.c
+src/ui.h
+src/ui.c
 src/commands.h
 src/commands.c
 src/file.h
index a9acaca8a6cb9b1a6ae6f86f34783cf0f631990f..8099522d68c6027637426a181db36c14e920fe95 100644 (file)
@@ -53,8 +53,8 @@ glabels_SOURCES =                     \
        mdi-child.h                     \
        stock.c                         \
        stock.h                         \
-       menus.h                         \
-       menus.c                         \
+       ui.h                            \
+       ui.c                            \
        commands.h                      \
        commands.c                      \
        file.h                          \
index 4882f4f4c60a9c73000965d387925b3c82aff30e..db983d38706c1764f1d1d321c97e201bbf932f3d 100644 (file)
@@ -39,7 +39,7 @@
 #include "mdi.h"
 #include "mdi-child.h"
 #include "glabels.h"
-#include "menus.h"
+#include "ui.h"
 #include "prefs.h"
 #include "recent.h" 
 #include "file.h"
@@ -99,6 +99,7 @@ static void gl_mdi_child_changed_cb (BonoboMDI *mdi, BonoboMDIChild *old_child);
 static void gl_mdi_child_state_changed_cb (glMDIChild *child);
 
 static void gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi);
+static void gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi);
 
 static void gl_mdi_view_menu_item_toggled_cb (
                        BonoboUIComponent           *ui_component,
@@ -168,7 +169,7 @@ gl_mdi_init (glMDI  *mdi)
 
        bonobo_mdi_set_ui_template_file (BONOBO_MDI (mdi),
                                         GLABELS_UI_DIR "glabels-ui.xml",
-                                        gl_verbs);
+                                        gl_ui_verbs);
        
        bonobo_mdi_set_child_list_path (BONOBO_MDI (mdi), "/menu/Documents/");
 
@@ -220,7 +221,7 @@ gl_mdi_finalize (GObject *object)
 
 
 /*****************************************************************************/
-/* NEW mdi objecg.                                                           */
+/* NEW mdi object.                                                           */
 /*****************************************************************************/
 glMDI*
 gl_mdi_new (void)
@@ -283,9 +284,9 @@ gl_mdi_app_created_cb (BonoboMDI *mdi, BonoboWindow *win)
                        (gpointer)win);
 
 
-       gl_menus_set_verb_list_sensitive (ui_component, 
-                                         gl_menus_no_docs_sensible_verbs,
-                                         FALSE);
+       gl_ui_set_verb_list_sensitive (ui_component, 
+                                      gl_ui_no_docs_sensible_verbs,
+                                      FALSE);
 
         /* add a GeditRecentView object */
         model = gl_recent_get_model ();
@@ -383,38 +384,38 @@ gl_mdi_set_app_toolbar_style (BonoboWindow *win)
        bonobo_ui_component_freeze (ui_component, NULL);
 
        /* Updated view menu */
-       gl_menus_set_verb_state (ui_component, 
-                                   "/commands/ViewToolbar",
-                                   gl_prefs->toolbar_visible);
-
-       gl_menus_set_verb_sensitive (ui_component, 
-                                       "/commands/ToolbarSystem",
-                                       gl_prefs->toolbar_visible);
-       gl_menus_set_verb_sensitive (ui_component, 
-                                       "/commands/ToolbarIcon",
-                                       gl_prefs->toolbar_visible);
-       gl_menus_set_verb_sensitive (ui_component, 
-                                       "/commands/ToolbarIconText",
-                                       gl_prefs->toolbar_visible);
-       gl_menus_set_verb_sensitive (ui_component, 
-                                       "/commands/ToolbarTooltips",
-                                       gl_prefs->toolbar_visible);
-
-       gl_menus_set_verb_state (ui_component, 
-                                   "/commands/ToolbarSystem",
-                                   gl_prefs->toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
-
-       gl_menus_set_verb_state (ui_component, 
-                                   "/commands/ToolbarIcon",
-                                   gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS);
-
-       gl_menus_set_verb_state (ui_component, 
-                                   "/commands/ToolbarIconText",
-                                   gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
-
-       gl_menus_set_verb_state (ui_component, 
-                                   "/commands/ToolbarTooltips",
-                                   gl_prefs->toolbar_view_tooltips);
+       gl_ui_set_verb_state (ui_component, 
+                             "/commands/ViewToolbar",
+                             gl_prefs->toolbar_visible);
+
+       gl_ui_set_verb_sensitive (ui_component, 
+                                 "/commands/ToolbarSystem",
+                                 gl_prefs->toolbar_visible);
+       gl_ui_set_verb_sensitive (ui_component, 
+                                 "/commands/ToolbarIcon",
+                                 gl_prefs->toolbar_visible);
+       gl_ui_set_verb_sensitive (ui_component, 
+                                 "/commands/ToolbarIconText",
+                                 gl_prefs->toolbar_visible);
+       gl_ui_set_verb_sensitive (ui_component, 
+                                 "/commands/ToolbarTooltips",
+                                 gl_prefs->toolbar_visible);
+
+       gl_ui_set_verb_state (ui_component, 
+                             "/commands/ToolbarSystem",
+                             gl_prefs->toolbar_buttons_style == GL_TOOLBAR_SYSTEM);
+
+       gl_ui_set_verb_state (ui_component, 
+                             "/commands/ToolbarIcon",
+                             gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS);
+
+       gl_ui_set_verb_state (ui_component, 
+                             "/commands/ToolbarIconText",
+                             gl_prefs->toolbar_buttons_style == GL_TOOLBAR_ICONS_AND_TEXT);
+
+       gl_ui_set_verb_state (ui_component, 
+                             "/commands/ToolbarTooltips",
+                             gl_prefs->toolbar_view_tooltips);
 
        
        /* Actually update toolbar style */
@@ -532,6 +533,21 @@ gl_mdi_add_child_cb (BonoboMDI *mdi, BonoboMDIChild *child)
        return TRUE;
 }
 
+/*---------------------------------------------------------------------------*/
+/* View selection state changed callback.                                    */
+/*---------------------------------------------------------------------------*/
+static void 
+gl_mdi_view_selection_state_changed_cb (glView *view)
+{
+       gl_debug (DEBUG_MDI, "START");
+
+       if (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)) != GTK_WIDGET (view))
+               return;
+       
+       gl_mdi_set_active_window_selection_verbs_sensitivity (BONOBO_MDI (glabels_mdi));
+       gl_debug (DEBUG_MDI, "END");
+}
+
 /*---------------------------------------------------------------------------*/
 /* Add view callback.                                                        */
 /*---------------------------------------------------------------------------*/
@@ -539,6 +555,11 @@ static gint
 gl_mdi_add_view_cb (BonoboMDI *mdi, GtkWidget *view)
 {
        gl_debug (DEBUG_MDI, "START");
+
+       g_signal_connect (G_OBJECT (view), "selection_changed",
+                         G_CALLBACK (gl_mdi_view_selection_state_changed_cb), 
+                         NULL);
+
        gl_debug (DEBUG_MDI, "END");
        return TRUE;
 }
@@ -752,9 +773,10 @@ gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
 {
        /* FIXME: it is too slooooooow! - Paolo */
 
-       BonoboWindow* active_window = NULL;
-       BonoboMDIChild* active_child = NULL;
-       glLabel* doc = NULL;
+       BonoboWindow      *active_window = NULL;
+       BonoboMDIChild    *active_child = NULL;
+       glView            *view = NULL;
+       glLabel           *doc = NULL;
        BonoboUIComponent *ui_component;
        
        gl_debug (DEBUG_MDI, "START");
@@ -773,34 +795,44 @@ gl_mdi_set_active_window_verbs_sensitivity (BonoboMDI *mdi)
        
        if (active_child == NULL)
        {
-               gl_menus_set_verb_list_sensitive (ui_component, 
-                               gl_menus_no_docs_sensible_verbs, FALSE);
+               gl_ui_set_verb_list_sensitive (ui_component, 
+                                              gl_ui_no_docs_sensible_verbs,
+                                              FALSE);
                goto end;
        }
        else
        {
-               gl_menus_set_verb_list_sensitive (ui_component, 
-                               gl_menus_all_sensible_verbs, TRUE);
+               gl_ui_set_verb_list_sensitive (ui_component, 
+                                              gl_ui_all_sensible_verbs,
+                                              TRUE);
        }
 
        doc = GL_MDI_CHILD (active_child)->label;
        g_return_if_fail (doc != NULL);
 
        if (!gl_label_can_undo (doc))
-               gl_menus_set_verb_sensitive (ui_component,
-                                            "/commands/EditUndo", FALSE);
+               gl_ui_set_verb_sensitive (ui_component,
+                                         "/commands/EditUndo",
+                                         FALSE);
 
        if (!gl_label_can_redo (doc))
-               gl_menus_set_verb_sensitive (ui_component,
-                                            "/commands/EditRedo", FALSE);
+               gl_ui_set_verb_sensitive (ui_component,
+                                         "/commands/EditRedo",
+                                         FALSE);
 
-       if (!gl_label_is_modified (doc))
-       {
-               gl_menus_set_verb_list_sensitive (ui_component, 
-                               gl_menus_not_modified_doc_sensible_verbs,
-                                                 FALSE);
-               goto end;
-       }
+       gl_ui_set_verb_list_sensitive (ui_component, 
+                                      gl_ui_not_modified_doc_sensible_verbs,
+                                      gl_label_is_modified (doc));
+
+       view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
+       g_return_if_fail (view != NULL);
+
+       gl_ui_set_verb_list_sensitive (ui_component,
+                                      gl_ui_selection_sensible_verbs,
+                                      !gl_view_is_selection_empty (view));
+       gl_ui_set_verb_list_sensitive (ui_component,
+                                      gl_ui_atomic_selection_sensible_verbs,
+                                      gl_view_is_selection_atomic (view));
 
 end:
        bonobo_ui_component_thaw (ui_component, NULL);
@@ -834,11 +866,46 @@ gl_mdi_set_active_window_undo_redo_verbs_sensitivity (BonoboMDI *mdi)
 
        bonobo_ui_component_freeze (ui_component, NULL);
 
-       gl_menus_set_verb_sensitive (ui_component, "/commands/EditUndo", 
-                       gl_label_can_undo (doc));       
+       gl_ui_set_verb_sensitive (ui_component, "/commands/EditUndo", 
+                                 gl_label_can_undo (doc));     
+
+       gl_ui_set_verb_sensitive (ui_component, "/commands/EditRedo", 
+                                 gl_label_can_redo (doc));     
+
+       bonobo_ui_component_thaw (ui_component, NULL);
+
+       gl_debug (DEBUG_MDI, "END");
+}
+
+/*****************************************************************************/
+/* Set sensitivity of selection verbs in active window.                      */
+/*****************************************************************************/
+static void 
+gl_mdi_set_active_window_selection_verbs_sensitivity (BonoboMDI *mdi)
+{
+       BonoboWindow      *active_window = NULL;
+       glView            *view = NULL;
+       BonoboUIComponent *ui_component;
+       
+       gl_debug (DEBUG_MDI, "START");
+       
+       active_window = bonobo_mdi_get_active_window (mdi);
+       g_return_if_fail (active_window != NULL);
+       
+       ui_component = bonobo_mdi_get_ui_component_from_window (active_window);
+       g_return_if_fail (ui_component != NULL);
+       
+       view = GL_VIEW (bonobo_mdi_get_active_view (mdi));
+       g_return_if_fail (view != NULL);
+
+       bonobo_ui_component_freeze (ui_component, NULL);
 
-       gl_menus_set_verb_sensitive (ui_component, "/commands/EditRedo", 
-                       gl_label_can_redo (doc));       
+       gl_ui_set_verb_list_sensitive (ui_component,
+                                      gl_ui_selection_sensible_verbs,
+                                      !gl_view_is_selection_empty (view));
+       gl_ui_set_verb_list_sensitive (ui_component,
+                                      gl_ui_atomic_selection_sensible_verbs,
+                                      gl_view_is_selection_atomic (view));
 
        bonobo_ui_component_thaw (ui_component, NULL);
 
diff --git a/glabels2/src/menus.c b/glabels2/src/menus.c
deleted file mode 100644 (file)
index 68e673f..0000000
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  menus.c:  GLabels menus module
- *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
- *
- *  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
- */
-
-/*
- * This file is based on gedit-menus.c from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 
- *
- */
-#include <config.h>
-
-#include "menus.h"
-#include "commands.h"
-#include "tools.h"
-#include "glabels.h"
-
-BonoboUIVerb gl_verbs [] = {
-       BONOBO_UI_VERB ("FileNew", gl_cmd_file_new),
-       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 ("FileCloseAll", gl_cmd_file_close_all),
-       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 ("ToolsMergeProperties", gl_tools_merge_properties),
-       BONOBO_UI_VERB ("ToolsObjectProperties", gl_tools_object_properties),
-       BONOBO_UI_VERB ("ToolsRaiseObjects", gl_tools_raise_objects),
-       BONOBO_UI_VERB ("ToolsLowerObjects", gl_tools_lower_objects),
-       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
-};
-
-gchar* gl_menus_no_docs_sensible_verbs [] = {
-       "/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/ToolsMergeProperties",
-       "/commands/ToolsObjectProperties",
-       "/commands/ToolsRaiseObjects",
-       "/commands/ToolsLowerObjects",
-
-       NULL
-};
-
-gchar* gl_menus_not_modified_doc_sensible_verbs [] = {
-       "/commands/FileSave",
-
-       NULL
-};
-
-
-void
-gl_menus_set_verb_sensitive (BonoboUIComponent *ui_component, gchar* cname, gboolean sensitive)
-{
-       g_return_if_fail (cname != NULL);
-       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
-       bonobo_ui_component_set_prop (
-               ui_component, cname, "sensitive", sensitive ? "1" : "0", NULL);
-}
-
-void
-gl_menus_set_verb_list_sensitive (BonoboUIComponent *ui_component, gchar** vlist, gboolean sensitive)
-{
-       g_return_if_fail (vlist != NULL);
-       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
-
-       for ( ; *vlist; ++vlist)
-       {
-               bonobo_ui_component_set_prop (
-                       ui_component, *vlist, "sensitive", sensitive ? "1" : "0", NULL);
-       }
-}
-
-void
-gl_menus_set_verb_state (BonoboUIComponent *ui_component, gchar* cname, gboolean state)
-{
-       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);
-}
-
-void
-gl_menus_add_menu_item (BonoboWindow *window, const gchar *path,
-                    const gchar *name, const gchar *label,
-                    const gchar *tooltip, const gchar *stock_pixmap,
-                    BonoboUIVerbFn cb)
-{
-       BonoboUIComponent *ui_component;
-       gchar *item_path;
-       gchar *cmd;
-
-       g_return_if_fail (window != NULL);
-       g_return_if_fail (path != NULL);
-       g_return_if_fail (label != NULL);
-       g_return_if_fail (cb != NULL);
-       
-       item_path = g_strconcat (path, name, NULL);
-       ui_component = bonobo_mdi_get_ui_component_from_window (BONOBO_WINDOW (window));
-       if (!bonobo_ui_component_path_exists (ui_component, item_path, NULL)) {
-               gchar *xml;
-
-               xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"\""
-                                      " _label=\"%s\""
-                                      " _tip=\"%s\" hident=\"0\" />", name,
-                                      label, tooltip);
-
-
-               if (stock_pixmap != NULL) {
-                       cmd = g_strdup_printf ("<cmd name=\"%s\""
-                               " pixtype=\"stock\" pixname=\"%s\" />",
-                               name, stock_pixmap);
-               }
-               else {
-                       cmd = g_strdup_printf ("<cmd name=\"%s\" />", name);
-               }
-
-
-               bonobo_ui_component_set_translate (ui_component, path,
-                                                  xml, NULL);
-
-               bonobo_ui_component_set_translate (ui_component, "/commands/",
-                                                  cmd, NULL);
-                                                  
-               bonobo_ui_component_add_verb (ui_component, name, cb, NULL);
-
-               g_free (xml);
-               g_free (cmd);
-       }
-
-       g_free (item_path);
-}
-
-void
-gl_menus_remove_menu_item (BonoboWindow *window, const gchar *path,
-                       const gchar *name)
-{
-       BonoboUIComponent *ui_component;
-       gchar *item_path;
-
-       g_return_if_fail (window != NULL);
-       g_return_if_fail (path != NULL);
-       g_return_if_fail (name != NULL);
-
-       item_path = g_strconcat (path, name, NULL);
-       ui_component = bonobo_mdi_get_ui_component_from_window (BONOBO_WINDOW (window));
-
-       if (bonobo_ui_component_path_exists (ui_component, item_path, NULL)) {
-               gchar *cmd;
-
-               cmd = g_strdup_printf ("/commands/%s", name);
-               
-               bonobo_ui_component_rm (ui_component, item_path, NULL);
-               bonobo_ui_component_rm (ui_component, cmd, NULL);
-               
-               g_free (cmd);
-       }
-
-       g_free (item_path);
-}
-
-void
-gl_menus_add_menu_item_all (const gchar *path, const gchar *name,
-                        const gchar *label, const gchar *tooltip,
-                        const gchar *stock_pixmap,
-                        BonoboUIVerbFn cb)
-{
-       GList* top_windows;
-       
-       top_windows = glabels_get_top_windows ();
-       g_return_if_fail (top_windows != NULL);
-       
-       while (top_windows)
-       {
-               BonoboWindow* window = BONOBO_WINDOW (top_windows->data);
-
-
-               gl_menus_add_menu_item (window, path, name, label, tooltip,
-                                    stock_pixmap, cb);
-               
-               top_windows = g_list_next (top_windows);
-       }
-}
-
-void
-gl_menus_remove_menu_item_all (const gchar *path, const gchar *name)
-{
-       GList* top_windows;
-       
-       top_windows = glabels_get_top_windows ();
-       g_return_if_fail (top_windows != NULL);
-       
-       while (top_windows)
-       {
-               BonoboWindow* window = BONOBO_WINDOW (top_windows->data);
-
-
-               gl_menus_remove_menu_item (window, path, name);
-
-               
-               top_windows = g_list_next (top_windows);
-       }
-}
diff --git a/glabels2/src/menus.h b/glabels2/src/menus.h
deleted file mode 100644 (file)
index 24a0541..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- *  (GLABELS) Label and Business Card Creation program for GNOME
- *
- *  menus.h:  GLabels menus module header file
- *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
- *
- *  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
- */
-
-/*
- * This file is based on gedit-menus.h from gedit2:
- *
- * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
- * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 
- *
- */
-#ifndef __GL_MENU_H__
-#define __GL_MENU_H__
-
-#include <bonobo/bonobo-ui-component.h>
-#include <bonobo/bonobo-ui-engine.h>
-#include <bonobo/bonobo-window.h>
-
-extern BonoboUIVerb gl_verbs [];
-extern gchar* gl_menus_no_docs_sensible_verbs []; 
-extern gchar* gl_menus_untitled_doc_sensible_verbs [];
-extern gchar* gl_menus_not_modified_doc_sensible_verbs []; 
-
-#define gl_menus_all_sensible_verbs gl_menus_no_docs_sensible_verbs
-
-void gl_menus_set_verb_sensitive               (BonoboUIComponent *ui_component,
-                                                gchar             *cname,
-                                                gboolean           sensitive);
-void gl_menus_set_verb_list_sensitive  (BonoboUIComponent *ui_component, 
-                                                gchar            **vlist,
-                                                gboolean           sensitive);
-void gl_menus_set_verb_state           (BonoboUIComponent *ui_component, 
-                                                gchar* cname, 
-                                                gboolean state);
-
-/* convenience functions for plugins */
-
-void gl_menus_add_menu_item (BonoboWindow *window,
-                    const gchar *path,
-                    const gchar *name,
-                    const gchar *label,
-                    const gchar *tooltip,
-                    const gchar *stock_pixmap,
-                    BonoboUIVerbFn cb);
-
-void gl_menus_remove_menu_item (BonoboWindow *window,
-                    const gchar *path,
-                    const gchar *name);
-
-
-void gl_menus_add_menu_item_all (const gchar *path,
-                    const gchar *name,
-                    const gchar *label,
-                    const gchar *tooltip,
-                    const gchar *stock_pixmap,
-                    BonoboUIVerbFn cb);
-
-void gl_menus_remove_menu_item_all (const gchar *path,
-                    const gchar *name);
-
-
-#endif /* __GL_MENU_H__ */
diff --git a/glabels2/src/ui.c b/glabels2/src/ui.c
new file mode 100644 (file)
index 0000000..61fad4d
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ *  (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ *  ui.c:  GLabels ui module
+ *
+ *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *
+ *  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
+ */
+
+/*
+ * This file is based on gedit-menus.c from gedit2:
+ *
+ * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
+ * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 
+ *
+ */
+#include <config.h>
+
+#include "ui.h"
+#include "commands.h"
+#include "tools.h"
+#include "glabels.h"
+
+BonoboUIVerb gl_ui_verbs [] = {
+       BONOBO_UI_VERB ("FileNew", gl_cmd_file_new),
+       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 ("FileCloseAll", gl_cmd_file_close_all),
+       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 ("ToolsMergeProperties", gl_tools_merge_properties),
+       BONOBO_UI_VERB ("ToolsObjectProperties", gl_tools_object_properties),
+       BONOBO_UI_VERB ("ToolsRaiseObjects", gl_tools_raise_objects),
+       BONOBO_UI_VERB ("ToolsLowerObjects", gl_tools_lower_objects),
+       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
+};
+
+gchar* gl_ui_no_docs_sensible_verbs [] = {
+       "/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/ToolsMergeProperties",
+       "/commands/ToolsObjectProperties",
+       "/commands/ToolsRaiseObjects",
+       "/commands/ToolsLowerObjects",
+
+       NULL
+};
+
+gchar* gl_ui_not_modified_doc_sensible_verbs [] = {
+       "/commands/FileSave",
+
+       NULL
+};
+
+gchar* gl_ui_selection_sensible_verbs [] = {
+       "/commands/EditCut",
+       "/commands/EditCopy",
+       "/commands/EditDelete",
+       "/commands/EditUnSelectAll",
+       "/commands/ToolsRaiseObjects",
+       "/commands/ToolsLowerObjects",
+
+       NULL
+};
+
+gchar* gl_ui_atomic_selection_sensible_verbs [] = {
+       "/commands/ToolsObjectProperties",
+
+       NULL
+};
+
+
+void
+gl_ui_set_verb_sensitive (BonoboUIComponent  *ui_component,
+                         gchar              *cname,
+                         gboolean            sensitive)
+{
+       g_return_if_fail (cname != NULL);
+       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+       bonobo_ui_component_set_prop (ui_component,
+                                     cname,
+                                     "sensitive",
+                                     sensitive ? "1" : "0",
+                                     NULL);
+}
+
+void
+gl_ui_set_verb_list_sensitive (BonoboUIComponent   *ui_component,
+                              gchar              **vlist,
+                              gboolean             sensitive)
+{
+       g_return_if_fail (vlist != NULL);
+       g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui_component));
+
+       for ( ; *vlist; ++vlist)
+       {
+               bonobo_ui_component_set_prop (ui_component,
+                                             *vlist,
+                                             "sensitive",
+                                             sensitive ? "1" : "0",
+                                             NULL);
+       }
+}
+
+void
+gl_ui_set_verb_state (BonoboUIComponent   *ui_component,
+                     gchar               *cname,
+                     gboolean             state)
+{
+       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);
+}
+
+void
+gl_ui_add_menu_item (BonoboWindow   *window,
+                    const gchar    *path,
+                    const gchar    *name,
+                    const gchar    *label,
+                    const gchar    *tooltip,
+                    const gchar    *stock_pixmap,
+                    BonoboUIVerbFn  cb)
+{
+       BonoboUIComponent *ui_component;
+       gchar *item_path;
+       gchar *cmd;
+
+       g_return_if_fail (window != NULL);
+       g_return_if_fail (path != NULL);
+       g_return_if_fail (label != NULL);
+       g_return_if_fail (cb != NULL);
+       
+       item_path = g_strconcat (path, name, NULL);
+       ui_component =
+               bonobo_mdi_get_ui_component_from_window (BONOBO_WINDOW (window));
+       if (!bonobo_ui_component_path_exists (ui_component, item_path, NULL)) {
+               gchar *xml;
+
+               xml = g_strdup_printf ("<menuitem name=\"%s\" verb=\"\""
+                                      " _label=\"%s\""
+                                      " _tip=\"%s\" hident=\"0\" />", name,
+                                      label, tooltip);
+
+
+               if (stock_pixmap != NULL) {
+                       cmd = g_strdup_printf ("<cmd name=\"%s\""
+                               " pixtype=\"stock\" pixname=\"%s\" />",
+                               name, stock_pixmap);
+               }
+               else {
+                       cmd = g_strdup_printf ("<cmd name=\"%s\" />", name);
+               }
+
+
+               bonobo_ui_component_set_translate (ui_component,
+                                                  path,
+                                                  xml,
+                                                  NULL);
+
+               bonobo_ui_component_set_translate (ui_component,
+                                                  "/commands/",
+                                                  cmd,
+                                                  NULL);
+                                                  
+               bonobo_ui_component_add_verb (ui_component, name, cb, NULL);
+
+               g_free (xml);
+               g_free (cmd);
+       }
+
+       g_free (item_path);
+}
+
+void
+gl_ui_remove_menu_item (BonoboWindow *window,
+                       const gchar  *path,
+                       const gchar  *name)
+{
+       BonoboUIComponent *ui_component;
+       gchar *item_path;
+
+       g_return_if_fail (window != NULL);
+       g_return_if_fail (path != NULL);
+       g_return_if_fail (name != NULL);
+
+       item_path = g_strconcat (path, name, NULL);
+       ui_component =
+               bonobo_mdi_get_ui_component_from_window (BONOBO_WINDOW (window));
+
+       if (bonobo_ui_component_path_exists (ui_component, item_path, NULL)) {
+               gchar *cmd;
+
+               cmd = g_strdup_printf ("/commands/%s", name);
+               
+               bonobo_ui_component_rm (ui_component, item_path, NULL);
+               bonobo_ui_component_rm (ui_component, cmd, NULL);
+               
+               g_free (cmd);
+       }
+
+       g_free (item_path);
+}
+
+void
+gl_ui_add_menu_item_all (const gchar    *path,
+                        const gchar    *name,
+                        const gchar    *label,
+                        const gchar    *tooltip,
+                        const gchar    *stock_pixmap,
+                        BonoboUIVerbFn  cb)
+{
+       GList* top_windows;
+       
+       top_windows = glabels_get_top_windows ();
+       g_return_if_fail (top_windows != NULL);
+       
+       while (top_windows)
+       {
+               BonoboWindow* window = BONOBO_WINDOW (top_windows->data);
+
+
+               gl_ui_add_menu_item (window,
+                                    path,
+                                    name,
+                                    label,
+                                    tooltip,
+                                    stock_pixmap,
+                                    cb);
+               
+               top_windows = g_list_next (top_windows);
+       }
+}
+
+void
+gl_ui_remove_menu_item_all (const gchar *path,
+                           const gchar *name)
+{
+       GList* top_windows;
+       
+       top_windows = glabels_get_top_windows ();
+       g_return_if_fail (top_windows != NULL);
+       
+       while (top_windows)
+       {
+               BonoboWindow* window = BONOBO_WINDOW (top_windows->data);
+
+
+               gl_ui_remove_menu_item (window, path, name);
+
+               
+               top_windows = g_list_next (top_windows);
+       }
+}
diff --git a/glabels2/src/ui.h b/glabels2/src/ui.h
new file mode 100644 (file)
index 0000000..36ecad4
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ *  (GLABELS) Label and Business Card Creation program for GNOME
+ *
+ *  ui.h:  GLabels UI module header file
+ *
+ *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *
+ *  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
+ */
+
+/*
+ * This file is based on gedit-menus.h from gedit2:
+ *
+ * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
+ * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi 
+ *
+ */
+#ifndef __GL_UI_H__
+#define __GL_UI_H__
+
+#include <bonobo/bonobo-ui-component.h>
+#include <bonobo/bonobo-ui-engine.h>
+#include <bonobo/bonobo-window.h>
+
+extern BonoboUIVerb gl_ui_verbs [];
+
+extern gchar *gl_ui_no_docs_sensible_verbs []; 
+extern gchar *gl_ui_not_modified_doc_sensible_verbs []; 
+extern gchar *gl_ui_selection_sensible_verbs [];
+extern gchar *gl_ui_atomic_selection_sensible_verbs [];
+
+#define gl_ui_all_sensible_verbs gl_ui_no_docs_sensible_verbs
+
+void gl_ui_set_verb_sensitive          (BonoboUIComponent *ui_component,
+                                        gchar             *cname,
+                                        gboolean           sensitive);
+void gl_ui_set_verb_list_sensitive     (BonoboUIComponent *ui_component, 
+                                        gchar            **vlist,
+                                        gboolean           sensitive);
+void gl_ui_set_verb_state              (BonoboUIComponent *ui_component, 
+                                        gchar* cname, 
+                                        gboolean state);
+
+/* convenience functions for plugins */
+
+void gl_ui_add_menu_item        (BonoboWindow   *window,
+                                const gchar    *path,
+                                const gchar    *name,
+                                const gchar    *label,
+                                const gchar    *tooltip,
+                                const gchar    *stock_pixmap,
+                                BonoboUIVerbFn  cb);
+
+void gl_ui_remove_menu_item     (BonoboWindow   *window,
+                                const gchar    *path,
+                                const gchar    *name);
+
+
+void gl_ui_add_menu_item_all    (const gchar    *path,
+                                const gchar    *name,
+                                const gchar    *label,
+                                const gchar    *tooltip,
+                                const gchar    *stock_pixmap,
+                                BonoboUIVerbFn  cb);
+
+void gl_ui_remove_menu_item_all (const gchar    *path,
+                                const gchar    *name);
+
+
+#endif /* __GL_UI_H__ */
index 3fd1e7401629e705e995c5a2c46e88913228b404..f30e33600e349fd591251bc946ac68210235c526 100644 (file)
 #include "view-barcode.h"
 #include "xml-label.h"
 #include "color.h"
+#include "marshal.h"
 
 #include "debug.h"
 
+/*========================================================*/
+/* Private macros and constants.                          */
+/*========================================================*/
+
 #define SEL_LINE_COLOR  GL_COLOR_A (0, 0, 255, 128)
 #define SEL_FILL_COLOR  GL_COLOR_A (192, 192, 255, 128)
 
+/*========================================================*/
+/* Private types.                                         */
+/*========================================================*/
+
+enum {
+       SELECTION_CHANGED,
+       LAST_SIGNAL
+};
+
 /*===========================================*/
 /* Private globals                           */
 /*===========================================*/
 
 static GtkContainerClass *parent_class;
 
+static guint signals[LAST_SIGNAL] = {0};
+
 /* "CLIPBOARD" selection */
 static GdkAtom clipboard_atom = GDK_NONE;
 
@@ -65,68 +81,66 @@ static gdouble scales[] = {
 /* Local function prototypes                 */
 /*===========================================*/
 
-static void      gl_view_class_init          (glViewClass *class);
-static void      gl_view_init                (glView *view);
-static void      gl_view_finalize            (GObject *object);
-
-static void      gl_view_construct           (glView *view);
-static GtkWidget *gl_view_construct_canvas   (glView *view);
-static void      gl_view_construct_selection (glView *view);
-
-static gdouble   get_apropriate_scale        (gdouble w, gdouble h);
-
-static void      draw_rect_bg_fg             (glView *view);
-static void      draw_rounded_rect_bg_fg     (glView *view);
-static void      draw_round_bg_fg            (glView *view);
-static void      draw_cd_bg_fg               (glView *view);
-
-static int       canvas_event                (GnomeCanvas *canvas,
-                                             GdkEvent    *event,
-                                             glView      *view);
-static int       canvas_event_arrow_mode     (GnomeCanvas *canvas,
-                                             GdkEvent    *event,
-                                             glView      *view);
-
-static void      select_region              (glView *view,
-                                            gdouble x1,
-                                            gdouble y1,
-                                            gdouble x2,
-                                            gdouble y2);
-static void      select_object              (glViewObject *view_object);
-static void      unselect_object            (glViewObject *view_object);
-static gboolean  object_at                  (glView *view,
-                                            gdouble x, gdouble y);
-static gboolean  object_selected            (glViewObject *view_object);
-
-static int       item_event_arrow_mode      (GnomeCanvasItem *item,
-                                            GdkEvent        *event,
-                                            glViewObject    *view_object);
-
-static GtkWidget *new_selection_menu        (glView *view);
-
-static void      popup_selection_menu       (glView       *view,
-                                            glViewObject *view_object,
-                                            GdkEvent     *event);
-
-static void      move_selected_items        (glView *view,
-                                            gdouble dx, gdouble dy);
-static void      move_item                  (GnomeCanvasItem *item,
-                                            gdouble dx, gdouble dy);
-
-static void      selection_clear_cb         (GtkWidget         *widget,
-                                            GdkEventSelection *event,
-                                            gpointer          data);
-
-static void      selection_get_cb           (GtkWidget         *widget,
-                                            GtkSelectionData  *selection_data,
-                                            guint             info,
-                                            guint             time,
-                                            gpointer          data);
-
-static void      selection_received_cb      (GtkWidget         *widget,
-                                            GtkSelectionData  *selection_data,
-                                            guint             time,
-                                            gpointer          data);
+static void       gl_view_class_init          (glViewClass *class);
+static void       gl_view_init                (glView *view);
+static void       gl_view_finalize            (GObject *object);
+
+static void       gl_view_construct           (glView *view);
+static GtkWidget *gl_view_construct_canvas    (glView *view);
+static void       gl_view_construct_selection (glView *view);
+
+static gdouble    get_apropriate_scale        (gdouble w, gdouble h);
+
+static void       draw_rect_bg_fg             (glView *view);
+static void       draw_rounded_rect_bg_fg     (glView *view);
+static void       draw_round_bg_fg            (glView *view);
+static void       draw_cd_bg_fg               (glView *view);
+
+static void       select_region              (glView *view,
+                                             gdouble x1,
+                                             gdouble y1,
+                                             gdouble x2,
+                                             gdouble y2);
+static void       select_object              (glViewObject *view_object);
+static void       unselect_object            (glViewObject *view_object);
+static gboolean   object_at                  (glView *view,
+                                             gdouble x, gdouble y);
+static gboolean   is_object_selected         (glViewObject *view_object);
+
+static void       move_selection             (glView *view,
+                                             gdouble dx, gdouble dy);
+
+static int        canvas_event                (GnomeCanvas *canvas,
+                                              GdkEvent    *event,
+                                              glView      *view);
+static int        canvas_event_arrow_mode     (GnomeCanvas *canvas,
+                                              GdkEvent    *event,
+                                              glView      *view);
+
+static int        item_event_arrow_mode      (GnomeCanvasItem *item,
+                                             GdkEvent        *event,
+                                             glViewObject    *view_object);
+
+static GtkWidget *new_selection_menu         (glView *view);
+
+static void       popup_selection_menu       (glView       *view,
+                                             glViewObject *view_object,
+                                             GdkEvent     *event);
+
+static void       selection_clear_cb         (GtkWidget         *widget,
+                                             GdkEventSelection *event,
+                                             gpointer          data);
+
+static void       selection_get_cb           (GtkWidget         *widget,
+                                             GtkSelectionData  *selection_data,
+                                             guint             info,
+                                             guint             time,
+                                             gpointer          data);
+
+static void       selection_received_cb      (GtkWidget         *widget,
+                                             GtkSelectionData  *selection_data,
+                                             guint             time,
+                                             gpointer          data);
 \f
 /****************************************************************************/
 /* Boilerplate Object stuff.                                                */
@@ -168,6 +182,16 @@ gl_view_class_init (glViewClass *class)
 
        object_class->finalize = gl_view_finalize;
 
+       signals[SELECTION_CHANGED] =
+               g_signal_new ("selection_changed",
+                             G_OBJECT_CLASS_TYPE (object_class),
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (glViewClass, selection_changed),
+                             NULL, NULL,
+                             gl_marshal_VOID__VOID,
+                             G_TYPE_NONE,
+                             0);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -897,6 +921,8 @@ gl_view_select_object (glView *view, glViewObject *view_object)
 
        select_object (view_object);
 
+       g_signal_emit (G_OBJECT(view), signals[SELECTION_CHANGED], 0);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -906,18 +932,25 @@ gl_view_select_object (glView *view, glViewObject *view_object)
 void
 gl_view_select_all (glView *view)
 {
-       GList *p;
+       GList *p, *p_next;
 
        gl_debug (DEBUG_VIEW, "START");
 
        g_return_if_fail (GL_IS_VIEW (view));
 
-       gl_view_unselect_all (view);
+       /* 1st unselect anything already selected. */
+       for (p = view->selected_object_list; p != NULL; p = p_next) {
+               p_next = p->next;
+               unselect_object (GL_VIEW_OBJECT (p->data));
+       }
 
+       /* Finally select all objects. */
        for (p = view->object_list; p != NULL; p = p->next) {
                select_object (GL_VIEW_OBJECT (p->data));
        }
 
+       g_signal_emit (G_OBJECT(view), signals[SELECTION_CHANGED], 0);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -938,9 +971,147 @@ gl_view_unselect_all (glView *view)
                unselect_object (GL_VIEW_OBJECT (p->data));
        }
 
+       g_signal_emit (G_OBJECT(view), signals[SELECTION_CHANGED], 0);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Select all objects within given rectangular region.             */
+/*---------------------------------------------------------------------------*/
+static void
+select_region (glView  *view,
+              gdouble x1,
+              gdouble y1,
+              gdouble x2,
+              gdouble y2)
+{
+       GList *p;
+       glViewObject *view_object;
+       glLabelObject *object;
+       gdouble i_x1, i_y1, i_x2, i_y2, w, h;
+
+       gl_debug (DEBUG_VIEW, "START");
+
+       g_return_if_fail (GL_IS_VIEW (view));
+       g_return_if_fail ((x1 <= x2) && (y1 <= y2));
+
+       for (p = view->object_list; p != NULL; p = p->next) {
+               view_object = GL_VIEW_OBJECT(p->data);
+               if (!is_object_selected (view_object)) {
+
+                       object = gl_view_object_get_object (view_object);
+
+                       gl_label_object_get_position (object, &i_x1, &i_y1);
+                       gl_label_object_get_size (object, &w, &h);
+                       i_x2 = i_x1 + w;
+                       i_y2 = i_y1 + h;
+                       if ((i_x1 >= x1) && (i_x2 <= x2) && (i_y1 >= y1)
+                           && (i_y2 <= y2)) {
+                               select_object (view_object);
+                       }
+
+               }
+       }
+
+       g_signal_emit (G_OBJECT(view), signals[SELECTION_CHANGED], 0);
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Select an object.                                                */
+/*---------------------------------------------------------------------------*/
+static void
+select_object (glViewObject *view_object)
+{
+       glView *view;
+
+       gl_debug (DEBUG_VIEW, "START");
+
+       g_return_if_fail (GL_IS_VIEW_OBJECT (view_object));
+
+       view = gl_view_object_get_view (view_object);
+
+       if (!is_object_selected (view_object)) {
+               view->selected_object_list =
+                   g_list_prepend (view->selected_object_list, view_object);
+       }
+       gl_view_object_show_highlight (view_object);
+       gtk_widget_grab_focus (GTK_WIDGET (view->canvas));
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Un-select object.                                               */
+/*---------------------------------------------------------------------------*/
+static void
+unselect_object (glViewObject *view_object)
+{
+       glView *view;
+
+       gl_debug (DEBUG_VIEW, "START");
+
+       g_return_if_fail (GL_IS_VIEW_OBJECT (view_object));
+
+       view = gl_view_object_get_view (view_object);
+
+       gl_view_object_hide_highlight (view_object);
+
+       view->selected_object_list =
+           g_list_remove (view->selected_object_list, view_object);
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. Return object at (x,y).                                          */
+/*---------------------------------------------------------------------------*/
+static gboolean
+object_at (glView  *view,
+          gdouble x,
+          gdouble y)
+{
+       GnomeCanvasItem *item, *p_item;
+       GList *p;
+
+       gl_debug (DEBUG_VIEW, "");
+
+       g_return_val_if_fail (GL_IS_VIEW (view), FALSE);
+
+       item = gnome_canvas_get_item_at (GNOME_CANVAS (view->canvas), x, y);
+
+       /* No item is at x, y */
+       if (item == NULL)
+               return FALSE;
+
+       /* ignore our background items */
+       if (g_list_find (view->bg_item_list, item) != NULL)
+               return FALSE;
+
+       return TRUE;
+}
+
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Is the object in our current selection?                         */
+/*---------------------------------------------------------------------------*/
+static gboolean
+is_object_selected (glViewObject *view_object)
+{
+       glView *view;
+
+       gl_debug (DEBUG_VIEW, "");
+
+       g_return_val_if_fail (GL_IS_VIEW_OBJECT (view_object), FALSE);
+
+       view = gl_view_object_get_view (view_object);
+       if (g_list_find (view->selected_object_list, view_object) == NULL) {
+               return FALSE;
+       }
+       return TRUE;
+}
+
 /*****************************************************************************/
 /* Is our current selection empty?                                           */
 /*****************************************************************************/
@@ -992,6 +1163,8 @@ gl_view_delete_selection (glView *view)
                g_object_unref (G_OBJECT (p->data));
        }
 
+       g_signal_emit (G_OBJECT(view), signals[SELECTION_CHANGED], 0);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -1166,6 +1339,31 @@ gl_view_paste (glView *view)
        gl_debug (DEBUG_VIEW, "END");
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  move selected objects                                           */
+/*---------------------------------------------------------------------------*/
+static void
+move_selection (glView  *view,
+               gdouble  dx,
+               gdouble  dy)
+{
+       GList *p;
+       glLabelObject *object;
+
+       gl_debug (DEBUG_VIEW, "START");
+
+       g_return_if_fail (GL_IS_VIEW (view));
+
+       for (p = view->selected_object_list; p != NULL; p = p->next) {
+
+               object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
+               gl_label_object_set_position_relative (object, dx, dy);
+
+       }
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
 /*****************************************************************************/
 /* Zoom in one "notch"                                                       */
 /*****************************************************************************/
@@ -1435,25 +1633,23 @@ canvas_event_arrow_mode (GnomeCanvas *canvas,
                        switch (event->key.keyval) {
                        case GDK_Left:
                        case GDK_KP_Left:
-                               move_selected_items (view,
-                                                    -1.0 / (view->scale),
-                                                    0.0);
+                               move_selection (view,
+                                               -1.0 / (view->scale), 0.0);
                                break;
                        case GDK_Up:
                        case GDK_KP_Up:
-                               move_selected_items (view, 0.0,
-                                                    -1.0 / (view->scale));
+                               move_selection (view,
+                                               0.0, -1.0 / (view->scale));
                                break;
                        case GDK_Right:
                        case GDK_KP_Right:
-                               move_selected_items (view,
-                                                    1.0 / (view->scale),
-                                                    0.0);
+                               move_selection (view,
+                                               1.0 / (view->scale), 0.0);
                                break;
                        case GDK_Down:
                        case GDK_KP_Down:
-                               move_selected_items (view, 0.0,
-                                                    1.0 / (view->scale));
+                               move_selection (view,
+                                               0.0, 1.0 / (view->scale));
                                break;
                        case GDK_Delete:
                        case GDK_KP_Delete:
@@ -1476,140 +1672,6 @@ canvas_event_arrow_mode (GnomeCanvas *canvas,
 
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Select all objects within given rectangular region.             */
-/*---------------------------------------------------------------------------*/
-static void
-select_region (glView  *view,
-              gdouble x1,
-              gdouble y1,
-              gdouble x2,
-              gdouble y2)
-{
-       GList *p;
-       glViewObject *view_object;
-       glLabelObject *object;
-       gdouble i_x1, i_y1, i_x2, i_y2, w, h;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (GL_IS_VIEW (view));
-       g_return_if_fail ((x1 <= x2) && (y1 <= y2));
-
-       for (p = view->object_list; p != NULL; p = p->next) {
-               view_object = GL_VIEW_OBJECT(p->data);
-               if (!object_selected (view_object)) {
-
-                       object = gl_view_object_get_object (view_object);
-
-                       gl_label_object_get_position (object, &i_x1, &i_y1);
-                       gl_label_object_get_size (object, &w, &h);
-                       i_x2 = i_x1 + w;
-                       i_y2 = i_y1 + h;
-                       if ((i_x1 >= x1) && (i_x2 <= x2) && (i_y1 >= y1)
-                           && (i_y2 <= y2)) {
-                               select_object (view_object);
-                       }
-
-               }
-       }
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE. Select an object.                                                */
-/*---------------------------------------------------------------------------*/
-static void
-select_object (glViewObject *view_object)
-{
-       glView *view;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (GL_IS_VIEW_OBJECT (view_object));
-
-       view = gl_view_object_get_view (view_object);
-
-       if (!object_selected (view_object)) {
-               view->selected_object_list =
-                   g_list_prepend (view->selected_object_list, view_object);
-       }
-       gl_view_object_show_highlight (view_object);
-       gtk_widget_grab_focus (GTK_WIDGET (view->canvas));
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Un-select object.                                               */
-/*---------------------------------------------------------------------------*/
-static void
-unselect_object (glViewObject *view_object)
-{
-       glView *view;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (GL_IS_VIEW_OBJECT (view_object));
-
-       view = gl_view_object_get_view (view_object);
-
-       gl_view_object_hide_highlight (view_object);
-
-       view->selected_object_list =
-           g_list_remove (view->selected_object_list, view_object);
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE. Return object at (x,y).                                          */
-/*---------------------------------------------------------------------------*/
-static gboolean
-object_at (glView  *view,
-          gdouble x,
-          gdouble y)
-{
-       GnomeCanvasItem *item, *p_item;
-       GList *p;
-
-       gl_debug (DEBUG_VIEW, "");
-
-       g_return_val_if_fail (GL_IS_VIEW (view), FALSE);
-
-       item = gnome_canvas_get_item_at (GNOME_CANVAS (view->canvas), x, y);
-
-       /* No item is at x, y */
-       if (item == NULL)
-               return FALSE;
-
-       /* ignore our background items */
-       if (g_list_find (view->bg_item_list, item) != NULL)
-               return FALSE;
-
-       return TRUE;
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  Is the object in our current selection?                         */
-/*---------------------------------------------------------------------------*/
-static gboolean
-object_selected (glViewObject *view_object)
-{
-       glView *view;
-
-       gl_debug (DEBUG_VIEW, "");
-
-       g_return_val_if_fail (GL_IS_VIEW_OBJECT (view_object), FALSE);
-
-       view = gl_view_object_get_view (view_object);
-       if (g_list_find (view->selected_object_list, view_object) == NULL) {
-               return FALSE;
-       }
-       return TRUE;
-}
-
 /*****************************************************************************/
 /* Item event handler.                                                       */
 /*****************************************************************************/
@@ -1667,20 +1729,29 @@ item_event_arrow_mode (GnomeCanvasItem *item,
                switch (event->button.button) {
                case 1:
                        if (control_key_pressed) {
-                               if (object_selected (view_object)) {
+                               if (is_object_selected (view_object)) {
                                        /* Un-selecting a selected item */
                                        unselect_object (view_object);
+                                       g_signal_emit (G_OBJECT(view),
+                                                      signals[SELECTION_CHANGED],
+                                                      0);
                                        return TRUE;
                                } else {
                                        /* Add to current selection */
                                        select_object (view_object);
+                                       g_signal_emit (G_OBJECT(view),
+                                                      signals[SELECTION_CHANGED],
+                                                      0);
                                }
                        } else {
-                               if (!object_selected (view_object)) {
+                               if (!is_object_selected (view_object)) {
                                        /* No control, key so remove any selections before adding */
                                        gl_view_unselect_all (view);
                                        /* Add to current selection */
                                        select_object (view_object);
+                                       g_signal_emit (G_OBJECT(view),
+                                                      signals[SELECTION_CHANGED],
+                                                      0);
                                }
                        }
                        /* Go into dragging mode while button remains pressed. */
@@ -1697,7 +1768,7 @@ item_event_arrow_mode (GnomeCanvasItem *item,
                        return TRUE;
 
                case 3:
-                       if (!object_selected (view_object)) {
+                       if (!is_object_selected (view_object)) {
                                if (!control_key_pressed) {
                                        /* No control, key so remove any selections before adding */
                                        gl_view_unselect_all (view);
@@ -1705,6 +1776,9 @@ item_event_arrow_mode (GnomeCanvasItem *item,
                        }
                        /* Add to current selection */
                        select_object (view_object);
+                       g_signal_emit (G_OBJECT(view),
+                                      signals[SELECTION_CHANGED],
+                                      0);
                        /* bring up apropriate menu for selection. */
                        popup_selection_menu (view, view_object, event);
                        return TRUE;
@@ -1732,7 +1806,7 @@ item_event_arrow_mode (GnomeCanvasItem *item,
                        /* Dragging mode, move selection */
                        new_x = item_x;
                        new_y = item_y;
-                       move_selected_items (view, (new_x - x), (new_y - y));
+                       move_selection (view, (new_x - x), (new_y - y));
                        x = new_x;
                        y = new_y;
                        return TRUE;
@@ -1748,6 +1822,9 @@ item_event_arrow_mode (GnomeCanvasItem *item,
                        gnome_canvas_item_ungrab (item, event->button.time);
                        dragging = FALSE;
                        select_object (view_object);
+                       g_signal_emit (G_OBJECT(view),
+                                      signals[SELECTION_CHANGED],
+                                      0);
                        gl_view_object_show_dialog (view_object);
                        return TRUE;
 
@@ -1856,31 +1933,6 @@ popup_selection_menu (glView       *view,
        gl_debug (DEBUG_VIEW, "END");
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  move selected items                                             */
-/*---------------------------------------------------------------------------*/
-static void
-move_selected_items (glView  *view,
-                    gdouble dx,
-                    gdouble dy)
-{
-       GList *p;
-       glLabelObject *object;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (GL_IS_VIEW (view));
-
-       for (p = view->selected_object_list; p != NULL; p = p->next) {
-
-               object = gl_view_object_get_object(GL_VIEW_OBJECT (p->data));
-               gl_label_object_set_position_relative (object, dx, dy);
-
-       }
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Handle "selection-clear" signal.                                */
 /*---------------------------------------------------------------------------*/