[glade] * gladeui/glade-project.[ch]: - Added glade_project_widget_changed() to manually notify a "row-c



commit f99c4bd02d9fe0db297634661be81f7d64ac96ef
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Sun Jan 16 17:13:53 2011 +0900

    	* gladeui/glade-project.[ch]:
    	  - Added glade_project_widget_changed() to manually notify a "row-change"
    	  - Add property references to the MISC_COLUMN (i.e. "Image Widget of button1" texts).
    
    	* gladeui/glade-widget.c: Notify widget row changes when parentless widget references
    	  are added/removed from a widget.

 ChangeLog               |    7 +++++++
 gladeui/glade-project.c |   32 ++++++++++++++++++++++++++++++++
 gladeui/glade-project.h |    7 ++++---
 gladeui/glade-widget.c  |   20 +++++++++++++++++++-
 4 files changed, 62 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 187f0b7..25f32ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,13 @@
 	* plugins/gtk+/glade-gtk.c: Fixed warnings from glade_gtk_box_get_first_blank() when
 	  project closes.
 
+	* gladeui/glade-project.[ch]:
+	  - Added glade_project_widget_changed() to manually notify a "row-change"
+	  - Add property references to the MISC_COLUMN (i.e. "Image Widget of button1" texts).
+
+	* gladeui/glade-widget.c: Notify widget row changes when parentless widget references
+	  are added/removed from a widget.
+
 2011-01-15  Emilio Pozuelo Monfort <pochu27 gmail com>
 
 	* plugins/gtk+/Makefile.am: Don't install .in files.
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 15a1d76..2f2f15a 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -3035,6 +3035,26 @@ glade_project_has_object (GladeProject * project, GObject * object)
 	  glade_widget_in_project (gwidget));
 }
 
+void
+glade_project_widget_changed (GladeProject       *project,
+			      GladeWidget        *gwidget)
+{
+  GObject     *object;
+  GtkTreeIter  iter;
+  GtkTreePath *path;
+
+  g_return_if_fail (GLADE_IS_PROJECT (project));
+  g_return_if_fail (GLADE_IS_WIDGET (gwidget));
+
+  object = glade_widget_get_object (gwidget);
+  g_return_if_fail (glade_project_has_object (project, object));
+
+  glade_project_model_get_iter_for_object (project, object, &iter);
+  path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
+  gtk_tree_model_row_changed (GTK_TREE_MODEL (project), path, &iter);
+  gtk_tree_path_free (path);
+}
+
 /**
  * glade_project_remove_object:
  * @project: a #GladeProject
@@ -4678,6 +4698,7 @@ glade_project_model_get_value (GtkTreeModel * model,
 {
   GObject *object;
   GladeWidget *widget;
+  GladeProperty *ref_prop;
   gchar *str = NULL, *child_type;
 
   g_return_if_fail (VALID_ITER (model, iter));
@@ -4712,6 +4733,17 @@ glade_project_model_get_value (GtkTreeModel * model,
                   g_object_get_data (glade_widget_get_object (widget),
                                      "special-child-type")) != NULL)
           str = g_strdup_printf (_("(%s child)"), child_type);
+	else if ((ref_prop = 
+		  glade_widget_get_parentless_widget_ref (widget)) != NULL)
+	  {
+	    GladePropertyClass *pclass     = glade_property_get_class (ref_prop);
+	    GladeWidget        *ref_widget = glade_property_get_widget (ref_prop);
+
+	    /* translators: reffers to a property named '%s' of widget '%s' */
+	    str = g_strdup_printf (_("(%s of %s)"), 
+				   glade_property_class_get_name (pclass),
+				   glade_widget_get_name (ref_widget));
+	  }
 
         g_value_take_string (value, str);
         break;
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index 8a731f3..87331d6 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -128,6 +128,8 @@ void                glade_project_cancel_load          (GladeProject       *proj
 void                glade_project_preview              (GladeProject       *project, 
 							GladeWidget        *gwidget);
 void                glade_project_preferences          (GladeProject       *project);
+gchar              *glade_project_resource_fullpath    (GladeProject       *project,
+							const gchar        *resource);
 
 /* Commands */
 void                glade_project_undo                 (GladeProject       *project);
@@ -147,8 +149,8 @@ void                glade_project_remove_object        (GladeProject       *proj
 							GObject            *object);
 gboolean            glade_project_has_object           (GladeProject       *project, 
 							GObject            *object);
-gchar              *glade_project_resource_fullpath    (GladeProject       *project,
-							const gchar        *resource);
+void                glade_project_widget_changed       (GladeProject       *project,
+							GladeWidget        *gwidget);
 
 /* Widget names */
 GladeWidget        *glade_project_get_widget_by_name   (GladeProject       *project, 
@@ -164,7 +166,6 @@ gboolean            glade_project_available_widget_name(GladeProject       *proj
 							GladeWidget        *widget,
 							const gchar        *name);
 
-
 /* Selection */
 gboolean            glade_project_is_selected          (GladeProject       *project,
 							GObject            *object);
diff --git a/gladeui/glade-widget.c b/gladeui/glade-widget.c
index 3e14a5b..fc0d452 100644
--- a/gladeui/glade-widget.c
+++ b/gladeui/glade-widget.c
@@ -2141,7 +2141,14 @@ glade_widget_add_prop_ref (GladeWidget * widget, GladeProperty * property)
    */
   pclass = glade_property_get_class (property);
   if (glade_property_class_parentless_widget (pclass))
-    glade_widget_hide (widget);
+    {
+      GladeProject *project = glade_widget_get_project (widget);
+
+      if (project)
+	glade_project_widget_changed (project, widget);
+
+      glade_widget_hide (widget);
+    }
 }
 
 /**
@@ -2157,10 +2164,21 @@ glade_widget_add_prop_ref (GladeWidget * widget, GladeProperty * property)
 void
 glade_widget_remove_prop_ref (GladeWidget * widget, GladeProperty * property)
 {
+  GladePropertyClass *pclass;
+
   g_return_if_fail (GLADE_IS_WIDGET (widget));
   g_return_if_fail (GLADE_IS_PROPERTY (property));
 
   widget->priv->prop_refs = g_list_remove (widget->priv->prop_refs, property);
+
+  pclass = glade_property_get_class (property);
+  if (glade_property_class_parentless_widget (pclass))
+    {
+      GladeProject *project = glade_widget_get_project (widget);
+
+      if (project)
+	glade_project_widget_changed (project, widget);
+    }
 }
 
 GList *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]