]> git.sur5r.net Git - glabels/commitdiff
Preferences and object property dialogs are now rebuilt if previously destroyed rathe...
authorJim Evins <evins@snaught.com>
Thu, 10 Oct 2002 03:56:48 +0000 (03:56 +0000)
committerJim Evins <evins@snaught.com>
Thu, 10 Oct 2002 03:56:48 +0000 (03:56 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@155 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/prefs-dialog.c
glabels2/src/view-barcode.c
glabels2/src/view-box.c
glabels2/src/view-ellipse.c
glabels2/src/view-image.c
glabels2/src/view-line.c
glabels2/src/view-object.c
glabels2/src/view-object.h
glabels2/src/view-text.c

index 523f06a7e5a0aa8e6115101db54fa3b753e55e6a..e9abc340c3223006d0f221ce06cbde50d299f7bd 100644 (file)
@@ -247,8 +247,11 @@ response_cb (glPrefsDialog *dlg,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dlg));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
-               g_assert_not_reached();
+               g_print ("response = %d", response);
+               g_assert_not_reached ();
        }
 
        gl_debug (DEBUG_VIEW, "END");
index 8f4d71900995077577ed79f9bfb1e935798f944e..14e2964b7a9ca447d620553fb6838ea7c77ad16a 100644 (file)
@@ -186,7 +186,6 @@ gl_view_barcode_new (glLabelBarcode *object,
 {
        glViewBarcode      *view_barcode;
        GtkMenu            *menu;
-       GtkWidget          *dialog;
 
        gl_debug (DEBUG_VIEW, "START");
        g_return_if_fail (object && GL_IS_LABEL_BARCODE (object));
@@ -206,8 +205,8 @@ gl_view_barcode_new (glLabelBarcode *object,
                          G_CALLBACK (update_view_barcode_cb), view_barcode);
 
        /* Create a dialog for controlling/viewing object properties. */
-       dialog = construct_properties_dialog (view_barcode);
-       gl_view_object_set_dialog     (GL_VIEW_OBJECT(view_barcode), dialog);
+       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_barcode),
+                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
 
        gl_debug (DEBUG_VIEW, "END");
 
@@ -253,6 +252,7 @@ construct_properties_dialog (glViewBarcode *view_barcode)
        gdouble            scale;
        glMerge            *merge;
        GtkSizeGroup       *label_size_group;
+       GtkWidget          *window;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -269,8 +269,10 @@ construct_properties_dialog (glViewBarcode *view_barcode)
        /*-----------------------------------------------------------------*/
        /* Build dialog.                                                   */
        /*-----------------------------------------------------------------*/
+       window = gtk_widget_get_toplevel (
+               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_barcode))));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"),
-                                                 NULL,
+                                                 GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_STOCK_CLOSE,
                                                           GTK_RESPONSE_CLOSE,
@@ -385,7 +387,10 @@ response_cb (GtkDialog     *dialog,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dialog));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
+               g_print ("response = %d", response);
                g_assert_not_reached();
        }
 
index 67233f0f84d041fa5a5e305839b70d7fd8955c8c..3617fdfa082e33ba63df5dd837e69629840b16df 100644 (file)
@@ -184,7 +184,6 @@ gl_view_box_new (glLabelBox *object,
        guint              line_color, fill_color;
        gdouble            w, h;
        GtkMenu            *menu;
-       GtkWidget          *dialog;
 
        gl_debug (DEBUG_VIEW, "START");
        g_return_if_fail (object && GL_IS_LABEL_BOX (object));
@@ -221,8 +220,8 @@ gl_view_box_new (glLabelBox *object,
                          G_CALLBACK (update_view_box_cb), view_box);
 
        /* Create a dialog for controlling/viewing object properties. */
-       dialog = construct_properties_dialog (view_box);
-       gl_view_object_set_dialog     (GL_VIEW_OBJECT(view_box), dialog);
+       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_box),
+                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
 
        gl_debug (DEBUG_VIEW, "END");
 
@@ -275,6 +274,7 @@ construct_properties_dialog (glViewBox *view_box)
        guint              line_color, fill_color;
        gdouble            x, y, w, h, label_width, label_height;
        GtkSizeGroup       *label_size_group;
+       GtkWidget          *window;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -291,8 +291,10 @@ construct_properties_dialog (glViewBox *view_box)
        /*-----------------------------------------------------------------*/
        /* Build dialog with notebook.                                     */
        /*-----------------------------------------------------------------*/
+       window = gtk_widget_get_toplevel (
+               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_box))));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit box object properties"),
-                                                 NULL,
+                                                 GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_STOCK_CLOSE,
                                                           GTK_RESPONSE_CLOSE,
@@ -397,8 +399,11 @@ response_cb (GtkDialog *dialog,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dialog));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
-               g_assert_not_reached();
+               g_print ("response = %d", response);
+               g_assert_not_reached ();
        }
 
        gl_debug (DEBUG_VIEW, "END");
index 41836c3aafc5dd57b4b201343a9bb14fea5529ee..55ae8080577818e9f30ca2e5b50fe8e615fd0bf1 100644 (file)
@@ -184,7 +184,6 @@ gl_view_ellipse_new (glLabelEllipse *object,
        guint              line_color, fill_color;
        gdouble            w, h;
        GtkMenu            *menu;
-       GtkWidget          *dialog;
 
        gl_debug (DEBUG_VIEW, "START");
        g_return_if_fail (object && GL_IS_LABEL_ELLIPSE (object));
@@ -221,8 +220,8 @@ gl_view_ellipse_new (glLabelEllipse *object,
                          G_CALLBACK (update_view_ellipse_cb), view_ellipse);
 
        /* Create a dialog for controlling/viewing object properties. */
-       dialog = construct_properties_dialog (view_ellipse);
-       gl_view_object_set_dialog     (GL_VIEW_OBJECT(view_ellipse), dialog);
+       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_ellipse),
+                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
 
        gl_debug (DEBUG_VIEW, "END");
 
@@ -275,6 +274,7 @@ construct_properties_dialog (glViewEllipse *view_ellipse)
        guint              line_color, fill_color;
        gdouble            x, y, w, h, label_width, label_height;
        GtkSizeGroup       *label_size_group;
+       GtkWidget          *window;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -291,8 +291,10 @@ construct_properties_dialog (glViewEllipse *view_ellipse)
        /*-----------------------------------------------------------------*/
        /* Build dialog with notebook.                                     */
        /*-----------------------------------------------------------------*/
+       window = gtk_widget_get_toplevel (
+               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_ellipse))));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit ellipse object properties"),
-                                                 NULL,
+                                                 GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_STOCK_CLOSE,
                                                           GTK_RESPONSE_CLOSE,
@@ -398,7 +400,10 @@ response_cb (GtkDialog     *dialog,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dialog));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
+               g_print ("response = %d", response);
                g_assert_not_reached();
        }
 
index 0a30f06541e2590179dd67933d6f99fd38d2b5cf..77cd8a3227febd96ca6731e8dd2802c75b008ebc 100644 (file)
@@ -183,7 +183,6 @@ gl_view_image_new (glLabelImage *object,
        const GdkPixbuf    *pixbuf;
        gdouble            w, h;
        GtkMenu            *menu;
-       GtkWidget          *dialog;
 
        gl_debug (DEBUG_VIEW, "START");
        g_return_if_fail (object && GL_IS_LABEL_IMAGE (object));
@@ -218,8 +217,8 @@ gl_view_image_new (glLabelImage *object,
                          G_CALLBACK (update_view_image_cb), view_image);
 
        /* Create a dialog for controlling/viewing object properties. */
-       dialog = construct_properties_dialog (view_image);
-       gl_view_object_set_dialog     (GL_VIEW_OBJECT(view_image), dialog);
+       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_image),
+                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
 
        gl_debug (DEBUG_VIEW, "END");
 
@@ -268,6 +267,7 @@ construct_properties_dialog (glViewImage *view_image)
        gdouble            x, y, w, h, label_width, label_height;
        gchar              *filename;
        GtkSizeGroup       *label_size_group;
+       GtkWidget          *window;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -282,8 +282,10 @@ construct_properties_dialog (glViewImage *view_image)
        /*-----------------------------------------------------------------*/
        /* Build dialog.                                                   */
        /*-----------------------------------------------------------------*/
+       window = gtk_widget_get_toplevel (
+               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_image))));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit image object properties"),
-                                                 NULL,
+                                                 GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_STOCK_CLOSE,
                                                           GTK_RESPONSE_CLOSE,
@@ -396,7 +398,10 @@ response_cb (GtkDialog     *dialog,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dialog));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
+               g_print ("response = %d", response);
                g_assert_not_reached();
        }
 
index a6313893cf2402a37b68c85f83caedec2920ecd1..18e13765a9796b7e63b6bf1445e9b66a785fb2f9 100644 (file)
@@ -177,7 +177,6 @@ gl_view_line_new (glLabelLine *object,
        guint              line_color;
        gdouble            w, h;
        GtkMenu            *menu;
-       GtkWidget          *dialog;
        GnomeCanvasPoints  *points;
 
        gl_debug (DEBUG_VIEW, "START");
@@ -217,8 +216,8 @@ gl_view_line_new (glLabelLine *object,
                          G_CALLBACK (update_view_line_cb), view_line);
 
        /* Create a dialog for controlling/viewing object properties. */
-       dialog = construct_properties_dialog (view_line);
-       gl_view_object_set_dialog     (GL_VIEW_OBJECT(view_line), dialog);
+       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_line),
+                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
 
        gl_debug (DEBUG_VIEW, "END");
 
@@ -275,6 +274,7 @@ construct_properties_dialog (glViewLine *view_line)
        guint              line_color;
        gdouble            x, y, w, h, label_width, label_height;
        GtkSizeGroup       *label_size_group;
+       GtkWidget          *window;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -290,8 +290,10 @@ construct_properties_dialog (glViewLine *view_line)
        /*-----------------------------------------------------------------*/
        /* Build dialog with notebook.                                     */
        /*-----------------------------------------------------------------*/
+       window = gtk_widget_get_toplevel (
+               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_line))));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit line object properties"),
-                                                 NULL,
+                                                 GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_STOCK_CLOSE,
                                                           GTK_RESPONSE_CLOSE,
@@ -383,7 +385,10 @@ response_cb (GtkDialog     *dialog,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dialog));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
+               g_print ("response = %d", response);
                g_assert_not_reached();
        }
 
index b6dfa1c53b559394d29df5ae6befb2d5fb925574..2982f1d0f1132a483687af6a9f64b25c8ed37c49 100644 (file)
 
 struct _glViewObjectPrivate {
 
-       glView               *view;
-       glLabelObject        *object;
+       glView                     *view;
+       glLabelObject              *object;
 
-       GnomeCanvasItem      *group;
-       GnomeCanvasItem      *highlight;
+       GnomeCanvasItem            *group;
+       GnomeCanvasItem            *highlight;
 
-       GtkWidget            *menu;
-       GtkWidget            *property_dialog;
+       GtkWidget                  *menu;
+       GtkWidget                  *property_dialog;
+
+       glViewObjectDlgConstructor  dialog_constructor;
 };
 
 /*========================================================*/
@@ -241,16 +243,15 @@ gl_view_object_set_object     (glViewObject         *view_object,
 /* Set dialog for controlling/viewing object properties.                     */
 /*****************************************************************************/
 void
-gl_view_object_set_dialog     (glViewObject *view_object,
-                              GtkWidget *dialog)
+gl_view_object_set_dlg_constructor (glViewObject               *view_object,
+                                   glViewObjectDlgConstructor  dlg_constructor)
 
 {
        gl_debug (DEBUG_VIEW, "START");
 
        g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
-       g_return_if_fail (dialog && GTK_IS_WIDGET (dialog));
        
-       view_object->private->property_dialog = dialog;
+       view_object->private->dialog_constructor = dlg_constructor;
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -446,8 +447,22 @@ gl_view_object_show_dialog (glViewObject *view_object)
 
        g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object));
 
+       if (view_object->private->property_dialog != NULL) {
+               gtk_window_present (GTK_WINDOW (view_object->private->property_dialog));
+               return;
+       }
+
+       view_object->private->property_dialog =
+               view_object->private->dialog_constructor (view_object);
+
+       g_signal_connect (G_OBJECT (view_object->private->property_dialog),
+                         "destroy",
+                         G_CALLBACK (gtk_widget_destroyed),
+                         &view_object->private->property_dialog);
+       
        gtk_widget_show_all (view_object->private->property_dialog);
 
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
index 4defc538d7785e17c0b3c06713b57db1ed63213f..4798fff02f689348a45dd1910d89d554b29ae796 100644 (file)
@@ -27,9 +27,6 @@
 #include <gnome.h>
 #include "label-object.h"
 
-G_BEGIN_DECLS
-
-
 #define GL_TYPE_VIEW_OBJECT            (gl_view_object_get_type ())
 #define GL_VIEW_OBJECT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_VIEW_OBJECT, glViewObject))
 #define GL_VIEW_OBJECT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_VIEW_OBJECT, glViewObjectClass))
@@ -55,30 +52,44 @@ struct _glViewObjectClass {
        GObjectClass         parent_class;
 };
 
-extern GType     gl_view_object_get_type       (void);
 
-extern GObject  *gl_view_object_new            (void);
+typedef GtkWidget * (*glViewObjectDlgConstructor)(glViewObject *);
+#define GL_VIEW_OBJECT_DLG_CONSTRUCTOR(f) ((glViewObjectDlgConstructor) (f))
+
+G_BEGIN_DECLS
+
+GType            gl_view_object_get_type          (void);
+
+GObject         *gl_view_object_new               (void);
+
+
+void             gl_view_object_set_view          (glViewObject         *view_object,
+                                                  glView               *view);
+
+void             gl_view_object_set_object        (glViewObject         *view_object,
+                                                  glLabelObject        *object,
+                                                  glViewHighlightStyle  style);
+
+void             gl_view_object_set_dlg_constructor (glViewObject       *view_object,
+                                            glViewObjectDlgConstructor  dlg_constructor);
+
+glView          *gl_view_object_get_view          (glViewObject         *view_object);
+
+glLabelObject   *gl_view_object_get_object        (glViewObject         *view_object);
+
+GnomeCanvasItem *gl_view_object_get_group         (glViewObject         *view_object);
+
+GtkMenu         *gl_view_object_get_menu          (glViewObject         *view_object);
 
-extern void      gl_view_object_set_view       (glViewObject *view_object,
-                                               glView *view);
-extern void      gl_view_object_set_object     (glViewObject *view_object,
-                                               glLabelObject *object,
-                                               glViewHighlightStyle style);
-extern void      gl_view_object_set_dialog     (glViewObject *view_object,
-                                               GtkWidget *dialog);
+void             gl_view_object_update_highlight  (glViewObject         *view_object);
 
-extern glView          *gl_view_object_get_view   (glViewObject *view_object);
-extern glLabelObject   *gl_view_object_get_object (glViewObject *view_object);
-extern GnomeCanvasItem *gl_view_object_get_group  (glViewObject *view_object);
-extern GtkMenu         *gl_view_object_get_menu   (glViewObject *view_object);
+void             gl_view_object_show_highlight    (glViewObject         *view_object);
 
-extern void      gl_view_object_update_highlight  (glViewObject *view_object);
-extern void      gl_view_object_show_highlight    (glViewObject *view_object);
-extern void      gl_view_object_hide_highlight    (glViewObject *view_object);
+void             gl_view_object_hide_highlight    (glViewObject         *view_object);
 
-extern void      gl_view_object_show_dialog       (glViewObject *view_object);
+void             gl_view_object_show_dialog       (glViewObject         *view_object);
 
-extern void      gl_view_object_select            (glViewObject *view_object);
+void             gl_view_object_select            (glViewObject         *view_object);
 
 G_END_DECLS
 
index 1cab9af52b41aa4d519ba044cbd4b6b2e331428d..308abec6d278979534ee32aa8386ba888d3d210d 100644 (file)
@@ -180,7 +180,6 @@ gl_view_text_new (glLabelText *object,
 {
        glViewText         *view_text;
        GtkMenu            *menu;
-       GtkWidget          *dialog;
 
        gl_debug (DEBUG_VIEW, "START");
        g_return_if_fail (object && GL_IS_LABEL_TEXT (object));
@@ -200,8 +199,8 @@ gl_view_text_new (glLabelText *object,
                          G_CALLBACK (update_view_text_cb), view_text);
 
        /* Create a dialog for controlling/viewing object properties. */
-       dialog = construct_properties_dialog (view_text);
-       gl_view_object_set_dialog     (GL_VIEW_OBJECT(view_text), dialog);
+       gl_view_object_set_dlg_constructor (GL_VIEW_OBJECT(view_text),
+                                           GL_VIEW_OBJECT_DLG_CONSTRUCTOR(construct_properties_dialog));
 
        gl_debug (DEBUG_VIEW, "END");
 
@@ -248,6 +247,7 @@ construct_properties_dialog (glViewText *view_text)
        GtkJustification   just;
        glMerge            *merge;
        GtkSizeGroup       *label_size_group;
+       GtkWidget          *window;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -266,8 +266,10 @@ construct_properties_dialog (glViewText *view_text)
        /*-----------------------------------------------------------------*/
        /* Build dialog.                                                   */
        /*-----------------------------------------------------------------*/
+       window = gtk_widget_get_toplevel (
+               GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_text))));
        dialog = gl_hig_dialog_new_with_buttons ( _("Edit text object properties"),
-                                                 NULL,
+                                                 GTK_WINDOW (window),
                                                  GTK_DIALOG_DESTROY_WITH_PARENT,
                                                  GTK_STOCK_CLOSE,
                                                           GTK_RESPONSE_CLOSE,
@@ -363,7 +365,10 @@ response_cb (GtkDialog     *dialog,
        case GTK_RESPONSE_CLOSE:
                gtk_widget_hide (GTK_WIDGET(dialog));
                break;
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
        default:
+               g_print ("response = %d", response);
                g_assert_not_reached();
        }