From: Jim Evins Date: Thu, 10 Oct 2002 03:56:48 +0000 (+0000) Subject: Preferences and object property dialogs are now rebuilt if previously destroyed rathe... X-Git-Tag: glabels-2_3_0~732 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9b27951549f2ee5db410e25c0bf553fba8400196;p=glabels Preferences and object property dialogs are now rebuilt if previously destroyed rather than assuming they were cleanly closed. This fixes bug #619052. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@155 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index 523f06a7..e9abc340 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -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"); diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index 8f4d7190..14e2964b 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -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(); } diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index 67233f0f..3617fdfa 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -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"); diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index 41836c3a..55ae8080 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -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(); } diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 0a30f065..77cd8a32 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -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(); } diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index a6313893..18e13765 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.c @@ -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(); } diff --git a/glabels2/src/view-object.c b/glabels2/src/view-object.c index b6dfa1c5..2982f1d0 100644 --- a/glabels2/src/view-object.c +++ b/glabels2/src/view-object.c @@ -32,14 +32,16 @@ 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"); } diff --git a/glabels2/src/view-object.h b/glabels2/src/view-object.h index 4defc538..4798fff0 100644 --- a/glabels2/src/view-object.h +++ b/glabels2/src/view-object.h @@ -27,9 +27,6 @@ #include #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 diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 1cab9af5..308abec6 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -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(); }