Commit 4e1ac87b authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

add move_selected signal to allow overriding the default internal

2007-06-15  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkmenushell.[ch]: add move_selected signal to allow
        overriding the default internal behaviour.  (#446833, Ryan Lortie)



svn path=/trunk/; revision=18145
parent a34dfc3c
2007-06-15 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkmenushell.[ch]: add move_selected signal to allow
overriding the default internal behaviour. (#446833, Ryan Lortie)
2007-06-15 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* gtk/gtkwidget.c: Forgot to free the unescaped tooltip text.
......
......@@ -57,6 +57,7 @@ enum {
ACTIVATE_CURRENT,
CANCEL,
CYCLE_FOCUS,
MOVE_SELECTED,
LAST_SIGNAL
};
......@@ -193,6 +194,8 @@ static void gtk_real_menu_shell_cycle_focus (GtkMenuShell *menu_shell,
static void gtk_menu_shell_reset_key_hash (GtkMenuShell *menu_shell);
static gboolean gtk_menu_shell_activate_mnemonic (GtkMenuShell *menu_shell,
GdkEventKey *event);
static gboolean gtk_menu_shell_real_move_selected (GtkMenuShell *menu_shell,
gint distance);
static guint menu_shell_signals[LAST_SIGNAL] = { 0 };
......@@ -237,6 +240,7 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
klass->cancel = gtk_real_menu_shell_cancel;
klass->select_item = gtk_menu_shell_real_select_item;
klass->insert = gtk_menu_shell_real_insert;
klass->move_selected = gtk_menu_shell_real_move_selected;
menu_shell_signals[DEACTIVATE] =
g_signal_new (I_("deactivate"),
......@@ -289,7 +293,15 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
_gtk_marshal_VOID__ENUM,
G_TYPE_NONE, 1,
GTK_TYPE_DIRECTION_TYPE);
menu_shell_signals[MOVE_SELECTED] =
g_signal_new (I_("move_selected"),
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkMenuShellClass, move_selected),
_gtk_boolean_handled_accumulator, NULL,
_gtk_marshal_BOOLEAN__INT,
G_TYPE_BOOLEAN, 1,
G_TYPE_INT);
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set,
......@@ -1132,9 +1144,9 @@ gtk_menu_shell_activate_item (GtkMenuShell *menu_shell,
}
/* Distance should be +/- 1 */
static void
gtk_menu_shell_move_selected (GtkMenuShell *menu_shell,
gint distance)
static gboolean
gtk_menu_shell_real_move_selected (GtkMenuShell *menu_shell,
gint distance)
{
if (menu_shell->active_menu_item)
{
......@@ -1185,6 +1197,19 @@ gtk_menu_shell_move_selected (GtkMenuShell *menu_shell,
if (node)
gtk_menu_shell_select_item (menu_shell, node->data);
}
return TRUE;
}
/* Distance should be +/- 1 */
static void
gtk_menu_shell_move_selected (GtkMenuShell *menu_shell,
gint distance)
{
gboolean handled = FALSE;
g_signal_emit (menu_shell, menu_shell_signals[MOVE_SELECTED], 0,
distance, &handled);
}
/**
......@@ -1261,6 +1286,9 @@ gtk_menu_shell_select_submenu_first (GtkMenuShell *menu_shell)
{
GtkMenuItem *menu_item;
if (menu_shell->active_menu_item == NULL)
return FALSE;
menu_item = GTK_MENU_ITEM (menu_shell->active_menu_item);
if (menu_item->submenu)
......
......@@ -84,11 +84,12 @@ struct _GtkMenuShellClass
GtkWidget *child,
gint position);
gint (*get_popup_delay) (GtkMenuShell *menu_shell);
gboolean (*move_selected) (GtkMenuShell *menu_shell,
gint distance);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
};
......
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