Commit b86588e9 authored by William Jon McCann's avatar William Jon McCann

Deprecate GtkImageMenuItem

Use GtkMenuItem for menus with only text or GMenu for those
with icons for "nouns" and just text for "verbs".
parent d741b7b8
......@@ -209,7 +209,9 @@ gtk_action_class_init (GtkActionClass *klass)
klass->create_menu_item = create_menu_item;
klass->create_tool_item = create_tool_item;
klass->create_menu = NULL;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
klass->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
G_GNUC_END_IGNORE_DEPRECATIONS;
klass->toolbar_item_type = GTK_TYPE_TOOL_BUTTON;
klass->connect_proxy = connect_proxy;
klass->disconnect_proxy = disconnect_proxy;
......
......@@ -24,6 +24,8 @@
#include "config.h"
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include "gtkimagemenuitem.h"
#include "gtkmenuitemprivate.h"
......@@ -149,6 +151,13 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
gobject_class->set_property = gtk_image_menu_item_set_property;
gobject_class->get_property = gtk_image_menu_item_get_property;
/**
* GtkImageMenuItem:image:
*
* Child widget to appear next to the menu text.
*
* Deprecated: 3.10
*/
g_object_class_install_property (gobject_class,
PROP_IMAGE,
g_param_spec_object ("image",
......@@ -183,6 +192,8 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
* without the image.
*
* Since: 2.16
*
* Deprecated: 3.10
*/
g_object_class_install_property (gobject_class,
PROP_ALWAYS_SHOW_IMAGE,
......@@ -784,6 +795,8 @@ gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
* Creates a new #GtkImageMenuItem with an empty label.
*
* Returns: a new #GtkImageMenuItem
*
* Deprecated: 3.10: Use gtk_menu_item_new() instead.
*/
GtkWidget*
gtk_image_menu_item_new (void)
......@@ -798,6 +811,8 @@ gtk_image_menu_item_new (void)
* Creates a new #GtkImageMenuItem containing a label.
*
* Returns: a new #GtkImageMenuItem.
*
* Deprecated: 3.10: Use gtk_menu_item_new_with_label() instead.
*/
GtkWidget*
gtk_image_menu_item_new_with_label (const gchar *label)
......@@ -817,6 +832,8 @@ gtk_image_menu_item_new_with_label (const gchar *label)
* in @label indicate the mnemonic for the menu item.
*
* Returns: a new #GtkImageMenuItem
*
* Deprecated: 3.10: Use gtk_menu_item_new_with_mnemonic() instead.
*/
GtkWidget*
gtk_image_menu_item_new_with_mnemonic (const gchar *label)
......@@ -923,6 +940,8 @@ gtk_image_menu_item_get_use_stock (GtkImageMenuItem *image_menu_item)
* without the image.
*
* Since: 2.16
*
* Deprecated: 3.10
*/
void
gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
......@@ -959,6 +978,8 @@ gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
* Returns: %TRUE if the menu item will always show the image
*
* Since: 2.16
*
* Deprecated: 3.10
*/
gboolean
gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item)
......@@ -1029,6 +1050,8 @@ gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
* Sets the image of @image_menu_item to the given widget.
* Note that it depends on the show-menu-images setting whether
* the image will be displayed or not.
*
* Deprecated: 3.10
*/
void
gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
......@@ -1069,6 +1092,8 @@ gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
* See gtk_image_menu_item_set_image().
*
* Return value: (transfer none): the widget set as image of @image_menu_item
*
* Deprecated: 3.10
**/
GtkWidget*
gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item)
......
......@@ -66,27 +66,26 @@ struct _GtkImageMenuItemClass
void (*_gtk_reserved4) (void);
};
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_get_type)
GType gtk_image_menu_item_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new)
GtkWidget* gtk_image_menu_item_new (void);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new_with_label)
GtkWidget* gtk_image_menu_item_new_with_label (const gchar *label);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new_with_mnemonic)
GtkWidget* gtk_image_menu_item_new_with_mnemonic (const gchar *label);
GDK_DEPRECATED_IN_3_10_FOR(gtk_image_menu_item_new)
GDK_DEPRECATED_IN_3_10_FOR(gtk_menu_item_new)
GtkWidget* gtk_image_menu_item_new_from_stock (const gchar *stock_id,
GtkAccelGroup *accel_group);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10
void gtk_image_menu_item_set_always_show_image (GtkImageMenuItem *image_menu_item,
gboolean always_show);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10
gboolean gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10
void gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
GtkWidget *image);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_3_10
GtkWidget* gtk_image_menu_item_get_image (GtkImageMenuItem *image_menu_item);
GDK_DEPRECATED_IN_3_10
void gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,
......
......@@ -434,7 +434,9 @@ gtk_recent_action_create_menu_item (GtkAction *action)
GtkWidget *menuitem;
menu = gtk_recent_action_create_menu (action);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menuitem = g_object_new (GTK_TYPE_IMAGE_MENU_ITEM, NULL);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
gtk_widget_show (menu);
......@@ -622,7 +624,9 @@ gtk_recent_action_class_init (GtkRecentActionClass *klass)
action_class->create_menu_item = gtk_recent_action_create_menu_item;
action_class->create_tool_item = gtk_recent_action_create_tool_item;
action_class->create_menu = gtk_recent_action_create_menu;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
action_class->menu_item_type = GTK_TYPE_IMAGE_MENU_ITEM;
G_GNUC_END_IGNORE_DEPRECATIONS;
action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
_gtk_recent_chooser_install_properties (gobject_class);
......
......@@ -836,22 +836,28 @@ gtk_recent_chooser_menu_create_item (GtkRecentChooserMenu *menu,
* The %d is the number of the item, the %s is the name of the item.
*/
text = g_strdup_printf (C_("recent menu label", "%d. %s"), count, escaped);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
item = gtk_image_menu_item_new_with_mnemonic (text);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_free (escaped);
g_free (name);
}
else
{
text = g_strdup (gtk_recent_info_get_display_name (info));
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
item = gtk_image_menu_item_new_with_label (text);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
g_free (text);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item),
TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
/* ellipsize the menu item label, in case the recent document
* display name is huge.
......@@ -868,8 +874,10 @@ gtk_recent_chooser_menu_create_item (GtkRecentChooserMenu *menu,
icon = gtk_recent_info_get_gicon (info);
image = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_MENU);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
if (icon)
g_object_unref (icon);
}
......
......@@ -863,8 +863,6 @@ gtk_tool_button_create_menu_proxy (GtkToolItem *item)
label = "";
}
G_GNUC_END_IGNORE_DEPRECATIONS;
if (use_mnemonic)
menu_item = gtk_image_menu_item_new_with_mnemonic (label);
else
......@@ -876,14 +874,14 @@ gtk_tool_button_create_menu_proxy (GtkToolItem *item)
}
else if (button->priv->stock_id)
{
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menu_image = gtk_image_new_from_stock (button->priv->stock_id, GTK_ICON_SIZE_MENU);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
if (menu_image)
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), menu_image);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_signal_connect_closure_by_id (menu_item,
g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0,
g_cclosure_new_object_swap (G_CALLBACK (gtk_button_clicked),
......
......@@ -2909,11 +2909,15 @@ G_GNUC_END_IGNORE_DEPRECATIONS
g_object_ref_sink (info->proxy);
gtk_widget_set_name (info->proxy, info->name);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
if (info->always_show_image_set &&
GTK_IS_IMAGE_MENU_ITEM (info->proxy))
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (info->proxy),
info->always_show_image);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_shell_insert (GTK_MENU_SHELL (menushell),
info->proxy, pos);
}
......
......@@ -7794,7 +7794,7 @@ gtk_window_do_popup (GtkWindow *window,
gtk_widget_show (menuitem);
gtk_menu_shell_append (GTK_MENU_SHELL (priv->popup_menu), menuitem);
menuitem = gtk_image_menu_item_new_with_label (_("Close"));
menuitem = gtk_menu_item_new_with_label (_("Close"));
gtk_widget_show (menuitem);
if (!priv->deletable)
gtk_widget_set_sensitive (menuitem, FALSE);
......
......@@ -3002,8 +3002,11 @@ create_menu (GdkScreen *screen, gint depth, gint length)
image = gtk_image_new_from_icon_name ("document-open",
GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menuitem = gtk_image_menu_item_new_with_label ("Image item");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
......@@ -3059,8 +3062,11 @@ create_table_menu (GdkScreen *screen, gint cols, gint rows)
image = gtk_image_new_from_icon_name ("help-broswer",
GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menuitem = gtk_image_menu_item_new_with_label ("Image");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 0, 1);
gtk_widget_show (menuitem);
......@@ -3075,8 +3081,11 @@ create_table_menu (GdkScreen *screen, gint cols, gint rows)
image = gtk_image_new_from_icon_name ("help-browser",
GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menuitem = gtk_image_menu_item_new_with_label ("Image");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 1, 2);
gtk_widget_show (menuitem);
......@@ -3280,8 +3289,11 @@ create_menus (GtkWidget *widget)
image = gtk_image_new_from_icon_name ("help-browser",
GTK_ICON_SIZE_MENU);
gtk_widget_show (image);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menuitem = gtk_image_menu_item_new_with_label ("Help");
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem), TRUE);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), create_menu (screen, 4, 5));
gtk_widget_set_hexpand (menuitem, TRUE);
gtk_widget_set_halign (menuitem, GTK_ALIGN_END);
......@@ -3307,12 +3319,6 @@ create_menus (GtkWidget *widget)
menu = create_menu (screen, 1, 5);
gtk_menu_set_accel_group (GTK_MENU (menu), accel_group);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, accel_group);
G_GNUC_END_IGNORE_DEPRECATIONS;
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_check_menu_item_new_with_label ("Accelerate Me");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
......
......@@ -117,7 +117,7 @@ create_file_menu (GtkAccelGroup *accelgroup)
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
menuitem = gtk_image_menu_item_new_with_mnemonic ("_Open");
menuitem = gtk_menu_item_new_with_mnemonic ("_Open");
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
......
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