[glade3] Enhanced performance wrt GtkAction and GtkActivatable:use-action-appearance in the Glade runtime
- From: Tristan Van Berkom <tvb src gnome org>
- To: svn-commits-list gnome org
- Subject: [glade3] Enhanced performance wrt GtkAction and GtkActivatable:use-action-appearance in the Glade runtime
- Date: Thu, 25 Jun 2009 19:01:22 +0000 (UTC)
commit 608a792e393e3f6502eb085546137be1f15ebd0b
Author: Tristan Van Berkom <vantr TheBully local>
Date: Thu Jun 25 14:59:01 2009 -0400
Enhanced performance wrt GtkAction and GtkActivatable:use-action-appearance in the Glade runtime
(improved usability).
* plugins/gtk+/glade-gtk.c:
- Added sync_use_appearance() to reset the use-appearance property when local widget property
updates demand that the appearance be resynchronized (this is actually a bug in GTK+ somewhere).
- Avoid tampering with the virtual GtkBox:size property while loading a project.
* plugins/gtk+/gtk+.xml.in: Attributed use-action-appearance property with "needs-sync"
for better chances at a good visual result when copy/pasting etc.
* plugins/gtk+/glade-activatable-editor.c: Reverse order in which the image is
removed from GtkImageMenuItems (so that mucking with stock doesnt recreate one
2 lines further), now image menu items with controlling actions dont get orphaned images.
* gladeui/glade-widget-adaptor.c: Sync remaining properties at load time
which were not specified in the glade file (now the use-action-appearance
property shows up right even if default and not present in the Glade file).
ChangeLog | 20 +++++++++++++++-
gladeui/glade-widget-adaptor.c | 14 ++++++++++++
plugins/gtk+/glade-activatable-editor.c | 9 +++----
plugins/gtk+/glade-gtk.c | 36 +++++++++++++++++++++++++++++++
plugins/gtk+/gtk+.xml.in | 3 +-
5 files changed, 74 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 622e25b..4e6fc4d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,8 +5,24 @@
can float outside of widget->properties in some cases, shouldnt effect the
widget though).
- * plugins/gtk+/glade-gtk.c: glade_gtk_button_write_widget (), make stock
- button labels save as non-translatable automatically (bug 352446).
+ * plugins/gtk+/glade-gtk.c:
+ - glade_gtk_button_write_widget (), make stock button labels save as
+ non-translatable automatically (bug 352446).
+ - Added sync_use_appearance() to reset the use-appearance property when local
+ widget property updates demand that the appearance be resynchronized (this
+ is actually a bug in GTK+ somewhere).
+ - Avoid tampering with the virtual GtkBox:size property while loading a project.
+
+ * plugins/gtk+/gtk+.xml.in: Attributed use-action-appearance property with "needs-sync"
+ for better chances at a good visual result when copy/pasting etc.
+
+ * plugins/gtk+/glade-activatable-editor.c: Reverse order in which the image is
+ removed from GtkImageMenuItems (so that mucking with stock doesnt recreate one
+ 2 lines further), now image menu items with controlling actions dont get orphaned images.
+
+ * gladeui/glade-widget-adaptor.c: Sync remaining properties at load time
+ which were not specified in the glade file (now the use-action-appearance
+ property shows up right even if default and not present in the Glade file).
2009-06-22 Tristan Van Berkom <tvb gnome org>
diff --git a/gladeui/glade-widget-adaptor.c b/gladeui/glade-widget-adaptor.c
index 42bee90..a47bd04 100644
--- a/gladeui/glade-widget-adaptor.c
+++ b/gladeui/glade-widget-adaptor.c
@@ -868,6 +868,7 @@ glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor *adaptor,
GladeSignal *signal;
GladeProperty *property;
gchar *name, *prop_name;
+ GList *read_properties = NULL, *l;
/* Read in the properties */
for (iter_node = glade_xml_node_get_children (node);
@@ -885,12 +886,25 @@ glade_widget_adaptor_object_read_widget (GladeWidgetAdaptor *adaptor,
/* Some properties may be special child type of custom, just leave them for the adaptor */
if ((property = glade_widget_get_property (widget, prop_name)) != NULL)
+ {
glade_property_read (property, widget->project, iter_node);
+ read_properties = g_list_prepend (read_properties, property);
+ }
g_free (prop_name);
g_free (name);
}
+ /* Sync the remaining values not read in from the Glade file.. */
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
+
+ if (!g_list_find (read_properties, property))
+ glade_property_sync (property);
+ }
+ g_list_free (read_properties);
+
/* Read in the signals */
for (iter_node = glade_xml_node_get_children (node);
diff --git a/plugins/gtk+/glade-activatable-editor.c b/plugins/gtk+/glade-activatable-editor.c
index 59d0b80..97b30e9 100644
--- a/plugins/gtk+/glade-activatable-editor.c
+++ b/plugins/gtk+/glade-activatable-editor.c
@@ -229,6 +229,10 @@ reset_properties (GladeWidget *gwidget,
GladeWidget *image;
GladeProperty *property;
+ reset_property (gwidget, "stock");
+ reset_property (gwidget, "use-underline");
+ reset_property (gwidget, "use-stock");
+
/* Delete image... */
if ((image = get_image_widget (gwidget)) != NULL)
{
@@ -240,11 +244,6 @@ reset_properties (GladeWidget *gwidget,
property = glade_widget_get_property (gwidget, "label");
glade_command_set_property (property, NULL);
-
- reset_property (gwidget, "stock");
- reset_property (gwidget, "use-underline");
- reset_property (gwidget, "use-stock");
-
}
else if (use_appearance_changed)
{
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 270142a..5f87a65 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -2018,6 +2018,9 @@ glade_gtk_box_set_size (GObject *object, const GValue *value)
box = GTK_BOX (object);
g_return_if_fail (GTK_IS_BOX (box));
+ if (glade_util_object_is_loading (object))
+ return;
+
old_size = g_list_length (box->children);
new_size = g_value_get_int (value);
@@ -5743,6 +5746,24 @@ glade_gtk_color_button_refresh_color (GtkColorButton *button,
/* ----------------------------- GtkButton ------------------------------ */
+static void
+sync_use_appearance (GladeWidget *gwidget)
+{
+ GladeProperty *prop = glade_widget_get_property (gwidget, "use-action-appearance");
+ gboolean use_appearance = FALSE;
+
+ /* This is the kind of thing we avoid doing at project load time ;-) */
+ if (glade_widget_superuser ())
+ return;
+
+ glade_property_get (prop, &use_appearance);
+ if (use_appearance)
+ {
+ glade_property_set (prop, FALSE);
+ glade_property_set (prop, TRUE);
+ }
+}
+
/* shared between menuitems and toolitems too */
static void
evaluate_activatable_property_sensitivity (GObject *object,
@@ -5878,6 +5899,15 @@ glade_gtk_button_set_property (GladeWidgetAdaptor *adaptor,
if (use_stock)
gtk_button_set_label (GTK_BUTTON (object), g_value_get_string (value));
}
+ else if (strcmp (id, "use-stock") == 0)
+ {
+ /* I guess its my bug in GTK+, we need to resync the appearance property
+ * on GtkButton when the GtkButton:use-stock property changes.
+ */
+ GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
+ id, value);
+ sync_use_appearance (widget);
+ }
else if (property->klass->version_since_major <= gtk_major_version &&
property->klass->version_since_minor <= (gtk_minor_version + 1))
GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
@@ -6889,6 +6919,12 @@ glade_gtk_image_menu_item_set_use_stock (GObject *object, const GValue *value)
glade_widget_property_set_sensitive (widget, "stock", FALSE, NOT_SELECTED_MSG);
glade_widget_property_set_sensitive (widget, "accel-group", FALSE, NOT_SELECTED_MSG);
}
+
+#if GTK_CHECK_VERSION (2, 16, 0)
+ gtk_image_menu_item_set_use_stock (GTK_IMAGE_MENU_ITEM (object), use_stock);
+
+ sync_use_appearance (widget);
+#endif
}
static gboolean
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index 4cfddec..830bb75 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -477,7 +477,8 @@ embedded in another object</_tooltip>
<value-type>GtkAction</value-type>
</parameter-spec>
</property>
- <property id="use-action-appearance" _name="Use Action Appearance" custom-layout="True" default="False" since="2.16">
+ <property id="use-action-appearance" _name="Use Action Appearance"
+ custom-layout="True" needs-sync="True" default="False" since="2.16">
<parameter-spec>
<type>GParamBoolean</type>
</parameter-spec>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]