glade3 r2053 - in trunk: . plugins/gtk+
- From: tvb svn gnome org
- To: svn-commits-list gnome org
- Subject: glade3 r2053 - in trunk: . plugins/gtk+
- Date: Tue, 25 Nov 2008 19:01:52 +0000 (UTC)
Author: tvb
Date: Tue Nov 25 19:01:52 2008
New Revision: 2053
URL: http://svn.gnome.org/viewvc/glade3?rev=2053&view=rev
Log:
* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in:
- Renderers watch project format changes and now sync attributes in an idle
when moving into builder format (fixes renderer appearance after undo of project
conversions).
Modified:
trunk/ChangeLog
trunk/plugins/gtk+/glade-gtk.c
trunk/plugins/gtk+/gtk+.xml.in
Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c (original)
+++ trunk/plugins/gtk+/glade-gtk.c Tue Nov 25 19:01:52 2008
@@ -1093,7 +1093,7 @@
{
GladeProject
*project = glade_widget_get_project (gwidget),
- *old_project = g_object_get_data (G_OBJECT (gwidget), "notebook-project-ptr");
+ *old_project = g_object_get_data (G_OBJECT (gwidget), "widget-project-ptr");
if (old_project)
g_signal_handlers_disconnect_by_func (G_OBJECT (old_project),
@@ -1104,7 +1104,7 @@
g_signal_connect (G_OBJECT (project), "notify::format",
G_CALLBACK (widget_format_changed), gwidget);
- g_object_set_data (G_OBJECT (gwidget), "notebook-project-ptr", project);
+ g_object_set_data (G_OBJECT (gwidget), "widget-project-ptr", project);
}
void
@@ -9940,10 +9940,125 @@
action_path);
}
+
+static gboolean
+glade_gtk_cell_layout_has_renderer (GtkCellLayout *layout,
+ GtkCellRenderer *renderer)
+{
+ GList *cells = gtk_cell_layout_get_cells (layout);
+ gboolean has_renderer;
+
+ has_renderer = (g_list_find (cells, renderer) != NULL);
+
+ g_list_free (cells);
+
+ return has_renderer;
+}
+
+static void
+glade_gtk_cell_renderer_sync_attributes (GObject *object)
+{
+
+ GtkCellLayout *layout;
+ GtkCellRenderer *cell;
+ GladeWidget *widget = glade_widget_get_from_gobject (object);
+ GladeWidget *gmodel;
+ GladeProperty *property;
+ gchar *attr_prop_name;
+ GList *l;
+ gint columns = 0;
+ static gint attr_len = 0;
+
+ if (!attr_len)
+ attr_len = strlen ("attr-");
+
+ /* Apply attributes to renderer when bound to a model in runtime */
+ widget = glade_widget_get_from_gobject (object);
+
+ if (widget->parent == NULL) return;
+
+ /* When creating widgets, sometimes the parent is set before parenting happens,
+ * here we have to be careful for that..
+ */
+ layout = GTK_CELL_LAYOUT (widget->parent->object);
+ cell = GTK_CELL_RENDERER (object);
+
+ if (!glade_gtk_cell_layout_has_renderer (layout, cell))
+ return;
+
+ if ((gmodel = glade_cell_renderer_get_model (widget)) != NULL)
+ {
+ GList *column_list = NULL;
+ glade_widget_property_get (gmodel, "columns", &column_list);
+ columns = g_list_length (column_list);
+ }
+
+ gtk_cell_layout_clear_attributes (layout, cell);
+
+ for (l = widget->properties; l; l = l->next)
+ {
+ property = l->data;
+
+ if (strncmp (property->klass->id, "attr-", attr_len) == 0)
+ {
+ attr_prop_name = &property->klass->id[attr_len];
+
+ /* XXX TODO: Check that the cell supports the data type in the indexed column.
+ *
+ * use: gtk_tree_model_get_column_type (icon_view->priv->model, column)
+ */
+ if (g_value_get_int (property->value) >= 0 &&
+ /* We have to set attributes before parenting when loading */
+ (glade_widget_superuser () || g_value_get_int (property->value) < columns))
+ gtk_cell_layout_add_attribute (layout, cell,
+ attr_prop_name,
+ g_value_get_int (property->value));
+ }
+ }
+}
+
+
+static gboolean
+sync_attributes_idle (GladeWidget *gwidget)
+{
+ glade_gtk_cell_renderer_sync_attributes (gwidget->object);
+ return FALSE;
+}
+
+static void
+renderer_format_changed (GladeProject *project,
+ GParamSpec *pspec,
+ GladeWidget *gwidget)
+{
+ if (glade_project_get_format (project) == GLADE_PROJECT_FORMAT_GTKBUILDER)
+ g_idle_add ((GSourceFunc)sync_attributes_idle, gwidget);
+}
+
+static void
+renderer_project_changed (GladeWidget *gwidget,
+ GParamSpec *pspec,
+ gpointer userdata)
+{
+ GladeProject
+ *project = glade_widget_get_project (gwidget),
+ *old_project = g_object_get_data (G_OBJECT (gwidget), "renderer-project-ptr");
+
+ if (old_project)
+ g_signal_handlers_disconnect_by_func (G_OBJECT (old_project),
+ G_CALLBACK (renderer_format_changed),
+ gwidget);
+
+ if (project)
+ g_signal_connect (G_OBJECT (project), "notify::format",
+ G_CALLBACK (renderer_format_changed), gwidget);
+
+ g_object_set_data (G_OBJECT (gwidget), "renderer-project-ptr", project);
+}
+
void
-glade_gtk_cell_renderer_post_create (GladeWidgetAdaptor *adaptor,
- GObject *object,
- GladeCreateReason reason)
+glade_gtk_cell_renderer_deep_post_create (GladeWidgetAdaptor *adaptor,
+ GObject *object,
+ GladeCreateReason reason)
{
GladePropertyClass *pclass;
GladeProperty *property;
@@ -9962,6 +10077,12 @@
glade_property_sync (property);
}
}
+
+ g_signal_connect (G_OBJECT (widget), "notify::project",
+ G_CALLBACK (renderer_project_changed), NULL);
+
+ renderer_project_changed (widget, NULL, NULL);
+
}
GladeEditorProperty *
@@ -10028,82 +10149,6 @@
g_free (attr_prop_name);
}
-static gboolean
-glade_gtk_cell_layout_has_renderer (GtkCellLayout *layout,
- GtkCellRenderer *renderer)
-{
- GList *cells = gtk_cell_layout_get_cells (layout);
- gboolean has_renderer;
-
- has_renderer = (g_list_find (cells, renderer) != NULL);
-
- g_list_free (cells);
-
- return has_renderer;
-}
-
-static void
-glade_gtk_cell_renderer_sync_attributes (GObject *object)
-{
-
- GtkCellLayout *layout;
- GtkCellRenderer *cell;
- GladeWidget *widget = glade_widget_get_from_gobject (object);
- GladeWidget *gmodel;
- GladeProperty *property;
- gchar *attr_prop_name;
- GList *l;
- gint columns = 0;
- static gint attr_len = 0;
-
- if (!attr_len)
- attr_len = strlen ("attr-");
-
- /* Apply attributes to renderer when bound to a model in runtime */
- widget = glade_widget_get_from_gobject (object);
-
- if (widget->parent == NULL) return;
-
- /* When creating widgets, sometimes the parent is set before parenting happens,
- * here we have to be careful for that..
- */
- layout = GTK_CELL_LAYOUT (widget->parent->object);
- cell = GTK_CELL_RENDERER (object);
-
- if (!glade_gtk_cell_layout_has_renderer (layout, cell))
- return;
-
- if ((gmodel = glade_cell_renderer_get_model (widget)) != NULL)
- {
- GList *column_list = NULL;
- glade_widget_property_get (gmodel, "columns", &column_list);
- columns = g_list_length (column_list);
- }
-
- gtk_cell_layout_clear_attributes (layout, cell);
-
- for (l = widget->properties; l; l = l->next)
- {
- property = l->data;
-
- if (strncmp (property->klass->id, "attr-", attr_len) == 0)
- {
- attr_prop_name = &property->klass->id[attr_len];
-
- /* XXX TODO: Check that the cell supports the data type in the indexed column.
- *
- * use: gtk_tree_model_get_column_type (icon_view->priv->model, column)
- */
- if (g_value_get_int (property->value) >= 0 &&
- /* We have to set attributes before parenting when loading */
- (glade_widget_superuser () || g_value_get_int (property->value) < columns))
- gtk_cell_layout_add_attribute (layout, cell,
- attr_prop_name,
- g_value_get_int (property->value));
- }
- }
-}
-
static gboolean
glade_gtk_cell_renderer_property_enabled (GObject *object,
const gchar *property_name)
Modified: trunk/plugins/gtk+/gtk+.xml.in
==============================================================================
--- trunk/plugins/gtk+/gtk+.xml.in (original)
+++ trunk/plugins/gtk+/gtk+.xml.in Tue Nov 25 19:01:52 2008
@@ -1964,7 +1964,7 @@
</glade-widget-class>
<glade-widget-class name="GtkCellRenderer" _title="Cell Renderer">
- <post-create-function>glade_gtk_cell_renderer_post_create</post-create-function>
+ <deep-post-create-function>glade_gtk_cell_renderer_deep_post_create</deep-post-create-function>
<create-editor-property-function>glade_gtk_cell_renderer_create_eprop</create-editor-property-function>
<create-editable-function>glade_gtk_cell_renderer_create_editable</create-editable-function>
<set-property-function>glade_gtk_cell_renderer_set_property</set-property-function>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]