From: Richard Kettlewell Date: Mon, 9 Jun 2008 08:54:34 +0000 (+0100) Subject: Encourage choose tab's input focus to the search box a bit. Really we X-Git-Tag: 4.1~15^2~64 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/2a3fe554189ec0e25f65ccb7c06b9705794d0f15 Encourage choose tab's input focus to the search box a bit. Really we want up+down keys to go to the scrollable layout and everything else to the search box but this is a start. --- diff --git a/disobedience/choose.c b/disobedience/choose.c index 941e897..353ed98 100644 --- a/disobedience/choose.c +++ b/disobedience/choose.c @@ -784,6 +784,8 @@ static void initiate_search(void) { static void clearsearch_clicked(GtkButton attribute((unused)) *button, gpointer attribute((unused)) userdata) { gtk_entry_set_text(GTK_ENTRY(searchentry), ""); + /* Put the input focus back */ + gtk_widget_grab_focus(searchentry); } /** @brief Called when the 'next search result' button is clicked */ @@ -1417,6 +1419,11 @@ static void choose_selectall_activate(GtkWidget attribute((unused)) *w) { static void choose_selectnone_activate(GtkWidget attribute((unused)) *w) { } +/** @brief Called when the choose tab is selected */ +static void choose_tab_selected(void) { + gtk_widget_grab_focus(searchentry); +} + /** @brief Main menu callbacks for Choose screen */ static const struct tabtype tabtype_choose = { choose_properties_sensitive, @@ -1425,6 +1432,7 @@ static const struct tabtype tabtype_choose = { choose_properties_activate, choose_selectall_activate, choose_selectnone_activate, + choose_tab_selected, }; /* Public entry points ----------------------------------------------------- */ diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index e8bbc40..443eaa4 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -116,11 +116,15 @@ static gboolean delete_event(GtkWidget attribute((unused)) *widget, * * Updates the menu settings to correspond to the new page. */ -static void tab_switched(GtkNotebook attribute((unused)) *notebook, +static void tab_switched(GtkNotebook *notebook, GtkNotebookPage attribute((unused)) *page, guint page_num, gpointer attribute((unused)) user_data) { menu_update(page_num); + GtkWidget *const tab = gtk_notebook_get_nth_page(notebook, page_num); + const struct tabtype *const t = g_object_get_data(G_OBJECT(tab), "type"); + if(t->selected) + t->selected(); } /** @brief Create the report box */ diff --git a/disobedience/disobedience.h b/disobedience/disobedience.h index 938a69e..29215cd 100644 --- a/disobedience/disobedience.h +++ b/disobedience/disobedience.h @@ -92,6 +92,7 @@ struct tabtype { void (*properties_activate)(GtkWidget *tab); void (*selectall_activate)(GtkWidget *tab); void (*selectnone_activate)(GtkWidget *tab); + void (*selected)(void); }; /** @brief Button definitions */ diff --git a/disobedience/queue.c b/disobedience/queue.c index 48c43fb..1bda111 100644 --- a/disobedience/queue.c +++ b/disobedience/queue.c @@ -1561,6 +1561,7 @@ static const struct tabtype tabtype_queue = { queue_properties_activate, queue_selectall_activate, queue_selectnone_activate, + 0 }; /* Other entry points ------------------------------------------------------ */