-static gboolean
-idle_select_default_focus (gpointer data)
-{
- ModestGlobalSettingsDialogPrivate *ppriv;
- ModestMaemoGlobalSettingsDialogPrivate *priv;
- SwitchPageHelper *helper;
-
- helper = (SwitchPageHelper *) data;
- priv = MODEST_MAEMO_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (helper->dia);
- ppriv = MODEST_GLOBAL_SETTINGS_DIALOG_GET_PRIVATE (helper->dia);
-
- /* Grab focus, we need to block in order to prevent a
- recursive call to this callback */
- g_signal_handler_block (G_OBJECT (ppriv->notebook), priv->switch_handler);
-
- /* This is a GDK lock because we are an idle callback and
- * the code below is or does Gtk+ code */
-
- gdk_threads_enter (); /* CHECKED */
- gtk_widget_grab_focus (helper->focus_widget);
- gdk_threads_leave (); /* CHECKED */
-
- g_signal_handler_unblock (G_OBJECT (ppriv->notebook), priv->switch_handler);
- g_free (helper);
-
- return FALSE;
-}
-
-
-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 *selected_page = NULL, *focus_item = NULL;
- SwitchPageHelper *helper;
-
- selected_page = gtk_notebook_get_nth_page (notebook, page_num);
- focus_item = GTK_WIDGET(g_object_get_data (G_OBJECT(selected_page), DEFAULT_FOCUS_WIDGET));
- if (!focus_item) {
- g_printerr ("modest: cannot get focus item\n");
- return;
- }
-
- /* Create the helper */
- helper = g_malloc0 (sizeof (SwitchPageHelper));
- helper->dia = MODEST_MAEMO_GLOBAL_SETTINGS_DIALOG (user_data);
- helper->focus_widget = focus_item;
-
- /* Focus the widget in an idle. We need to do this in an idle,
- because this handler is executed *before* the page was
- really switched, so the focus is not placed in the right
- widget */
- g_idle_add (idle_select_default_focus, helper);
-}
-