--- a/gntbox.c Wed Jan 07 15:57:08 2009 +0000
+++ b/gntbox.c Tue Jan 13 23:13:32 2009 +0000
@@ -21,6 +21,7 @@
@@ -304,38 +305,38 @@
gnt_box_key_pressed(GntWidget *widget, const char *text)
GntBox *box = GNT_BOX(widget);
+ if (!GNT_WIDGET_IS_FLAG_SET(widget, GNT_WIDGET_DISABLE_ACTIONS)) if (box->active == NULL && !find_focusable_widget(box))
if (gnt_widget_key_pressed(box->active, text))
+ /* This dance is necessary to make sure that the child widgets get a chance + to trigger their bindings first */ + GNT_WIDGET_UNSET_FLAGS(widget, GNT_WIDGET_DISABLE_ACTIONS); + ret = gnt_widget_key_pressed(widget, text); + GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_DISABLE_ACTIONS); +box_focus_change(GntBox *box, gboolean next)
- if (strcmp(text, GNT_KEY_LEFT) == 0)
- else if (strcmp(text, GNT_KEY_RIGHT) == 0)
- else if (strcmp(text, GNT_KEY_BACK_TAB) == 0)
- else if (text[0] == '\t')
- if (now && now != box->active)
+ if (now && now != box->active) { gnt_widget_set_focus(now, FALSE);
gnt_widget_set_focus(box->active, TRUE);
@@ -344,6 +345,18 @@
+action_focus_next(GntBindable *bindable, GList *null) + return box_focus_change(GNT_BOX(bindable), TRUE); +action_focus_prev(GntBindable *bindable, GList *null) + return box_focus_change(GNT_BOX(bindable), FALSE); gnt_box_lost_focus(GntWidget *widget)
@@ -556,6 +569,7 @@
gnt_box_class_init(GntBoxClass *klass)
+ GntBindableClass *bindable = GNT_BINDABLE_CLASS(klass); GObjectClass *gclass = G_OBJECT_CLASS(klass);
parent_class = GNT_WIDGET_CLASS(klass);
parent_class->destroy = gnt_box_destroy;
@@ -589,6 +603,15 @@
G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
+ gnt_bindable_class_register_action(bindable, "focus-next", action_focus_next, + gnt_bindable_register_binding(bindable, "focus-next", GNT_KEY_RIGHT, NULL); + gnt_bindable_class_register_action(bindable, "focus-prev", action_focus_prev, + GNT_KEY_BACK_TAB, NULL); + gnt_bindable_register_binding(bindable, "focus-prev", GNT_KEY_LEFT, NULL); + gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), bindable); @@ -599,7 +622,7 @@
/* Initially make both the height and width resizable.
* Update the flags as necessary when widgets are added to it. */
GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_GROW_X | GNT_WIDGET_GROW_Y);
- GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS);
+ GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_CAN_TAKE_FOCUS | GNT_WIDGET_DISABLE_ACTIONS); GNT_WIDGET_SET_FLAGS(widget, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);