make Home and End keys navigate to top/bottom of the active menu

This commit is contained in:
Dana Jansens 2010-01-08 09:04:25 -05:00
parent 70c074afe8
commit bafd9e9edc
5 changed files with 50 additions and 0 deletions

View file

@ -1729,6 +1729,16 @@ static gboolean event_handle_menu_keyboard(XEvent *ev)
menu_frame_select_next(frame);
ret = TRUE;
}
else if (ob_keycode_match(keycode, OB_KEY_HOME)) {
menu_frame_select_first(frame);
ret = TRUE;
}
else if (ob_keycode_match(keycode, OB_KEY_END)) {
menu_frame_select_last(frame);
ret = TRUE;
}
}
/* Use KeyRelease events for running things so that the key release doesn't

View file

@ -1316,3 +1316,35 @@ void menu_frame_select_next(ObMenuFrame *self)
}
menu_frame_select(self, it ? it->data : NULL, FALSE);
}
void menu_frame_select_first(ObMenuFrame *self)
{
GList *it = NULL;
if (self->entries) {
for (it = self->entries; it; it = g_list_next(it)) {
ObMenuEntryFrame *e = it->data;
if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
break;
if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
break;
}
}
menu_frame_select(self, it ? it->data : NULL, FALSE);
}
void menu_frame_select_last(ObMenuFrame *self)
{
GList *it = NULL;
if (self->entries) {
for (it = g_list_last(self->entries); it; it = g_list_previous(it)) {
ObMenuEntryFrame *e = it->data;
if (e->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)
break;
if (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL)
break;
}
}
menu_frame_select(self, it ? it->data : NULL, FALSE);
}

View file

@ -127,6 +127,8 @@ void menu_frame_select(ObMenuFrame *self, ObMenuEntryFrame *entry,
gboolean immediate);
void menu_frame_select_previous(ObMenuFrame *self);
void menu_frame_select_next(ObMenuFrame *self);
void menu_frame_select_first(ObMenuFrame *self);
void menu_frame_select_last(ObMenuFrame *self);
ObMenuFrame* menu_frame_under(gint x, gint y);
ObMenuEntryFrame* menu_entry_frame_under(gint x, gint y);

View file

@ -53,6 +53,8 @@ typedef enum
OB_KEY_DOWN,
OB_KEY_TAB,
OB_KEY_SPACE,
OB_KEY_HOME,
OB_KEY_END,
OB_NUM_KEYS
} ObKey;

View file

@ -239,6 +239,8 @@ gint main(gint argc, gchar **argv)
keys[OB_KEY_DOWN] = modkeys_sym_to_code(XK_Down);
keys[OB_KEY_TAB] = modkeys_sym_to_code(XK_Tab);
keys[OB_KEY_SPACE] = modkeys_sym_to_code(XK_space);
keys[OB_KEY_HOME] = modkeys_sym_to_code(XK_Home);
keys[OB_KEY_END] = modkeys_sym_to_code(XK_End);
{
ObParseInst *i;
@ -427,6 +429,8 @@ gint main(gint argc, gchar **argv)
g_free(keys[OB_KEY_DOWN]);
g_free(keys[OB_KEY_TAB]);
g_free(keys[OB_KEY_SPACE]);
g_free(keys[OB_KEY_HOME]);
g_free(keys[OB_KEY_END]);
modkeys_shutdown(reconfigure);
} while (reconfigure);