move the other if-else into the switch

This commit is contained in:
Daniel Micay 2012-09-28 12:18:13 -04:00
parent a4de8fdbc1
commit 4f515865f6
1 changed files with 25 additions and 24 deletions

View File

@ -580,30 +580,6 @@ static void synthesize_keypress(GtkWidget *widget, unsigned keyval) {
gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *info) { gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *info) {
gboolean ret = FALSE; gboolean ret = FALSE;
if (event->keyval == GDK_KEY_Escape) {
ret = TRUE;
} else if (event->keyval == GDK_KEY_Return) {
const char *text = gtk_entry_get_text(entry);
switch (info->panel.mode) {
case overlay_mode::search:
search(info->panel.vte, text, false);
break;
case overlay_mode::rsearch:
search(info->panel.vte, text, true);
break;
case overlay_mode::completion:
vte_terminal_feed_child(info->panel.vte, text, -1);
break;
case overlay_mode::urlselect:
launch_url(text, &info->panel);
break;
case overlay_mode::hidden:
break;
}
ret = TRUE;
}
switch (event->keyval) { switch (event->keyval) {
case GDK_KEY_Tab: case GDK_KEY_Tab:
synthesize_keypress(GTK_WIDGET(entry), GDK_KEY_Down); synthesize_keypress(GTK_WIDGET(entry), GDK_KEY_Down);
@ -614,6 +590,31 @@ gboolean entry_key_press_cb(GtkEntry *entry, GdkEventKey *event, keybind_info *i
case GDK_KEY_Down: case GDK_KEY_Down:
// this stops the down key from leaving the GtkEntry... // this stops the down key from leaving the GtkEntry...
event->hardware_keycode = 0; event->hardware_keycode = 0;
break;
case GDK_KEY_Escape:
ret = TRUE;
break;
case GDK_KEY_Return: {
const char *text = gtk_entry_get_text(entry);
switch (info->panel.mode) {
case overlay_mode::search:
search(info->panel.vte, text, false);
break;
case overlay_mode::rsearch:
search(info->panel.vte, text, true);
break;
case overlay_mode::completion:
vte_terminal_feed_child(info->panel.vte, text, -1);
break;
case overlay_mode::urlselect:
launch_url(text, &info->panel);
break;
case overlay_mode::hidden:
break;
}
ret = TRUE;
}
} }
if (ret) { if (ret) {