]> git.sur5r.net Git - glabels/commitdiff
2005-05-14 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Sun, 15 May 2005 00:12:15 +0000 (00:12 +0000)
committerJim Evins <evins@snaught.com>
Sun, 15 May 2005 00:12:15 +0000 (00:12 +0000)
* src/Makefile.am:
Removed obsolete macros.
* src/marshal.list:
Added marshalling template to support new view signal: "context_menu_activate."
* src/view.h:
* src/view.c: (gl_view_class_init), (gl_view_construct),
(canvas_event_arrow_mode):
- Removed hardcoded context menus and added new signal "context_menu_activate"
to push this up to the uimanager.
- Removed merge properties and print dialogs so that they can be managed with
the window by the uimanager.
* src/merge-properties-dialog.h:
* src/merge-properties-dialog.c: (gl_merge_properties_dialog_new),
(gl_merge_properties_dialog_construct):
Changed calling convention of gl_merge_properties_dialog_new() to use
glLabel and GtkWindow instead of view to make more consistent with other
dialogs.
* src/print-dialog.h:
* src/print-dialog.c: (gl_print_dialog_new),
(gl_print_dialog_construct):
Removed last artifact of libbonoboui.
* src/ui-commands.c: (gl_ui_cmd_file_print),
(gl_ui_cmd_objects_merge_properties), (gl_ui_cmd_help_about):
Reconciled style for launching dialogs.
* src/ui.c: (gl_ui_new):
Added context menus to ui manager.
* src/view-object.c: (item_event_arrow_mode):
No longer try to select objects with right-click.
* src/window.h:
* src/window.c: (gl_window_init), (gl_window_set_label),
(context_menu_activate_cb):
Context menus and all dialogs are now managed in a consistent way in window
by the ui manager.

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

14 files changed:
glabels2/ChangeLog
glabels2/src/Makefile.am
glabels2/src/marshal.list
glabels2/src/merge-properties-dialog.c
glabels2/src/merge-properties-dialog.h
glabels2/src/print-dialog.c
glabels2/src/print-dialog.h
glabels2/src/ui-commands.c
glabels2/src/ui.c
glabels2/src/view-object.c
glabels2/src/view.c
glabels2/src/view.h
glabels2/src/window.c
glabels2/src/window.h

index e664467921fdbe5993e0088adcdb3d8d2676ee12..eaf630da61c0f4ded01519c349a476c62551c76f 100644 (file)
@@ -1,3 +1,39 @@
+2005-05-14  Jim Evins  <evins@snaught.com>
+
+       * src/Makefile.am:
+               Removed obsolete macros.
+       * src/marshal.list:
+               Added marshalling template to support new view signal: "context_menu_activate."
+       * src/view.h:
+       * src/view.c: (gl_view_class_init), (gl_view_construct),
+       (canvas_event_arrow_mode):
+               - Removed hardcoded context menus and added new signal "context_menu_activate"
+               to push this up to the uimanager.
+               - Removed merge properties and print dialogs so that they can be managed with
+               the window by the uimanager.
+       * src/merge-properties-dialog.h:
+       * src/merge-properties-dialog.c: (gl_merge_properties_dialog_new),
+       (gl_merge_properties_dialog_construct):
+               Changed calling convention of gl_merge_properties_dialog_new() to use
+               glLabel and GtkWindow instead of view to make more consistent with other
+               dialogs.
+       * src/print-dialog.h:
+       * src/print-dialog.c: (gl_print_dialog_new),
+       (gl_print_dialog_construct):
+               Removed last artifact of libbonoboui.
+       * src/ui-commands.c: (gl_ui_cmd_file_print),
+       (gl_ui_cmd_objects_merge_properties), (gl_ui_cmd_help_about):
+               Reconciled style for launching dialogs.
+       * src/ui.c: (gl_ui_new):
+               Added context menus to ui manager.
+       * src/view-object.c: (item_event_arrow_mode):
+               No longer try to select objects with right-click.
+       * src/window.h:
+       * src/window.c: (gl_window_init), (gl_window_set_label),
+       (context_menu_activate_cb):
+               Context menus and all dialogs are now managed in a consistent way in window
+               by the ui manager.
+
 2005-05-11  Jim Evins  <evins@snaught.com>
 
        * src/window.h:
index 5833c8eedebf20d30d9a2afbf6c50b514459f41f..fb9d6e9da6baee824bed07d83655ab7601af7aba 100644 (file)
@@ -4,10 +4,6 @@ SUBDIRS= pixmaps stock-pixmaps mygal recent-files
 
 bin_PROGRAMS = glabels glabels-batch
 
-uidir = $(datadir)/glabels/ui/
-gladedir = $(datadir)/glabels/glade/
-
-
 INCLUDES = \
        -I$(top_srcdir)                                         \
        -I$(top_builddir)                                       \
@@ -18,7 +14,6 @@ INCLUDES = \
        -DDATADIR=\""$(datadir)"\"                              \
        -DLIBDIR=\""$(libdir)"\"                                \
        -DGLABELS_LOCALEDIR=\""$(datadir)/locale"\"             \
-       -DGLABELS_UI_DIR=\""$(datadir)/glabels/ui/"\"           \
        -DGLABELS_GLADE_DIR=\""$(datadir)/glabels/glade/"\"     \
        $(DISABLE_DEPRECATED_CFLAGS)
 
index 4497960490e57903604fea0f100dff579de2b7db..019f5a6eaff521dc295dbb9cd94d280215a14a73 100644 (file)
@@ -2,6 +2,7 @@ VOID:VOID
 VOID:BOOLEAN
 VOID:INT
 VOID:INT,INT
+VOID:INT,UINT
 VOID:INT,DOUBLE
 VOID:DOUBLE
 VOID:DOUBLE,DOUBLE
index 0a90d8f1605e6f6dfc9ffe80a177eb4143d41bb6..04c92905bb07a0e0944be1448aa3267ce21cc6f7 100644 (file)
@@ -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
  *
@@ -33,7 +35,7 @@
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtklabel.h>
 
-#include "view.h"
+#include "label.h"
 #include "merge.h"
 #include "util.h"
 
@@ -47,7 +49,6 @@ struct _glMergePropertiesDialogPrivate {
 
        GladeXML     *gui;
 
-       glView       *view;
        glLabel      *label;
        glMerge      *merge;
 
@@ -92,7 +93,8 @@ static void gl_merge_properties_dialog_class_init (glMergePropertiesDialogClass
 static void gl_merge_properties_dialog_init       (glMergePropertiesDialog      *dlg);
 static void gl_merge_properties_dialog_finalize   (GObject                      *object);
 static void gl_merge_properties_dialog_construct  (glMergePropertiesDialog      *dialog,
-                                                  glView                       *view);
+                                                  glLabel                      *label,
+                                                  GtkWindow                    *window);
 
 static void type_changed_cb                       (GtkWidget                    *widget,
                                                   glMergePropertiesDialog      *dialog);
@@ -209,7 +211,8 @@ gl_merge_properties_dialog_finalize (GObject *object)
 /* NEW merge properties dialog.                                              */
 /*****************************************************************************/
 GtkWidget*
-gl_merge_properties_dialog_new (glView *view)
+gl_merge_properties_dialog_new (glLabel   *label,
+                               GtkWindow *window)
 {
        GtkWidget *dialog;
 
@@ -218,7 +221,7 @@ gl_merge_properties_dialog_new (glView *view)
        dialog = GTK_WIDGET (g_object_new (GL_TYPE_MERGE_PROPERTIES_DIALOG, NULL));
 
        gl_merge_properties_dialog_construct (GL_MERGE_PROPERTIES_DIALOG (dialog),
-                                             view);
+                                             label, window);
 
        gl_debug (DEBUG_MERGE, "END");
 
@@ -230,7 +233,8 @@ gl_merge_properties_dialog_new (glView *view)
 /*--------------------------------------------------------------------------*/
 static void
 gl_merge_properties_dialog_construct (glMergePropertiesDialog *dialog,
-                                     glView                  *view)
+                                     glLabel                 *label,
+                                     GtkWindow               *window)
 {
        gchar             *description;
        glMergeSrcType     src_type;
@@ -252,6 +256,11 @@ gl_merge_properties_dialog_construct (glMergePropertiesDialog *dialog,
                                GTK_STOCK_OK, GTK_RESPONSE_OK,
                                NULL);
 
+       if (window) {
+               gtk_window_set_transient_for (GTK_WINDOW(dialog), GTK_WINDOW(window));
+               gtk_window_set_destroy_with_parent (GTK_WINDOW(dialog), TRUE);
+       }
+
        gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
        g_signal_connect(G_OBJECT (dialog), "response",
@@ -275,8 +284,7 @@ gl_merge_properties_dialog_construct (glMergePropertiesDialog *dialog,
 
        gl_util_combo_box_add_text_model (GTK_COMBO_BOX (dialog->priv->type_combo));
 
-       dialog->priv->view  = view;
-       dialog->priv->label = view->label;
+       dialog->priv->label = label;
 
        dialog->priv->merge = gl_label_get_merge (dialog->priv->label);
        description         = gl_merge_get_description (dialog->priv->merge);
@@ -284,7 +292,7 @@ gl_merge_properties_dialog_construct (glMergePropertiesDialog *dialog,
        src                 = gl_merge_get_src (dialog->priv->merge);
 
        /* --- Window title --- */
-       name = gl_label_get_short_name (view->label);
+       name = gl_label_get_short_name (label);
        title = g_strdup_printf ("%s %s", name, _("Merge Properties"));
        gtk_window_set_title (GTK_WINDOW (dialog), title);
        g_free (name);
index eb5a7a9b5ea8560d6562de79bf1d489fc9186e2d..3fcc28a5e50b34bdec64d4f10eb96568de11dd75 100644 (file)
@@ -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,8 @@
 #define __MERGE_PROPERTIES_DIALOG_H__
 
 #include <gtk/gtkdialog.h>
-#include "view.h"
+#include <gtk/gtkwindow.h>
+#include "label.h"
 
 G_BEGIN_DECLS
 
@@ -55,7 +58,8 @@ struct  _glMergePropertiesDialogClass
 
 GType      gl_merge_properties_dialog_get_type    (void) G_GNUC_CONST;
 
-GtkWidget *gl_merge_properties_dialog_new         (glView *view);
+GtkWidget *gl_merge_properties_dialog_new         (glLabel   *label,
+                                                  GtkWindow *window);
 
 G_END_DECLS
 
index a1240c96a884fdfc0ab4554a671afd5f8eb04854..f0a5edbb6241c199d3353cc5a3c71681254d9203 100644 (file)
@@ -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
  *
@@ -88,7 +90,7 @@ static void       gl_print_dialog_finalize        (GObject            *object);
 
 static void       gl_print_dialog_construct       (glPrintDialog      *dialog,
                                                   glLabel            *label,
-                                                  BonoboWindow       *win);
+                                                  GtkWindow          *win);
 
 static GtkWidget *job_page_new                    (glPrintDialog      *dialog,
                                                   glLabel            *label);
@@ -235,7 +237,7 @@ gl_print_dialog_finalize (GObject *object)
 /*****************************************************************************/
 GtkWidget *
 gl_print_dialog_new (glLabel      *label,
-                    BonoboWindow *win)
+                    GtkWindow    *win)
 {
        GtkWidget *dialog;
 
@@ -254,7 +256,7 @@ gl_print_dialog_new (glLabel      *label,
 static void
 gl_print_dialog_construct (glPrintDialog      *dialog,
                           glLabel            *label,
-                          BonoboWindow       *win)
+                          GtkWindow          *win)
 {
        GtkWidget *notebook, *page;
        gchar     *name, *title;
index efbce89727bdf32f26ecd82dbdb0dee85f0ec032..5f909503077a1dabff95275f8c41ccd0fd621692 100644 (file)
@@ -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
  *
@@ -22,7 +24,7 @@
 #ifndef __PRINT_DIALOG_H__
 #define __PRINT_DIALOG_H__
 
-#include <bonobo/bonobo-window.h>
+#include <gtk/gtkwindow.h>
 #include "hig.h"
 #include "view.h"
 
@@ -58,7 +60,7 @@ struct  _glPrintDialogClass
 GType      gl_print_dialog_get_type            (void) G_GNUC_CONST;
 
 GtkWidget *gl_print_dialog_new                 (glLabel       *label,
-                                               BonoboWindow  *win);
+                                               GtkWindow     *win);
 
 void       gl_print_dialog_force_outline_flag  (glPrintDialog *dialog);
 
index ef528ebc2eadd9dfdc85e067a412eac93b873700..6a9802ed6771300fd1e6203d0d7f03ec0c7e5dd1 100644 (file)
@@ -1,6 +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-commands.c:  GLabels UI commands module
@@ -194,18 +194,24 @@ gl_ui_cmd_file_print (GtkAction *action,
        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) {
+       if (window->print_dialog) {
 
-               gtk_window_present (GTK_WINDOW(GL_VIEW(window->view)->print_dialog));
+               gtk_window_present (GTK_WINDOW(window->print_dialog));
+               gtk_window_set_transient_for (GTK_WINDOW (window->print_dialog),
+                                             GTK_WINDOW (window));
 
        } else {
 
-               GL_VIEW(window->view)->print_dialog =
+               window->print_dialog =
                        g_object_ref (
                                gl_print_dialog_new (GL_VIEW(window->view)->label,
-                                                    BONOBO_WINDOW(window)) );
+                                                    GTK_WINDOW(window)) );
+
+               g_signal_connect (G_OBJECT(window->print_dialog), "destroy",
+                                 G_CALLBACK (gtk_widget_destroyed),
+                                 &window->print_dialog);
 
-               gtk_widget_show (GL_VIEW(window->view)->print_dialog);
+               gtk_widget_show (GTK_WIDGET (window->print_dialog));
        }
 
        gl_debug (DEBUG_COMMANDS, "END");
@@ -1006,8 +1012,25 @@ gl_ui_cmd_objects_merge_properties (GtkAction *action,
        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));
+       if (window->merge_dialog) {
+
+               gtk_window_present (GTK_WINDOW(window->merge_dialog));
+               gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
+                                             GTK_WINDOW (window));
+
+       } else {
+
+               window->merge_dialog =
+                       g_object_ref (
+                               gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
+                                                               GTK_WINDOW(window)) );
+
+               g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
+                                 G_CALLBACK (gtk_widget_destroyed),
+                                 &window->merge_dialog);
+
+               gtk_widget_show (GTK_WIDGET (window->merge_dialog));
+
        }
 
        gl_debug (DEBUG_COMMANDS, "END");
@@ -1111,9 +1134,9 @@ gl_ui_cmd_help_about (GtkAction *action,
        if (about != NULL)
        {
 
+               gtk_window_present (GTK_WINDOW (about));
                gtk_window_set_transient_for (GTK_WINDOW (about),
                                              GTK_WINDOW (window));
-               gtk_window_present (GTK_WINDOW (about));
 
        } else {
        
index 53727197cea1765e9f75b1a5f00bdd8b263fe5e3..30d4d763454d25c7ffd40971c3547c65c863a552 100644 (file)
@@ -105,6 +105,9 @@ static GtkActionEntry entries[] = {
        { "ObjectsAlignVertMenu",    NULL, N_("Align _Vertical") },
        { "HelpMenu",                NULL, N_("_Help") },
 
+       /* Popup entries. */
+       { "ContextMenu", NULL, N_("Context Menu") },
+       { "EmptySelectionContextMenu", NULL, N_("Context Menu") },
 
        /* File action entries. */
        { "FileNew",
@@ -628,6 +631,40 @@ static const gchar *ui_info =
 "              <toolitem action='ObjectsMergeProperties' />"
 "      </toolbar>"
 ""
+"      <popup action='ContextMenu'>"
+"              <menu action='ObjectsOrderMenu'>"
+"                      <menuitem action='ObjectsRaise' />"
+"                      <menuitem action='ObjectsLower' />"
+"              </menu>"
+"              <menu action='ObjectsRotateFlipMenu'>"
+"                      <menuitem action='ObjectsRotateLeft' />"
+"                      <menuitem action='ObjectsRotateRight' />"
+"                      <menuitem action='ObjectsFlipHorizontal' />"
+"                      <menuitem action='ObjectsFlipVertical' />"
+"              </menu>"
+"              <menu action='ObjectsAlignHorizMenu'>"
+"                      <menuitem action='ObjectsAlignLeft' />"
+"                      <menuitem action='ObjectsAlignHCenter' />"
+"                      <menuitem action='ObjectsAlignRight' />"
+"                      <menuitem action='ObjectsCenterHorizontal' />"
+"              </menu>"
+"              <menu action='ObjectsAlignVertMenu'>"
+"                      <menuitem action='ObjectsAlignTop' />"
+"                      <menuitem action='ObjectsAlignVCenter' />"
+"                      <menuitem action='ObjectsAlignBottom' />"
+"                      <menuitem action='ObjectsCenterVertical' />"
+"              </menu>"
+"              <separator />"
+"              <menuitem action='EditCut' />"
+"              <menuitem action='EditCopy' />"
+"              <menuitem action='EditPaste' />"
+"              <menuitem action='EditDelete' />"
+"      </popup>"
+""
+"      <popup action='EmptySelectionContextMenu'>"
+"              <menuitem action='EditPaste' />"
+"      </popup>"
+""
 "</ui>";
 
 
@@ -751,6 +788,7 @@ gl_ui_new (glWindow *window)
        gtk_ui_manager_insert_action_group (ui, actions, 0);
        gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui));
 
+       gl_debug (DEBUG_UI, "Creating ui from string");
        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);
index 95b41b7b943ac4729ad093cb91cf9ddd672153f9..a8efeb04da30cdd22cb0c0dfb41dcab74a89e4b6 100644 (file)
@@ -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
  *
@@ -584,19 +586,6 @@ item_event_arrow_mode (GnomeCanvasItem *item,
                        dragging = TRUE;
                        return TRUE;
 
-               case 3:
-                       if (!gl_view_is_object_selected (view, view_object)) {
-                               if (!control_key_pressed) {
-                                       /* No control, key so remove any selections before adding */
-                                       gl_view_unselect_all (view);
-                               }
-                       }
-                       /* Add to current selection */
-                       gl_view_select_object (view, view_object);
-                       /* bring up apropriate menu for selection. */
-                       gl_view_popup_menu (view, event);
-                       return TRUE;
-
                default:
                        return FALSE;
                }
index ec7b8541e1d03b0c1fbd40462ddc5c164230d8e7..9f72d79ec82672c3377a0affcbcb04af9b7d19b1 100644 (file)
@@ -1,9 +1,11 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
 /*
  *  (GLABELS) Label and Business Card Creation program for GNOME
  *
  *  view.c:  GLabels View module
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2005  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
@@ -28,9 +30,6 @@
 #include <gtk/gtkscrolledwindow.h>
 #include <gtk/gtkselection.h>
 #include <gtk/gtkinvisible.h>
-#include <gtk/gtkmenu.h>
-#include <gtk/gtkimagemenuitem.h>
-#include <gtk/gtkstock.h>
 #include <gdk/gdkkeysyms.h>
 #include <string.h>
 #include <math.h>
@@ -44,8 +43,6 @@
 #include "view-barcode.h"
 #include "xml-label.h"
 #include "color.h"
-#include "stock.h"
-#include "merge-properties-dialog.h"
 #include "prefs.h"
 #include "marshal.h"
 
@@ -79,6 +76,7 @@
 
 enum {
        SELECTION_CHANGED,
+       CONTEXT_MENU_ACTIVATE,
        ZOOM_CHANGED,
        POINTER_MOVED,
        POINTER_EXIT,
@@ -199,10 +197,6 @@ static int        canvas_event_arrow_mode         (GnomeCanvas *canvas,
                                                   GdkEvent    *event,
                                                   glView      *view);
 
-static void       construct_selection_menu       (glView *view);
-
-static void       construct_empty_selection_menu (glView *view);
-
 static void       selection_clear_cb             (GtkWidget         *widget,
                                                  GdkEventSelection *event,
                                                  gpointer          data);
@@ -268,6 +262,16 @@ gl_view_class_init (glViewClass *class)
                              G_TYPE_NONE,
                              0);
 
+       signals[CONTEXT_MENU_ACTIVATE] =
+               g_signal_new ("context_menu_activate",
+                             G_OBJECT_CLASS_TYPE (object_class),
+                             G_SIGNAL_RUN_LAST,
+                             G_STRUCT_OFFSET (glViewClass, context_menu_activate),
+                             NULL, NULL,
+                             gl_marshal_VOID__INT_UINT,
+                             G_TYPE_NONE,
+                             2, G_TYPE_INT, G_TYPE_UINT);
+
        signals[ZOOM_CHANGED] =
                g_signal_new ("zoom_changed",
                              G_OBJECT_CLASS_TYPE (object_class),
@@ -391,9 +395,6 @@ gl_view_construct (glView *view)
 
        gl_view_construct_selection (view);
 
-       construct_selection_menu (view);
-       construct_empty_selection_menu (view);
-
        gl_view_set_default_font_family      (view, gl_prefs->default_font_family);
        gl_view_set_default_font_size        (view, gl_prefs->default_font_size);
        gl_view_set_default_font_weight      (view, gl_prefs->default_font_weight);
@@ -3286,29 +3287,6 @@ gl_view_is_zoom_min (glView *view)
        return view->zoom <= zooms[N_ZOOMS-1];
 }
 
-/*****************************************************************************/
-/* Launch merge properties dialog.                                           */
-/*****************************************************************************/
-void
-gl_view_edit_merge_props (glView *view)
-{
-       gl_debug (DEBUG_VIEW, "");
-
-       g_return_if_fail (view && GL_IS_VIEW (view));
-
-       if (view->merge_props_dialog != NULL) {
-               gtk_window_present (GTK_WINDOW(view->merge_props_dialog));
-               return;
-       }
-
-       view->merge_props_dialog = gl_merge_properties_dialog_new (view);
-       gtk_window_present (GTK_WINDOW (view->merge_props_dialog));
-
-       g_signal_connect (G_OBJECT(view->merge_props_dialog), "destroy",
-                         G_CALLBACK (gtk_widget_destroyed),
-                         &view->merge_props_dialog);
-}
-
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Canvas event handler.                                           */
 /*---------------------------------------------------------------------------*/
@@ -3456,14 +3434,10 @@ canvas_event_arrow_mode (GnomeCanvas *canvas,
                        }
                        return FALSE;
                case 3:
-                       gnome_canvas_window_to_world (canvas,
-                                                     event->button.x,
-                                                     event->button.y, &x, &y);
-
-                       if (!object_at (view, x, y)) {
-                               /* bring up apropriate menu for selection. */
-                               gl_view_popup_menu (view, event);
-                       }
+                       /* activate context menu. */
+                       g_signal_emit (G_OBJECT (view),
+                                      signals[CONTEXT_MENU_ACTIVATE], 0,
+                                      event->button.button, event->button.time);
                        return FALSE;
                default:
                        return FALSE;
@@ -3559,262 +3533,6 @@ canvas_event_arrow_mode (GnomeCanvas *canvas,
 
 }
 
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  create menu for selections.                                     */
-/*---------------------------------------------------------------------------*/
-void
-construct_selection_menu (glView *view)
-{
-       GtkWidget *menu, *menuitem, *submenu;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (view && GL_IS_VIEW (view));
-
-       menu = gtk_menu_new ();
-
-       /*
-        * Submenu: Order
-        */
-       menuitem = gtk_menu_item_new_with_mnemonic (_("_Order"));
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       submenu = gtk_menu_new ();
-       gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ORDER_TOP, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_raise_selection), view);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ORDER_BOTTOM, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_lower_selection), view);
-
-       /*
-        * Submenu: Rotate/Flip
-        */
-       menuitem = gtk_menu_item_new_with_mnemonic (_("_Rotate/Flip"));
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       submenu = gtk_menu_new ();
-       gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ROTATE_LEFT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_rotate_selection_left), view);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ROTATE_RIGHT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_rotate_selection_right), view);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_FLIP_HORIZ, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_flip_selection_horiz), view);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_FLIP_VERT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_flip_selection_vert), view);
-
-       /*
-        * Submenu: Align Horizontally
-        */
-       menuitem = gtk_menu_item_new_with_mnemonic (_("Align _Horizontally"));
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       submenu = gtk_menu_new ();
-       gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ALIGN_LEFT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_align_selection_left), view);
-       view->multi_selection_items =
-               g_list_prepend (view->multi_selection_items, menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ALIGN_HCENTER, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_align_selection_hcenter), view);
-       view->multi_selection_items =
-               g_list_prepend (view->multi_selection_items, menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ALIGN_RIGHT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_align_selection_right), view);
-       view->multi_selection_items =
-               g_list_prepend (view->multi_selection_items, menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_CENTER_HORIZ, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_center_selection_horiz), view);
-
-       /*
-        * Submenu: Align Vertically
-        */
-       menuitem = gtk_menu_item_new_with_mnemonic (_("Align _Vertically"));
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       submenu = gtk_menu_new ();
-       gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ALIGN_TOP, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_align_selection_top), view);
-       view->multi_selection_items =
-               g_list_prepend (view->multi_selection_items, menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ALIGN_VCENTER, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_align_selection_vcenter), view);
-       view->multi_selection_items =
-               g_list_prepend (view->multi_selection_items, menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_ALIGN_BOTTOM, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_align_selection_bottom), view);
-       view->multi_selection_items =
-               g_list_prepend (view->multi_selection_items, menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_CENTER_VERT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (submenu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_center_selection_vert), view);
-
-       /*
-        * Separator -------------------------
-        */
-       menuitem = gtk_menu_item_new ();
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_CUT, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_cut), view);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_copy), view);
-
-       menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_PASTE, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_paste), view);
-
-       menuitem = gtk_menu_item_new_with_mnemonic (_("_Delete"));
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_delete_selection), view);
-
-
-       view->selection_menu = menu;
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
-/*---------------------------------------------------------------------------*/
-/* PRIVATE.  create menu for empty selections.                               */
-/*---------------------------------------------------------------------------*/
-void
-construct_empty_selection_menu (glView *view)
-{
-       GtkWidget *menu, *menuitem, *submenu;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (view && GL_IS_VIEW (view));
-
-       menu = gtk_menu_new ();
-
-       menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_PASTE, NULL);
-       gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
-       gtk_widget_show (menuitem);
-       g_signal_connect_swapped (G_OBJECT (menuitem), "activate",
-                                 G_CALLBACK (gl_view_paste), view);
-
-
-       view->empty_selection_menu = menu;
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
-/****************************************************************************/
-/* popup menu.                                                              */
-/****************************************************************************/
-void
-gl_view_popup_menu (glView       *view,
-                   GdkEvent     *event)
-{
-       GtkMenu *menu;
-       GList   *p;
-
-       gl_debug (DEBUG_VIEW, "START");
-
-       g_return_if_fail (view && GL_IS_VIEW (view));
-
-       if (gl_view_is_selection_empty (view)) {
-
-               if (view->empty_selection_menu != NULL) {
-                       gtk_menu_popup (GTK_MENU (view->empty_selection_menu),
-                                       NULL, NULL, NULL, NULL,
-                                       event->button.button,
-                                       event->button.time);
-               }
-
-       } else {
-
-               for (p=view->atomic_selection_items; p!=NULL; p=p->next) {
-                       gtk_widget_set_sensitive (GTK_WIDGET(p->data),
-                                                 gl_view_is_selection_atomic(view));
-               }
-
-               for (p=view->multi_selection_items; p!=NULL; p=p->next) {
-                       gtk_widget_set_sensitive (GTK_WIDGET(p->data),
-                                                 !gl_view_is_selection_atomic(view));
-               }
-
-               if (view->selection_menu != NULL) {
-                       gtk_menu_popup (GTK_MENU (view->selection_menu),
-                                       NULL, NULL, NULL, NULL,
-                                       event->button.button,
-                                       event->button.time);
-               }
-
-       }
-
-       gl_debug (DEBUG_VIEW, "END");
-}
-
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Handle "selection-clear" signal.                                */
 /*---------------------------------------------------------------------------*/
index d4a453b42ec92a2838305028ced5f650eb03fdfc..28c6d4361db96e5886b69595304df17c9538555e 100644 (file)
@@ -1,9 +1,11 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
 /*
  *  (GLABELS) Label and Business Card Creation program for GNOME
  *
  *  view.h:  GLabels View module header file
  *
- *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
+ *  Copyright (C) 2001-2005  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
@@ -77,18 +79,6 @@ struct _glView {
        glLabel           *selection_data;
        GtkWidget         *invisible;
 
-       /* Menus */
-       GList             *atomic_selection_items;
-       GList             *multi_selection_items;
-       GtkWidget         *selection_menu;
-       GtkWidget         *empty_selection_menu;
-
-       /* Merge Properties Dialog */
-       GtkWidget         *merge_props_dialog;
-
-       /* Print Dialog */
-       GtkWidget         *print_dialog;
-
        /* Default object text properties */
        gchar             *default_font_family;
        gdouble            default_font_size;
@@ -113,6 +103,12 @@ struct _glViewClass {
        void (*selection_changed) (glView   *view,
                                   gpointer  user_data);
 
+       /* Signal to launch a context menu */
+       void (*context_menu_activate) (glView   *view,
+                                      gint      button,
+                                      guint32   activate_time,
+                                      gpointer  user_data);
+
        /* Signals to support a status bar */
        void (*zoom_changed)      (glView   *view,
                                   gdouble   zoom,
@@ -275,12 +271,6 @@ gboolean   gl_view_is_zoom_max             (glView            *view);
 gboolean   gl_view_is_zoom_min             (glView            *view);
 
 
-void       gl_view_popup_menu              (glView            *view,
-                                           GdkEvent          *event);
-
-void       gl_view_edit_merge_props        (glView            *view);
-
-
 void       gl_view_set_default_font_family      (glView            *view,
                                                 const gchar       *font_family);
 
index d3754865f8f36591ed5a048552c9a3f36b37c095..6e98056a13671db6431fdcc5c4cdc99c7140586f 100644 (file)
@@ -1,6 +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
@@ -79,6 +79,11 @@ static gboolean window_delete_event_cb (glWindow      *window,
 static void     selection_changed_cb   (glView        *view,
                                        glWindow      *window);
 
+static void   context_menu_activate_cb (glView       *view,
+                                       gint          button,
+                                       guint32       activate_time,
+                                       glWindow     *window);
+
 static void     zoom_changed_cb        (glView        *view,
                                        gdouble        zoom,
                                        glWindow      *window);
@@ -214,6 +219,12 @@ gl_window_init (glWindow *window)
        window->menu_tips_context_id =
                gtk_statusbar_get_context_id (GTK_STATUSBAR (window->status_bar), "menu_tips");
 
+       window->print_dialog = NULL;
+       window->merge_dialog = NULL;
+       window->context_menu = GTK_MENU (gtk_ui_manager_get_widget (ui, "/ContextMenu"));
+       window->empty_selection_context_menu =
+               GTK_MENU (gtk_ui_manager_get_widget (ui, "/EmptySelectionContextMenu"));
+
        window->view = NULL;
 
        window_list = g_list_append (window_list, window);
@@ -398,6 +409,9 @@ gl_window_set_label (glWindow    *window,
        g_signal_connect (G_OBJECT(window->view), "selection_changed",
                          G_CALLBACK(selection_changed_cb), window);
 
+       g_signal_connect (G_OBJECT(window->view), "context_menu_activate",
+                         G_CALLBACK(context_menu_activate_cb), window);
+
        g_signal_connect (G_OBJECT(window->view), "zoom_changed",
                          G_CALLBACK(zoom_changed_cb), window);
 
@@ -494,6 +508,35 @@ selection_changed_cb (glView   *view,
        gl_debug (DEBUG_WINDOW, "END");
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  View "context menu activate" callback.                          */
+/*---------------------------------------------------------------------------*/
+static void
+context_menu_activate_cb (glView       *view,
+                         gint          button,
+                         guint32       activate_time,
+                         glWindow     *window)
+{
+        gl_debug (DEBUG_WINDOW, "START");
+
+        g_return_if_fail (view && GL_IS_VIEW (view));
+       g_return_if_fail (window && GL_IS_WINDOW (window));
+
+        if (gl_view_is_selection_empty (view)) {
+
+               gtk_menu_popup (GTK_MENU (window->empty_selection_context_menu),
+                               NULL, NULL, NULL, NULL, button, activate_time);
+
+        } else {
+
+               gtk_menu_popup (GTK_MENU (window->context_menu),
+                               NULL, NULL, NULL, NULL, button, activate_time);
+
+        }
+
+        gl_debug (DEBUG_WINDOW, "END");
+}
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  View "zoom state changed" callback.                             */
 /*---------------------------------------------------------------------------*/
index 502b1d6c2efa84d1149a34d4bd52938109c8fc07..287155d10adf773919325a1132755a40fd1e5dc0 100644 (file)
 
 #include <gtk/gtkwindow.h>
 #include <gtk/gtkuimanager.h>
+#include <gtk/gtkmenu.h>
 
 #include "view.h"
 #include "label.h"
-
 #include "ui-property-bar.h"
 #include "ui-sidebar.h"
+#include "print-dialog.h"
+#include "merge-properties-dialog.h"
 
 G_BEGIN_DECLS
 
@@ -52,22 +54,27 @@ typedef struct _glWindowClass glWindowClass;
 struct _glWindow {
        GtkWindow               parent_widget;
 
-       GtkUIManager           *ui;
+       GtkUIManager            *ui;
+
+       GtkWidget               *view;
 
-       GtkWidget              *view;
+       GtkWidget               *hbox;
 
-       GtkWidget              *hbox;
+       glUIPropertyBar         *property_bar;
+       glUISidebar             *sidebar;
 
-       glUIPropertyBar        *property_bar;
-       glUISidebar            *sidebar;
+       GtkWidget               *status_bar;
+       GtkWidget               *cursor_info;
+       GtkWidget               *cursor_info_frame;
+       GtkWidget               *zoom_info;
+       GtkWidget               *zoom_info_frame;
 
-       GtkWidget              *status_bar;
-       GtkWidget              *cursor_info;
-       GtkWidget              *cursor_info_frame;
-       GtkWidget              *zoom_info;
-       GtkWidget              *zoom_info_frame;
+       guint                    menu_tips_context_id;
 
-       guint                   menu_tips_context_id;
+       glPrintDialog           *print_dialog;
+       glMergePropertiesDialog *merge_dialog;
+       GtkMenu                 *context_menu;
+       GtkMenu                 *empty_selection_context_menu;
 };
 
 struct _glWindowClass {