Make it possible to overrule the gtk-menu-images setting.

2008-11-02  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkimagemenuitem.c: Make it possible to overrule the
        gtk-menu-images setting.

        * gtk/gtkaction.c (connect_proxy): Show the image before adding
it to the image menu item.

svn path=/trunk/; revision=21751
This commit is contained in:
Matthias Clasen 2008-11-02 05:01:23 +00:00 committed by Matthias Clasen
parent 2b9ac5df0b
commit cbc5d3e33d
3 changed files with 29 additions and 9 deletions

View File

@ -1,3 +1,11 @@
2008-11-02 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkimagemenuitem.c: Make it possible to overrule the
gtk-menu-images setting.
* gtk/gtkaction.c (connect_proxy): Show the image before adding
it to the image menu item.
2008-11-01 Tor Lillqvist <tml@novell.com> 2008-11-01 Tor Lillqvist <tml@novell.com>
Bug 558278 - Crash when calling a callback set by Bug 558278 - Crash when calling a callback set by

View File

@ -749,9 +749,9 @@ connect_proxy (GtkAction *action,
if (!image) if (!image)
{ {
image = gtk_image_new (); image = gtk_image_new ();
gtk_widget_show (image);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy),
image); image);
gtk_widget_show (image);
} }
if (action->private_data->stock_id && if (action->private_data->stock_id &&

View File

@ -42,6 +42,7 @@ static void gtk_image_menu_item_size_request (GtkWidget *widget,
GtkRequisition *requisition); GtkRequisition *requisition);
static void gtk_image_menu_item_size_allocate (GtkWidget *widget, static void gtk_image_menu_item_size_allocate (GtkWidget *widget,
GtkAllocation *allocation); GtkAllocation *allocation);
static void gtk_image_menu_item_map (GtkWidget *widget);
static void gtk_image_menu_item_remove (GtkContainer *container, static void gtk_image_menu_item_remove (GtkContainer *container,
GtkWidget *child); GtkWidget *child);
static void gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item, static void gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
@ -85,6 +86,7 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
widget_class->screen_changed = gtk_image_menu_item_screen_changed; widget_class->screen_changed = gtk_image_menu_item_screen_changed;
widget_class->size_request = gtk_image_menu_item_size_request; widget_class->size_request = gtk_image_menu_item_size_request;
widget_class->size_allocate = gtk_image_menu_item_size_allocate; widget_class->size_allocate = gtk_image_menu_item_size_allocate;
widget_class->map = gtk_image_menu_item_map;
container_class->forall = gtk_image_menu_item_forall; container_class->forall = gtk_image_menu_item_forall;
container_class->remove = gtk_image_menu_item_remove; container_class->remove = gtk_image_menu_item_remove;
@ -171,6 +173,19 @@ show_image (GtkImageMenuItem *image_menu_item)
return show; return show;
} }
static void
gtk_image_menu_item_map (GtkWidget *widget)
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->map (widget);
if (image_menu_item->image)
g_object_set (image_menu_item->image,
"visible", show_image (image_menu_item),
NULL);
}
static void static void
gtk_image_menu_item_destroy (GtkObject *object) gtk_image_menu_item_destroy (GtkObject *object)
{ {
@ -197,7 +212,7 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
*requisition = 0; *requisition = 0;
if (image_menu_item->image && show_image (image_menu_item)) if (image_menu_item->image && GTK_WIDGET_VISIBLE (image_menu_item->image))
{ {
GtkRequisition image_requisition; GtkRequisition image_requisition;
guint toggle_spacing; guint toggle_spacing;
@ -238,9 +253,7 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
image_menu_item = GTK_IMAGE_MENU_ITEM (widget); image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
if (image_menu_item->image && if (image_menu_item->image && GTK_WIDGET_VISIBLE (image_menu_item->image))
GTK_WIDGET_VISIBLE (image_menu_item->image) &&
show_image (image_menu_item))
{ {
GtkRequisition child_requisition; GtkRequisition child_requisition;
@ -284,7 +297,7 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_allocate (widget, allocation); GTK_WIDGET_CLASS (gtk_image_menu_item_parent_class)->size_allocate (widget, allocation);
if (image_menu_item->image && show_image (image_menu_item)) if (image_menu_item->image && GTK_WIDGET_VISIBLE (image_menu_item->image))
{ {
gint x, y, offset; gint x, y, offset;
GtkRequisition child_requisition; GtkRequisition child_requisition;
@ -486,7 +499,6 @@ gtk_image_menu_item_new_from_stock (const gchar *stock_id,
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
} }
gtk_widget_show (image);
return item; return item;
} }