diff --git a/midori/main.c b/midori/main.c index 628665c3..759dc81f 100644 --- a/midori/main.c +++ b/midori/main.c @@ -430,6 +430,18 @@ midori_history_terminate (sqlite3* db, } #endif +static void +midori_session_add_delay (KatzeArray* session) +{ + KatzeItem* item; + gint i = 0; + while ((item = katze_array_get_nth_item (session, i++))) + { + if (katze_item_get_meta_integer (item, "delay") < 0) + katze_item_set_meta_integer (item, "delay", 1); + } +} + static void settings_notify_cb (MidoriWebSettings* settings, GParamSpec* pspec, @@ -1230,11 +1242,13 @@ midori_load_session (gpointer data) KatzeArray* _session = KATZE_ARRAY (data); MidoriBrowser* browser; MidoriApp* app = katze_item_get_parent (KATZE_ITEM (_session)); + MidoriWebSettings* settings = katze_object_get_object (app, "settings"); gchar* config_file; KatzeArray* session; KatzeItem* item; guint i; gint64 current; + MidoriStartup load_on_startup; gchar** command = g_object_get_data (G_OBJECT (app), "execute-command"); #ifdef G_ENABLE_DEBUG gboolean startup_timer = g_getenv ("MIDORI_STARTTIME") != NULL; @@ -1263,14 +1277,13 @@ midori_load_session (gpointer data) g_signal_connect_after (gtk_accel_map_get (), "changed", G_CALLBACK (accel_map_changed_cb), NULL); + g_object_get (settings, "load-on-startup", &load_on_startup, NULL); + if (katze_array_is_empty (_session)) { - MidoriWebSettings* settings = katze_object_get_object (app, "settings"); - MidoriStartup load_on_startup; gchar* homepage; item = katze_item_new (); - g_object_get (settings, "load-on-startup", &load_on_startup, NULL); if (load_on_startup == MIDORI_STARTUP_BLANK_PAGE) katze_item_set_uri (item, ""); else @@ -1279,11 +1292,13 @@ midori_load_session (gpointer data) katze_item_set_uri (item, homepage); g_free (homepage); } - g_object_unref (settings); katze_array_add_item (_session, item); g_object_unref (item); } + if (load_on_startup == MIDORI_STARTUP_DELAYED_PAGES) + midori_session_add_delay (_session); + session = midori_browser_get_proxy_array (browser); i = 0; while ((item = katze_array_get_nth_item (_session, i++))) @@ -1299,6 +1314,8 @@ midori_load_session (gpointer data) item = katze_array_get_nth_item (_session, 0); if (!strcmp (katze_item_get_uri (item), "")) midori_browser_activate_action (browser, "Location"); + + g_object_unref (settings); g_object_unref (_session); katze_assign (config_file, build_config_filename ("session.xbel")); @@ -1541,6 +1558,7 @@ main (int argc, gchar* webapp; gchar* config; gboolean diagnostic_dialog; + gboolean back_from_crash; gboolean run; gchar* snapshot; gboolean execute; @@ -1649,6 +1667,7 @@ main (int argc, /* Parse cli options */ webapp = NULL; config = NULL; + back_from_crash = FALSE; diagnostic_dialog = FALSE; run = FALSE; snapshot = NULL; @@ -1926,7 +1945,7 @@ main (int argc, _session = katze_array_new (KATZE_TYPE_ITEM); #if HAVE_LIBXML g_object_get (settings, "load-on-startup", &load_on_startup, NULL); - if (load_on_startup == MIDORI_STARTUP_LAST_OPEN_PAGES) + if (load_on_startup >= MIDORI_STARTUP_LAST_OPEN_PAGES) { katze_assign (config_file, build_config_filename ("session.xbel")); error = NULL; @@ -2026,6 +2045,7 @@ main (int argc, uri_ready = midori_prepare_uri (uri); katze_item_set_uri (item, uri_ready); g_free (uri_ready); + katze_item_set_meta_integer (item, "delay", 0); katze_array_add_item (_session, item); uri = strtok (NULL, "|"); } @@ -2075,12 +2095,21 @@ main (int argc, katze_assign (config_file, build_config_filename ("running")); if (g_access (config_file, F_OK) == 0) { - if (katze_object_get_boolean (settings, "show-crash-dialog")) - diagnostic_dialog = TRUE; + back_from_crash = TRUE; } else g_file_set_contents (config_file, "RUNNING", -1, NULL); + if (back_from_crash) + { + if (katze_object_get_int (settings, "load-on-startup") + >= MIDORI_STARTUP_LAST_OPEN_PAGES) + midori_session_add_delay (_session); + + if (katze_object_get_boolean (settings, "show-crash-dialog")) + diagnostic_dialog = TRUE; + } + if (diagnostic_dialog) { GtkWidget* dialog = midori_create_diagnostic_dialog (settings, _session); @@ -2156,8 +2185,8 @@ main (int argc, } } - if (katze_object_get_boolean (settings, "load-on-startup") - != MIDORI_STARTUP_LAST_OPEN_PAGES) + if (katze_object_get_int (settings, "load-on-startup") + < MIDORI_STARTUP_LAST_OPEN_PAGES) { katze_assign (config_file, build_config_filename ("session.xbel")); g_unlink (config_file); diff --git a/midori/midori-browser.c b/midori/midori-browser.c index 534a2a05..066fd13f 100644 --- a/midori/midori-browser.c +++ b/midori/midori-browser.c @@ -7488,7 +7488,6 @@ gint midori_browser_add_item (MidoriBrowser* browser, KatzeItem* item) { - const gchar* uri; const gchar* title; GtkWidget* view; gint page; @@ -7498,13 +7497,21 @@ midori_browser_add_item (MidoriBrowser* browser, g_return_val_if_fail (MIDORI_IS_BROWSER (browser), -1); g_return_val_if_fail (KATZE_IS_ITEM (item), -1); - uri = katze_item_get_uri (item); title = katze_item_get_name (item); view = g_object_new (MIDORI_TYPE_VIEW, "title", title, "settings", browser->settings, NULL); - midori_view_set_uri (MIDORI_VIEW (view), uri); + if (katze_item_get_meta_integer (item, "delay") > 0) + { + gchar* new_uri; + new_uri = g_strdup_printf ("pause:%s", katze_item_get_uri (item)); + midori_view_set_uri (MIDORI_VIEW (view), new_uri); + g_free (new_uri); + } + else + midori_view_set_uri (MIDORI_VIEW (view), katze_item_get_uri (item)); + gtk_widget_show (view); /* FIXME: We should have public API for that */ diff --git a/midori/midori-view.c b/midori/midori-view.c index 655b1df5..f99934db 100644 --- a/midori/midori-view.c +++ b/midori/midori-view.c @@ -3680,6 +3680,23 @@ midori_view_set_uri (MidoriView* view, katze_item_set_uri (view->item, uri); return; } + else if (g_str_has_prefix (uri, "pause:")) + { + gchar* title; + + title = g_strdup_printf ("%s", view->title); + katze_assign (view->uri, g_strdup (&uri[6])); + midori_view_display_error ( + view, view->uri, title, + _("Page loading delayed"), + _("Loading delayed either due to a recent crash or startup preferences."), + _("Load Page"), + NULL); + g_free (title); + g_object_notify (G_OBJECT (view), "uri"); + if (view->item) + katze_item_set_uri (view->item, uri); + } else if (g_str_has_prefix (uri, "javascript:")) { gboolean result; diff --git a/midori/midori-websettings.c b/midori/midori-websettings.c index b7e573af..4102bf2b 100644 --- a/midori/midori-websettings.c +++ b/midori/midori-websettings.c @@ -204,6 +204,7 @@ midori_startup_get_type (void) { MIDORI_STARTUP_BLANK_PAGE, "MIDORI_STARTUP_BLANK_PAGE", N_("Show Blank page") }, { MIDORI_STARTUP_HOMEPAGE, "MIDORI_STARTUP_HOMEPAGE", N_("Show Homepage") }, { MIDORI_STARTUP_LAST_OPEN_PAGES, "MIDORI_STARTUP_LAST_OPEN_PAGES", N_("Show last open tabs") }, + { MIDORI_STARTUP_DELAYED_PAGES, "MIDORI_STARTUP_DELAYED_PAGES", N_("Show last tabs without loading") }, { 0, NULL, NULL } }; type = g_enum_register_static ("MidoriStartup", values); diff --git a/midori/midori-websettings.h b/midori/midori-websettings.h index 05ad0f7c..2cedff15 100644 --- a/midori/midori-websettings.h +++ b/midori/midori-websettings.h @@ -60,11 +60,13 @@ midori_window_state_get_type (void) G_GNUC_CONST; #define MIDORI_TYPE_WINDOW_STATE \ (midori_window_state_get_type ()) +/* values >= MIDORI_STARTUP_LAST_OPEN_PAGES mean session is saved */ typedef enum { - MIDORI_STARTUP_BLANK_PAGE, - MIDORI_STARTUP_HOMEPAGE, - MIDORI_STARTUP_LAST_OPEN_PAGES + MIDORI_STARTUP_BLANK_PAGE, /* One blank tab or speed dial is opened */ + MIDORI_STARTUP_HOMEPAGE, /* One homepage tab is opened */ + MIDORI_STARTUP_LAST_OPEN_PAGES, /* The session is loaded and saved */ + MIDORI_STARTUP_DELAYED_PAGES /* The session is saved, loading pages is delayed */ } MidoriStartup; GType