+
+static void
+on_switch_page (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data)
+{
+ /* grab the focus to the default element in the current page */
+ GtkWidget *child, *focus_item;
+
+ child = gtk_notebook_get_nth_page (notebook, page_num);
+ if (!child) {
+ g_printerr ("modest: cannot get nth page\n");
+ return;
+ }
+
+ focus_item = GTK_WIDGET(g_object_get_data (G_OBJECT(child), DEFAULT_FOCUS_WIDGET));
+ if (!focus_item) {
+ g_printerr ("modest: cannot get focus item\n");
+ return;
+ }
+
+ gtk_widget_grab_focus (focus_item);
+}
+