diff --git a/src/main.c b/src/main.c index 2fabe7cd..1933c254 100644 --- a/src/main.c +++ b/src/main.c @@ -456,7 +456,7 @@ int main(int argc, char** argv) "signal::delete-event", midori_browser_delete_event_cb, browsers, "signal::quit", midori_browser_quit_cb, browsers, NULL); - browsers = g_list_prepend(browsers, browser); + browsers = g_list_prepend (browsers, browser); gtk_widget_show (GTK_WIDGET (browser)); KatzeXbelItem* session = katze_xbel_folder_new (); @@ -466,6 +466,10 @@ int main(int argc, char** argv) KatzeXbelItem* item = katze_xbel_folder_get_nth_item (_session, i); midori_browser_append_xbel_item (browser, item); } + // FIXME: Switch to the last active page + KatzeXbelItem* item = katze_xbel_folder_get_nth_item (_session, 0); + if (!strcmp (katze_xbel_bookmark_get_href (item), "")) + midori_browser_activate_action (browser, "Location"); katze_xbel_item_unref (_session); gtk_main (); diff --git a/src/midori-browser.c b/src/midori-browser.c index b19460c2..fadf1fcd 100644 --- a/src/midori-browser.c +++ b/src/midori-browser.c @@ -2797,7 +2797,7 @@ midori_browser_settings_notify (MidoriWebSettings* web_settings, g_value_get_boolean (&value)); else if (!g_object_class_find_property (G_OBJECT_GET_CLASS (web_settings), name)) - g_warning("Unexpected setting '%s'", name); + g_warning (_("Unexpected setting '%s'"), name); g_value_unset (&value); } @@ -3070,6 +3070,26 @@ midori_browser_append_uri (MidoriBrowser* browser, return midori_browser_append_tab (browser, web_view); } +/** + * midori_browser_activate_action: + * @browser: a #MidoriBrowser + * @name: name of the action + * + * Activates the specified action. + **/ +void +midori_browser_activate_action (MidoriBrowser* browser, + const gchar* name) +{ + MidoriBrowserPrivate* priv = browser->priv; + + GtkAction* action = _action_by_name (browser, name); + if (action) + gtk_action_activate (action); + else + g_warning (_("Unexpected action '%s'."), name); +} + /** * midori_browser_set_current_page: * @browser: a #MidoriBrowser @@ -3086,8 +3106,14 @@ midori_browser_set_current_page (MidoriBrowser* browser, MidoriBrowserPrivate* priv = browser->priv; gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), n); - GtkWidget* widget = midori_browser_get_current_page (browser); - if (widget) + GtkWidget* scrolled = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), n); + GtkWidget* widget = _midori_browser_child_for_scrolled (browser, scrolled); + printf ("_nth_page: %s\n", G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (widget))); + if (widget && MIDORI_IS_WEB_VIEW (widget) + && !strcmp (midori_web_view_get_display_uri ( + MIDORI_WEB_VIEW (widget)), "")) + gtk_widget_grab_focus (priv->location); + else gtk_widget_grab_focus (widget); } diff --git a/src/midori-browser.h b/src/midori-browser.h index f0b8e0a4..a6a797d8 100644 --- a/src/midori-browser.h +++ b/src/midori-browser.h @@ -76,6 +76,10 @@ gint midori_browser_append_uri (MidoriBrowser* browser, const gchar* uri); +void +midori_browser_activate_action (MidoriBrowser* browser, + const gchar* name); + void midori_browser_set_current_page (MidoriBrowser* browser, gint n);