gtk+ r22230 - in trunk: . docs/reference docs/reference/gtk gtk
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r22230 - in trunk: . docs/reference docs/reference/gtk gtk
- Date: Tue, 27 Jan 2009 03:56:03 +0000 (UTC)
Author: matthiasc
Date: Tue Jan 27 03:56:03 2009
New Revision: 22230
URL: http://svn.gnome.org/viewvc/gtk+?rev=22230&view=rev
Log:
Bug 322932 â Always show icons on panel menus
* gtk/gtk.symbols:
* gtk/gtkimagemenuitem.[hc]: Add a property to override the
show-menu-images setting for individual menuitems. Patch by
William Jon McCann.
Modified:
trunk/ChangeLog
trunk/docs/reference/ChangeLog
trunk/docs/reference/gtk/gtk-sections.txt
trunk/gtk/gtk.symbols
trunk/gtk/gtkimagemenuitem.c
trunk/gtk/gtkimagemenuitem.h
Modified: trunk/docs/reference/gtk/gtk-sections.txt
==============================================================================
--- trunk/docs/reference/gtk/gtk-sections.txt (original)
+++ trunk/docs/reference/gtk/gtk-sections.txt Tue Jan 27 03:56:03 2009
@@ -2041,6 +2041,8 @@
gtk_image_menu_item_new_with_mnemonic
gtk_image_menu_item_get_use_stock
gtk_image_menu_item_set_use_stock
+gtk_image_menu_item_get_always_show_image
+gtk_image_menu_item_set_always_show_image
gtk_image_menu_item_set_accel_group
<SUBSECTION Standard>
GtkImageMenuItemClass
Modified: trunk/gtk/gtk.symbols
==============================================================================
--- trunk/gtk/gtk.symbols (original)
+++ trunk/gtk/gtk.symbols Tue Jan 27 03:56:03 2009
@@ -2062,6 +2062,7 @@
#if IN_HEADER(__GTK_IMAGE_MENU_ITEM_H__)
#if IN_FILE(__GTK_IMAGE_MENU_ITEM_C__)
+gtk_image_menu_item_get_always_show_image
gtk_image_menu_item_get_image
gtk_image_menu_item_get_type G_GNUC_CONST
gtk_image_menu_item_get_use_stock
@@ -2070,6 +2071,7 @@
gtk_image_menu_item_new_with_label
gtk_image_menu_item_new_with_mnemonic
gtk_image_menu_item_set_accel_group
+gtk_image_menu_item_set_always_show_image
gtk_image_menu_item_set_image
gtk_image_menu_item_set_use_stock
#endif
Modified: trunk/gtk/gtkimagemenuitem.c
==============================================================================
--- trunk/gtk/gtkimagemenuitem.c (original)
+++ trunk/gtk/gtkimagemenuitem.c Tue Jan 27 03:56:03 2009
@@ -79,15 +79,17 @@
GtkAction *action);
typedef struct {
- gchar *label;
- gboolean use_stock;
+ gchar *label;
+ guint use_stock : 1;
+ guint always_show_image : 1;
} GtkImageMenuItemPrivate;
enum {
PROP_0,
PROP_IMAGE,
PROP_USE_STOCK,
- PROP_ACCEL_GROUP
+ PROP_ACCEL_GROUP,
+ PROP_ALWAYS_SHOW_IMAGE
};
static GtkActivatableIface *parent_activatable_iface;
@@ -151,6 +153,25 @@
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/**
+ * GtkImageMenuItem:always-show-image:
+ *
+ * If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images
+ * setting and always show the image, if available.
+ *
+ * Use this property if the menuitem would be useless or hard to use
+ * without the image.
+ *
+ * Since: 2.16
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_ALWAYS_SHOW_IMAGE,
+ g_param_spec_boolean ("always-show-image",
+ P_("Always show image"),
+ P_("Whether the image will always be shown"),
+ FALSE,
+ GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
+ /**
* GtkImageMenuItem:accel-group:
*
* The Accel Group to use for stock accelerator keys
@@ -214,6 +235,9 @@
case PROP_USE_STOCK:
gtk_image_menu_item_set_use_stock (image_menu_item, g_value_get_boolean (value));
break;
+ case PROP_ALWAYS_SHOW_IMAGE:
+ gtk_image_menu_item_set_always_show_image (image_menu_item, g_value_get_boolean (value));
+ break;
case PROP_ACCEL_GROUP:
gtk_image_menu_item_set_accel_group (image_menu_item, g_value_get_object (value));
break;
@@ -239,6 +263,9 @@
case PROP_USE_STOCK:
g_value_set_boolean (value, gtk_image_menu_item_get_use_stock (image_menu_item));
break;
+ case PROP_ALWAYS_SHOW_IMAGE:
+ g_value_set_boolean (value, gtk_image_menu_item_get_always_show_image (image_menu_item));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -248,10 +275,14 @@
static gboolean
show_image (GtkImageMenuItem *image_menu_item)
{
+ GtkImageMenuItemPrivate *priv = GET_PRIVATE (image_menu_item);
GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (image_menu_item));
gboolean show;
- g_object_get (settings, "gtk-menu-images", &show, NULL);
+ if (priv->always_show_image)
+ show = TRUE;
+ else
+ g_object_get (settings, "gtk-menu-images", &show, NULL);
return show;
}
@@ -773,6 +804,69 @@
return priv->use_stock;
}
+/**
+ * gtk_image_menu_item_set_always_show_image:
+ * @image_menu_item: a #GtkImageMenuItem
+ * @always_show: %TRUE if the menuitem should always show the image
+ *
+ * If %TRUE, the menu item will ignore the #GtkSettings:gtk-menu-images
+ * setting and always show the image, if available.
+ *
+ * Use this property if the menuitem would be useless or hard to use
+ * without the image.
+ *
+ * Since: 2.16
+ */
+void
+gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
+ gboolean always_show)
+{
+ GtkImageMenuItemPrivate *priv;
+
+ g_return_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item));
+
+ priv = GET_PRIVATE (image_menu_item);
+
+ if (priv->always_show_image != always_show)
+ {
+ priv->always_show_image = always_show;
+
+ if (image_menu_item->image)
+ {
+ if (show_image (image_menu_item))
+ gtk_widget_show (image_menu_item->image);
+ else
+ gtk_widget_hide (image_menu_item->image);
+ }
+
+ g_object_notify (G_OBJECT (image_menu_item), "always-show-image");
+ }
+}
+
+/**
+ * gtk_image_menu_item_get_always_show_image:
+ * @image_menu_item: a #GtkImageMenuItem
+ * @always_show: %TRUE if the menuitem should always show the image
+ *
+ * Returns whether the menu item will ignore the #GtkSettings:gtk-menu-images
+ * setting and always show the image, if available.
+ *
+ * Returns: %TRUE if the menu item will always show the image
+ *
+ * Since: 2.16
+ */
+gboolean
+gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item)
+{
+ GtkImageMenuItemPrivate *priv;
+
+ g_return_val_if_fail (GTK_IS_IMAGE_MENU_ITEM (image_menu_item), FALSE);
+
+ priv = GET_PRIVATE (image_menu_item);
+
+ return priv->always_show_image;
+}
+
/**
* gtk_image_menu_item_set_accel_group:
Modified: trunk/gtk/gtkimagemenuitem.h
==============================================================================
--- trunk/gtk/gtkimagemenuitem.h (original)
+++ trunk/gtk/gtkimagemenuitem.h Tue Jan 27 03:56:03 2009
@@ -69,6 +69,9 @@
GtkWidget* gtk_image_menu_item_new_with_mnemonic (const gchar *label);
GtkWidget* gtk_image_menu_item_new_from_stock (const gchar *stock_id,
GtkAccelGroup *accel_group);
+void gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
+ gboolean always_show);
+gboolean gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item);
void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
GtkWidget *image);
GtkWidget* gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]