changeset 21260:084c5d5472ad

Fix menu hiding.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sun, 21 Oct 2007 08:40:42 +0000
parents 512da37d0b4f
children 7f1910f62246
files finch/libgnt/gntmenu.c
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntmenu.c	Sat Oct 20 05:55:44 2007 +0000
+++ b/finch/libgnt/gntmenu.c	Sun Oct 21 08:40:42 2007 +0000
@@ -48,6 +48,14 @@
 static gboolean (*org_key_pressed)(GntWidget *w, const char *t);
 
 static void
+menu_hide_all(GntMenu *menu)
+{
+	while (menu->parentmenu)
+		menu = menu->parentmenu;
+	gnt_widget_hide(GNT_WIDGET(menu));
+}
+
+static void
 gnt_menu_draw(GntWidget *widget)
 {
 	GntMenu *menu = GNT_MENU(widget);
@@ -185,10 +193,7 @@
 		return;
 
 	if (gnt_menuitem_activate(item)) {
-		while (menu) {
-			gnt_widget_hide(GNT_WIDGET(menu));
-			menu = menu->parentmenu;
-		}
+		menu_hide_all(menu);
 	} else {
 		if (item->submenu) {
 			GntMenu *sub = GNT_MENU(item->submenu);
@@ -203,6 +208,8 @@
 			gnt_widget_set_position(GNT_WIDGET(sub), item->priv.x, item->priv.y);
 			GNT_WIDGET_UNSET_FLAGS(GNT_WIDGET(sub), GNT_WIDGET_INVISIBLE);
 			gnt_widget_draw(GNT_WIDGET(sub));
+		} else {
+			menu_hide_all(menu);
 		}
 	}
 }
@@ -288,10 +295,8 @@
 
 		if (current != menu->selected) {
 			GntMenu *sub = menu->submenu;
-			while (sub) {
+			if (sub)
 				gnt_widget_hide(GNT_WIDGET(sub));
-				sub = sub->submenu;
-			}
 			gnt_widget_draw(widget);
 			return TRUE;
 		}