diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-03-28 13:31:06 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-03-28 13:31:06 -0400 |
commit | 3693cac9254023afaad7a681b525851f23eb2a15 (patch) | |
tree | 8824a5528f9a2208d9cb5374bc872b1370ca5c98 | |
parent | f1bcd41832d6a919af24e94b58f86b0f819059fc (diff) | |
download | glade-3693cac9254023afaad7a681b525851f23eb2a15.tar.gz |
2010-03-28 Tristan Van Berkom <tvb@gnome.org>
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in:
- Sync attributes when they are set to be used directly and not by the model (fixes loaded state
of explicitly set cell renderer properties).
- Fix last patch to reset cellrenderer attributes from a GladeProperty::value-changed signal
instead of the property mutator implementation (as the "columns" property is construct-only
and the widget is rebuilt - property reference lists are unavailable at ->set_property time).
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | plugins/gtk+/glade-gtk.c | 141 | ||||
-rw-r--r-- | plugins/gtk+/gtk+.xml.in | 1 |
3 files changed, 77 insertions, 74 deletions
@@ -1,3 +1,12 @@ +2010-03-28 Tristan Van Berkom <tvb@gnome.org> + + * plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: + - Sync attributes when they are set to be used directly and not by the model (fixes loaded state + of explicitly set cell renderer properties). + - Fix last patch to reset cellrenderer attributes from a GladeProperty::value-changed signal + instead of the property mutator implementation (as the "columns" property is construct-only + and the widget is rebuilt - property reference lists are unavailable at ->set_property time). + 2010-03-27 Tristan Van Berkom <tvb@gnome.org> * gladeui/glade-marshallers.list, gladeui/glade-placeholder.c: diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c index fb30166c..91c6c568 100644 --- a/plugins/gtk+/glade-gtk.c +++ b/plugins/gtk+/glade-gtk.c @@ -10242,62 +10242,14 @@ glade_gtk_cell_layout_sync_attributes (GObject *layout) return FALSE; } -static gboolean -glade_gtk_cell_layout_clear_attributes (GObject *layout) -{ - GladeWidget *gwidget = glade_widget_get_from_gobject (layout); - GObject *cell; - GList *children, *l; - - children = glade_widget_adaptor_get_children (gwidget->adaptor, layout); - for (l = children; l; l = l->next) - { - cell = l->data; - if (!GTK_IS_CELL_RENDERER (cell)) - continue; - - gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (layout), - GTK_CELL_RENDERER (cell)); - } - g_list_free (children); - - return FALSE; -} - static void glade_gtk_store_set_columns (GObject *object, const GValue *value) { - GladeWidget *widget = glade_widget_get_from_gobject (object); GList *l; gint i, n; GType *types; - /* Clear the attributes for all cell renderers referring to this store */ - for (l = widget->prop_refs; l; l = l->next) - { - GladeWidget *referring_widget = GLADE_PROPERTY (l->data)->widget; - - if (GTK_IS_CELL_LAYOUT (referring_widget->object)) - glade_gtk_cell_layout_clear_attributes (referring_widget->object); - else if (GTK_IS_TREE_VIEW (referring_widget->object)) - { - GList *list, *children = - glade_widget_adaptor_get_children (referring_widget->adaptor, - referring_widget->object); - - for (list = children; list; list = list->next) - { - /* Clear the GtkTreeViewColumns... */ - if (GTK_IS_CELL_LAYOUT (l->data)) - glade_gtk_cell_layout_clear_attributes (G_OBJECT (l->data)); - } - - g_list_free (children); - } - } - - /* Apply new column types */ for (i = 0, l = g_value_get_boxed (value), n = g_list_length (l), types = g_new (GType, n); l; l = g_list_next (l), i++) { @@ -10315,31 +10267,6 @@ glade_gtk_store_set_columns (GObject *object, gtk_tree_store_set_column_types (GTK_TREE_STORE (object), n, types); g_free (types); - - /* Reset the attributes for all cell renderers referring to this store */ - for (l = widget->prop_refs; l; l = l->next) - { - GladeWidget *referring_widget = GLADE_PROPERTY (l->data)->widget; - - if (GTK_IS_CELL_LAYOUT (referring_widget->object)) - glade_gtk_cell_layout_sync_attributes (referring_widget->object); - else if (GTK_IS_TREE_VIEW (referring_widget->object)) - { - GList *list, *children = - glade_widget_adaptor_get_children (referring_widget->adaptor, - referring_widget->object); - - for (list = children; list; list = list->next) - { - /* Clear the GtkTreeViewColumns... */ - if (GTK_IS_CELL_LAYOUT (l->data)) - glade_gtk_cell_layout_sync_attributes (G_OBJECT (l->data)); - } - - g_list_free (children); - } - } - } static void @@ -10449,6 +10376,67 @@ glade_gtk_store_create_eprop (GladeWidgetAdaptor *adaptor, return eprop; } + +static void +glade_gtk_store_columns_changed (GladeProperty *property, + GValue *old_value, + GValue *new_value, + GladeWidget *store) +{ + GList *l, *list, *children; + + /* Reset the attributes for all cell renderers referring to this store */ + for (l = store->prop_refs; l; l = l->next) + { + GladeWidget *referring_widget = GLADE_PROPERTY (l->data)->widget; + + if (GTK_IS_CELL_LAYOUT (referring_widget->object)) + glade_gtk_cell_layout_sync_attributes (referring_widget->object); + else if (GTK_IS_TREE_VIEW (referring_widget->object)) + { + children = glade_widget_adaptor_get_children (referring_widget->adaptor, + referring_widget->object); + + for (list = children; list; list = list->next) + { + /* Clear the GtkTreeViewColumns... */ + if (GTK_IS_CELL_LAYOUT (list->data)) + glade_gtk_cell_layout_sync_attributes (G_OBJECT (list->data)); + } + + g_list_free (children); + } + } +} + +void +glade_gtk_store_post_create (GladeWidgetAdaptor *adaptor, + GObject *object, + GladeCreateReason reason) +{ + GladeWidget *gwidget; + GladeProperty *property; + + if (reason == GLADE_CREATE_REBUILD) + return; + + gwidget = glade_widget_get_from_gobject (object); + property = glade_widget_get_property (gwidget, "columns"); + + /* Here we watch the value-changed signal on the "columns" property, we need + * to reset all the Cell Renderer attributes when the underlying "columns" change, + * the reason we do it from "value-changed" is because GladeWidget prop references + * are unavailable while rebuilding an object, and the liststore needs to be rebuilt + * in order to set the columns. + * + * This signal will be envoked after applying the new column types to the store + * and before the views get any signal to update themselves from the changed model, + * perfect time to reset the attributes. + */ + g_signal_connect (G_OBJECT (property), "value-changed", + G_CALLBACK (glade_gtk_store_columns_changed), gwidget); +} + GladeEditable * glade_gtk_store_create_editable (GladeWidgetAdaptor *adaptor, GladeEditorPageType type) @@ -11007,7 +10995,12 @@ glade_gtk_cell_renderer_set_use_attribute (GObject *object, if (g_value_get_boolean (value)) glade_widget_property_set_sensitive (widget, attr_prop_name, TRUE, NULL); else - glade_widget_property_set_sensitive (widget, property_name, TRUE, NULL); + { + GladeProperty *property = glade_widget_get_property (widget, property_name); + + glade_property_set_sensitive (property, TRUE, NULL); + glade_property_sync (property); + } g_free (prop_msg); g_free (attr_msg); diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in index 049396b2..8682b0a4 100644 --- a/plugins/gtk+/gtk+.xml.in +++ b/plugins/gtk+/gtk+.xml.in @@ -1999,6 +1999,7 @@ embedded in another object</_tooltip> <glade-widget-class name="GtkListStore" generic-name="liststore" _title="List Store" libglade-unsupported="True" toplevel="True"> + <post-create-function>glade_gtk_store_post_create</post-create-function> <set-property-function>glade_gtk_store_set_property</set-property-function> <create-editor-property-function>glade_gtk_store_create_eprop</create-editor-property-function> <create-editable-function>glade_gtk_store_create_editable</create-editable-function> |