Merged in default (pull request #45)
Hide GntMenu internals
Approved-by: Gary Kramlich
--- a/gntmain.c Wed Apr 24 03:44:25 2019 -0400
+++ b/gntmain.c Fri Apr 26 03:42:29 2019 +0000
@@ -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 Wed Apr 24 03:44:25 2019 -0400
+++ b/gntmenu.c Fri Apr 26 03:42:29 2019 +0000
@@ -29,6 +29,20 @@
+ /* This will keep track of its immediate submenu which is visible so + * that keystrokes can be passed to it. */ @@ -551,3 +565,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); --- a/gntmenu.h Wed Apr 24 03:44:25 2019 -0400
+++ b/gntmenu.h Fri Apr 26 03:42:29 2019 +0000
@@ -35,15 +35,9 @@
-#define GNT_TYPE_MENU (gnt_menu_get_type())
-#define GNT_MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_MENU, GntMenu))
-#define GNT_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_MENU, GntMenuClass))
-#define GNT_IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_MENU))
-#define GNT_IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_MENU))
-#define GNT_MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_MENU, GntMenuClass))
+#define GNT_TYPE_MENU gnt_menu_get_type() typedef struct _GntMenu GntMenu;
-typedef struct _GntMenuClass GntMenuClass;
@@ -62,36 +56,6 @@
- * Access to any fields is deprecated. See inline comments for replacements.
- GntMenuType GNTSEAL(type);
- guint GNTSEAL(selected);
- /* This will keep track of its immediate submenu which is visible so that
- * keystrokes can be passed to it. */
- GntMenu *GNTSEAL(submenu);
- GntMenu *GNTSEAL(parentmenu);
- void (*gnt_reserved1)(void);
- void (*gnt_reserved2)(void);
- void (*gnt_reserved3)(void);
- void (*gnt_reserved4)(void);
@@ -99,7 +63,7 @@
* Returns: The GType for GntMenu.
-GType gnt_menu_get_type(void);
+G_DECLARE_FINAL_TYPE(GntMenu, gnt_menu, GNT, MENU, GntTree) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gntmenuprivate.h Fri Apr 26 03:42:29 2019 +0000
@@ -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 Wed Apr 24 03:44:25 2019 -0400
+++ b/gntwindow.c Fri Apr 26 03:42:29 2019 +0000
@@ -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 Wed Apr 24 03:44:25 2019 -0400
+++ b/gntwm.c Fri Apr 26 03:42:29 2019 +0000
@@ -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();