Add private accessors to some GntMenu internals.
--- a/gntmain.c Thu Apr 25 03:42:09 2019 -0400
+++ b/gntmain.c Wed Apr 24 01:05:07 2019 -0400
@@ -50,6 +50,7 @@
+#include "gntmenuprivate.h" #include "gntwsprivate.h"
@@ -497,7 +498,7 @@
gnt_widget_hide(GNT_WIDGET(wm->menu));
- wm->menu = wm->menu->parentmenu;
+ wm->menu = gnt_menu_get_parent_menu(wm->menu); --- a/gntmenu.c Thu Apr 25 03:42:09 2019 -0400
+++ b/gntmenu.c Wed Apr 24 01:05:07 2019 -0400
@@ -527,3 +527,34 @@
+gnt_menu_get_menutype(GntMenu *menu) + g_return_val_if_fail(GNT_IS_MENU(menu), 0); +gnt_menu_get_selected_item(GntMenu *menu) + g_return_val_if_fail(GNT_IS_MENU(menu), NULL); + return g_list_nth_data(menu->list, menu->selected); +gnt_menu_get_parent_menu(GntMenu *menu) + g_return_val_if_fail(GNT_IS_MENU(menu), NULL); + return menu->parentmenu; +gnt_menu_get_submenu(GntMenu *menu) + g_return_val_if_fail(GNT_IS_MENU(menu), NULL); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gntmenuprivate.h Wed Apr 24 01:05:07 2019 -0400
@@ -0,0 +1,39 @@
+ * GNT - The GLib Ncurses Toolkit + * GNT is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * This library is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * This program 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 General Public License for more details. + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifndef GNT_MENU_PRIVATE_H +#define GNT_MENU_PRIVATE_H +/* Private access to some internals. Contact us if you need these. */ +GntMenuType gnt_menu_get_menutype(GntMenu *menu); +GntMenuItem *gnt_menu_get_selected_item(GntMenu *menu); +GntMenu *gnt_menu_get_parent_menu(GntMenu *menu); +GntMenu *gnt_menu_get_submenu(GntMenu *menu); +#endif /* GNT_MENU_PRIVATE_H */ --- a/gntwindow.c Thu Apr 25 03:42:09 2019 -0400
+++ b/gntwindow.c Wed Apr 24 01:05:07 2019 -0400
@@ -24,6 +24,8 @@
+#include "gntmenuprivate.h" @@ -56,9 +58,8 @@
GntMenu *menu = priv->menu;
gnt_screen_menu_show(menu);
- if (menu->type == GNT_MENU_TOPLEVEL) {
- item = g_list_nth_data(menu->list, menu->selected);
+ if (gnt_menu_get_menutype(menu) == GNT_MENU_TOPLEVEL) { + GntMenuItem *item = gnt_menu_get_selected_item(menu); if (item && gnt_menuitem_get_submenu(item)) {
gnt_widget_activate(GNT_WIDGET(menu));
--- a/gntwm.c Thu Apr 25 03:42:09 2019 -0400
+++ b/gntwm.c Wed Apr 24 01:05:07 2019 -0400
@@ -60,6 +60,7 @@
+#include "gntmenuprivate.h" #include "gntwsprivate.h"
#define IDLE_CHECK_INTERVAL 5 /* 5 seconds */
@@ -237,7 +238,7 @@
GntNode *node = g_hash_table_lookup(wm->nodes, top);
+ top = gnt_menu_get_submenu(top); work_around_for_ncurses_bug();