glade3 r2007 - in trunk: . gladeui plugins/gtk+ src



Author: tvb
Date: Tue Oct 28 06:11:11 2008
New Revision: 2007
URL: http://svn.gnome.org/viewvc/glade3?rev=2007&view=rev

Log:

	* gladeui/glade-gtk.c: Fixed bugs around load/save of button/imagemenuitem
	label (stock driven) properties.

	* plugins/gtk+/glade-image-item-editor.c: Fixed a null dereference, glade_command_create()
	sometimes ends up changeing the selection, so the editable may be reloaded in the
	midst of its flow.

	* gladeui/glade-property.c, gladeui/glade-widget-adaptor.c: Now check for pclass->save
	and pclass->enabled *before* calling glade_property_write(), this allows plugins to
	mark props as save="False" and save those properties with custom values, still allowing
	them to use the GladeProperty api.



Modified:
   trunk/ChangeLog
   trunk/gladeui/glade-property.c
   trunk/gladeui/glade-widget-adaptor.c
   trunk/plugins/gtk+/glade-gtk.c
   trunk/plugins/gtk+/glade-image-item-editor.c
   trunk/plugins/gtk+/gtk+.xml.in
   trunk/src/glade-window.c

Modified: trunk/gladeui/glade-property.c
==============================================================================
--- trunk/gladeui/glade-property.c	(original)
+++ trunk/gladeui/glade-property.c	Tue Oct 28 06:11:11 2008
@@ -1111,9 +1111,6 @@
 	      glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET (fmt))))
 		return;
 
-	if (!property->klass->save || !property->enabled)
-		return;
-
 	/* Dont write unsupported properties */
 	if ((fmt == GLADE_PROJECT_FORMAT_GTKBUILDER &&
 	     property->klass->libglade_only) ||

Modified: trunk/gladeui/glade-widget-adaptor.c
==============================================================================
--- trunk/gladeui/glade-widget-adaptor.c	(original)
+++ trunk/gladeui/glade-widget-adaptor.c	Tue Oct 28 06:11:11 2008
@@ -938,7 +938,11 @@
 	/* Write the properties */
 	for (props = widget->properties; 
 	     props; props = props->next)
-		glade_property_write (GLADE_PROPERTY (props->data), context, node);
+	{
+		if (GLADE_PROPERTY (props->data)->klass->save && 
+		    GLADE_PROPERTY (props->data)->enabled)
+			glade_property_write (GLADE_PROPERTY (props->data), context, node);
+	}
 
 	/* Write the signals */
 	g_hash_table_foreach (widget->signals,
@@ -1067,8 +1071,12 @@
 
 	for (props = widget->packing_properties; 
 	     props; props = props->next)
-		glade_property_write (GLADE_PROPERTY (props->data), 
-				      context, packing_node);
+	{
+		if (GLADE_PROPERTY (props->data)->klass->save && 
+		    GLADE_PROPERTY (props->data)->enabled)
+			glade_property_write (GLADE_PROPERTY (props->data), 
+					      context, packing_node);
+	}
 
 	glade_widget_write_special_child_prop (widget->parent,
 					       widget->object,

Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c	(original)
+++ trunk/plugins/gtk+/glade-gtk.c	Tue Oct 28 06:11:11 2008
@@ -5176,7 +5176,11 @@
 	}
 	else if (strcmp (id, "stock") == 0)
 	{
-		gtk_button_set_label (GTK_BUTTON (object), g_value_get_string (value));
+		GladeWidget *widget = glade_widget_get_from_gobject (object);
+		gboolean use_stock  = FALSE;
+		glade_widget_property_get (widget, "use-stock", &use_stock);
+		if (use_stock)
+			gtk_button_set_label (GTK_BUTTON (object), g_value_get_string (value));
 	}
 	else
 		GWA_GET_CLASS (GTK_TYPE_CONTAINER)->set_property (adaptor, object,
@@ -5235,8 +5239,6 @@
 		glade_property_set (label_prop, stock);
 	}
 	glade_property_write (label_prop, context, node);
-
-	g_print ("Finalizing property, ref_count %d\n", G_OBJECT (label_prop)->ref_count);
 	g_object_unref (G_OBJECT (label_prop));
 }
 
@@ -5980,7 +5982,7 @@
 	GladeWidget *gitem;
 	GtkWidget *label;
 	gboolean use_underline = FALSE, use_stock = FALSE;
-	gchar *text;
+	const gchar *text;
 
 	gitem = glade_widget_get_from_gobject (object);
 	label = gtk_bin_get_child (GTK_BIN (object));
@@ -6192,23 +6194,57 @@
 	/* First chain up and read in all the normal properties.. */
         GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);
 
-	/* Read in the internal images as normal ones !
-	 */
-
-
 	/* This will read legacy "stock-item" properties and make them usable */
 	glade_gtk_image_menu_item_fix_stock_item (widget);
 
 	glade_widget_property_get (widget, "use-stock", &use_stock);
 	if (use_stock)
 	{
+		GladeProperty *property = glade_widget_get_property (widget, "label");
 		gchar *label = NULL;
-		glade_widget_property_get (widget, "label", &label);
+
+		glade_property_get (property, &label);
 		glade_widget_property_set (widget, "stock", label);
+		glade_property_sync (property);
+	}
+}
+
+
+void
+glade_gtk_image_menu_item_write_widget (GladeWidgetAdaptor *adaptor,
+					GladeWidget        *widget,
+					GladeXmlContext    *context,
+					GladeXmlNode       *node)
+{
+	GladeProperty *label_prop;
+	gboolean       use_stock;
+	gchar         *stock;
+
+	if (!glade_xml_node_verify
+	    (node, GLADE_XML_TAG_WIDGET (glade_project_get_format (widget->project))))
+		return;
+
+	/* Make a copy of the GladeProperty, override its value if use-stock is TRUE */
+	label_prop = glade_widget_get_property (widget, "label");
+	label_prop = glade_property_dup (label_prop, widget);
+	glade_widget_property_get (widget, "use-stock", &use_stock);
+	if (use_stock)
+	{
+		glade_widget_property_get (widget, "stock", &stock);
+		glade_property_set (label_prop, stock);
+		glade_property_set_i18n_translatable (label_prop, FALSE);
 	}
+	glade_property_write (label_prop, context, node);
+	g_object_unref (G_OBJECT (label_prop));
+
+	/* Chain up and write all the normal properties ... */
+        GWA_GET_CLASS (G_TYPE_OBJECT)->write_widget (adaptor, widget, context, node);
 
 }
 
+
+/* Read in the internal "image" widgets as normal "protected" widgets...
+ */
 void
 glade_gtk_image_menu_item_read_child (GladeWidgetAdaptor *adaptor,
 				      GladeWidget        *widget,

Modified: trunk/plugins/gtk+/glade-image-item-editor.c
==============================================================================
--- trunk/plugins/gtk+/glade-image-item-editor.c	(original)
+++ trunk/plugins/gtk+/glade-image-item-editor.c	Tue Oct 28 06:11:11 2008
@@ -273,14 +273,15 @@
 	/* There shouldnt be an image widget here... */
 	if (!get_image_widget (item_editor->loaded_widget))
 	{
+		/* item_editor->loaded_widget may be set to NULL after the create_command. */
+		GladeWidget *loaded = item_editor->loaded_widget;
 		GladeWidget *image =
 			glade_command_create (glade_widget_adaptor_get_by_type (GTK_TYPE_IMAGE),
 					      item_editor->loaded_widget, NULL, 
 					      glade_widget_get_project (item_editor->loaded_widget));
 		gchar *protection = g_strdup_printf (_("Cannot delete %s because it is used by %s, "
 						       "try editing %s instead."),
-						       image->name, item_editor->loaded_widget->name,
-						       item_editor->loaded_widget->name);
+						       image->name, loaded->name, loaded->name);
 		glade_command_protect_widget (image, protection);
 		g_free (protection);
 	}

Modified: trunk/plugins/gtk+/gtk+.xml.in
==============================================================================
--- trunk/plugins/gtk+/gtk+.xml.in	(original)
+++ trunk/plugins/gtk+/gtk+.xml.in	Tue Oct 28 06:11:11 2008
@@ -392,6 +392,7 @@
 
     <glade-widget-class name="GtkImageMenuItem" generic-name="imagemenuitem" _title="Image Menu Item">
       <read-widget-function>glade_gtk_image_menu_item_read_widget</read-widget-function>
+      <write-widget-function>glade_gtk_image_menu_item_write_widget</write-widget-function>
       <read-child-function>glade_gtk_image_menu_item_read_child</read-child-function>
       <write-child-function>glade_gtk_image_menu_item_write_child</write-child-function>
       <set-property-function>glade_gtk_image_menu_item_set_property</set-property-function>
@@ -407,7 +408,8 @@
 	  <_tooltip>The stock item for this menu item</_tooltip>
 	  <spec>glade_standard_string_spec</spec>
 	</property>
-        <property id="label" custom-layout="True"/>
+	<!-- We save the label manually with the stock value if use_stock is set. -->
+        <property id="label" save="False" custom-layout="True"/>
         <property id="use-underline" custom-layout="True"/>
 	<property id="image" disabled="True" />
 	<!--

Modified: trunk/src/glade-window.c
==============================================================================
--- trunk/src/glade-window.c	(original)
+++ trunk/src/glade-window.c	Tue Oct 28 06:11:11 2008
@@ -608,6 +608,7 @@
 						   a->klass->label);
 		
 		g_object_set_data (G_OBJECT (item), "glade-widget", widget);
+
 		/* We use destroy_data to keep track of notify::sensitive callbacks
 		 * on the action object and disconnect them when the toolbar item
 		 * gets destroyed.
@@ -1716,6 +1717,8 @@
 
 	gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), page_num);
 
+	clean_actions (window);
+
 	/* FIXME: this function needs to be preferably called somewhere else */
 	glade_app_remove_project (project);
 



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