glade3 r2000 - in trunk: . gladeui plugins/gtk+



Author: tvb
Date: Sat Oct 25 18:15:48 2008
New Revision: 2000
URL: http://svn.gnome.org/viewvc/glade3?rev=2000&view=rev

Log:

	* plugins/gtk+/glade-gtk.c: Ignore parent-changes on internal widgets (that
	causes problems when internal widgets get destroyed at project close time).

	* plugins/gtk+/glade-button-editor.c: Fixed custom/standard commands,
	now standard mode sets up a default label etc also.

	* gladeui/glade-project.c, gladeui/glade-property.c, gladeui/glade-widget.c,
	gladeui/glade-property-class.[ch], gladeui/glade-xml-utils.h:
	Removed hack for GtkToolButton:icon --> iconfactory (will do in glade-convert.c
	properly).



Modified:
   trunk/ChangeLog
   trunk/gladeui/glade-editor-property.c
   trunk/gladeui/glade-editor-table.c
   trunk/gladeui/glade-editor.c
   trunk/gladeui/glade-editor.h
   trunk/gladeui/glade-project.c
   trunk/gladeui/glade-property-class.c
   trunk/gladeui/glade-property-class.h
   trunk/gladeui/glade-property.c
   trunk/gladeui/glade-widget.c
   trunk/gladeui/glade-widget.h
   trunk/gladeui/glade-xml-utils.h
   trunk/plugins/gtk+/glade-button-editor.c
   trunk/plugins/gtk+/glade-gtk.c
   trunk/plugins/gtk+/gtk+.xml.in

Modified: trunk/gladeui/glade-editor-property.c
==============================================================================
--- trunk/gladeui/glade-editor-property.c	(original)
+++ trunk/gladeui/glade-editor-property.c	Sat Oct 25 18:15:48 2008
@@ -459,6 +459,9 @@
 		if (eprop->state_id > 0)
 			g_signal_handler_disconnect (eprop->property, 
 						     eprop->state_id);
+		if (eprop->enabled_id > 0)
+			g_signal_handler_disconnect (eprop->property, 
+						     eprop->enabled_id);
 
 		eprop->tooltip_id   = 0;
 		eprop->sensitive_id = 0;

Modified: trunk/gladeui/glade-editor-table.c
==============================================================================
--- trunk/gladeui/glade-editor-table.c	(original)
+++ trunk/gladeui/glade-editor-table.c	Sat Oct 25 18:15:48 2008
@@ -113,7 +113,7 @@
 
 	/* abort mission */
 	if ((!table->loaded_widget && !widget) ||
-	    (table->loaded_widget && widget && table->loaded_widget == widget))
+	    (table->loaded_widget && table->loaded_widget == widget))
 		return;
 
 	table->loading = TRUE;

Modified: trunk/gladeui/glade-editor.c
==============================================================================
--- trunk/gladeui/glade-editor.c	(original)
+++ trunk/gladeui/glade-editor.c	Sat Oct 25 18:15:48 2008
@@ -628,6 +628,19 @@
 }
 
 static void
+clear_editables (GladeEditor *editor)
+{
+	GladeEditable *editable;
+	GList *l;
+
+	for (l = editor->editables; l; l = l->next)
+	{
+		editable = l->data;
+		glade_editable_load (editable, NULL);
+	}
+}
+
+static void
 glade_editor_load_widget_real (GladeEditor *editor, GladeWidget *widget)
 {
 	GladeWidgetAdaptor *adaptor;
@@ -637,6 +650,11 @@
 	/* Disconnect from last widget */
 	if (editor->loaded_widget != NULL)
 	{
+		/* better pay a small price now and avoid unseen editables
+		 * waking up on project metadata changes.
+		 */
+		clear_editables (editor);
+
 		project = glade_widget_get_project (editor->loaded_widget);
 		g_signal_handler_disconnect (G_OBJECT (project),
 					     editor->project_closed_signal_id);

Modified: trunk/gladeui/glade-editor.h
==============================================================================
--- trunk/gladeui/glade-editor.h	(original)
+++ trunk/gladeui/glade-editor.h	Sat Oct 25 18:15:48 2008
@@ -48,15 +48,6 @@
 					     * same class
 					     */
 
-
-	/* The editor has (at this moment) four tabs; these are pointers to the 
-	 * widget inside each tab. The widgets are wrapped into a scrolled window.
-	 * The page_* widgets are deparented and parented with
-	 * ((GladeEditorTable *)etable)->table_widget when a widget is selected and
-	 * the correct editor table is found. The exception is `page_signals' which
-	 * always contains the same signal editor widget which simply reloads when
-	 * loading a widget.
-	 */
 	GtkWidget *page_widget;
 	GtkWidget *page_packing;
 	GtkWidget *page_common;

Modified: trunk/gladeui/glade-project.c
==============================================================================
--- trunk/gladeui/glade-project.c	(original)
+++ trunk/gladeui/glade-project.c	Sat Oct 25 18:15:48 2008
@@ -133,8 +133,6 @@
 	GHashTable *target_versions_major; /* target versions by catalog */
 	GHashTable *target_versions_minor; /* target versions by catalog */
 
-	GList *loaded_factory_files;
-
 	GladeNamingPolicy naming_policy;	/* What rules apply to widget names */
 /* Control on the preferences dialog to update buttons etc when properties change */
 	GtkWidget *prefs_dialog;
@@ -209,12 +207,6 @@
 
 G_DEFINE_TYPE (GladeProject, glade_project, G_TYPE_OBJECT)
 
-
-
-#define GLADE_GENERATED_ICON_FACTORY_NAME   "glade-generated-icon-factory"
-#define GLADE_ICON_FACTORY_CLASS_NAME       "GtkIconFactory"
-
-
 /*******************************************************************
                             GObjectClass
  *******************************************************************/
@@ -863,209 +855,6 @@
 	return project;
 }
 
-static GList *
-glade_project_get_factory_stock_id_props (GladeProject *project)
-{
-	GladeWidget *widget;
-	GladeProperty *property;
-	GList *list, *l;
-	GList *properties = NULL;
-
-	for (list = project->priv->objects; list; list = list->next)
-	{
-		widget = glade_widget_get_from_gobject (list->data);
-
-		for (l = widget->properties; l; l = l->next)
-		{
-			property = l->data;
-			if (property->klass->factory_stock_id &&
-			    property->enabled &&
-			    !glade_property_default (property))
-				properties = g_list_prepend (properties, property);
-		}
-
-		for (l = widget->packing_properties; l; l = l->next)
-		{
-			property = l->data;
-			if (property->klass->factory_stock_id &&
-			    property->enabled &&
-			    !glade_property_default (property))
-				properties = g_list_prepend (properties, property);
-		}
-
-	}
-
-	return properties;
-}
-
-static void
-glade_project_generate_nodes (GladeProject    *project, 
-			      GladeXmlContext *context,
-			      GladeXmlNode    *node)
-
-{
-	GladeProperty *property;
-	GladeXmlNode  *widget_node;
-	GladeXmlNode  *source_node;
-	GladeXmlNode  *sources_node;
-	GList         *properties, *list;
-	gchar         *icon_name, *filename;
-
-	if (project->priv->format == GLADE_PROJECT_FORMAT_GTKBUILDER &&
-	    (properties = glade_project_get_factory_stock_id_props (project)))
-	{
-
-		widget_node = glade_xml_node_new
-			(context, GLADE_XML_TAG_WIDGET (project->priv->format));
-		glade_xml_node_append_child (node, widget_node);
-
-		/* Set class and id */
-		glade_xml_node_set_property_string (widget_node, 
-						    GLADE_XML_TAG_CLASS, 
-						    GLADE_ICON_FACTORY_CLASS_NAME);
-		glade_xml_node_set_property_string (widget_node, 
-						    GLADE_XML_TAG_ID, 
-						    GLADE_GENERATED_ICON_FACTORY_NAME);
-		
-
-		sources_node = glade_xml_node_new (context, GLADE_XML_TAG_SOURCES);
-		glade_xml_node_append_child (widget_node, sources_node);
-
-		for (list = properties; list; list = list->next)
-		{
-			property = list->data;
-
-			source_node = glade_xml_node_new (context, GLADE_XML_TAG_SOURCE);
-			glade_xml_node_append_child (sources_node, source_node);
-
-			if ((filename = glade_widget_adaptor_string_from_value
-			     (GLADE_WIDGET_ADAPTOR (property->klass->handle),
-			      property->klass, property->value, project->priv->format)) != NULL)
-			{
-				icon_name = glade_util_filename_to_icon_name (filename);
-
-				/* Set stock-id and filename */
-				glade_xml_node_set_property_string
-					(source_node, 
-					 GLADE_XML_TAG_STOCK_ID, 
-					 icon_name);
-				glade_xml_node_set_property_string (source_node, 
-								    GLADE_XML_TAG_FILENAME, 
-								    filename);
-				g_free (icon_name);
-				g_free (filename);
-			}
-		}
-		g_list_free (properties);
-	}
-}
-
-gboolean
-glade_project_is_loaded_factory_file (GladeProject *project, 
-				      const gchar  *stock_id)
-{
-	GList *list;
-	StockFilePair *pair;
-
-	for (list = project->priv->loaded_factory_files;
-	     list; list = list->next)
-	{
-		pair = list->data;
-		if (!strcmp (stock_id, pair->stock))
-			return TRUE;
-	}
-	return FALSE;
-}
-
-static void
-glade_project_free_loaded_factory_files (GladeProject *project)
-{
-	GList *list;
-	StockFilePair *pair;
-
-	for (list = project->priv->loaded_factory_files;
-	     list; list = list->next)
-	{
-		pair = list->data;
-		g_free (pair->stock);
-		g_free (pair->filename);
-		g_free (pair);
-	}
-	g_list_free (project->priv->loaded_factory_files);
-	project->priv->loaded_factory_files = NULL;
-}
-
-static void
-glade_project_read_factory_files (GladeProject *project, 
-				  GladeXmlNode *node)
-{
-	GladeXmlNode  *source;
-	StockFilePair *pair;
-
-	if ((source = 
-	     glade_xml_search_child_required (node, GLADE_XML_TAG_SOURCES)))
-	{
-		for (source = glade_xml_node_get_children (source);
-		     source; source = glade_xml_node_next (source))
-		{
-			if (!glade_xml_node_verify (source, GLADE_XML_TAG_SOURCE))
-				continue;
-
-			pair = g_new (StockFilePair, 1);
-			
-			pair->stock = glade_xml_get_property_string_required 
-				(source, GLADE_XML_TAG_STOCK_ID, NULL);
-			pair->filename = glade_xml_get_property_string_required 
-				(source, GLADE_XML_TAG_FILENAME, NULL);
-
-			if (!pair->stock || !pair->filename)
-			{
-				g_free (pair->stock);
-				g_free (pair->filename);
-				g_free (pair);
-				continue;
-			}
-			
-			project->priv->loaded_factory_files =
-				g_list_prepend (project->priv->loaded_factory_files, pair);
-		}
-	}
-}
-
-static gboolean
-glade_project_is_generated_node (GladeProject *project, 
-				 GladeXmlNode *node)
-{
-	gboolean  generated = FALSE;
-	gchar    *klass, *id;
-
-	if (!glade_xml_node_verify
-	    (node, GLADE_XML_TAG_WIDGET (project->priv->format)))
-		return FALSE;
-
-	if ((klass = 
-	     glade_xml_get_property_string_required
-	     (node, GLADE_XML_TAG_CLASS, NULL)) != NULL)
-	{
-		if ((id = 
-		     glade_xml_get_property_string_required
-		     (node, GLADE_XML_TAG_ID, NULL)) != NULL)
-		{
-			if (!strcmp (klass, GLADE_ICON_FACTORY_CLASS_NAME) &&
-			    !strcmp (id, GLADE_GENERATED_ICON_FACTORY_NAME))
-			{
-				/* Read in the generated stock names and files */
-				glade_project_read_factory_files (project, node);
-				generated = TRUE;
-			}
-			g_free (id);
-		}
-		g_free (klass);
-	}
-	return generated;
-}
-
-
 /* Called when finishing loading a glade file to resolve object type properties
  */
 static void 
@@ -1316,10 +1105,6 @@
 		    (node, GLADE_XML_TAG_WIDGET (project->priv->format)))
 			continue;
 
-		/* Skip toplevel glade generated nodes */
-		if (glade_project_is_generated_node (project, node))
-			continue;
-
 		if ((widget = glade_widget_read (project, NULL, node, NULL)) != NULL)
 			glade_project_add_object (project, NULL, widget->object);
 	}
@@ -1340,9 +1125,6 @@
 
 	/* Emit "parse-finished" signal */
 	g_signal_emit (project, glade_project_signals [PARSE_FINISHED], 0);
-
-	/* Free up some load time metadata */
-	glade_project_free_loaded_factory_files (project);
 	
 	/* Now we have to loop over all the object properties
 	 * and fix'em all ('cause they probably weren't found)
@@ -1558,9 +1340,6 @@
 
 	glade_project_write_naming_policy (project, context, root);
 
-	/* Any automatically generated stuff goes here */
-	glade_project_generate_nodes (project, context, root);
-
 	for (list = project->priv->objects; list; list = list->next)
 	{
 		GladeWidget *widget;

Modified: trunk/gladeui/glade-property-class.c
==============================================================================
--- trunk/gladeui/glade-property-class.c	(original)
+++ trunk/gladeui/glade-property-class.c	Sat Oct 25 18:15:48 2008
@@ -128,7 +128,6 @@
 	clone->id = g_strdup (clone->id);
 	clone->name = g_strdup (clone->name);
 	clone->tooltip = g_strdup (clone->tooltip);
-	clone->factory_stock_id = g_strdup (clone->factory_stock_id);
 
 	if (G_IS_VALUE (property_class->def))
 	{
@@ -1428,14 +1427,6 @@
 
 
 	if ((buf = glade_xml_get_property_string
-	     (node, GLADE_TAG_FACTORY_STOCK_ID)) != NULL)
-	{
-		if (klass->factory_stock_id)
-			g_free (klass->factory_stock_id);
-		klass->factory_stock_id = buf;
-	}
-
-	if ((buf = glade_xml_get_property_string
 	     (node, GLADE_TAG_CREATE_TYPE)) != NULL)
 	{
 		if (klass->create_type)

Modified: trunk/gladeui/glade-property-class.h
==============================================================================
--- trunk/gladeui/glade-property-class.h	(original)
+++ trunk/gladeui/glade-property-class.h	Sat Oct 25 18:15:48 2008
@@ -172,15 +172,6 @@
 			 * the editor.
 			 */
 	
-	gchar *factory_stock_id; /* Used for legacy fake libglade properties
-				  * that reffer to pixbufs, glade creates
-				  * an internal icon factory so that builder
-				  * can load them as stock icons. The string
-				  * if set reffers to the property name that
-				  * will be used to lookup the theme by the
-				  * implementing widget
-				  */
-
 	gboolean parentless_widget;  /* True if this property should point to a parentless widget
 				      * in the project
 				      */

Modified: trunk/gladeui/glade-property.c
==============================================================================
--- trunk/gladeui/glade-property.c	(original)
+++ trunk/gladeui/glade-property.c	Sat Oct 25 18:15:48 2008
@@ -1151,25 +1151,6 @@
 		g_free (tmp);
 	}
 
-	/* Switch up the values if we are using GtkIconFactory in builder
-	 * to save some hacked out pixbufs
-	 */
-	if (fmt == GLADE_PROJECT_FORMAT_GTKBUILDER &&
-	    property->klass->factory_stock_id)
-	{
-		gchar *icon_name;
-
-		/* Create a string representation for the icon factory */
-		icon_name = glade_util_filename_to_icon_name (value);
-		g_free (value);
-		value = icon_name;
-
-		/* Use the alternate property name */
-		g_free (name);
-		name = g_strdup (property->klass->factory_stock_id);
-		glade_util_replace (name, '-', '_');
-	}
-
 	/* Now dump the node values... */
 	prop_node = glade_xml_node_new (context, GLADE_XML_TAG_PROPERTY);
 	glade_xml_node_append_child (node, prop_node);

Modified: trunk/gladeui/glade-widget.c
==============================================================================
--- trunk/gladeui/glade-widget.c	(original)
+++ trunk/gladeui/glade-widget.c	Sat Oct 25 18:15:48 2008
@@ -764,6 +764,11 @@
 
 	g_return_if_fail (GLADE_IS_WIDGET (object));
 
+	/* At this point, any callbacks on "object" generated by destroy 
+	 * wont come with a GladeWidget 
+	 */
+	g_object_set_qdata (G_OBJECT (object), glade_widget_name_quark, NULL);
+
 	/* We do not keep a reference to internal widgets */
 	if (widget->internal == NULL)
 	{
@@ -4156,31 +4161,3 @@
 
 	g_object_notify (G_OBJECT (widget), "support-warning");
 }
-
-gboolean
-glade_widget_has_factory_stock_id (GladeWidget *widget,
-				   const gchar *property_name)
-{
-	GList *l;
-	GladeProperty *property;
-
-	g_return_val_if_fail (GLADE_IS_WIDGET (widget), FALSE);
-	g_return_val_if_fail (property_name, FALSE);
-
-	for (l = widget->properties; l; l = l->next)
-	{
-		property = l->data;
-		if (property->klass->factory_stock_id &&
-		    !strcmp (property->klass->factory_stock_id, property_name))
-			return TRUE;
-	}
-
-	for (l = widget->packing_properties; l; l = l->next)
-	{
-		property = l->data;
-		if (property->klass->factory_stock_id &&
-		    !strcmp (property->klass->factory_stock_id, property_name))
-			return TRUE;
-	}
-	return FALSE;
-}

Modified: trunk/gladeui/glade-widget.h
==============================================================================
--- trunk/gladeui/glade-widget.h	(original)
+++ trunk/gladeui/glade-widget.h	Sat Oct 25 18:15:48 2008
@@ -403,9 +403,6 @@
 void                    glade_widget_set_support_warning    (GladeWidget      *widget,
 							     const gchar      *warning);
 
-gboolean                glade_widget_has_factory_stock_id   (GladeWidget      *widget,
-							     const gchar      *property_name);
-
 G_END_DECLS
 
 #endif /* __GLADE_WIDGET_H__ */

Modified: trunk/gladeui/glade-xml-utils.h
==============================================================================
--- trunk/gladeui/glade-xml-utils.h	(original)
+++ trunk/gladeui/glade-xml-utils.h	Sat Oct 25 18:15:48 2008
@@ -85,7 +85,6 @@
 #define GLADE_XML_TAG_SOURCE                      "source"
 #define GLADE_XML_TAG_FILENAME                    "filename"
 #define GLADE_XML_TAG_STOCK_ID                    "stock-id"
-#define GLADE_TAG_FACTORY_STOCK_ID                "factory-stock-id"
 
 #define GLADE_TAG_VERSION                         "version"
 #define GLADE_TAG_TARGETABLE                      "targetable"

Modified: trunk/plugins/gtk+/glade-button-editor.c
==============================================================================
--- trunk/plugins/gtk+/glade-button-editor.c	(original)
+++ trunk/plugins/gtk+/glade-button-editor.c	Sat Oct 25 18:15:48 2008
@@ -200,6 +200,7 @@
 	GladeProperty     *property;
 	GladeWidget       *gchild = NULL;
 	GtkWidget         *child, *button;
+	GValue             value;
 
 	if (button_editor->loading || !button_editor->loaded_widget)
 		return;
@@ -228,6 +229,18 @@
 	property = glade_widget_get_property (button_editor->loaded_widget, "custom-child");
 	glade_command_set_property (property, FALSE);
 
+	/* Setup reasonable defaults for button label. */
+	property = glade_widget_get_property (button_editor->loaded_widget, "stock");
+	glade_command_set_property (property, 0);
+
+	property = glade_widget_get_property (button_editor->loaded_widget, "use-stock");
+	glade_command_set_property (property, FALSE);
+
+	property = glade_widget_get_property (button_editor->loaded_widget, "label");
+	glade_property_get_default (property, &value);
+	glade_command_set_property_value (property, &value);
+	g_value_unset (&value);
+
 	glade_command_pop_group ();
 
 	button_editor->modifying = FALSE;

Modified: trunk/plugins/gtk+/glade-gtk.c
==============================================================================
--- trunk/plugins/gtk+/glade-gtk.c	(original)
+++ trunk/plugins/gtk+/glade-gtk.c	Sat Oct 25 18:15:48 2008
@@ -1056,9 +1056,6 @@
 		glade_widget_set_action_sensitive (gwidget, "remove_parent", TRUE);
 	else
 		glade_widget_set_action_sensitive (gwidget, "remove_parent", FALSE);
-
-	if (gwidget->internal)
-		glade_widget_set_action_sensitive (gwidget, "add_parent", FALSE);	
 }
 
 
@@ -1111,10 +1108,12 @@
 	if (GTK_IS_WINDOW (widget) || gwidget->internal)
 		glade_widget_set_action_sensitive (gwidget, "add_parent", FALSE);
 
-	/* Watch parents/projects and set actions sensitive/insensitive */
-	g_signal_connect (G_OBJECT (widget), "notify::parent",
-			  G_CALLBACK (widget_parent_changed), adaptor);
 
+	/* Watch parents/projects and set actions sensitive/insensitive */
+	if (gwidget->internal == NULL)
+		g_signal_connect (G_OBJECT (widget), "notify::parent",
+				  G_CALLBACK (widget_parent_changed), adaptor);
+	
 	g_signal_connect (G_OBJECT (gwidget), "notify::project",
 			  G_CALLBACK (widget_project_changed), NULL);
 
@@ -5182,6 +5181,10 @@
 
 			gtk_container_add (GTK_CONTAINER (object), glade_placeholder_new ());
 		}
+		else if (GTK_BIN (object)->child &&
+			 GLADE_IS_PLACEHOLDER (GTK_BIN (object)->child))
+			gtk_container_remove (GTK_CONTAINER (object),
+					      GTK_BIN (object)->child);
 	}
 	else if (strcmp (id, "stock") == 0)
 	{

Modified: trunk/plugins/gtk+/gtk+.xml.in
==============================================================================
--- trunk/plugins/gtk+/gtk+.xml.in	(original)
+++ trunk/plugins/gtk+/gtk+.xml.in	Sat Oct 25 18:15:48 2008
@@ -534,7 +534,7 @@
 	  <spec>glade_standard_stock_image_spec</spec>
 	</property>
         <property id="label" translatable="True"/>
-	<property id="icon" _name="File Name" factory-stock-id="stock-id">
+	<property id="icon" _name="File Name">
 	  <spec>glade_standard_pixbuf_spec</spec>
 	</property>
       </properties>



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