static gboolean session_command_dispatch (EphySession *session) { EphySessionPrivate *priv = session->priv; SessionCommand *cmd; gboolean run_again = TRUE; cmd = g_queue_pop_head (priv->queue); g_assert (cmd != NULL); LOG ("dispatching queue cmd:%d", cmd->command); switch (cmd->command) { case EPHY_SESSION_CMD_RESUME_SESSION: session_command_autoresume (session, cmd->user_time); break; case EPHY_SESSION_CMD_LOAD_SESSION: ephy_session_load (session, cmd->arg, cmd->user_time); break; case EPHY_SESSION_CMD_OPEN_BOOKMARKS_EDITOR: session_command_open_bookmarks_editor (session, cmd->user_time); break; case EPHY_SESSION_CMD_OPEN_URIS: session_command_open_uris (session, cmd->args, cmd->arg, cmd->user_time); break; case EPHY_SESSION_CMD_MAYBE_OPEN_WINDOW: /* FIXME: maybe just check for normal windows? */ if (priv->windows == NULL && priv->tool_windows == NULL) { ephy_shell_new_tab_full (ephy_shell_get_default (), NULL /* window */, NULL /* tab */, NULL /* NetworkRequest */, EPHY_NEW_TAB_IN_NEW_WINDOW | EPHY_NEW_TAB_HOME_PAGE, EPHY_WEB_VIEW_CHROME_ALL, FALSE /* is popup? */, cmd->user_time); } break; default: g_assert_not_reached (); break; } /* Look if there's anything else to dispatch */ if (g_queue_is_empty (priv->queue)) { priv->queue_idle_id = 0; run_again = FALSE; } g_application_release (G_APPLICATION (ephy_shell_get_default ())); /* This unrefs the shell! */ session_command_free (cmd); return run_again; }
static void session_maybe_open_window (EphySession *session, guint32 user_time) { EphyShell *shell = ephy_shell_get_default (); /* FIXME: maybe just check for normal windows? */ if (ephy_shell_get_n_windows (shell) == 0) { ephy_shell_new_tab_full (shell, NULL /* window */, NULL /* tab */, NULL /* NetworkRequest */, EPHY_NEW_TAB_IN_NEW_WINDOW | EPHY_NEW_TAB_HOME_PAGE, EPHY_WEB_VIEW_CHROME_ALL, FALSE /* is popup? */, user_time); } }
static void session_command_open_uris (EphySession *session, char **uris, const char *options, guint32 user_time) { EphyShell *shell; EphyWindow *window; EphyEmbed *embed; EphySessionPrivate *priv; EphyNewTabFlags flags = 0; guint i; priv = session->priv; shell = ephy_shell_get_default (); g_object_ref (shell); window = ephy_session_get_active_window (session); if (options != NULL && strstr (options, "external") != NULL) { flags |= EPHY_NEW_TAB_FROM_EXTERNAL; } if (options != NULL && strstr (options, "new-window") != NULL) { window = NULL; flags |= EPHY_NEW_TAB_IN_NEW_WINDOW; } else if (options != NULL && strstr (options, "new-tab") != NULL) { flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_JUMP; } for (i = 0; uris[i] != NULL; ++i) { const char *url = uris[i]; EphyNewTabFlags page_flags; #ifdef HAVE_WEBKIT2 WebKitURIRequest *request = NULL; #else WebKitNetworkRequest *request = NULL; #endif if (url[0] == '\0') { page_flags = EPHY_NEW_TAB_HOME_PAGE; } else { page_flags = EPHY_NEW_TAB_OPEN_PAGE; #ifdef HAVE_WEBKIT2 request = webkit_uri_request_new (url); #else request = webkit_network_request_new (url); #endif } /* For the first URI, if we have a valid recovery * window, reuse the already existing embed instead of * creating a new one, except if we still want to * present the option to resume a crashed session, in * that case use a new tab in the same window */ if (i == 0 && priv->resume_window != NULL) { EphyWebView *web_view; embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (priv->resume_window)); web_view = ephy_embed_get_web_view (embed); ephy_web_view_load_url (web_view, url); } else { embed = ephy_shell_new_tab_full (shell, window, NULL /* parent tab */, request, flags | page_flags, EPHY_WEB_VIEW_CHROME_ALL, FALSE /* is popup? */, user_time); } if (request) g_object_unref (request); window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))); } g_object_unref (shell); }