--- a/gnt.h Fri Apr 25 16:55:07 2014 +0530
+++ b/gnt.h Tue Apr 29 03:19:51 2014 +0530
@@ -64,6 +64,8 @@
* You have to call this before #gnt_init. You might want to call this
* with %NULL, to free the resources, but not before a call to #gnt_quit.
void gnt_set_config_dir(const gchar *config_dir);
--- a/gntbox.c Fri Apr 25 16:55:07 2014 +0530
+++ b/gntbox.c Tue Apr 29 03:19:51 2014 +0530
@@ -677,6 +677,12 @@
widget->parent = GNT_WIDGET(b);
+void gnt_box_add_widget_in_front(GntBox *b, GntWidget *widget) + b->list = g_list_prepend(b->list, widget); + widget->parent = GNT_WIDGET(b); void gnt_box_set_title(GntBox *b, const char *title)
--- a/gntbox.h Fri Apr 25 16:55:07 2014 +0530
+++ b/gntbox.h Tue Apr 29 03:19:51 2014 +0530
@@ -125,6 +125,17 @@
void gnt_box_add_widget(GntBox *box, GntWidget *widget);
+ * gnt_box_add_widget_in_front: + * @widget: The widget to add + * Add a widget in the box at its front. +void gnt_box_add_widget_in_front(GntBox *b, GntWidget *widget); * @title: The title to set
--- a/gntcolors.c Fri Apr 25 16:55:07 2014 +0530
+++ b/gntcolors.c Tue Apr 29 03:19:51 2014 +0530
@@ -177,10 +177,15 @@
- char **keys = g_key_file_get_keys(kfile, "colors", &nkeys, &error);
+ if (!g_key_file_has_group(kfile, "colors")) { + gnt_color_pairs_parse(kfile); + keys = g_key_file_get_keys(kfile, "colors", &nkeys, &error); gnt_warning("%s", error->message);
@@ -223,8 +228,12 @@
- char **keys = g_key_file_get_keys(kfile, "colorpairs", &nkeys, &error);
+ if (!g_key_file_has_group(kfile, "colorpairs")) + keys = g_key_file_get_keys(kfile, "colorpairs", &nkeys, &error); gnt_warning("%s", error->message);
--- a/gntmain.c Fri Apr 25 16:55:07 2014 +0530
+++ b/gntmain.c Tue Apr 29 03:19:51 2014 +0530
@@ -466,7 +466,9 @@
g_io_channel_unref(channel);
gnt_warning("setting up IO (%d)", channel_read_callback);
--- a/gntmenu.c Fri Apr 25 16:55:07 2014 +0530
+++ b/gntmenu.c Tue Apr 29 03:19:51 2014 +0530
@@ -87,7 +87,13 @@
for (i = 0, iter = menu->list; iter; iter = iter->next, i++) {
GntMenuItem *item = GNT_MENU_ITEM(iter->data);
- type = ' ' | gnt_color_pair(GNT_COLOR_HIGHLIGHT);
+ if (!gnt_menuitem_is_visible(item)) + if (item->callback || item->submenu) + type |= gnt_color_pair(GNT_COLOR_HIGHLIGHT); + type |= gnt_color_pair(GNT_COLOR_DISABLED); item->priv.x = getcurx(widget->window) + widget->priv.x;
@@ -119,7 +125,7 @@
menu_tree_add(GntMenu *menu, GntMenuItem *item, GntMenuItem *parent)
- char trigger[4] = "\0 )\0";
+ char trigger[] = "\0 )\0"; g_return_if_fail(item != NULL);
@@ -130,9 +136,12 @@
gnt_tree_add_choice(GNT_TREE(menu), item,
gnt_tree_create_row(GNT_TREE(menu), item->text, trigger, " "), parent, NULL);
gnt_tree_set_choice(GNT_TREE(menu), item, gnt_menuitem_check_get_checked(GNT_MENU_ITEM_CHECK(item)));
gnt_tree_add_row_last(GNT_TREE(menu), item,
gnt_tree_create_row(GNT_TREE(menu), item->text, trigger, item->submenu ? ">" : " "), parent);
+ if (!item->callback && !item->submenu) + gnt_tree_set_row_color(GNT_TREE(menu), item, GNT_COLOR_DISABLED); if (0 && item->submenu) {
GntMenu *sub = GNT_MENU(item->submenu);
@@ -305,15 +314,25 @@
if (menu->type == GNT_MENU_TOPLEVEL) {
if (strcmp(text, GNT_KEY_LEFT) == 0) {
- if (menu->selected == 0)
- menu->selected = g_list_length(menu->list) - 1;
+ if (menu->selected == 0) + menu->selected = g_list_length(menu->list) - 1; + it = g_list_nth(menu->list, menu->selected); + item = it ? it->data : NULL; + } while (!gnt_menuitem_is_visible(item)); } else if (strcmp(text, GNT_KEY_RIGHT) == 0) {
- if (menu->selected >= g_list_length(menu->list))
+ if (menu->selected >= g_list_length(menu->list)) + it = g_list_nth(menu->list, menu->selected); + item = it ? it->data : NULL; + } while (!gnt_menuitem_is_visible(item)); } else if (strcmp(text, GNT_KEY_ENTER) == 0 ||
strcmp(text, GNT_KEY_DOWN) == 0) {
gnt_widget_activate(widget);
--- a/gntmenuitem.c Fri Apr 25 16:55:07 2014 +0530
+++ b/gntmenuitem.c Tue Apr 29 03:19:51 2014 +0530
@@ -65,6 +65,14 @@
gnt_menuitem_init(GTypeInstance *instance, gpointer klass)
+ GntMenuItem *item = GNT_MENU_ITEM(instance); + GntMenuItemPriv *priv = &item->priv; /******************************************************************************
@@ -157,3 +165,33 @@
+gnt_menuitem_set_visible(GntMenuItem *item, gboolean visible) + GntMenuItemPriv *priv = &item->priv; + priv->visible = visible; + item->visible = visible; +gnt_menuitem_is_visible(GntMenuItem *item) + g_return_val_if_fail(GNT_IS_MENU_ITEM(item), FALSE); + return item->priv.visible; +gnt_menuitem_set_text(GntMenuItem *item, const gchar *text) + item->text = g_strdup(text); --- a/gntmenuitem.h Fri Apr 25 16:55:07 2014 +0530
+++ b/gntmenuitem.h Tue Apr 29 03:19:51 2014 +0530
@@ -74,6 +74,9 @@
GntMenuItemCallback callback;
@@ -195,6 +198,43 @@
gboolean gnt_menuitem_activate(GntMenuItem *item);
+ * gnt_menuitem_set_visible: + * @visible: %TRUE to make @item visible, %FALSE to hide it. + * Sets @item visible or not. +gnt_menuitem_set_visible(GntMenuItem *item, gboolean visible); + * gnt_menuitem_is_visible: + * Checks, if the @item is visible. + * Returns: %TRUE, if the @item is visible. +gnt_menuitem_is_visible(GntMenuItem *item); + * gnt_menuitem_set_text: + * Changes the text for an @item. +gnt_menuitem_set_text(GntMenuItem *item, const gchar *text); #endif /* GNT_MENUITEM_H */