Removed sealed members from GtkMenuItem
This commit is contained in:
parent
05eb55dcfc
commit
9dee9a84d0
@ -394,10 +394,11 @@ gtk_private_h_sources = \
|
|||||||
gtkfilesystem.h \
|
gtkfilesystem.h \
|
||||||
gtkfilesystemmodel.h \
|
gtkfilesystemmodel.h \
|
||||||
gtkiconcache.h \
|
gtkiconcache.h \
|
||||||
gtkimcontextsimpleseqs.h \
|
gtkimcontextsimpleseqs.h \
|
||||||
gtkintl.h \
|
gtkintl.h \
|
||||||
gtkkeyhash.h \
|
gtkkeyhash.h \
|
||||||
gtkmenuprivate.h \
|
gtkmenuprivate.h \
|
||||||
|
gtkmenuitemprivate.h \
|
||||||
gtkmenushellprivate.h \
|
gtkmenushellprivate.h \
|
||||||
gtkmnemonichash.h \
|
gtkmnemonichash.h \
|
||||||
gtkmodifierstyle.h \
|
gtkmodifierstyle.h \
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "gtkcheckmenuitem.h"
|
#include "gtkcheckmenuitem.h"
|
||||||
|
#include "gtkmenuitemprivate.h"
|
||||||
#include "gtkaccellabel.h"
|
#include "gtkaccellabel.h"
|
||||||
#include "gtkactivatable.h"
|
#include "gtkactivatable.h"
|
||||||
#include "gtktoggleaction.h"
|
#include "gtktoggleaction.h"
|
||||||
@ -59,31 +60,31 @@ static gint gtk_check_menu_item_draw (GtkWidget *wid
|
|||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
static void gtk_check_menu_item_activate (GtkMenuItem *menu_item);
|
static void gtk_check_menu_item_activate (GtkMenuItem *menu_item);
|
||||||
static void gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
static void gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||||
gint *requisition);
|
gint *requisition);
|
||||||
static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
static void gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
||||||
cairo_t *cr);
|
cairo_t *cr);
|
||||||
static void gtk_check_menu_item_set_property (GObject *object,
|
static void gtk_check_menu_item_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
static void gtk_check_menu_item_get_property (GObject *object,
|
static void gtk_check_menu_item_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
|
|
||||||
static void gtk_check_menu_item_activatable_interface_init (GtkActivatableIface *iface);
|
static void gtk_check_menu_item_activatable_interface_init (GtkActivatableIface *iface);
|
||||||
static void gtk_check_menu_item_update (GtkActivatable *activatable,
|
static void gtk_check_menu_item_update (GtkActivatable *activatable,
|
||||||
GtkAction *action,
|
GtkAction *action,
|
||||||
const gchar *property_name);
|
const gchar *property_name);
|
||||||
static void gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
|
static void gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
|
||||||
GtkAction *action);
|
GtkAction *action);
|
||||||
|
|
||||||
static GtkActivatableIface *parent_activatable_iface;
|
static GtkActivatableIface *parent_activatable_iface;
|
||||||
static guint check_menu_item_signals[LAST_SIGNAL] = { 0 };
|
static guint check_menu_item_signals[LAST_SIGNAL] = { 0 };
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_ITEM,
|
G_DEFINE_TYPE_WITH_CODE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_ITEM,
|
||||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
||||||
gtk_check_menu_item_activatable_interface_init))
|
gtk_check_menu_item_activatable_interface_init))
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
|
gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
|
||||||
@ -143,12 +144,12 @@ gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
|
|||||||
|
|
||||||
check_menu_item_signals[TOGGLED] =
|
check_menu_item_signals[TOGGLED] =
|
||||||
g_signal_new (I_("toggled"),
|
g_signal_new (I_("toggled"),
|
||||||
G_OBJECT_CLASS_TYPE (gobject_class),
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (GtkCheckMenuItemClass, toggled),
|
G_STRUCT_OFFSET (GtkCheckMenuItemClass, toggled),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
_gtk_marshal_VOID__VOID,
|
_gtk_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPrivate));
|
g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPrivate));
|
||||||
}
|
}
|
||||||
@ -163,8 +164,8 @@ gtk_check_menu_item_activatable_interface_init (GtkActivatableIface *iface)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_update (GtkActivatable *activatable,
|
gtk_check_menu_item_update (GtkActivatable *activatable,
|
||||||
GtkAction *action,
|
GtkAction *action,
|
||||||
const gchar *property_name)
|
const gchar *property_name)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItem *check_menu_item;
|
GtkCheckMenuItem *check_menu_item;
|
||||||
|
|
||||||
@ -184,12 +185,12 @@ gtk_check_menu_item_update (GtkActivatable *activatable,
|
|||||||
|
|
||||||
if (strcmp (property_name, "draw-as-radio") == 0)
|
if (strcmp (property_name, "draw-as-radio") == 0)
|
||||||
gtk_check_menu_item_set_draw_as_radio (check_menu_item,
|
gtk_check_menu_item_set_draw_as_radio (check_menu_item,
|
||||||
gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
|
gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
|
gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
|
||||||
GtkAction *action)
|
GtkAction *action)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItem *check_menu_item;
|
GtkCheckMenuItem *check_menu_item;
|
||||||
|
|
||||||
@ -208,7 +209,7 @@ gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
gtk_check_menu_item_set_draw_as_radio (check_menu_item,
|
gtk_check_menu_item_set_draw_as_radio (check_menu_item,
|
||||||
gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
|
gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
@ -221,8 +222,8 @@ GtkWidget*
|
|||||||
gtk_check_menu_item_new_with_label (const gchar *label)
|
gtk_check_menu_item_new_with_label (const gchar *label)
|
||||||
{
|
{
|
||||||
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
||||||
"label", label,
|
"label", label,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -240,14 +241,14 @@ GtkWidget*
|
|||||||
gtk_check_menu_item_new_with_mnemonic (const gchar *label)
|
gtk_check_menu_item_new_with_mnemonic (const gchar *label)
|
||||||
{
|
{
|
||||||
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
return g_object_new (GTK_TYPE_CHECK_MENU_ITEM,
|
||||||
"label", label,
|
"label", label,
|
||||||
"use-underline", TRUE,
|
"use-underline", TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
|
gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
|
||||||
gboolean is_active)
|
gboolean is_active)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItemPrivate *priv;
|
GtkCheckMenuItemPrivate *priv;
|
||||||
|
|
||||||
@ -280,7 +281,7 @@ gtk_check_menu_item_get_active (GtkCheckMenuItem *check_menu_item)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||||
gint *requisition)
|
gint *requisition)
|
||||||
{
|
{
|
||||||
guint toggle_spacing;
|
guint toggle_spacing;
|
||||||
guint indicator_size;
|
guint indicator_size;
|
||||||
@ -288,9 +289,9 @@ gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
|||||||
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
|
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (menu_item),
|
gtk_widget_style_get (GTK_WIDGET (menu_item),
|
||||||
"toggle-spacing", &toggle_spacing,
|
"toggle-spacing", &toggle_spacing,
|
||||||
"indicator-size", &indicator_size,
|
"indicator-size", &indicator_size,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
*requisition = indicator_size + toggle_spacing;
|
*requisition = indicator_size + toggle_spacing;
|
||||||
}
|
}
|
||||||
@ -363,7 +364,7 @@ gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
|
|||||||
**/
|
**/
|
||||||
void
|
void
|
||||||
gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
|
gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
|
||||||
gboolean draw_as_radio)
|
gboolean draw_as_radio)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItemPrivate *priv;
|
GtkCheckMenuItemPrivate *priv;
|
||||||
|
|
||||||
@ -450,7 +451,7 @@ gtk_check_menu_item_activate (GtkMenuItem *menu_item)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
||||||
cairo_t *cr)
|
cairo_t *cr)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
|
GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
@ -475,72 +476,72 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
|
|||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
|
|
||||||
gtk_widget_style_get (widget,
|
gtk_widget_style_get (widget,
|
||||||
"toggle-spacing", &toggle_spacing,
|
"toggle-spacing", &toggle_spacing,
|
||||||
"horizontal-padding", &horizontal_padding,
|
"horizontal-padding", &horizontal_padding,
|
||||||
"indicator-size", &indicator_size,
|
"indicator-size", &indicator_size,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size;
|
toggle_size = GTK_MENU_ITEM (check_menu_item)->priv->toggle_size;
|
||||||
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
|
||||||
offset = border_width + style->xthickness + 2;
|
offset = border_width + style->xthickness + 2;
|
||||||
|
|
||||||
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
|
||||||
{
|
{
|
||||||
x = offset + horizontal_padding +
|
x = offset + horizontal_padding +
|
||||||
(toggle_size - toggle_spacing - indicator_size) / 2;
|
(toggle_size - toggle_spacing - indicator_size) / 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = allocation.width -
|
x = allocation.width -
|
||||||
offset - horizontal_padding - toggle_size + toggle_spacing +
|
offset - horizontal_padding - toggle_size + toggle_spacing +
|
||||||
(toggle_size - toggle_spacing - indicator_size) / 2;
|
(toggle_size - toggle_spacing - indicator_size) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
y = (allocation.height - indicator_size) / 2;
|
y = (allocation.height - indicator_size) / 2;
|
||||||
|
|
||||||
if (priv->active ||
|
if (priv->active ||
|
||||||
priv->always_show_toggle ||
|
priv->always_show_toggle ||
|
||||||
(gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT))
|
(gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT))
|
||||||
{
|
{
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
|
||||||
window = gtk_widget_get_window (widget);
|
window = gtk_widget_get_window (widget);
|
||||||
state_type = gtk_widget_get_state (widget);
|
state_type = gtk_widget_get_state (widget);
|
||||||
|
|
||||||
if (priv->inconsistent)
|
if (priv->inconsistent)
|
||||||
shadow_type = GTK_SHADOW_ETCHED_IN;
|
shadow_type = GTK_SHADOW_ETCHED_IN;
|
||||||
else if (priv->active)
|
else if (priv->active)
|
||||||
shadow_type = GTK_SHADOW_IN;
|
shadow_type = GTK_SHADOW_IN;
|
||||||
else
|
else
|
||||||
shadow_type = GTK_SHADOW_OUT;
|
shadow_type = GTK_SHADOW_OUT;
|
||||||
|
|
||||||
if (!gtk_widget_is_sensitive (widget))
|
if (!gtk_widget_is_sensitive (widget))
|
||||||
state_type = GTK_STATE_INSENSITIVE;
|
state_type = GTK_STATE_INSENSITIVE;
|
||||||
|
|
||||||
if (priv->draw_as_radio)
|
if (priv->draw_as_radio)
|
||||||
{
|
{
|
||||||
gtk_paint_option (style, cr,
|
gtk_paint_option (style, cr,
|
||||||
state_type, shadow_type,
|
state_type, shadow_type,
|
||||||
widget, "option",
|
widget, "option",
|
||||||
x, y, indicator_size, indicator_size);
|
x, y, indicator_size, indicator_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_paint_check (style, cr,
|
gtk_paint_check (style, cr,
|
||||||
state_type, shadow_type,
|
state_type, shadow_type,
|
||||||
widget, "check",
|
widget, "check",
|
||||||
x, y, indicator_size, indicator_size);
|
x, y, indicator_size, indicator_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_get_property (GObject *object,
|
gtk_check_menu_item_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
|
GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
|
||||||
GtkCheckMenuItemPrivate *priv = checkitem->priv;
|
GtkCheckMenuItemPrivate *priv = checkitem->priv;
|
||||||
@ -565,9 +566,9 @@ gtk_check_menu_item_get_property (GObject *object,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_check_menu_item_set_property (GObject *object,
|
gtk_check_menu_item_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
|
GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "gtkimagemenuitem.h"
|
#include "gtkimagemenuitem.h"
|
||||||
|
|
||||||
|
#include "gtkmenuitemprivate.h"
|
||||||
#include "gtkaccellabel.h"
|
#include "gtkaccellabel.h"
|
||||||
#include "gtkstock.h"
|
#include "gtkstock.h"
|
||||||
#include "gtkiconfactory.h"
|
#include "gtkiconfactory.h"
|
||||||
@ -64,55 +65,55 @@ static GtkActivatableIface *parent_activatable_iface;
|
|||||||
static void gtk_image_menu_item_destroy (GtkWidget *widget);
|
static void gtk_image_menu_item_destroy (GtkWidget *widget);
|
||||||
static void gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
static void gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural);
|
gint *natural);
|
||||||
static void gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
|
static void gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
|
||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural);
|
gint *natural);
|
||||||
static void gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
|
static void gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
|
||||||
gint width,
|
gint width,
|
||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural);
|
gint *natural);
|
||||||
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_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,
|
||||||
gint *requisition);
|
gint *requisition);
|
||||||
static void gtk_image_menu_item_set_label (GtkMenuItem *menu_item,
|
static void gtk_image_menu_item_set_label (GtkMenuItem *menu_item,
|
||||||
const gchar *label);
|
const gchar *label);
|
||||||
static G_CONST_RETURN gchar *gtk_image_menu_item_get_label (GtkMenuItem *menu_item);
|
static G_CONST_RETURN gchar *gtk_image_menu_item_get_label (GtkMenuItem *menu_item);
|
||||||
|
|
||||||
static void gtk_image_menu_item_forall (GtkContainer *container,
|
static void gtk_image_menu_item_forall (GtkContainer *container,
|
||||||
gboolean include_internals,
|
gboolean include_internals,
|
||||||
GtkCallback callback,
|
GtkCallback callback,
|
||||||
gpointer callback_data);
|
gpointer callback_data);
|
||||||
|
|
||||||
static void gtk_image_menu_item_finalize (GObject *object);
|
static void gtk_image_menu_item_finalize (GObject *object);
|
||||||
static void gtk_image_menu_item_set_property (GObject *object,
|
static void gtk_image_menu_item_set_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
static void gtk_image_menu_item_get_property (GObject *object,
|
static void gtk_image_menu_item_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec);
|
GParamSpec *pspec);
|
||||||
static void gtk_image_menu_item_screen_changed (GtkWidget *widget,
|
static void gtk_image_menu_item_screen_changed (GtkWidget *widget,
|
||||||
GdkScreen *previous_screen);
|
GdkScreen *previous_screen);
|
||||||
|
|
||||||
static void gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item);
|
static void gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item);
|
||||||
|
|
||||||
static void gtk_image_menu_item_activatable_interface_init (GtkActivatableIface *iface);
|
static void gtk_image_menu_item_activatable_interface_init (GtkActivatableIface *iface);
|
||||||
static void gtk_image_menu_item_update (GtkActivatable *activatable,
|
static void gtk_image_menu_item_update (GtkActivatable *activatable,
|
||||||
GtkAction *action,
|
GtkAction *action,
|
||||||
const gchar *property_name);
|
const gchar *property_name);
|
||||||
static void gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
|
static void gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
|
||||||
GtkAction *action);
|
GtkAction *action);
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE (GtkImageMenuItem, gtk_image_menu_item, GTK_TYPE_MENU_ITEM,
|
G_DEFINE_TYPE_WITH_CODE (GtkImageMenuItem, gtk_image_menu_item, GTK_TYPE_MENU_ITEM,
|
||||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
|
||||||
gtk_image_menu_item_activatable_interface_init))
|
gtk_image_menu_item_activatable_interface_init))
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -156,14 +157,14 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
|
|||||||
* stock id to select the stock item for the item.
|
* stock id to select the stock item for the item.
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
**/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_USE_STOCK,
|
PROP_USE_STOCK,
|
||||||
g_param_spec_boolean ("use-stock",
|
g_param_spec_boolean ("use-stock",
|
||||||
P_("Use stock"),
|
P_("Use stock"),
|
||||||
P_("Whether to use the label text to create a stock menu item"),
|
P_("Whether to use the label text to create a stock menu item"),
|
||||||
FALSE,
|
FALSE,
|
||||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkImageMenuItem:always-show-image:
|
* GtkImageMenuItem:always-show-image:
|
||||||
@ -175,14 +176,14 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
|
|||||||
* without the image.
|
* without the image.
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
**/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_ALWAYS_SHOW_IMAGE,
|
PROP_ALWAYS_SHOW_IMAGE,
|
||||||
g_param_spec_boolean ("always-show-image",
|
g_param_spec_boolean ("always-show-image",
|
||||||
P_("Always show image"),
|
P_("Always show image"),
|
||||||
P_("Whether the image will always be shown"),
|
P_("Whether the image will always be shown"),
|
||||||
FALSE,
|
FALSE,
|
||||||
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkImageMenuItem:accel-group:
|
* GtkImageMenuItem:accel-group:
|
||||||
@ -190,14 +191,14 @@ gtk_image_menu_item_class_init (GtkImageMenuItemClass *klass)
|
|||||||
* The Accel Group to use for stock accelerator keys
|
* The Accel Group to use for stock accelerator keys
|
||||||
*
|
*
|
||||||
* Since: 2.16
|
* Since: 2.16
|
||||||
**/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_ACCEL_GROUP,
|
PROP_ACCEL_GROUP,
|
||||||
g_param_spec_object ("accel-group",
|
g_param_spec_object ("accel-group",
|
||||||
P_("Accel Group"),
|
P_("Accel Group"),
|
||||||
P_("The Accel Group to use for stock accelerator keys"),
|
P_("The Accel Group to use for stock accelerator keys"),
|
||||||
GTK_TYPE_ACCEL_GROUP,
|
GTK_TYPE_ACCEL_GROUP,
|
||||||
GTK_PARAM_WRITABLE));
|
GTK_PARAM_WRITABLE));
|
||||||
|
|
||||||
g_type_class_add_private (klass, sizeof (GtkImageMenuItemPrivate));
|
g_type_class_add_private (klass, sizeof (GtkImageMenuItemPrivate));
|
||||||
}
|
}
|
||||||
@ -325,7 +326,7 @@ gtk_image_menu_item_destroy (GtkWidget *widget)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||||
gint *requisition)
|
gint *requisition)
|
||||||
{
|
{
|
||||||
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
|
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
|
||||||
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
||||||
@ -350,19 +351,19 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
|||||||
gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL);
|
gtk_widget_get_preferred_size (priv->image, &image_requisition, NULL);
|
||||||
|
|
||||||
gtk_widget_style_get (GTK_WIDGET (menu_item),
|
gtk_widget_style_get (GTK_WIDGET (menu_item),
|
||||||
"toggle-spacing", &toggle_spacing,
|
"toggle-spacing", &toggle_spacing,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
|
if (pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL)
|
||||||
{
|
{
|
||||||
if (image_requisition.width > 0)
|
if (image_requisition.width > 0)
|
||||||
*requisition = image_requisition.width + toggle_spacing;
|
*requisition = image_requisition.width + toggle_spacing;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (image_requisition.height > 0)
|
if (image_requisition.height > 0)
|
||||||
*requisition = image_requisition.height + toggle_spacing;
|
*requisition = image_requisition.height + toggle_spacing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,15 +379,15 @@ gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!priv->image)
|
if (!priv->image)
|
||||||
{
|
{
|
||||||
image = gtk_image_new_from_stock (priv->label, GTK_ICON_SIZE_MENU);
|
image = gtk_image_new_from_stock (priv->label, GTK_ICON_SIZE_MENU);
|
||||||
gtk_image_menu_item_set_image (image_menu_item, image);
|
gtk_image_menu_item_set_image (image_menu_item, image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_stock_lookup (priv->label, &stock_item))
|
if (gtk_stock_lookup (priv->label, &stock_item))
|
||||||
resolved_label = stock_item.label;
|
resolved_label = stock_item.label;
|
||||||
|
|
||||||
gtk_menu_item_set_use_underline (GTK_MENU_ITEM (image_menu_item), TRUE);
|
gtk_menu_item_set_use_underline (GTK_MENU_ITEM (image_menu_item), TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
GTK_MENU_ITEM_CLASS
|
GTK_MENU_ITEM_CLASS
|
||||||
@ -396,7 +397,7 @@ gtk_image_menu_item_recalculate (GtkImageMenuItem *image_menu_item)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_set_label (GtkMenuItem *menu_item,
|
gtk_image_menu_item_set_label (GtkMenuItem *menu_item,
|
||||||
const gchar *label)
|
const gchar *label)
|
||||||
{
|
{
|
||||||
GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv;
|
GtkImageMenuItemPrivate *priv = GTK_IMAGE_MENU_ITEM (menu_item)->priv;
|
||||||
|
|
||||||
@ -422,8 +423,8 @@ gtk_image_menu_item_get_label (GtkMenuItem *menu_item)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural)
|
gint *natural)
|
||||||
{
|
{
|
||||||
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
||||||
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
||||||
@ -458,8 +459,8 @@ gtk_image_menu_item_get_preferred_width (GtkWidget *widget,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
|
gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
|
||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural)
|
gint *natural)
|
||||||
{
|
{
|
||||||
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
||||||
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
||||||
@ -494,9 +495,9 @@ gtk_image_menu_item_get_preferred_height (GtkWidget *widget,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
|
gtk_image_menu_item_get_preferred_height_for_width (GtkWidget *widget,
|
||||||
gint width,
|
gint width,
|
||||||
gint *minimum,
|
gint *minimum,
|
||||||
gint *natural)
|
gint *natural)
|
||||||
{
|
{
|
||||||
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
|
||||||
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
GtkImageMenuItemPrivate *priv = image_menu_item->priv;
|
||||||
@ -556,11 +557,13 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
|
|||||||
GtkRequisition child_requisition;
|
GtkRequisition child_requisition;
|
||||||
GtkAllocation child_allocation;
|
GtkAllocation child_allocation;
|
||||||
guint horizontal_padding, toggle_spacing;
|
guint horizontal_padding, toggle_spacing;
|
||||||
|
gint toggle_size;
|
||||||
|
|
||||||
|
toggle_size = GTK_MENU_ITEM (image_menu_item)->priv->toggle_size;
|
||||||
gtk_widget_style_get (widget,
|
gtk_widget_style_get (widget,
|
||||||
"horizontal-padding", &horizontal_padding,
|
"horizontal-padding", &horizontal_padding,
|
||||||
"toggle-spacing", &toggle_spacing,
|
"toggle-spacing", &toggle_spacing,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Man this is lame hardcoding action, but I can't
|
/* Man this is lame hardcoding action, but I can't
|
||||||
* come up with a solution that's really better.
|
* come up with a solution that's really better.
|
||||||
@ -571,42 +574,38 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
|
|||||||
gtk_widget_get_allocation (widget, &widget_allocation);
|
gtk_widget_get_allocation (widget, &widget_allocation);
|
||||||
|
|
||||||
if (pack_dir == GTK_PACK_DIRECTION_LTR ||
|
if (pack_dir == GTK_PACK_DIRECTION_LTR ||
|
||||||
pack_dir == GTK_PACK_DIRECTION_RTL)
|
pack_dir == GTK_PACK_DIRECTION_RTL)
|
||||||
{
|
{
|
||||||
offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) +
|
offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) +
|
||||||
gtk_widget_get_style (widget)->xthickness;
|
gtk_widget_get_style (widget)->xthickness;
|
||||||
|
|
||||||
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
|
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
|
||||||
(pack_dir == GTK_PACK_DIRECTION_LTR))
|
(pack_dir == GTK_PACK_DIRECTION_LTR))
|
||||||
x = offset + horizontal_padding +
|
x = offset + horizontal_padding +
|
||||||
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
|
(toggle_size - toggle_spacing - child_requisition.width) / 2;
|
||||||
toggle_spacing - child_requisition.width) / 2;
|
else
|
||||||
else
|
|
||||||
x = widget_allocation.width - offset - horizontal_padding -
|
x = widget_allocation.width - offset - horizontal_padding -
|
||||||
GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
|
toggle_size + toggle_spacing +
|
||||||
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
|
(toggle_size - toggle_spacing - child_requisition.width) / 2;
|
||||||
toggle_spacing - child_requisition.width) / 2;
|
|
||||||
|
|
||||||
y = (widget_allocation.height - child_requisition.height) / 2;
|
y = (widget_allocation.height - child_requisition.height) / 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) +
|
offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) +
|
||||||
gtk_widget_get_style (widget)->ythickness;
|
gtk_widget_get_style (widget)->ythickness;
|
||||||
|
|
||||||
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
|
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
|
||||||
(pack_dir == GTK_PACK_DIRECTION_TTB))
|
(pack_dir == GTK_PACK_DIRECTION_TTB))
|
||||||
y = offset + horizontal_padding +
|
y = offset + horizontal_padding +
|
||||||
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
|
(toggle_size - toggle_spacing - child_requisition.height) / 2;
|
||||||
toggle_spacing - child_requisition.height) / 2;
|
else
|
||||||
else
|
|
||||||
y = widget_allocation.height - offset - horizontal_padding -
|
y = widget_allocation.height - offset - horizontal_padding -
|
||||||
GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
|
toggle_size + toggle_spacing +
|
||||||
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
|
(toggle_size - toggle_spacing - child_requisition.height) / 2;
|
||||||
toggle_spacing - child_requisition.height) / 2;
|
|
||||||
|
|
||||||
x = (widget_allocation.width - child_requisition.width) / 2;
|
x = (widget_allocation.width - child_requisition.width) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
child_allocation.width = child_requisition.width;
|
child_allocation.width = child_requisition.width;
|
||||||
child_allocation.height = child_requisition.height;
|
child_allocation.height = child_requisition.height;
|
||||||
@ -619,7 +618,7 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_forall (GtkContainer *container,
|
gtk_image_menu_item_forall (GtkContainer *container,
|
||||||
gboolean include_internals,
|
gboolean include_internals,
|
||||||
GtkCallback callback,
|
GtkCallback callback,
|
||||||
gpointer callback_data)
|
gpointer callback_data)
|
||||||
{
|
{
|
||||||
@ -699,8 +698,8 @@ activatable_update_icon_name (GtkImageMenuItem *image_menu_item, GtkAction *acti
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_update (GtkActivatable *activatable,
|
gtk_image_menu_item_update (GtkActivatable *activatable,
|
||||||
GtkAction *action,
|
GtkAction *action,
|
||||||
const gchar *property_name)
|
const gchar *property_name)
|
||||||
{
|
{
|
||||||
GtkImageMenuItem *image_menu_item;
|
GtkImageMenuItem *image_menu_item;
|
||||||
gboolean use_appearance;
|
gboolean use_appearance;
|
||||||
@ -723,7 +722,7 @@ gtk_image_menu_item_update (GtkActivatable *activatable,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
|
gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
|
||||||
GtkAction *action)
|
GtkAction *action)
|
||||||
{
|
{
|
||||||
GtkImageMenuItem *image_menu_item;
|
GtkImageMenuItem *image_menu_item;
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
@ -752,7 +751,7 @@ gtk_image_menu_item_sync_action_properties (GtkActivatable *activatable,
|
|||||||
image = gtk_image_new ();
|
image = gtk_image_new ();
|
||||||
gtk_widget_show (image);
|
gtk_widget_show (image);
|
||||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (activatable),
|
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (activatable),
|
||||||
image);
|
image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!activatable_update_stock_id (image_menu_item, action) &&
|
if (!activatable_update_stock_id (image_menu_item, action) &&
|
||||||
@ -782,13 +781,13 @@ gtk_image_menu_item_new (void)
|
|||||||
* @returns: a new #GtkImageMenuItem.
|
* @returns: a new #GtkImageMenuItem.
|
||||||
*
|
*
|
||||||
* Creates a new #GtkImageMenuItem containing a label.
|
* Creates a new #GtkImageMenuItem containing a label.
|
||||||
**/
|
*/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
gtk_image_menu_item_new_with_label (const gchar *label)
|
gtk_image_menu_item_new_with_label (const gchar *label)
|
||||||
{
|
{
|
||||||
return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
|
return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
|
||||||
"label", label,
|
"label", label,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -801,14 +800,14 @@ gtk_image_menu_item_new_with_label (const gchar *label)
|
|||||||
* Creates a new #GtkImageMenuItem containing a label. The label
|
* Creates a new #GtkImageMenuItem containing a label. The label
|
||||||
* will be created using gtk_label_new_with_mnemonic(), so underscores
|
* will be created using gtk_label_new_with_mnemonic(), so underscores
|
||||||
* in @label indicate the mnemonic for the menu item.
|
* in @label indicate the mnemonic for the menu item.
|
||||||
**/
|
*/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
gtk_image_menu_item_new_with_mnemonic (const gchar *label)
|
gtk_image_menu_item_new_with_mnemonic (const gchar *label)
|
||||||
{
|
{
|
||||||
return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
|
return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
|
||||||
"use-underline", TRUE,
|
"use-underline", TRUE,
|
||||||
"label", label,
|
"label", label,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -827,16 +826,16 @@ gtk_image_menu_item_new_with_mnemonic (const gchar *label)
|
|||||||
* appropriate path for the menu item, use gtk_stock_lookup() to look up the
|
* appropriate path for the menu item, use gtk_stock_lookup() to look up the
|
||||||
* standard accelerator for the stock item, and if one is found, call
|
* standard accelerator for the stock item, and if one is found, call
|
||||||
* gtk_accel_map_add_entry() to register it.
|
* gtk_accel_map_add_entry() to register it.
|
||||||
**/
|
*/
|
||||||
GtkWidget*
|
GtkWidget*
|
||||||
gtk_image_menu_item_new_from_stock (const gchar *stock_id,
|
gtk_image_menu_item_new_from_stock (const gchar *stock_id,
|
||||||
GtkAccelGroup *accel_group)
|
GtkAccelGroup *accel_group)
|
||||||
{
|
{
|
||||||
return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
|
return g_object_new (GTK_TYPE_IMAGE_MENU_ITEM,
|
||||||
"label", stock_id,
|
"label", stock_id,
|
||||||
"use-stock", TRUE,
|
"use-stock", TRUE,
|
||||||
"accel-group", accel_group,
|
"accel-group", accel_group,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -851,7 +850,7 @@ gtk_image_menu_item_new_from_stock (const gchar *stock_id,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,
|
gtk_image_menu_item_set_use_stock (GtkImageMenuItem *image_menu_item,
|
||||||
gboolean use_stock)
|
gboolean use_stock)
|
||||||
{
|
{
|
||||||
GtkImageMenuItemPrivate *priv;
|
GtkImageMenuItemPrivate *priv;
|
||||||
|
|
||||||
@ -965,7 +964,7 @@ gtk_image_menu_item_get_always_show_image (GtkImageMenuItem *image_menu_item)
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
|
gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
|
||||||
GtkAccelGroup *accel_group)
|
GtkAccelGroup *accel_group)
|
||||||
{
|
{
|
||||||
GtkImageMenuItemPrivate *priv;
|
GtkImageMenuItemPrivate *priv;
|
||||||
GtkStockItem stock_item;
|
GtkStockItem stock_item;
|
||||||
@ -982,14 +981,14 @@ gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
|
|||||||
if (priv->use_stock && priv->label && gtk_stock_lookup (priv->label, &stock_item))
|
if (priv->use_stock && priv->label && gtk_stock_lookup (priv->label, &stock_item))
|
||||||
if (stock_item.keyval)
|
if (stock_item.keyval)
|
||||||
{
|
{
|
||||||
gtk_widget_add_accelerator (GTK_WIDGET (image_menu_item),
|
gtk_widget_add_accelerator (GTK_WIDGET (image_menu_item),
|
||||||
"activate",
|
"activate",
|
||||||
accel_group,
|
accel_group,
|
||||||
stock_item.keyval,
|
stock_item.keyval,
|
||||||
stock_item.modifier,
|
stock_item.modifier,
|
||||||
GTK_ACCEL_VISIBLE);
|
GTK_ACCEL_VISIBLE);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (image_menu_item), "accel-group");
|
g_object_notify (G_OBJECT (image_menu_item), "accel-group");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,7 +1000,7 @@ gtk_image_menu_item_set_accel_group (GtkImageMenuItem *image_menu_item,
|
|||||||
* Sets the image of @image_menu_item to the given widget.
|
* Sets the image of @image_menu_item to the given widget.
|
||||||
* Note that it depends on the show-menu-images setting whether
|
* Note that it depends on the show-menu-images setting whether
|
||||||
* the image will be displayed or not.
|
* the image will be displayed or not.
|
||||||
**/
|
*/
|
||||||
void
|
void
|
||||||
gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
|
gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
|
||||||
GtkWidget *image)
|
GtkWidget *image)
|
||||||
@ -1026,9 +1025,9 @@ gtk_image_menu_item_set_image (GtkImageMenuItem *image_menu_item,
|
|||||||
|
|
||||||
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
|
gtk_widget_set_parent (image, GTK_WIDGET (image_menu_item));
|
||||||
g_object_set (image,
|
g_object_set (image,
|
||||||
"visible", show_image (image_menu_item),
|
"visible", show_image (image_menu_item),
|
||||||
"no-show-all", TRUE,
|
"no-show-all", TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (image_menu_item), "image");
|
g_object_notify (G_OBJECT (image_menu_item), "image");
|
||||||
}
|
}
|
||||||
@ -1086,15 +1085,15 @@ show_image_change_notify (GtkImageMenuItem *image_menu_item)
|
|||||||
if (priv->image)
|
if (priv->image)
|
||||||
{
|
{
|
||||||
if (show_image (image_menu_item))
|
if (show_image (image_menu_item))
|
||||||
gtk_widget_show (priv->image);
|
gtk_widget_show (priv->image);
|
||||||
else
|
else
|
||||||
gtk_widget_hide (priv->image);
|
gtk_widget_hide (priv->image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
traverse_container (GtkWidget *widget,
|
traverse_container (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
if (GTK_IS_IMAGE_MENU_ITEM (widget))
|
if (GTK_IS_IMAGE_MENU_ITEM (widget))
|
||||||
show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
|
show_image_change_notify (GTK_IMAGE_MENU_ITEM (widget));
|
||||||
@ -1111,14 +1110,14 @@ gtk_image_menu_item_setting_changed (GtkSettings *settings)
|
|||||||
|
|
||||||
for (l = list; l; l = l->next)
|
for (l = list; l; l = l->next)
|
||||||
gtk_container_forall (GTK_CONTAINER (l->data),
|
gtk_container_forall (GTK_CONTAINER (l->data),
|
||||||
traverse_container, NULL);
|
traverse_container, NULL);
|
||||||
|
|
||||||
g_list_free (list);
|
g_list_free (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_image_menu_item_screen_changed (GtkWidget *widget,
|
gtk_image_menu_item_screen_changed (GtkWidget *widget,
|
||||||
GdkScreen *previous_screen)
|
GdkScreen *previous_screen)
|
||||||
{
|
{
|
||||||
GtkSettings *settings;
|
GtkSettings *settings;
|
||||||
gulong show_image_connection;
|
gulong show_image_connection;
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkmenuprivate.h"
|
#include "gtkmenuprivate.h"
|
||||||
|
#include "gtkmenuitemprivate.h"
|
||||||
#include "gtkmenushellprivate.h"
|
#include "gtkmenushellprivate.h"
|
||||||
#include "gtktearoffmenuitem.h"
|
#include "gtktearoffmenuitem.h"
|
||||||
#include "gtkwindow.h"
|
#include "gtkwindow.h"
|
||||||
@ -3032,13 +3033,13 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
|
|||||||
* case the toggle size request depends on the size
|
* case the toggle size request depends on the size
|
||||||
* request of a child of the child (e.g. for ImageMenuItem)
|
* request of a child of the child (e.g. for ImageMenuItem)
|
||||||
*/
|
*/
|
||||||
GTK_MENU_ITEM (child)->show_submenu_indicator = TRUE;
|
GTK_MENU_ITEM (child)->priv->show_submenu_indicator = TRUE;
|
||||||
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
|
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
|
||||||
|
|
||||||
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
|
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child), &toggle_size);
|
||||||
max_toggle_size = MAX (max_toggle_size, toggle_size);
|
max_toggle_size = MAX (max_toggle_size, toggle_size);
|
||||||
max_accel_width = MAX (max_accel_width,
|
max_accel_width = MAX (max_accel_width,
|
||||||
GTK_MENU_ITEM (child)->accelerator_width);
|
GTK_MENU_ITEM (child)->priv->accelerator_width);
|
||||||
|
|
||||||
part = child_min / (r - l);
|
part = child_min / (r - l);
|
||||||
min_width = MAX (min_width, part);
|
min_width = MAX (min_width, part);
|
||||||
@ -3325,7 +3326,7 @@ get_accel_path (GtkWidget *menu_item,
|
|||||||
path = _gtk_widget_get_accel_path (menu_item, locked);
|
path = _gtk_widget_get_accel_path (menu_item, locked);
|
||||||
if (!path)
|
if (!path)
|
||||||
{
|
{
|
||||||
path = GTK_MENU_ITEM (menu_item)->accel_path;
|
path = GTK_MENU_ITEM (menu_item)->priv->accel_path;
|
||||||
|
|
||||||
if (locked)
|
if (locked)
|
||||||
{
|
{
|
||||||
@ -3437,7 +3438,7 @@ gtk_menu_key_press (GtkWidget *widget,
|
|||||||
if (can_change_accels &&
|
if (can_change_accels &&
|
||||||
menu_shell->priv->active_menu_item &&
|
menu_shell->priv->active_menu_item &&
|
||||||
gtk_bin_get_child (GTK_BIN (menu_shell->priv->active_menu_item)) && /* no separators */
|
gtk_bin_get_child (GTK_BIN (menu_shell->priv->active_menu_item)) && /* no separators */
|
||||||
GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->submenu == NULL && /* no submenus */
|
GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->priv->submenu == NULL && /* no submenus */
|
||||||
(delete || gtk_accelerator_valid (accel_key, accel_mods)))
|
(delete || gtk_accelerator_valid (accel_key, accel_mods)))
|
||||||
{
|
{
|
||||||
GtkWidget *menu_item = menu_shell->priv->active_menu_item;
|
GtkWidget *menu_item = menu_shell->priv->active_menu_item;
|
||||||
@ -3505,7 +3506,7 @@ definitely_within_item (GtkWidget *widget,
|
|||||||
gint x,
|
gint x,
|
||||||
gint y)
|
gint y)
|
||||||
{
|
{
|
||||||
GdkWindow *window = GTK_MENU_ITEM (widget)->event_window;
|
GdkWindow *window = GTK_MENU_ITEM (widget)->priv->event_window;
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
w = gdk_window_get_width (window);
|
w = gdk_window_get_width (window);
|
||||||
@ -4250,10 +4251,10 @@ gtk_menu_leave_notify (GtkWidget *widget,
|
|||||||
* with a submenu, in which case we enter submenu navigation mode.
|
* with a submenu, in which case we enter submenu navigation mode.
|
||||||
*/
|
*/
|
||||||
if (menu_shell->priv->active_menu_item != NULL
|
if (menu_shell->priv->active_menu_item != NULL
|
||||||
&& menu_item->submenu != NULL
|
&& menu_item->priv->submenu != NULL
|
||||||
&& menu_item->submenu_placement == GTK_LEFT_RIGHT)
|
&& menu_item->priv->submenu_placement == GTK_LEFT_RIGHT)
|
||||||
{
|
{
|
||||||
if (GTK_MENU_SHELL (menu_item->submenu)->priv->active)
|
if (GTK_MENU_SHELL (menu_item->priv->submenu)->priv->active)
|
||||||
{
|
{
|
||||||
gtk_menu_set_submenu_navigation_region (menu, menu_item, event);
|
gtk_menu_set_submenu_navigation_region (menu, menu_item, event);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -4389,12 +4390,12 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
|
|||||||
GtkMenuPopdownData *popdown_data;
|
GtkMenuPopdownData *popdown_data;
|
||||||
GdkWindow *window;
|
GdkWindow *window;
|
||||||
|
|
||||||
g_return_if_fail (menu_item->submenu != NULL);
|
g_return_if_fail (menu_item->priv->submenu != NULL);
|
||||||
g_return_if_fail (event != NULL);
|
g_return_if_fail (event != NULL);
|
||||||
|
|
||||||
event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
event_widget = gtk_get_event_widget ((GdkEvent*) event);
|
||||||
|
|
||||||
window = gtk_widget_get_window (menu_item->submenu);
|
window = gtk_widget_get_window (menu_item->priv->submenu);
|
||||||
gdk_window_get_origin (window, &submenu_left, &submenu_top);
|
gdk_window_get_origin (window, &submenu_left, &submenu_top);
|
||||||
|
|
||||||
submenu_right = submenu_left + gdk_window_get_width (window);
|
submenu_right = submenu_left + gdk_window_get_width (window);
|
||||||
@ -4413,7 +4414,7 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
|
|||||||
* location of the rectangle. This is why the width or height
|
* location of the rectangle. This is why the width or height
|
||||||
* can be negative.
|
* can be negative.
|
||||||
*/
|
*/
|
||||||
if (menu_item->submenu_direction == GTK_DIRECTION_RIGHT)
|
if (menu_item->priv->submenu_direction == GTK_DIRECTION_RIGHT)
|
||||||
{
|
{
|
||||||
/* right */
|
/* right */
|
||||||
priv->navigation_x = submenu_left;
|
priv->navigation_x = submenu_left;
|
||||||
@ -5359,7 +5360,7 @@ gtk_menu_move_current (GtkMenuShell *menu_shell,
|
|||||||
{
|
{
|
||||||
GtkWidget *parent = menu_shell->priv->parent_menu_shell;
|
GtkWidget *parent = menu_shell->priv->parent_menu_shell;
|
||||||
|
|
||||||
if (! GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->submenu &&
|
if (! GTK_MENU_ITEM (menu_shell->priv->active_menu_item)->priv->submenu &&
|
||||||
(!parent ||
|
(!parent ||
|
||||||
g_list_length (GTK_MENU_SHELL (parent)->priv->children) <= 1))
|
g_list_length (GTK_MENU_SHELL (parent)->priv->children) <= 1))
|
||||||
match = menu_shell->priv->active_menu_item;
|
match = menu_shell->priv->active_menu_item;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "gtkbindings.h"
|
#include "gtkbindings.h"
|
||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkmenuitem.h"
|
#include "gtkmenuitemprivate.h"
|
||||||
#include "gtkmenuprivate.h"
|
#include "gtkmenuprivate.h"
|
||||||
#include "gtkmenushellprivate.h"
|
#include "gtkmenushellprivate.h"
|
||||||
#include "gtksettings.h"
|
#include "gtksettings.h"
|
||||||
@ -313,7 +313,7 @@ gtk_menu_bar_size_request (GtkWidget *widget,
|
|||||||
{
|
{
|
||||||
gint toggle_size;
|
gint toggle_size;
|
||||||
|
|
||||||
GTK_MENU_ITEM (child)->show_submenu_indicator = FALSE;
|
GTK_MENU_ITEM (child)->priv->show_submenu_indicator = FALSE;
|
||||||
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
|
gtk_widget_get_preferred_size (child, &child_requisition, NULL);
|
||||||
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
|
gtk_menu_item_toggle_size_request (GTK_MENU_ITEM (child),
|
||||||
&toggle_size);
|
&toggle_size);
|
||||||
@ -478,8 +478,9 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
|
|||||||
child_requisition.height += toggle_size;
|
child_requisition.height += toggle_size;
|
||||||
|
|
||||||
/* Support for the right justified help menu */
|
/* Support for the right justified help menu */
|
||||||
if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
|
if (children == NULL &&
|
||||||
&& (GTK_MENU_ITEM(child)->right_justify))
|
GTK_IS_MENU_ITEM (child) &&
|
||||||
|
GTK_MENU_ITEM (child)->priv->right_justify)
|
||||||
{
|
{
|
||||||
ltr_x = allocation->width -
|
ltr_x = allocation->width -
|
||||||
child_requisition.width - offset;
|
child_requisition.width - offset;
|
||||||
@ -527,10 +528,11 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
child_requisition.height += toggle_size;
|
child_requisition.height += toggle_size;
|
||||||
|
|
||||||
/* Support for the right justified help menu */
|
/* Support for the right justified help menu */
|
||||||
if ((children == NULL) && (GTK_IS_MENU_ITEM(child))
|
if (children == NULL &&
|
||||||
&& (GTK_MENU_ITEM(child)->right_justify))
|
GTK_IS_MENU_ITEM (child) &&
|
||||||
{
|
GTK_MENU_ITEM (child)->priv->right_justify)
|
||||||
|
{
|
||||||
ltr_y = allocation->height -
|
ltr_y = allocation->height -
|
||||||
child_requisition.height - offset;
|
child_requisition.height - offset;
|
||||||
}
|
}
|
||||||
|
1133
gtk/gtkmenuitem.c
1133
gtk/gtkmenuitem.c
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* This library is distributed in the hope that it will be useful,
|
* This library is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
* Lesser General Public License for more details.
|
* Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
@ -36,43 +36,32 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GTK_TYPE_MENU_ITEM (gtk_menu_item_get_type ())
|
#define GTK_TYPE_MENU_ITEM (gtk_menu_item_get_type ())
|
||||||
#define GTK_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_ITEM, GtkMenuItem))
|
#define GTK_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_MENU_ITEM, GtkMenuItem))
|
||||||
#define GTK_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_ITEM, GtkMenuItemClass))
|
#define GTK_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_MENU_ITEM, GtkMenuItemClass))
|
||||||
#define GTK_IS_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_ITEM))
|
#define GTK_IS_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_MENU_ITEM))
|
||||||
#define GTK_IS_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_ITEM))
|
#define GTK_IS_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MENU_ITEM))
|
||||||
#define GTK_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU_ITEM, GtkMenuItemClass))
|
#define GTK_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_MENU_ITEM, GtkMenuItemClass))
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GtkMenuItem GtkMenuItem;
|
typedef struct _GtkMenuItem GtkMenuItem;
|
||||||
typedef struct _GtkMenuItemClass GtkMenuItemClass;
|
typedef struct _GtkMenuItemClass GtkMenuItemClass;
|
||||||
|
typedef struct _GtkMenuItemPrivate GtkMenuItemPrivate;
|
||||||
|
|
||||||
struct _GtkMenuItem
|
struct _GtkMenuItem
|
||||||
{
|
{
|
||||||
GtkBin bin;
|
GtkBin bin;
|
||||||
|
|
||||||
GtkWidget *GSEAL (submenu);
|
/*< private >*/
|
||||||
GdkWindow *GSEAL (event_window);
|
GtkMenuItemPrivate *priv;
|
||||||
|
|
||||||
guint16 GSEAL (toggle_size);
|
|
||||||
guint16 GSEAL (accelerator_width);
|
|
||||||
gchar *GSEAL (accel_path);
|
|
||||||
|
|
||||||
guint GSEAL (show_submenu_indicator) : 1;
|
|
||||||
guint GSEAL (submenu_placement) : 1;
|
|
||||||
guint GSEAL (submenu_direction) : 1;
|
|
||||||
guint GSEAL (right_justify): 1;
|
|
||||||
guint GSEAL (timer_from_keypress) : 1;
|
|
||||||
guint GSEAL (from_menubar) : 1;
|
|
||||||
guint GSEAL (timer);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkMenuItemClass
|
struct _GtkMenuItemClass
|
||||||
{
|
{
|
||||||
GtkBinClass parent_class;
|
GtkBinClass parent_class;
|
||||||
|
|
||||||
/* If the following flag is true, then we should always hide
|
/* If the following flag is true, then we should always
|
||||||
* the menu when the MenuItem is activated. Otherwise, the
|
* hide the menu when the MenuItem is activated. Otherwise,
|
||||||
* it is up to the caller. For instance, when navigating
|
* it is up to the caller. For instance, when navigating
|
||||||
* a menu with the keyboard, <Space> doesn't hide, but
|
* a menu with the keyboard, <Space> doesn't hide, but
|
||||||
* <Return> does.
|
* <Return> does.
|
||||||
@ -82,11 +71,11 @@ struct _GtkMenuItemClass
|
|||||||
void (* activate) (GtkMenuItem *menu_item);
|
void (* activate) (GtkMenuItem *menu_item);
|
||||||
void (* activate_item) (GtkMenuItem *menu_item);
|
void (* activate_item) (GtkMenuItem *menu_item);
|
||||||
void (* toggle_size_request) (GtkMenuItem *menu_item,
|
void (* toggle_size_request) (GtkMenuItem *menu_item,
|
||||||
gint *requisition);
|
gint *requisition);
|
||||||
void (* toggle_size_allocate) (GtkMenuItem *menu_item,
|
void (* toggle_size_allocate) (GtkMenuItem *menu_item,
|
||||||
gint allocation);
|
gint allocation);
|
||||||
void (* set_label) (GtkMenuItem *menu_item,
|
void (* set_label) (GtkMenuItem *menu_item,
|
||||||
const gchar *label);
|
const gchar *label);
|
||||||
G_CONST_RETURN gchar *(* get_label) (GtkMenuItem *menu_item);
|
G_CONST_RETURN gchar *(* get_label) (GtkMenuItem *menu_item);
|
||||||
|
|
||||||
void (* select) (GtkMenuItem *menu_item);
|
void (* select) (GtkMenuItem *menu_item);
|
||||||
@ -100,44 +89,36 @@ struct _GtkMenuItemClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
GType gtk_menu_item_get_type (void) G_GNUC_CONST;
|
GType gtk_menu_item_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GtkWidget* gtk_menu_item_new (void);
|
GtkWidget* gtk_menu_item_new (void);
|
||||||
GtkWidget* gtk_menu_item_new_with_label (const gchar *label);
|
GtkWidget* gtk_menu_item_new_with_label (const gchar *label);
|
||||||
GtkWidget* gtk_menu_item_new_with_mnemonic (const gchar *label);
|
GtkWidget* gtk_menu_item_new_with_mnemonic (const gchar *label);
|
||||||
void gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
|
void gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
|
||||||
GtkWidget *submenu);
|
GtkWidget *submenu);
|
||||||
GtkWidget* gtk_menu_item_get_submenu (GtkMenuItem *menu_item);
|
GtkWidget* gtk_menu_item_get_submenu (GtkMenuItem *menu_item);
|
||||||
void gtk_menu_item_select (GtkMenuItem *menu_item);
|
void gtk_menu_item_select (GtkMenuItem *menu_item);
|
||||||
void gtk_menu_item_deselect (GtkMenuItem *menu_item);
|
void gtk_menu_item_deselect (GtkMenuItem *menu_item);
|
||||||
void gtk_menu_item_activate (GtkMenuItem *menu_item);
|
void gtk_menu_item_activate (GtkMenuItem *menu_item);
|
||||||
void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
void gtk_menu_item_toggle_size_request (GtkMenuItem *menu_item,
|
||||||
gint *requisition);
|
gint *requisition);
|
||||||
void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
|
void gtk_menu_item_toggle_size_allocate (GtkMenuItem *menu_item,
|
||||||
gint allocation);
|
gint allocation);
|
||||||
void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item,
|
void gtk_menu_item_set_right_justified (GtkMenuItem *menu_item,
|
||||||
gboolean right_justified);
|
gboolean right_justified);
|
||||||
gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item);
|
gboolean gtk_menu_item_get_right_justified (GtkMenuItem *menu_item);
|
||||||
void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
|
void gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
|
||||||
const gchar *accel_path);
|
const gchar *accel_path);
|
||||||
G_CONST_RETURN gchar* gtk_menu_item_get_accel_path (GtkMenuItem *menu_item);
|
G_CONST_RETURN gchar* gtk_menu_item_get_accel_path (GtkMenuItem *menu_item);
|
||||||
|
|
||||||
void gtk_menu_item_set_label (GtkMenuItem *menu_item,
|
void gtk_menu_item_set_label (GtkMenuItem *menu_item,
|
||||||
const gchar *label);
|
const gchar *label);
|
||||||
G_CONST_RETURN gchar *gtk_menu_item_get_label (GtkMenuItem *menu_item);
|
G_CONST_RETURN gchar *gtk_menu_item_get_label (GtkMenuItem *menu_item);
|
||||||
|
|
||||||
void gtk_menu_item_set_use_underline (GtkMenuItem *menu_item,
|
void gtk_menu_item_set_use_underline (GtkMenuItem *menu_item,
|
||||||
gboolean setting);
|
gboolean setting);
|
||||||
gboolean gtk_menu_item_get_use_underline (GtkMenuItem *menu_item);
|
gboolean gtk_menu_item_get_use_underline (GtkMenuItem *menu_item);
|
||||||
|
|
||||||
/* private */
|
|
||||||
void _gtk_menu_item_refresh_accel_path (GtkMenuItem *menu_item,
|
|
||||||
const gchar *prefix,
|
|
||||||
GtkAccelGroup *accel_group,
|
|
||||||
gboolean group_changed);
|
|
||||||
gboolean _gtk_menu_item_is_selectable (GtkWidget *menu_item);
|
|
||||||
void _gtk_menu_item_popup_submenu (GtkWidget *menu_item,
|
|
||||||
gboolean with_delay);
|
|
||||||
void _gtk_menu_item_popdown_submenu (GtkWidget *menu_item);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
63
gtk/gtkmenuitemprivate.h
Normal file
63
gtk/gtkmenuitemprivate.h
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/* GTK - The GIMP Toolkit
|
||||||
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GTK_MENU_ITEM_PRIVATE_H__
|
||||||
|
#define __GTK_MENU_ITEM_PRIVATE_H__
|
||||||
|
|
||||||
|
#include <gtk/gtkmenuitem.h>
|
||||||
|
#include <gtk/gtkaction.h>
|
||||||
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
struct _GtkMenuItemPrivate
|
||||||
|
{
|
||||||
|
GtkWidget *submenu;
|
||||||
|
GdkWindow *event_window;
|
||||||
|
|
||||||
|
guint16 toggle_size;
|
||||||
|
guint16 accelerator_width;
|
||||||
|
gchar *accel_path;
|
||||||
|
|
||||||
|
guint show_submenu_indicator : 1;
|
||||||
|
guint submenu_placement : 1;
|
||||||
|
guint submenu_direction : 1;
|
||||||
|
guint right_justify : 1;
|
||||||
|
guint timer_from_keypress : 1;
|
||||||
|
guint from_menubar : 1;
|
||||||
|
guint use_action_appearance : 1;
|
||||||
|
|
||||||
|
guint timer;
|
||||||
|
|
||||||
|
GtkAction *action;
|
||||||
|
};
|
||||||
|
|
||||||
|
void _gtk_menu_item_refresh_accel_path (GtkMenuItem *menu_item,
|
||||||
|
const gchar *prefix,
|
||||||
|
GtkAccelGroup *accel_group,
|
||||||
|
gboolean group_changed);
|
||||||
|
gboolean _gtk_menu_item_is_selectable (GtkWidget *menu_item);
|
||||||
|
void _gtk_menu_item_popup_submenu (GtkWidget *menu_item,
|
||||||
|
gboolean with_delay);
|
||||||
|
void _gtk_menu_item_popdown_submenu (GtkWidget *menu_item);
|
||||||
|
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GTK_MENU_ITEM_PRIVATE_H__ */
|
@ -32,7 +32,7 @@
|
|||||||
#include "gtkmain.h"
|
#include "gtkmain.h"
|
||||||
#include "gtkmarshalers.h"
|
#include "gtkmarshalers.h"
|
||||||
#include "gtkmenubar.h"
|
#include "gtkmenubar.h"
|
||||||
#include "gtkmenuitem.h"
|
#include "gtkmenuitemprivate.h"
|
||||||
#include "gtkmenushellprivate.h"
|
#include "gtkmenushellprivate.h"
|
||||||
#include "gtkmenuprivate.h"
|
#include "gtkmenuprivate.h"
|
||||||
#include "gtkmnemonichash.h"
|
#include "gtkmnemonichash.h"
|
||||||
@ -645,9 +645,10 @@ gtk_menu_shell_button_press (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu_item && _gtk_menu_item_is_selectable (menu_item) &&
|
if (menu_item &&
|
||||||
GTK_MENU_ITEM (menu_item)->submenu != NULL &&
|
_gtk_menu_item_is_selectable (menu_item) &&
|
||||||
!gtk_widget_get_visible (GTK_MENU_ITEM (menu_item)->submenu))
|
GTK_MENU_ITEM (menu_item)->priv->submenu != NULL &&
|
||||||
|
!gtk_widget_get_visible (GTK_MENU_ITEM (menu_item)->priv->submenu))
|
||||||
{
|
{
|
||||||
_gtk_menu_item_popup_submenu (menu_item, FALSE);
|
_gtk_menu_item_popup_submenu (menu_item, FALSE);
|
||||||
priv->activated_submenu = TRUE;
|
priv->activated_submenu = TRUE;
|
||||||
@ -701,7 +702,7 @@ gtk_menu_shell_button_release (GtkWidget *widget,
|
|||||||
if (menu_item && (priv->active_menu_item == menu_item) &&
|
if (menu_item && (priv->active_menu_item == menu_item) &&
|
||||||
_gtk_menu_item_is_selectable (menu_item))
|
_gtk_menu_item_is_selectable (menu_item))
|
||||||
{
|
{
|
||||||
GtkWidget *submenu = GTK_MENU_ITEM (menu_item)->submenu;
|
GtkWidget *submenu = GTK_MENU_ITEM (menu_item)->priv->submenu;
|
||||||
|
|
||||||
if (submenu == NULL)
|
if (submenu == NULL)
|
||||||
{
|
{
|
||||||
@ -955,11 +956,11 @@ gtk_menu_shell_enter_notify (GtkWidget *widget,
|
|||||||
* its submenu.
|
* its submenu.
|
||||||
*/
|
*/
|
||||||
if ((event->state & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK)) &&
|
if ((event->state & (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK)) &&
|
||||||
GTK_MENU_ITEM (menu_item)->submenu != NULL)
|
GTK_MENU_ITEM (menu_item)->priv->submenu != NULL)
|
||||||
{
|
{
|
||||||
GTK_MENU_SHELL (parent)->priv->activated_submenu = TRUE;
|
GTK_MENU_SHELL (parent)->priv->activated_submenu = TRUE;
|
||||||
|
|
||||||
if (!gtk_widget_get_visible (GTK_MENU_ITEM (menu_item)->submenu))
|
if (!gtk_widget_get_visible (GTK_MENU_ITEM (menu_item)->priv->submenu))
|
||||||
{
|
{
|
||||||
gboolean touchscreen_mode;
|
gboolean touchscreen_mode;
|
||||||
|
|
||||||
@ -1010,7 +1011,7 @@ gtk_menu_shell_leave_notify (GtkWidget *widget,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((priv->active_menu_item == event_widget) &&
|
if ((priv->active_menu_item == event_widget) &&
|
||||||
(menu_item->submenu == NULL))
|
(menu_item->priv->submenu == NULL))
|
||||||
{
|
{
|
||||||
if ((event->detail != GDK_NOTIFY_INFERIOR) &&
|
if ((event->detail != GDK_NOTIFY_INFERIOR) &&
|
||||||
(gtk_widget_get_state (GTK_WIDGET (menu_item)) != GTK_STATE_NORMAL))
|
(gtk_widget_get_state (GTK_WIDGET (menu_item)) != GTK_STATE_NORMAL))
|
||||||
@ -1225,7 +1226,7 @@ gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
|
|||||||
/* This allows the bizarre radio buttons-with-submenus-display-history
|
/* This allows the bizarre radio buttons-with-submenus-display-history
|
||||||
* behavior
|
* behavior
|
||||||
*/
|
*/
|
||||||
if (GTK_MENU_ITEM (priv->active_menu_item)->submenu)
|
if (GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu)
|
||||||
gtk_widget_activate (priv->active_menu_item);
|
gtk_widget_activate (priv->active_menu_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1447,11 +1448,11 @@ gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
|
|||||||
|
|
||||||
menu_item = GTK_MENU_ITEM (priv->active_menu_item);
|
menu_item = GTK_MENU_ITEM (priv->active_menu_item);
|
||||||
|
|
||||||
if (menu_item->submenu)
|
if (menu_item->priv->submenu)
|
||||||
{
|
{
|
||||||
_gtk_menu_item_popup_submenu (GTK_WIDGET (menu_item), FALSE);
|
_gtk_menu_item_popup_submenu (GTK_WIDGET (menu_item), FALSE);
|
||||||
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE);
|
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->priv->submenu), TRUE);
|
||||||
if (GTK_MENU_SHELL (menu_item->submenu)->priv->active_menu_item)
|
if (GTK_MENU_SHELL (menu_item->priv->submenu)->priv->active_menu_item)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1483,8 +1484,8 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
|
|||||||
case GTK_MENU_DIR_PARENT:
|
case GTK_MENU_DIR_PARENT:
|
||||||
if (touchscreen_mode &&
|
if (touchscreen_mode &&
|
||||||
priv->active_menu_item &&
|
priv->active_menu_item &&
|
||||||
GTK_MENU_ITEM (priv->active_menu_item)->submenu &&
|
GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu &&
|
||||||
gtk_widget_get_visible (GTK_MENU_ITEM (priv->active_menu_item)->submenu))
|
gtk_widget_get_visible (GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu))
|
||||||
{
|
{
|
||||||
/* if we are on a menu item that has an open submenu but the
|
/* if we are on a menu item that has an open submenu but the
|
||||||
* focus is not in that submenu (e.g. because it's empty or
|
* focus is not in that submenu (e.g. because it's empty or
|
||||||
@ -1522,9 +1523,9 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
|
|||||||
*/
|
*/
|
||||||
else if (priv->active_menu_item &&
|
else if (priv->active_menu_item &&
|
||||||
_gtk_menu_item_is_selectable (priv->active_menu_item) &&
|
_gtk_menu_item_is_selectable (priv->active_menu_item) &&
|
||||||
GTK_MENU_ITEM (priv->active_menu_item)->submenu)
|
GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu)
|
||||||
{
|
{
|
||||||
GtkMenuShell *submenu = GTK_MENU_SHELL (GTK_MENU_ITEM (priv->active_menu_item)->submenu);
|
GtkMenuShell *submenu = GTK_MENU_SHELL (GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu);
|
||||||
|
|
||||||
if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement !=
|
if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement !=
|
||||||
GTK_MENU_SHELL_GET_CLASS (submenu)->submenu_placement)
|
GTK_MENU_SHELL_GET_CLASS (submenu)->submenu_placement)
|
||||||
@ -1535,7 +1536,7 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
|
|||||||
case GTK_MENU_DIR_CHILD:
|
case GTK_MENU_DIR_CHILD:
|
||||||
if (priv->active_menu_item &&
|
if (priv->active_menu_item &&
|
||||||
_gtk_menu_item_is_selectable (priv->active_menu_item) &&
|
_gtk_menu_item_is_selectable (priv->active_menu_item) &&
|
||||||
GTK_MENU_ITEM (priv->active_menu_item)->submenu)
|
GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu)
|
||||||
{
|
{
|
||||||
if (gtk_menu_shell_select_submenu_first (menu_shell))
|
if (gtk_menu_shell_select_submenu_first (menu_shell))
|
||||||
break;
|
break;
|
||||||
@ -1562,17 +1563,13 @@ gtk_real_menu_shell_move_current (GtkMenuShell *menu_shell,
|
|||||||
|
|
||||||
case GTK_MENU_DIR_PREV:
|
case GTK_MENU_DIR_PREV:
|
||||||
gtk_menu_shell_move_selected (menu_shell, -1);
|
gtk_menu_shell_move_selected (menu_shell, -1);
|
||||||
if (!had_selection &&
|
if (!had_selection && !priv->active_menu_item && priv->children)
|
||||||
!priv->active_menu_item &&
|
|
||||||
priv->children)
|
|
||||||
_gtk_menu_shell_select_last (menu_shell, TRUE);
|
_gtk_menu_shell_select_last (menu_shell, TRUE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_MENU_DIR_NEXT:
|
case GTK_MENU_DIR_NEXT:
|
||||||
gtk_menu_shell_move_selected (menu_shell, 1);
|
gtk_menu_shell_move_selected (menu_shell, 1);
|
||||||
if (!had_selection &&
|
if (!had_selection && !priv->active_menu_item && priv->children)
|
||||||
!priv->active_menu_item &&
|
|
||||||
priv->children)
|
|
||||||
gtk_menu_shell_select_first (menu_shell, TRUE);
|
gtk_menu_shell_select_first (menu_shell, TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1587,7 +1584,7 @@ gtk_real_menu_shell_activate_current (GtkMenuShell *menu_shell,
|
|||||||
if (priv->active_menu_item &&
|
if (priv->active_menu_item &&
|
||||||
_gtk_menu_item_is_selectable (priv->active_menu_item))
|
_gtk_menu_item_is_selectable (priv->active_menu_item))
|
||||||
{
|
{
|
||||||
if (GTK_MENU_ITEM (priv->active_menu_item)->submenu == NULL)
|
if (GTK_MENU_ITEM (priv->active_menu_item)->priv->submenu == NULL)
|
||||||
gtk_menu_shell_activate_item (menu_shell,
|
gtk_menu_shell_activate_item (menu_shell,
|
||||||
priv->active_menu_item,
|
priv->active_menu_item,
|
||||||
force_hide);
|
force_hide);
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gtkmenuprivate.h"
|
#include "gtkmenuprivate.h"
|
||||||
|
#include "gtkmenuitemprivate.h"
|
||||||
#include "gtktearoffmenuitem.h"
|
#include "gtktearoffmenuitem.h"
|
||||||
#include "gtkintl.h"
|
#include "gtkintl.h"
|
||||||
|
|
||||||
@ -186,28 +187,30 @@ gtk_tearoff_menu_item_draw (GtkWidget *widget,
|
|||||||
else
|
else
|
||||||
shadow_type = GTK_SHADOW_OUT;
|
shadow_type = GTK_SHADOW_OUT;
|
||||||
|
|
||||||
if (menu_item->toggle_size > ARROW_SIZE)
|
if (menu_item->priv->toggle_size > ARROW_SIZE)
|
||||||
{
|
{
|
||||||
if (direction == GTK_TEXT_DIR_LTR) {
|
if (direction == GTK_TEXT_DIR_LTR) {
|
||||||
arrow_x = x + (menu_item->toggle_size - ARROW_SIZE)/2;
|
arrow_x = x + (menu_item->priv->toggle_size - ARROW_SIZE)/2;
|
||||||
arrow_type = GTK_ARROW_LEFT;
|
arrow_type = GTK_ARROW_LEFT;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arrow_x = x + width - menu_item->toggle_size + (menu_item->toggle_size - ARROW_SIZE)/2;
|
arrow_x = x + width - menu_item->priv->toggle_size + (menu_item->priv->toggle_size - ARROW_SIZE)/2;
|
||||||
arrow_type = GTK_ARROW_RIGHT;
|
arrow_type = GTK_ARROW_RIGHT;
|
||||||
}
|
}
|
||||||
x += menu_item->toggle_size + BORDER_SPACING;
|
x += menu_item->priv->toggle_size + BORDER_SPACING;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (direction == GTK_TEXT_DIR_LTR) {
|
if (direction == GTK_TEXT_DIR_LTR)
|
||||||
arrow_x = ARROW_SIZE / 2;
|
{
|
||||||
arrow_type = GTK_ARROW_LEFT;
|
arrow_x = ARROW_SIZE / 2;
|
||||||
}
|
arrow_type = GTK_ARROW_LEFT;
|
||||||
else {
|
}
|
||||||
arrow_x = x + width - 2 * ARROW_SIZE + ARROW_SIZE / 2;
|
else
|
||||||
arrow_type = GTK_ARROW_RIGHT;
|
{
|
||||||
}
|
arrow_x = x + width - 2 * ARROW_SIZE + ARROW_SIZE / 2;
|
||||||
|
arrow_type = GTK_ARROW_RIGHT;
|
||||||
|
}
|
||||||
x += 2 * ARROW_SIZE;
|
x += 2 * ARROW_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user