# HG changeset patch # User Sadrul Habib Chowdhury # Date 1176620094 0 # Node ID d07f5128dd6bbd2f3f074a93b1a6af2de4a1910e # Parent 5f204f55af090e7f6b964a601e2492cec2bd1efe alt-/ to get a list of keybindings for the focused widget. diff -r 5f204f55af09 -r d07f5128dd6b finch/libgnt/gntwm.c --- a/finch/libgnt/gntwm.c Sun Apr 15 05:49:27 2007 +0000 +++ b/finch/libgnt/gntwm.c Sun Apr 15 06:54:54 2007 +0000 @@ -15,10 +15,12 @@ #include "gntmarshal.h" #include "gnt.h" #include "gntbox.h" +#include "gntlabel.h" #include "gntmenu.h" #include "gnttextview.h" #include "gnttree.h" #include "gntutils.h" +#include "gntwindow.h" #define IDLE_CHECK_INTERVAL 5 /* 5 seconds */ @@ -417,6 +419,35 @@ return TRUE; } +static gboolean +help_for_widget(GntBindable *bindable, GList *null) +{ + GntWM *wm = GNT_WM(bindable); + GntWidget *widget, *tree, *win, *active; + char *title; + + if (!wm->ordered) + return TRUE; + + widget = wm->ordered->data; + if (!GNT_IS_BOX(widget)) + return TRUE; + active = GNT_BOX(widget)->active; + + tree = gnt_widget_bindings_view(active); + win = gnt_window_new(); + title = g_strdup_printf("Bindings for %s", g_type_name(G_OBJECT_TYPE(active))); + gnt_box_set_title(GNT_BOX(win), title); + if (tree) + gnt_box_add_widget(GNT_BOX(win), tree); + else + gnt_box_add_widget(GNT_BOX(win), gnt_label_new("This widget has no customizable bindings.")); + + gnt_widget_show(win); + + return TRUE; +} + static void destroy__list(GntWidget *widget, GntWM *wm) { @@ -1006,6 +1037,8 @@ "\033" GNT_KEY_CTRL_J, NULL); gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "window-scroll-up", window_scroll_up, "\033" GNT_KEY_CTRL_K, NULL); + gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "help-for-widget", help_for_widget, + "\033" "/", NULL); gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass)); @@ -1230,8 +1263,12 @@ idle_update = TRUE; - if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) + wm->event_stack = TRUE; + + if (gnt_bindable_perform_action_key(GNT_BINDABLE(wm), keys)) { + wm->event_stack = FALSE; return TRUE; + } /* Do some manual checking */ if (wm->ordered && wm->mode != GNT_KP_MODE_NORMAL) { @@ -1262,6 +1299,7 @@ if (ox != x || oy != y) { gnt_screen_move_widget(widget, x, y); window_reverse(widget, TRUE, wm); + wm->event_stack = FALSE; return TRUE; } } else if (wm->mode == GNT_KP_MODE_RESIZE) { @@ -1279,6 +1317,7 @@ if (oh != h || ow != w) { gnt_screen_resize_widget(widget, w, h); window_reverse(widget, TRUE, wm); + wm->event_stack = FALSE; return TRUE; } } @@ -1286,11 +1325,10 @@ window_reverse(widget, FALSE, wm); wm->mode = GNT_KP_MODE_NORMAL; } + wm->event_stack = FALSE; return TRUE; } - wm->event_stack = TRUE; - /* Escape to close the window-list or action-list window */ if (strcmp(keys, "\033") == 0) { if (wm->_list.window) {