summaryrefslogtreecommitdiff
path: root/gtk/gtkoptionmenu.c
diff options
context:
space:
mode:
authorAlexander Larsson <alla@lysator.liu.se>2001-09-17 02:19:01 +0000
committerAlexander Larsson <alexl@src.gnome.org>2001-09-17 02:19:01 +0000
commit9c7f0f8c2abd8aac5b0697bfd40eede1e60461d7 (patch)
tree050275045446e8e09fa5bd759694eb9215edd5fc /gtk/gtkoptionmenu.c
parent136d4776ec3f6877cbfce53cdaa9917be5530fe7 (diff)
downloadgtk+-9c7f0f8c2abd8aac5b0697bfd40eede1e60461d7.tar.gz
Handle scroll wheel events.
2001-09-16 Alexander Larsson <alla@lysator.liu.se> * gtk/gtkoptionmenu.c: Handle scroll wheel events.
Diffstat (limited to 'gtk/gtkoptionmenu.c')
-rw-r--r--gtk/gtkoptionmenu.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gtk/gtkoptionmenu.c b/gtk/gtkoptionmenu.c
index 3af74664ad..6e8f10e856 100644
--- a/gtk/gtkoptionmenu.c
+++ b/gtk/gtkoptionmenu.c
@@ -80,6 +80,8 @@ static void gtk_option_menu_position (GtkMenu *menu,
static void gtk_option_menu_show_all (GtkWidget *widget);
static void gtk_option_menu_hide_all (GtkWidget *widget);
static GtkType gtk_option_menu_child_type (GtkContainer *container);
+static gint gtk_option_menu_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event);
enum
{
@@ -147,6 +149,7 @@ gtk_option_menu_class_init (GtkOptionMenuClass *class)
widget_class->expose_event = gtk_option_menu_expose;
widget_class->button_press_event = gtk_option_menu_button_press;
widget_class->key_press_event = gtk_option_menu_key_press;
+ widget_class->scroll_event = gtk_option_menu_scroll_event;
widget_class->show_all = gtk_option_menu_show_all;
widget_class->hide_all = gtk_option_menu_hide_all;
@@ -883,3 +886,49 @@ gtk_option_menu_hide_all (GtkWidget *widget)
gtk_container_foreach (container, (GtkCallback) gtk_widget_hide_all, NULL);
}
+static gint
+gtk_option_menu_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event)
+{
+ GtkOptionMenu *option_menu = GTK_OPTION_MENU (widget);
+ gint index;
+ gint n_children;
+ gint index_dir;
+ GList *l;
+ GtkMenuItem *item;
+
+ index = gtk_option_menu_get_history (option_menu);
+
+ if (index != -1)
+ {
+ n_children = g_list_length (GTK_MENU_SHELL (option_menu->menu)->children);
+
+ if (event->direction == GDK_SCROLL_UP)
+ index_dir = -1;
+ else
+ index_dir = 1;
+
+
+ while (TRUE)
+ {
+ index += index_dir;
+
+ if (index < 0)
+ break;
+ if (index >= n_children)
+ break;
+
+ l = g_list_nth (GTK_MENU_SHELL (option_menu->menu)->children, index);
+ item = GTK_MENU_ITEM (l->data);
+ if (GTK_WIDGET_VISIBLE (item) && GTK_WIDGET_IS_SENSITIVE (item))
+ {
+ gtk_option_menu_set_history (option_menu, index);
+ break;
+ }
+
+ }
+ }
+
+ return TRUE;
+}
+