Commit 59e22199 authored by Tristan Van Berkom's avatar Tristan Van Berkom

- Fixed gtk_image_menu_item_set_stock() to not override the label value if

	
	* plugins/gtk+/glade-gtk.c, plugins/gtk+/gtk+.xml.in: 
	  - Fixed gtk_image_menu_item_set_stock() to not override the label value if not
	    in use_stock mode (fixes missing labels in pasted imagemenuitems).


svn path=/trunk/; revision=2047
parent b2d41443
......@@ -18,6 +18,8 @@
(net result: copy/paste of treeviews now result in a nice runtime replica).
- Did some reordering in glade-gtk.c
- Added load/save support for <action-widgets> of GtkDialog (response ids).
- Fixed gtk_image_menu_item_set_stock() to not override the label value if not
in use_stock mode (fixes missing labels in pasted imagemenuitems).
2008-11-22 Tristan Van Berkom <tvb@gnome.org>
......
......@@ -929,6 +929,28 @@ glade_command_placeholder_connect (CommandData *cdata,
G_CALLBACK (glade_command_placeholder_destroyed), cdata);
}
static GList *
get_all_parentless_reffed_widgets (GList *reffed, GladeWidget *widget)
{
GList *children, *l, *list;
GladeWidget *child;
children = glade_widget_adaptor_get_children (widget->adaptor,
widget->object);
for (l = children; l; l = l->next)
{
child = glade_widget_get_from_gobject (l->data);
if ((list = glade_widget_get_parentless_reffed_widgets (child)) != NULL)
reffed = g_list_concat (reffed, list);
reffed = get_all_parentless_reffed_widgets (reffed, child);
}
return reffed;
}
/**
* glade_command_add:
* @widgets: a #Glist
......@@ -989,7 +1011,7 @@ glade_command_add (GList *widgets,
cdata->widget = g_object_ref (G_OBJECT (widget));
/* Parentless ref */
if ((cdata->reffed = glade_widget_get_parentless_reffed_widgets (widget)) != NULL)
if ((cdata->reffed = get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
g_list_foreach (cdata->reffed, (GFunc)g_object_ref, NULL);
/* Parent */
......@@ -1080,19 +1102,26 @@ glade_command_delete_prop_refs (GladeWidget *widget)
static void glade_command_remove (GList *widgets);
static void
glade_command_remove_locked (GladeWidget *widget)
glade_command_remove_locked (GladeWidget *widget, GList *reffed)
{
GList list = { 0, };
GList list = { 0, }, *widgets, *l;
GladeWidget *locked;
while (widget->locked_widgets)
widgets = g_list_copy (widget->locked_widgets);
for (l = widget->locked_widgets; l; l = l->next)
{
locked = widget->locked_widgets->data;
locked = l->data;
list.data = locked;
if (g_list_find (reffed, locked))
continue;
glade_command_unlock_widget (locked);
glade_command_remove (&list);
}
g_list_free (widgets);
}
/**
......@@ -1155,14 +1184,15 @@ glade_command_remove (GList *widgets)
cdata->widget = g_object_ref (G_OBJECT (widget));
cdata->parent = glade_widget_get_parent (widget);
cdata->project = glade_widget_get_project (widget);
if ((cdata->reffed = glade_widget_get_parentless_reffed_widgets (widget)) != NULL)
if ((cdata->reffed = get_all_parentless_reffed_widgets (cdata->reffed, widget)) != NULL)
g_list_foreach (cdata->reffed, (GFunc)g_object_ref, NULL);
/* Undoably unset any object properties that may point to the removed object */
glade_command_delete_prop_refs (widget);
/* Undoably unlock and remove any widgets locked by this widget */
glade_command_remove_locked (widget);
glade_command_remove_locked (widget, cdata->reffed);
if (widget->internal)
g_critical ("Internal widget in Remove");
......@@ -1433,7 +1463,7 @@ glade_command_add_remove_finalize (GObject *obj)
{
GladeCommandAddRemove *cmd;
CommandData *cdata;
GList *list, *l;
GList *list;
g_return_if_fail (GLADE_IS_COMMAND_ADD_REMOVE (obj));
......
......@@ -2080,7 +2080,7 @@ glade_widget_get_parentless_reffed_widgets (GladeWidget *widget)
{
glade_property_get (property, &reffed);
if (reffed)
widgets = g_list_prepend (widgets, reffed);
widgets = g_list_prepend (widgets, glade_widget_get_from_gobject (reffed));
}
}
return g_list_reverse (widgets);
......
......@@ -6616,7 +6616,7 @@ glade_gtk_image_menu_item_set_use_stock (GObject *object, const GValue *value)
}
}
static void
static gboolean
glade_gtk_image_menu_item_set_label (GObject *object, const GValue *value)
{
GladeWidget *gitem;
......@@ -6640,29 +6640,31 @@ glade_gtk_image_menu_item_set_label (GObject *object, const GValue *value)
image = gtk_image_new_from_stock (g_value_get_string (value), GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (object), image);
/* Just for display purposes, real stock menuitems automatically have underline
* property set. */
gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
/* Get the label string... */
if (text && gtk_stock_lookup (text, &item))
gtk_label_set_label (GTK_LABEL (label), item.label);
else
gtk_label_set_label (GTK_LABEL (label), text ? text : "");
return TRUE;
}
else
gtk_label_set_label (GTK_LABEL (label), text ? text : "");
/* Update underline incase... */
gtk_label_set_use_underline (GTK_LABEL (label), use_underline);
return FALSE;
}
static void
glade_gtk_image_menu_item_set_stock (GObject *object, const GValue *value)
{
GladeWidget *gitem;
gboolean use_stock = FALSE;
gitem = glade_widget_get_from_gobject (object);
glade_widget_property_get (gitem, "use-stock", &use_stock);
/* Forward the work along to the label handler... */
glade_gtk_image_menu_item_set_label (object, value);
if (use_stock)
glade_gtk_image_menu_item_set_label (object, value);
}
void
......@@ -6676,7 +6678,11 @@ glade_gtk_image_menu_item_set_property (GladeWidgetAdaptor *adaptor,
else if (!strcmp (id, "use-stock"))
glade_gtk_image_menu_item_set_use_stock (object, value);
else if (!strcmp (id, "label"))
glade_gtk_image_menu_item_set_label (object, value);
{
if (!glade_gtk_image_menu_item_set_label (object, value))
GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
id, value);
}
else
GWA_GET_CLASS (GTK_TYPE_MENU_ITEM)->set_property (adaptor, object,
id, value);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment