changeset 22309:07073da46dd5

Single clicking a menuitem should activate it.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 17 Feb 2008 17:26:37 +0000
parents 3867cef6a0d5
children f463d54e606b
files finch/libgnt/gntmenu.c
diffstat 1 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntmenu.c	Sun Feb 17 17:15:40 2008 +0000
+++ b/finch/libgnt/gntmenu.c	Sun Feb 17 17:26:37 2008 +0000
@@ -46,6 +46,7 @@
 static void (*org_map)(GntWidget *wid);
 static void (*org_size_request)(GntWidget *wid);
 static gboolean (*org_key_pressed)(GntWidget *w, const char *t);
+static gboolean (*org_clicked)(GntWidget *w, GntMouseEvent event, int x, int y);
 
 static void menuitem_activate(GntMenu *menu, GntMenuItem *item);
 
@@ -390,6 +391,16 @@
 		menu->parentmenu->submenu = NULL;
 }
 
+static gboolean
+gnt_menu_clicked(GntWidget *widget, GntMouseEvent event, int x, int y)
+{
+	if (!org_clicked || !org_clicked(widget, event, x, y) ||
+			!GNT_MENU(widget)->type == GNT_MENU_TOPLEVEL)
+			return FALSE;
+	gnt_widget_activate(widget);
+	return TRUE;
+}
+
 static void
 gnt_menu_class_init(GntMenuClass *klass)
 {
@@ -401,6 +412,7 @@
 	org_draw = wid_class->draw;
 	org_key_pressed = wid_class->key_pressed;
 	org_size_request = wid_class->size_request;
+	org_clicked = wid_class->clicked;
 
 	wid_class->destroy = gnt_menu_destroy;
 	wid_class->draw = gnt_menu_draw;
@@ -409,6 +421,7 @@
 	wid_class->key_pressed = gnt_menu_key_pressed;
 	wid_class->activate = gnt_menu_activate;
 	wid_class->hide = gnt_menu_hide;
+	wid_class->clicked = gnt_menu_clicked;
 
 	parent_class->toggled = gnt_menu_toggled;