diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-01-07 22:48:48 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-01-07 22:49:44 +0900 |
commit | 31cc1165e751c8a3283945b8035a2d5d6fb19165 (patch) | |
tree | d75ba12a5cb0d15bf1c6389146a0c2f5956b9725 | |
parent | e1fd5a3d402459dc8d28a193117bb0828330b2d9 (diff) | |
download | glade-31cc1165e751c8a3283945b8035a2d5d6fb19165.tar.gz |
* gladeui/glade-editable.[ch], plugins/gtk+/.. [ All GladeEditable editors ].
GladeEditable now watches the project for changes and updates itself by way
of the base class implementation (and is fixed for removed widgets that no
longer have a project pointer available), also glade_editable_block/unblock()
is added for implementations to avoid firing implicit loads while executing
commands... all custom editors updated to lose much code.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gladeui/glade-editable.c | 101 | ||||
-rw-r--r-- | gladeui/glade-editable.h | 4 | ||||
-rw-r--r-- | plugins/gtk+/glade-activatable-editor.c | 63 | ||||
-rw-r--r-- | plugins/gtk+/glade-activatable-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-button-editor.c | 72 | ||||
-rw-r--r-- | plugins/gtk+/glade-button-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-entry-editor.c | 86 | ||||
-rw-r--r-- | plugins/gtk+/glade-entry-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-icon-factory-editor.c | 51 | ||||
-rw-r--r-- | plugins/gtk+/glade-image-editor.c | 66 | ||||
-rw-r--r-- | plugins/gtk+/glade-image-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-image-item-editor.c | 61 | ||||
-rw-r--r-- | plugins/gtk+/glade-image-item-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-label-editor.c | 87 | ||||
-rw-r--r-- | plugins/gtk+/glade-label-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-store-editor.c | 52 | ||||
-rw-r--r-- | plugins/gtk+/glade-tool-button-editor.c | 76 | ||||
-rw-r--r-- | plugins/gtk+/glade-tool-button-editor.h | 1 | ||||
-rw-r--r-- | plugins/gtk+/glade-treeview-editor.c | 54 |
20 files changed, 237 insertions, 550 deletions
@@ -14,6 +14,13 @@ * plugins/gtk+/glade-gtk.c: Added accelerator and tooltip-text properties to menu items and toolitems in the menu editor (fixes bug 510083). + * gladeui/glade-editable.[ch], plugins/gtk+/.. [ All GladeEditable editors ]. + GladeEditable now watches the project for changes and updates itself by way + of the base class implementation (and is fixed for removed widgets that no + longer have a project pointer available), also glade_editable_block/unblock() + is added for implementations to avoid firing implicit loads while executing + commands... all custom editors updated to lose much code. + 2011-01-06 Tristan Van Berkom <tristanvb@openismus.com> * gladeui/glade-signal.c: Fixed glade_signal_load() careless mistake after GObjectifying. diff --git a/gladeui/glade-editable.c b/gladeui/glade-editable.c index 62c81a29..94bf3ca8 100644 --- a/gladeui/glade-editable.c +++ b/gladeui/glade-editable.c @@ -30,15 +30,76 @@ #include <string.h> #include <stdlib.h> - +#include "glade-project.h" #include "glade-widget.h" #include "glade-editable.h" +static GQuark glade_editable_project_quark = 0; +static GQuark glade_editable_widget_quark = 0; + +static void +project_changed (GladeProject *project, + GladeCommand *command, + gboolean execute, + GladeEditable *editable) +{ + GladeWidget *widget; + + widget = g_object_get_qdata (G_OBJECT (editable), glade_editable_widget_quark); + + glade_editable_load (editable, widget); +} + +static void +project_closed (GladeProject *project, + GladeEditable *editable) +{ + glade_editable_load (editable, NULL); +} + +static void +glade_editable_load_default (GladeEditable *editable, + GladeWidget *widget) +{ + GladeWidget *old_widget; + GladeProject *old_project; + + old_widget = g_object_get_qdata (G_OBJECT (editable), glade_editable_widget_quark); + old_project = g_object_get_qdata (G_OBJECT (editable), glade_editable_project_quark); + + if (old_widget != widget) + { + if (old_widget) + { + g_signal_handlers_disconnect_by_func (old_project, G_CALLBACK (project_changed), editable); + g_signal_handlers_disconnect_by_func (old_project, G_CALLBACK (project_closed), editable); + + g_object_set_qdata (G_OBJECT (editable), glade_editable_widget_quark, NULL); + g_object_set_qdata (G_OBJECT (editable), glade_editable_project_quark, NULL); + } + + if (widget) + { + GladeProject *project = glade_widget_get_project (widget); + + g_object_set_qdata (G_OBJECT (editable), glade_editable_widget_quark, widget); + g_object_set_qdata (G_OBJECT (editable), glade_editable_project_quark, project); + + g_signal_connect (project, "changed", + G_CALLBACK (project_changed), editable); + g_signal_connect (project, "close", + G_CALLBACK (project_closed), editable); + } + } +} static void -glade_editable_class_init (gpointer g_iface) +glade_editable_class_init (GladeEditableIface *iface) { - /* */ + glade_editable_project_quark = g_quark_from_static_string ("glade-editable-project-quark"); + glade_editable_widget_quark = g_quark_from_static_string ("glade-editable-widget-quark"); + + iface->load = glade_editable_load_default; } GType @@ -47,12 +108,15 @@ glade_editable_get_type (void) static GType editable_type = 0; if (!editable_type) - editable_type = + { + editable_type = g_type_register_static_simple (G_TYPE_INTERFACE, "GladeEditable", sizeof (GladeEditableIface), (GClassInitFunc) glade_editable_class_init, 0, NULL, (GTypeFlags) 0); + g_type_interface_add_prerequisite (editable_type, GTK_TYPE_WIDGET); + } return editable_type; } @@ -104,3 +168,32 @@ glade_editable_set_show_name (GladeEditable * editable, gboolean show_name) if (iface->set_show_name) iface->set_show_name (editable, show_name); } + + +void +glade_editable_block (GladeEditable *editable) +{ + GladeProject *project; + + g_return_if_fail (GLADE_IS_EDITABLE (editable)); + + project = g_object_get_qdata (G_OBJECT (editable), glade_editable_project_quark); + + g_return_if_fail (GLADE_IS_PROJECT (project)); + + g_signal_handlers_block_by_func (project, G_CALLBACK (project_changed), editable); +} + +void +glade_editable_unblock (GladeEditable *editable) +{ + GladeProject *project; + + g_return_if_fail (GLADE_IS_EDITABLE (editable)); + + project = g_object_get_qdata (G_OBJECT (editable), glade_editable_project_quark); + + g_return_if_fail (GLADE_IS_PROJECT (project)); + + g_signal_handlers_unblock_by_func (project, G_CALLBACK (project_changed), editable); +} diff --git a/gladeui/glade-editable.h b/gladeui/glade-editable.h index f74400aa..ab5bfcf3 100644 --- a/gladeui/glade-editable.h +++ b/gladeui/glade-editable.h @@ -38,11 +38,15 @@ struct _GladeEditableIface }; GType glade_editable_get_type (void) G_GNUC_CONST; + void glade_editable_load (GladeEditable *editable, GladeWidget *widget); void glade_editable_set_show_name (GladeEditable *editable, gboolean show_name); +void glade_editable_block (GladeEditable *editable); +void glade_editable_unblock (GladeEditable *editable); + G_END_DECLS diff --git a/plugins/gtk+/glade-activatable-editor.c b/plugins/gtk+/glade-activatable-editor.c index e5357180..3ff7f475 100644 --- a/plugins/gtk+/glade-activatable-editor.c +++ b/plugins/gtk+/glade-activatable-editor.c @@ -33,6 +33,7 @@ static void glade_activatable_editor_editable_init (GladeEditableIface * iface); static void glade_activatable_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; G_DEFINE_TYPE_WITH_CODE (GladeActivatableEditor, glade_activatable_editor, GTK_TYPE_VBOX, @@ -56,67 +57,20 @@ glade_activatable_editor_init (GladeActivatableEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeActivatableEditor * activatable_editor) -{ - if (activatable_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (activatable_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (activatable_editor), - activatable_editor->loaded_widget); -} - - -static void -project_finalized (GladeActivatableEditor * activatable_editor, - GladeProject * where_project_was) -{ - activatable_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (activatable_editor), NULL); -} - -static void glade_activatable_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeActivatableEditor *activatable_editor = GLADE_ACTIVATABLE_EDITOR (editable); GList *l; - activatable_editor->loading = TRUE; + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* Since we watch the project */ - if (activatable_editor->loaded_widget) - { - /* watch custom-child and use-stock properties here for reloads !!! */ - g_signal_handlers_disconnect_by_func (glade_widget_get_project (activatable_editor->loaded_widget), - G_CALLBACK (project_changed), - activatable_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT - (glade_widget_get_project (activatable_editor->loaded_widget)), - (GWeakNotify) project_finalized, activatable_editor); - } + activatable_editor->loading = TRUE; /* Mark our widget... */ activatable_editor->loaded_widget = widget; - if (activatable_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (activatable_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), - activatable_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (activatable_editor->loaded_widget)), - (GWeakNotify) project_finalized, activatable_editor); - } - /* load the embedded editable... */ if (activatable_editor->embed) glade_editable_load (GLADE_EDITABLE (activatable_editor->embed), widget); @@ -125,9 +79,6 @@ glade_activatable_editor_load (GladeEditable * editable, GladeWidget * widget) glade_editor_property_load_by_widget (GLADE_EDITOR_PROPERTY (l->data), widget); - if (widget) - { - } activatable_editor->loading = FALSE; } @@ -145,6 +96,8 @@ glade_activatable_editor_set_show_name (GladeEditable * editable, static void glade_activatable_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_activatable_editor_load; iface->set_show_name = glade_activatable_editor_set_show_name; } @@ -357,6 +310,8 @@ use_appearance_pre_commit (GladeEditorProperty * property, glade_widget_property_get (gwidget, "related-action", &action); + glade_editable_block (GLADE_EDITABLE (activatable_editor)); + glade_command_push_group (use_appearance ? _("Setting %s to use action appearance") : _("Setting %s to not use action appearance"), @@ -372,6 +327,8 @@ use_appearance_post_commit (GladeEditorProperty * property, { glade_command_pop_group (); + + glade_editable_unblock (GLADE_EDITABLE (activatable_editor)); } GtkWidget * diff --git a/plugins/gtk+/glade-activatable-editor.h b/plugins/gtk+/glade-activatable-editor.h index 9383457e..f59cba4d 100644 --- a/plugins/gtk+/glade-activatable-editor.h +++ b/plugins/gtk+/glade-activatable-editor.h @@ -46,7 +46,6 @@ struct _GladeActivatableEditor GList *properties; /* A list of eprops to update at load() time */ gboolean loading; /* Loading flag for loading widgets in the editor */ - gboolean modifying; /* Flag for monitoring project changes */ }; struct _GladeActivatableEditorClass diff --git a/plugins/gtk+/glade-button-editor.c b/plugins/gtk+/glade-button-editor.c index 34a29dd1..5c10fed2 100644 --- a/plugins/gtk+/glade-button-editor.c +++ b/plugins/gtk+/glade-button-editor.c @@ -34,6 +34,8 @@ static void glade_button_editor_editable_init (GladeEditableIface * iface); static void glade_button_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; + G_DEFINE_TYPE_WITH_CODE (GladeButtonEditor, glade_button_editor, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_button_editor_editable_init)); @@ -55,30 +57,6 @@ glade_button_editor_init (GladeButtonEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeButtonEditor * button_editor) -{ - if (button_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (button_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (button_editor), - button_editor->loaded_widget); -} - - -static void -project_finalized (GladeButtonEditor * button_editor, - GladeProject * where_project_was) -{ - button_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (button_editor), NULL); -} - -static void glade_button_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeButtonEditor *button_editor = GLADE_BUTTON_EDITOR (editable); @@ -87,36 +65,14 @@ glade_button_editor_load (GladeEditable * editable, GladeWidget * widget) gboolean use_stock = FALSE, use_appearance = FALSE; GList *l; - button_editor->loading = TRUE; + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* Since we watch the project */ - if (button_editor->loaded_widget) - { - /* watch custom-child and use-stock properties here for reloads !!! */ - - g_signal_handlers_disconnect_by_func (glade_widget_get_project (button_editor->loaded_widget), - G_CALLBACK (project_changed), - button_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (button_editor->loaded_widget)), - (GWeakNotify) project_finalized, button_editor); - } + button_editor->loading = TRUE; /* Mark our widget... */ button_editor->loaded_widget = widget; - if (button_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (button_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), button_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (button_editor->loaded_widget)), - (GWeakNotify) project_finalized, button_editor); - } - /* load the embedded editable... */ if (button_editor->embed) glade_editable_load (GLADE_EDITABLE (button_editor->embed), widget); @@ -191,6 +147,8 @@ glade_button_editor_set_show_name (GladeEditable * editable, gboolean show_name) static void glade_button_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_button_editor_load; iface->set_show_name = glade_button_editor_set_show_name; } @@ -235,7 +193,7 @@ standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->standard_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use standard configuration"), glade_widget_get_name (button_editor->loaded_widget)); @@ -278,7 +236,7 @@ standard_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -297,7 +255,7 @@ custom_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->custom_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use a custom child"), glade_widget_get_name (button_editor->loaded_widget)); @@ -323,7 +281,7 @@ custom_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -343,7 +301,7 @@ stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->stock_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use a stock button"), glade_widget_get_name (button_editor->loaded_widget)); @@ -370,7 +328,7 @@ stock_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -391,7 +349,7 @@ label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->label_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use a label and image"), glade_widget_get_name (button_editor->loaded_widget)); @@ -416,7 +374,7 @@ label_toggled (GtkWidget * widget, GladeButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), diff --git a/plugins/gtk+/glade-button-editor.h b/plugins/gtk+/glade-button-editor.h index 837c4c5d..0189d5bd 100644 --- a/plugins/gtk+/glade-button-editor.h +++ b/plugins/gtk+/glade-button-editor.h @@ -61,7 +61,6 @@ struct _GladeButtonEditor GList *properties; /* A list of eprops to update at load() time */ gboolean loading; /* Loading flag for loading widgets in the editor */ - gboolean modifying; /* Flag for monitoring project changes */ }; struct _GladeButtonEditorClass diff --git a/plugins/gtk+/glade-entry-editor.c b/plugins/gtk+/glade-entry-editor.c index be0243d4..c261aa41 100644 --- a/plugins/gtk+/glade-entry-editor.c +++ b/plugins/gtk+/glade-entry-editor.c @@ -34,6 +34,7 @@ static void glade_entry_editor_editable_init (GladeEditableIface * iface); static void glade_entry_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; G_DEFINE_TYPE_WITH_CODE (GladeEntryEditor, glade_entry_editor, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, @@ -56,30 +57,6 @@ glade_entry_editor_init (GladeEntryEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeEntryEditor * entry_editor) -{ - if (entry_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (entry_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (entry_editor), - entry_editor->loaded_widget); -} - - -static void -project_finalized (GladeEntryEditor * entry_editor, - GladeProject * where_project_was) -{ - entry_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (entry_editor), NULL); -} - -static void glade_entry_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeEntryEditor *entry_editor = GLADE_ENTRY_EDITOR (editable); @@ -87,35 +64,14 @@ glade_entry_editor_load (GladeEditable * editable, GladeWidget * widget) gboolean use_buffer = FALSE; GList *l; - entry_editor->loading = TRUE; + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* Since we watch the project */ - if (entry_editor->loaded_widget) - { - /* watch custom-child and use-stock properties here for reloads !!! */ - g_signal_handlers_disconnect_by_func (glade_widget_get_project (entry_editor->loaded_widget), - G_CALLBACK (project_changed), - entry_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (entry_editor->loaded_widget)), - (GWeakNotify) project_finalized, entry_editor); - } + entry_editor->loading = TRUE; /* Mark our widget... */ entry_editor->loaded_widget = widget; - if (entry_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (entry_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), entry_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (entry_editor->loaded_widget)), - (GWeakNotify) project_finalized, entry_editor); - } - /* load the embedded editable... */ if (entry_editor->embed) glade_editable_load (GLADE_EDITABLE (entry_editor->embed), widget); @@ -195,6 +151,8 @@ glade_entry_editor_set_show_name (GladeEditable * editable, gboolean show_name) static void glade_entry_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_entry_editor_load; iface->set_show_name = glade_entry_editor_set_show_name; } @@ -235,7 +193,7 @@ text_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->text_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use static text"), glade_widget_get_name (entry_editor->loaded_widget)); @@ -257,7 +215,7 @@ text_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -276,7 +234,7 @@ buffer_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->buffer_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use an external buffer"), glade_widget_get_name (entry_editor->loaded_widget)); @@ -292,7 +250,7 @@ buffer_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -384,14 +342,14 @@ primary_stock_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->primary_stock_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use a primary icon from stock"), glade_widget_get_name (entry_editor->loaded_widget)); set_stock_mode (entry_editor, TRUE); glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -409,14 +367,14 @@ primary_icon_name_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->primary_icon_name_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use a primary icon from the icon theme"), glade_widget_get_name (entry_editor->loaded_widget)); set_icon_name_mode (entry_editor, TRUE); glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -433,14 +391,14 @@ primary_pixbuf_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->primary_pixbuf_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use a primary icon from filename"), glade_widget_get_name (entry_editor->loaded_widget)); set_pixbuf_mode (entry_editor, TRUE); glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -459,14 +417,14 @@ secondary_stock_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->secondary_stock_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use a secondary icon from stock"), glade_widget_get_name (entry_editor->loaded_widget)); set_stock_mode (entry_editor, FALSE); glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -485,14 +443,14 @@ secondary_icon_name_toggled (GtkWidget * widget, (GTK_TOGGLE_BUTTON (entry_editor->secondary_icon_name_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use a secondary icon from the icon theme"), glade_widget_get_name (entry_editor->loaded_widget)); set_icon_name_mode (entry_editor, FALSE); glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), @@ -509,14 +467,14 @@ secondary_pixbuf_toggled (GtkWidget * widget, GladeEntryEditor * entry_editor) (GTK_TOGGLE_BUTTON (entry_editor->secondary_pixbuf_radio))) return; - entry_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (entry_editor)); glade_command_push_group (_("Setting %s to use a secondary icon from filename"), glade_widget_get_name (entry_editor->loaded_widget)); set_pixbuf_mode (entry_editor, FALSE); glade_command_pop_group (); - entry_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (entry_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (entry_editor), diff --git a/plugins/gtk+/glade-entry-editor.h b/plugins/gtk+/glade-entry-editor.h index 368888d8..c3fa1223 100644 --- a/plugins/gtk+/glade-entry-editor.h +++ b/plugins/gtk+/glade-entry-editor.h @@ -57,7 +57,6 @@ struct _GladeEntryEditor GList *properties; gboolean loading; - gboolean modifying; }; struct _GladeEntryEditorClass diff --git a/plugins/gtk+/glade-icon-factory-editor.c b/plugins/gtk+/glade-icon-factory-editor.c index 60e59454..b9fa4630 100644 --- a/plugins/gtk+/glade-icon-factory-editor.c +++ b/plugins/gtk+/glade-icon-factory-editor.c @@ -34,6 +34,7 @@ static void glade_icon_factory_editor_editable_init (GladeEditableIface * static void glade_icon_factory_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; G_DEFINE_TYPE_WITH_CODE (GladeIconFactoryEditor, glade_icon_factory_editor, GTK_TYPE_VBOX, @@ -57,61 +58,17 @@ glade_icon_factory_editor_init (GladeIconFactoryEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeIconFactoryEditor * factory_editor) -{ - if (!gtk_widget_get_mapped (GTK_WIDGET (factory_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (factory_editor), - factory_editor->loaded_widget); -} - - -static void -project_finalized (GladeIconFactoryEditor * factory_editor, - GladeProject * where_project_was) -{ - factory_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (factory_editor), NULL); -} - -static void glade_icon_factory_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeIconFactoryEditor *factory_editor = GLADE_ICON_FACTORY_EDITOR (editable); GList *l; - /* Since we watch the project */ - if (factory_editor->loaded_widget) - { - g_signal_handlers_disconnect_by_func (glade_widget_get_project (factory_editor->loaded_widget), - G_CALLBACK (project_changed), - factory_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (factory_editor->loaded_widget)), - (GWeakNotify) project_finalized, factory_editor); - } + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); /* Mark our widget... */ factory_editor->loaded_widget = widget; - if (factory_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (factory_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), - factory_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (factory_editor->loaded_widget)), - (GWeakNotify) project_finalized, factory_editor); - } - /* load the embedded editable... */ if (factory_editor->embed) glade_editable_load (GLADE_EDITABLE (factory_editor->embed), widget); @@ -134,6 +91,8 @@ glade_icon_factory_editor_set_show_name (GladeEditable * editable, static void glade_icon_factory_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_icon_factory_editor_load; iface->set_show_name = glade_icon_factory_editor_set_show_name; } diff --git a/plugins/gtk+/glade-image-editor.c b/plugins/gtk+/glade-image-editor.c index f42661da..fbb917b8 100644 --- a/plugins/gtk+/glade-image-editor.c +++ b/plugins/gtk+/glade-image-editor.c @@ -33,6 +33,7 @@ static void glade_image_editor_editable_init (GladeEditableIface * iface); static void glade_image_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; G_DEFINE_TYPE_WITH_CODE (GladeImageEditor, glade_image_editor, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, @@ -55,65 +56,20 @@ glade_image_editor_init (GladeImageEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeImageEditor * image_editor) -{ - if (image_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (image_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (image_editor), - image_editor->loaded_widget); -} - - -static void -project_finalized (GladeImageEditor * image_editor, - GladeProject * where_project_was) -{ - image_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (image_editor), NULL); -} - -static void glade_image_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeImageEditor *image_editor = GLADE_IMAGE_EDITOR (editable); GladeImageEditMode image_mode = 0; GList *l; - image_editor->loading = TRUE; + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* Since we watch the project */ - if (image_editor->loaded_widget) - { - /* watch custom-child and use-stock properties here for reloads !!! */ - g_signal_handlers_disconnect_by_func (glade_widget_get_project (image_editor->loaded_widget), - G_CALLBACK (project_changed), - image_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (image_editor->loaded_widget)), - (GWeakNotify) project_finalized, image_editor); - } + image_editor->loading = TRUE; /* Mark our widget... */ image_editor->loaded_widget = widget; - if (image_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (image_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), image_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (image_editor->loaded_widget)), - (GWeakNotify) project_finalized, image_editor); - } - /* load the embedded editable... */ if (image_editor->embed) glade_editable_load (GLADE_EDITABLE (image_editor->embed), widget); @@ -159,6 +115,8 @@ glade_image_editor_set_show_name (GladeEditable * editable, gboolean show_name) static void glade_image_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_image_editor_load; iface->set_show_name = glade_image_editor_set_show_name; } @@ -259,14 +217,14 @@ stock_toggled (GtkWidget * widget, GladeImageEditor * image_editor) (GTK_TOGGLE_BUTTON (image_editor->stock_radio))) return; - image_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (image_editor)); glade_command_push_group (_("Setting %s to use an image from stock"), glade_widget_get_name (image_editor->loaded_widget)); set_stock_mode (image_editor); glade_command_pop_group (); - image_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (image_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (image_editor), @@ -284,14 +242,14 @@ icon_toggled (GtkWidget * widget, GladeImageEditor * image_editor) (GTK_TOGGLE_BUTTON (image_editor->icon_radio))) return; - image_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (image_editor)); glade_command_push_group (_("Setting %s to use an image from the icon theme"), glade_widget_get_name (image_editor->loaded_widget)); set_icon_mode (image_editor); glade_command_pop_group (); - image_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (image_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (image_editor), @@ -308,14 +266,14 @@ file_toggled (GtkWidget * widget, GladeImageEditor * image_editor) (GTK_TOGGLE_BUTTON (image_editor->file_radio))) return; - image_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (image_editor)); glade_command_push_group (_("Setting %s to use an image from filename"), glade_widget_get_name (image_editor->loaded_widget)); set_file_mode (image_editor); glade_command_pop_group (); - image_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (image_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (image_editor), diff --git a/plugins/gtk+/glade-image-editor.h b/plugins/gtk+/glade-image-editor.h index e589cf24..61f61e00 100644 --- a/plugins/gtk+/glade-image-editor.h +++ b/plugins/gtk+/glade-image-editor.h @@ -59,7 +59,6 @@ struct _GladeImageEditor GList *properties; /* A list of eprops to update at load() time */ gboolean loading; /* Loading flag for loading widgets in the editor */ - gboolean modifying; /* Flag for monitoring project changes */ }; struct _GladeImageEditorClass diff --git a/plugins/gtk+/glade-image-item-editor.c b/plugins/gtk+/glade-image-item-editor.c index f6be1b09..374d8e35 100644 --- a/plugins/gtk+/glade-image-item-editor.c +++ b/plugins/gtk+/glade-image-item-editor.c @@ -33,6 +33,7 @@ static void glade_image_item_editor_editable_init (GladeEditableIface * iface); static void glade_image_item_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; G_DEFINE_TYPE_WITH_CODE (GladeImageItemEditor, glade_image_item_editor, GTK_TYPE_VBOX, @@ -55,30 +56,6 @@ glade_image_item_editor_init (GladeImageItemEditor * self) { } -static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeImageItemEditor * item_editor) -{ - if (item_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (item_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (item_editor), - item_editor->loaded_widget); -} - - -static void -project_finalized (GladeImageItemEditor * item_editor, - GladeProject * where_project_was) -{ - item_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (item_editor), NULL); -} - static GladeWidget * get_image_widget (GladeWidget * widget) { @@ -95,34 +72,14 @@ glade_image_item_editor_load (GladeEditable * editable, GladeWidget * widget) GList *l; gboolean use_stock = FALSE; - item_editor->loading = TRUE; - - /* Since we watch the project */ - if (item_editor->loaded_widget) - { - g_signal_handlers_disconnect_by_func (glade_widget_get_project (item_editor->loaded_widget), - G_CALLBACK (project_changed), - item_editor); + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (item_editor->loaded_widget)), - (GWeakNotify) project_finalized, item_editor); - } + item_editor->loading = TRUE; /* Mark our widget... */ item_editor->loaded_widget = widget; - if (item_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (item_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), item_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (item_editor->loaded_widget)), - (GWeakNotify) project_finalized, item_editor); - } - /* load the embedded editable... */ if (item_editor->embed) glade_editable_load (GLADE_EDITABLE (item_editor->embed), widget); @@ -169,6 +126,8 @@ glade_image_item_editor_set_show_name (GladeEditable * editable, static void glade_image_item_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_image_item_editor_load; iface->set_show_name = glade_image_item_editor_set_show_name; } @@ -212,7 +171,7 @@ stock_toggled (GtkWidget * widget, GladeImageItemEditor * item_editor) (GTK_TOGGLE_BUTTON (item_editor->stock_radio))) return; - item_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (item_editor)); loaded = item_editor->loaded_widget; glade_command_push_group (_("Setting %s to use a stock item"), glade_widget_get_name (loaded)); @@ -238,7 +197,7 @@ stock_toggled (GtkWidget * widget, GladeImageItemEditor * item_editor) glade_command_pop_group (); - item_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (item_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (item_editor), @@ -258,7 +217,7 @@ custom_toggled (GtkWidget * widget, GladeImageItemEditor * item_editor) (GTK_TOGGLE_BUTTON (item_editor->custom_radio))) return; - item_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (item_editor)); adaptor = glade_widget_get_adaptor (item_editor->loaded_widget); @@ -303,7 +262,7 @@ custom_toggled (GtkWidget * widget, GladeImageItemEditor * item_editor) } glade_command_pop_group (); - item_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (item_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (item_editor), diff --git a/plugins/gtk+/glade-image-item-editor.h b/plugins/gtk+/glade-image-item-editor.h index bcef41d7..acf229fb 100644 --- a/plugins/gtk+/glade-image-item-editor.h +++ b/plugins/gtk+/glade-image-item-editor.h @@ -52,7 +52,6 @@ struct _GladeImageItemEditor GList *properties; /* A list of eprops to update at load() time */ gboolean loading; /* Loading flag for loading widgets in the editor */ - gboolean modifying; /* Flag for monitoring project changes */ }; struct _GladeImageItemEditorClass diff --git a/plugins/gtk+/glade-label-editor.c b/plugins/gtk+/glade-label-editor.c index af270b4e..e9745645 100644 --- a/plugins/gtk+/glade-label-editor.c +++ b/plugins/gtk+/glade-label-editor.c @@ -34,6 +34,8 @@ static void glade_label_editor_editable_init (GladeEditableIface * iface); static void glade_label_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; + G_DEFINE_TYPE_WITH_CODE (GladeLabelEditor, glade_label_editor, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_label_editor_editable_init)); @@ -55,64 +57,19 @@ glade_label_editor_init (GladeLabelEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeLabelEditor * label_editor) -{ - if (label_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (label_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (label_editor), - label_editor->loaded_widget); -} - - -static void -project_finalized (GladeLabelEditor * label_editor, - GladeProject * where_project_was) -{ - label_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (label_editor), NULL); -} - -static void glade_label_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeLabelEditor *label_editor = GLADE_LABEL_EDITOR (editable); GList *l; - label_editor->loading = TRUE; + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* Since we watch the project */ - if (label_editor->loaded_widget) - { - /* watch custom-child and use-stock properties here for reloads !!! */ - g_signal_handlers_disconnect_by_func (glade_widget_get_project (label_editor->loaded_widget), - G_CALLBACK (project_changed), - label_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (label_editor->loaded_widget)), - (GWeakNotify) project_finalized, label_editor); - } + label_editor->loading = TRUE; /* Mark our widget... */ label_editor->loaded_widget = widget; - if (label_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (label_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), label_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (label_editor->loaded_widget)), - (GWeakNotify) project_finalized, label_editor); - } - /* load the embedded editable... */ if (label_editor->embed) glade_editable_load (GLADE_EDITABLE (label_editor->embed), widget); @@ -209,6 +166,8 @@ glade_label_editor_set_show_name (GladeEditable * editable, gboolean show_name) static void glade_label_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_label_editor_load; iface->set_show_name = glade_label_editor_set_show_name; } @@ -252,7 +211,7 @@ attributes_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->attributes_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to use an attribute list"), glade_widget_get_name (label_editor->loaded_widget)); @@ -269,7 +228,7 @@ attributes_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -288,7 +247,7 @@ markup_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->markup_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to use a Pango markup string"), glade_widget_get_name (label_editor->loaded_widget)); @@ -310,7 +269,7 @@ markup_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -329,7 +288,7 @@ pattern_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->pattern_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to use a pattern string"), glade_widget_get_name (label_editor->loaded_widget)); @@ -348,7 +307,7 @@ pattern_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -371,7 +330,7 @@ width_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->width_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to set desired width in characters"), glade_widget_get_name (label_editor->loaded_widget)); @@ -386,7 +345,7 @@ width_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -405,7 +364,7 @@ max_width_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->max_width_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to set maximum width in characters"), glade_widget_get_name (label_editor->loaded_widget)); @@ -419,7 +378,7 @@ max_width_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -441,7 +400,7 @@ wrap_free_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->wrap_free_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to use normal line wrapping"), glade_widget_get_name (label_editor->loaded_widget)); @@ -463,7 +422,7 @@ wrap_free_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -482,7 +441,7 @@ single_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->single_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to use a single line"), glade_widget_get_name (label_editor->loaded_widget)); @@ -504,7 +463,7 @@ single_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), @@ -523,7 +482,7 @@ wrap_mode_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) (GTK_TOGGLE_BUTTON (label_editor->wrap_mode_radio))) return; - label_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (label_editor)); glade_command_push_group (_("Setting %s to use specific Pango word wrapping"), glade_widget_get_name (label_editor->loaded_widget)); @@ -542,7 +501,7 @@ wrap_mode_toggled (GtkWidget * widget, GladeLabelEditor * label_editor) glade_command_pop_group (); - label_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (label_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (label_editor), diff --git a/plugins/gtk+/glade-label-editor.h b/plugins/gtk+/glade-label-editor.h index e501d345..2652f9b7 100644 --- a/plugins/gtk+/glade-label-editor.h +++ b/plugins/gtk+/glade-label-editor.h @@ -73,7 +73,6 @@ struct _GladeLabelEditor GList *properties; /* A list of eprops to update at load() time */ gboolean loading; /* Loading flag for loading widgets in the editor */ - gboolean modifying; /* Flag for monitoring project changes */ }; struct _GladeLabelEditorClass diff --git a/plugins/gtk+/glade-store-editor.c b/plugins/gtk+/glade-store-editor.c index 8211dd30..ceb194e3 100644 --- a/plugins/gtk+/glade-store-editor.c +++ b/plugins/gtk+/glade-store-editor.c @@ -34,6 +34,8 @@ static void glade_store_editor_editable_init (GladeEditableIface * iface); static void glade_store_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; + G_DEFINE_TYPE_WITH_CODE (GladeStoreEditor, glade_store_editor, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_store_editor_editable_init)); @@ -55,61 +57,17 @@ glade_store_editor_init (GladeStoreEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeStoreEditor * store_editor) -{ - if (!gtk_widget_get_mapped (GTK_WIDGET (store_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (store_editor), - store_editor->loaded_widget); -} - - -static void -project_finalized (GladeStoreEditor * store_editor, - GladeProject * where_project_was) -{ - store_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (store_editor), NULL); -} - -static void glade_store_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeStoreEditor *store_editor = GLADE_STORE_EDITOR (editable); GList *l; - /* Since we watch the project */ - if (store_editor->loaded_widget) - { - /* watch custom-child and use-stock properties here for reloads !!! */ - g_signal_handlers_disconnect_by_func (glade_widget_get_project (store_editor->loaded_widget), - G_CALLBACK (project_changed), - store_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (store_editor->loaded_widget)), - (GWeakNotify) project_finalized, store_editor); - } + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); /* Mark our widget... */ store_editor->loaded_widget = widget; - if (store_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (store_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), store_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (store_editor->loaded_widget)), - (GWeakNotify) project_finalized, store_editor); - } - /* load the embedded editable... */ if (store_editor->embed) glade_editable_load (GLADE_EDITABLE (store_editor->embed), widget); @@ -131,6 +89,8 @@ glade_store_editor_set_show_name (GladeEditable * editable, gboolean show_name) static void glade_store_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_store_editor_load; iface->set_show_name = glade_store_editor_set_show_name; } diff --git a/plugins/gtk+/glade-tool-button-editor.c b/plugins/gtk+/glade-tool-button-editor.c index 3f8e9472..96bf2aad 100644 --- a/plugins/gtk+/glade-tool-button-editor.c +++ b/plugins/gtk+/glade-tool-button-editor.c @@ -34,12 +34,13 @@ static void glade_tool_button_editor_editable_init (GladeEditableIface * iface); static void glade_tool_button_editor_grab_focus (GtkWidget * widget); +static GladeEditableIface *parent_editable_iface; + G_DEFINE_TYPE_WITH_CODE (GladeToolButtonEditor, glade_tool_button_editor, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_tool_button_editor_editable_init)); - static void glade_tool_button_editor_class_init (GladeToolButtonEditorClass * klass) { @@ -56,30 +57,6 @@ glade_tool_button_editor_init (GladeToolButtonEditor * self) } static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeToolButtonEditor * button_editor) -{ - if (button_editor->modifying || - !gtk_widget_get_mapped (GTK_WIDGET (button_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (button_editor), - button_editor->loaded_widget); -} - - -static void -project_finalized (GladeToolButtonEditor * button_editor, - GladeProject * where_project_was) -{ - button_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (button_editor), NULL); -} - -static void glade_tool_button_editor_load (GladeEditable * editable, GladeWidget * widget) { GladeToolButtonEditor *button_editor = GLADE_TOOL_BUTTON_EDITOR (editable); @@ -87,34 +64,14 @@ glade_tool_button_editor_load (GladeEditable * editable, GladeWidget * widget) GladeToolButtonImageMode image_mode = 0; GList *l; - button_editor->loading = TRUE; + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); - /* Since we watch the project */ - if (button_editor->loaded_widget) - { - g_signal_handlers_disconnect_by_func (glade_widget_get_project (button_editor->loaded_widget), - G_CALLBACK (project_changed), - button_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (button_editor->loaded_widget)), - (GWeakNotify) project_finalized, button_editor); - } + button_editor->loading = TRUE; /* Mark our widget... */ button_editor->loaded_widget = widget; - if (button_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (button_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), button_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (button_editor->loaded_widget)), - (GWeakNotify) project_finalized, button_editor); - } - /* load the embedded editable... */ if (button_editor->embed) glade_editable_load (GLADE_EDITABLE (button_editor->embed), widget); @@ -184,7 +141,8 @@ standard_label_toggled (GtkWidget * widget, (GTK_TOGGLE_BUTTON (button_editor->standard_label_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use standard label text"), glade_widget_get_name (button_editor->loaded_widget)); @@ -203,7 +161,7 @@ standard_label_toggled (GtkWidget * widget, glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -222,7 +180,7 @@ custom_label_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->custom_label_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use a custom label widget"), glade_widget_get_name (button_editor->loaded_widget)); @@ -235,7 +193,7 @@ custom_label_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -254,7 +212,7 @@ stock_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->stock_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use an image from stock"), glade_widget_get_name (button_editor->loaded_widget)); @@ -273,7 +231,7 @@ stock_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -293,7 +251,7 @@ icon_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->icon_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use an image from the icon theme"), glade_widget_get_name (button_editor->loaded_widget)); @@ -312,7 +270,7 @@ icon_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -331,7 +289,7 @@ custom_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) (GTK_TOGGLE_BUTTON (button_editor->custom_radio))) return; - button_editor->modifying = TRUE; + glade_editable_block (GLADE_EDITABLE (button_editor)); glade_command_push_group (_("Setting %s to use an image from the icon theme"), glade_widget_get_name (button_editor->loaded_widget)); @@ -350,7 +308,7 @@ custom_toggled (GtkWidget * widget, GladeToolButtonEditor * button_editor) glade_command_pop_group (); - button_editor->modifying = FALSE; + glade_editable_unblock (GLADE_EDITABLE (button_editor)); /* reload buttons and sensitivity and stuff... */ glade_editable_load (GLADE_EDITABLE (button_editor), @@ -370,6 +328,8 @@ glade_tool_button_editor_set_show_name (GladeEditable * editable, static void glade_tool_button_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_tool_button_editor_load; iface->set_show_name = glade_tool_button_editor_set_show_name; } diff --git a/plugins/gtk+/glade-tool-button-editor.h b/plugins/gtk+/glade-tool-button-editor.h index 5ecdd1b6..070bb799 100644 --- a/plugins/gtk+/glade-tool-button-editor.h +++ b/plugins/gtk+/glade-tool-button-editor.h @@ -64,7 +64,6 @@ struct _GladeToolButtonEditor GList *properties; /* A list of eprops to update at load() time */ gboolean loading; /* Loading flag for loading widgets in the editor */ - gboolean modifying; /* Flag for monitoring project changes */ }; struct _GladeToolButtonEditorClass diff --git a/plugins/gtk+/glade-treeview-editor.c b/plugins/gtk+/glade-treeview-editor.c index 7159d128..8232dc79 100644 --- a/plugins/gtk+/glade-treeview-editor.c +++ b/plugins/gtk+/glade-treeview-editor.c @@ -34,8 +34,10 @@ static void glade_tree_view_editor_realize (GtkWidget * widget); static void glade_tree_view_editor_grab_focus (GtkWidget * widget); -G_DEFINE_TYPE_WITH_CODE (GladeTreeViewEditor, glade_tree_view_editor, - GTK_TYPE_HBOX, + +static GladeEditableIface *parent_editable_iface; + +G_DEFINE_TYPE_WITH_CODE (GladeTreeViewEditor, glade_tree_view_editor, GTK_TYPE_HBOX, G_IMPLEMENT_INTERFACE (GLADE_TYPE_EDITABLE, glade_tree_view_editor_editable_init)); @@ -57,28 +59,6 @@ glade_tree_view_editor_init (GladeTreeViewEditor * self) { } -static void -project_changed (GladeProject * project, - GladeCommand * command, - gboolean execute, GladeTreeViewEditor * view_editor) -{ - if (!gtk_widget_get_mapped (GTK_WIDGET (view_editor))) - return; - - /* Reload on all commands */ - glade_editable_load (GLADE_EDITABLE (view_editor), - view_editor->loaded_widget); -} - -static void -project_finalized (GladeTreeViewEditor * view_editor, - GladeProject * where_project_was) -{ - view_editor->loaded_widget = NULL; - - glade_editable_load (GLADE_EDITABLE (view_editor), NULL); -} - static GladeWidget * get_model_widget (GladeWidget * view) { @@ -105,32 +85,12 @@ glade_tree_view_editor_load (GladeEditable * editable, GladeWidget * widget) GladeTreeViewEditor *view_editor = GLADE_TREE_VIEW_EDITOR (editable); GladeWidget *model_widget; - /* Since we watch the project */ - if (view_editor->loaded_widget) - { - g_signal_handlers_disconnect_by_func (glade_widget_get_project (view_editor->loaded_widget), - G_CALLBACK (project_changed), - view_editor); - - /* The widget could die unexpectedly... */ - g_object_weak_unref (G_OBJECT (glade_widget_get_project (view_editor->loaded_widget)), - (GWeakNotify) project_finalized, view_editor); - } + /* Chain up to default implementation */ + parent_editable_iface->load (editable, widget); /* Mark our widget... */ view_editor->loaded_widget = widget; - if (view_editor->loaded_widget) - { - /* This fires for undo/redo */ - g_signal_connect (glade_widget_get_project (view_editor->loaded_widget), - "changed", G_CALLBACK (project_changed), view_editor); - - /* The widget/project could die unexpectedly... */ - g_object_weak_ref (G_OBJECT (glade_widget_get_project (view_editor->loaded_widget)), - (GWeakNotify) project_finalized, view_editor); - } - /* load the embedded editable... */ if (view_editor->embed) glade_editable_load (GLADE_EDITABLE (view_editor->embed), widget); @@ -182,6 +142,8 @@ glade_tree_view_editor_set_show_name (GladeEditable * editable, static void glade_tree_view_editor_editable_init (GladeEditableIface * iface) { + parent_editable_iface = g_type_default_interface_peek (GLADE_TYPE_EDITABLE); + iface->load = glade_tree_view_editor_load; iface->set_show_name = glade_tree_view_editor_set_show_name; } |