diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2013-08-18 21:17:23 +0800 |
---|---|---|
committer | Giovanni Campagna <gcampagn@redhat.com> | 2013-08-29 22:09:41 +0800 |
commit | 77df45f51f70243aaad5ec88b816c881cfdb2dbe (patch) | |
tree | bba0f0b9ebb6c90390d4f68a8b041507c5fc4f7e | |
parent | fa9ed211b6457537492162d71d552ad5fee9c835 (diff) | |
download | gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.tar gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.tar.gz gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.tar.bz2 gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.tar.lz gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.tar.xz gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.tar.zst gsoc2013-epiphany-77df45f51f70243aaad5ec88b816c881cfdb2dbe.zip |
EphyShell: add support for starting without windows
To launch epiphany as a DBus service, we need to be able to launch
without opening windows, and then use the GApplication inactivity
timeout to manage our lifetime.
https://bugzilla.gnome.org/show_bug.cgi?id=694943
-rw-r--r-- | data/org.gnome.Epiphany.service.in | 2 | ||||
-rw-r--r-- | src/ephy-main.c | 6 | ||||
-rw-r--r-- | src/ephy-shell.c | 25 | ||||
-rw-r--r-- | src/ephy-shell.h | 1 |
4 files changed, 30 insertions, 4 deletions
diff --git a/data/org.gnome.Epiphany.service.in b/data/org.gnome.Epiphany.service.in index 003ec0c66..5af8cf1d7 100644 --- a/data/org.gnome.Epiphany.service.in +++ b/data/org.gnome.Epiphany.service.in @@ -1,3 +1,3 @@ [D-BUS Service] Name=org.gnome.Epiphany -Exec=@bindir@/epiphany +Exec=@bindir@/epiphany --headless-mode diff --git a/src/ephy-main.c b/src/ephy-main.c index 96ac40b31..0347a5770 100644 --- a/src/ephy-main.c +++ b/src/ephy-main.c @@ -56,6 +56,7 @@ static char *application_to_delete = NULL; static gboolean private_instance = FALSE; static gboolean incognito_mode = FALSE; static gboolean application_mode = FALSE; +static gboolean headless_mode = FALSE; static char *profile_directory = NULL; static gboolean @@ -90,6 +91,8 @@ static const GOptionEntry option_entries[] = N_("Start an instance in netbank mode"), NULL }, { "application-mode", 'a', 0, G_OPTION_ARG_NONE, &application_mode, N_("Start the browser in application mode"), NULL }, + { "headless-mode", 0, 0, G_OPTION_ARG_NONE, &headless_mode, + N_("Start the application without opening windows"), NULL }, { "profile", 0, 0, G_OPTION_ARG_STRING, &profile_directory, N_("Profile directory to use in the private instance"), N_("DIR") }, { G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &arguments, @@ -214,6 +217,9 @@ get_startup_flags (void) { EphyStartupFlags flags = 0; + if (headless_mode) + return EPHY_STARTUP_OPEN_NOTHING; + if (open_in_new_tab) flags |= EPHY_STARTUP_NEW_TAB; if (open_in_new_window) diff --git a/src/ephy-shell.c b/src/ephy-shell.c index f514c6398..9e91bc7b0 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -296,21 +296,38 @@ session_load_cb (GObject *object, } static void +ephy_shell_start_headless (EphyShell *shell) +{ + /* A bit of a hack: because we don't pass IS_SERVICE to GApplication + (because otherwise we would need a separate launcher binary), we + don't get the 10 seconds timeout for the first DBus call. + So just hold/release to get the inactivity timeout started instead. + */ + + g_application_hold (G_APPLICATION (shell)); + g_application_release (G_APPLICATION (shell)); + ephy_shell_startup_continue (shell); +} + +static void ephy_shell_activate (GApplication *application) { EphyShell *shell = EPHY_SHELL (application); /* * We get here on each new instance (remote or not). Autoresume the - * session unless we are in application mode and queue the + * session unless we are in application or headless mode and queue the * commands. */ if (ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (shell)) != EPHY_EMBED_SHELL_MODE_APPLICATION) { EphyShellStartupContext *ctx; ctx = shell->priv->startup_context; - ephy_session_resume (ephy_shell_get_session (shell), - ctx->user_time, NULL, session_load_cb, shell); + if (ctx->startup_flags != EPHY_STARTUP_OPEN_NOTHING) + ephy_session_resume (ephy_shell_get_session (shell), + ctx->user_time, NULL, session_load_cb, shell); + else + ephy_shell_start_headless (shell); } else ephy_shell_startup_continue (shell); } @@ -597,6 +614,8 @@ ephy_shell_init (EphyShell *shell) webkit_web_context_set_favicon_database_directory (web_context, favicon_db_path); g_free (favicon_db_path); #endif + + g_application_set_inactivity_timeout (G_APPLICATION (shell), 60 * 1000); } static void diff --git a/src/ephy-shell.h b/src/ephy-shell.h index 7b250fe26..2c817484a 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -113,6 +113,7 @@ typedef enum { typedef enum { EPHY_STARTUP_NEW_TAB = 1 << 0, EPHY_STARTUP_NEW_WINDOW = 1 << 1, + EPHY_STARTUP_OPEN_NOTHING = 1 << 2, } EphyStartupFlags; typedef struct { |