[epiphany/mcatanzaro/cli: 7/10] shell: Replace EphyStartupFlags with EphyStartupMode
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/cli: 7/10] shell: Replace EphyStartupFlags with EphyStartupMode
- Date: Fri, 4 Jan 2019 15:04:50 +0000 (UTC)
commit f1c3f5cb9e46139d05feef74dbde07111f2fca63
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Thu Jan 3 15:39:14 2019 -0600
shell: Replace EphyStartupFlags with EphyStartupMode
I was planning to get rid of EphyStartupFlags entirely and replace it
with a bool to indicate whether a new window should be created, since
there is only one flag needed now. But bool parameters are no good, and
I was planning to add a code style rule to avoid them. So convert it to
an enum instead.
src/ephy-main.c | 5 +----
src/ephy-shell.c | 33 +++++++++++++++++----------------
src/ephy-shell.h | 12 ++++++------
3 files changed, 24 insertions(+), 26 deletions(-)
---
diff --git a/src/ephy-main.c b/src/ephy-main.c
index cd48216d7..a7ceb1c5f 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -174,7 +174,6 @@ main (int argc,
guint32 user_time;
gboolean arbitrary_url;
EphyShellStartupContext *ctx;
- EphyStartupFlags startup_flags;
EphyEmbedShellMode mode;
int status;
EphyFileHelpersFlags flags;
@@ -377,8 +376,6 @@ main (int argc,
exit (0);
}
- startup_flags = open_in_new_window ? EPHY_STARTUP_NEW_WINDOW : 0;
-
/* Now create the shell */
if (private_instance) {
mode = EPHY_EMBED_SHELL_MODE_PRIVATE;
@@ -414,7 +411,7 @@ main (int argc,
_ephy_shell_create_instance (mode);
- ctx = ephy_shell_startup_context_new (startup_flags,
+ ctx = ephy_shell_startup_context_new (open_in_new_window ? EPHY_STARTUP_NEW_WINDOW : EPHY_STARTUP_NEW_TAB,
session_filename,
arguments,
user_time);
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 28f9b0d4d..c6938f80a 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -74,6 +74,7 @@ G_DEFINE_TYPE (EphyShell, ephy_shell, EPHY_TYPE_EMBED_SHELL)
/**
* ephy_shell_startup_context_new:
+ * @startup_mode: An #EphyStartupMode (new tab or new window)
* @session_filename: A session to restore.
* @arguments: A %NULL-terminated array of URLs and file URIs to be opened.
* @user_time: The user time when the EphyShell startup was invoked.
@@ -84,14 +85,14 @@ G_DEFINE_TYPE (EphyShell, ephy_shell, EPHY_TYPE_EMBED_SHELL)
* Returns: a newly allocated #EphyShellStartupContext
**/
EphyShellStartupContext *
-ephy_shell_startup_context_new (EphyStartupFlags startup_flags,
+ephy_shell_startup_context_new (EphyStartupMode startup_mode,
char *session_filename,
char **arguments,
guint32 user_time)
{
EphyShellStartupContext *ctx = g_new0 (EphyShellStartupContext, 1);
- ctx->startup_flags = startup_flags;
+ ctx->startup_mode = startup_mode;
ctx->session_filename = g_strdup (session_filename);
ctx->arguments = g_strdupv (arguments);
ctx->user_time = user_time;
@@ -122,7 +123,7 @@ ephy_shell_startup_continue (EphyShell *shell, EphyShellStartupContext *ctx)
/* Don't queue any window openings if no extra arguments given, */
/* since session autoresume will open one for us. */
ephy_shell_open_uris (shell, (const char **)ctx->arguments,
- ctx->startup_flags, ctx->user_time);
+ ctx->startup_mode, ctx->user_time);
}
}
@@ -486,7 +487,7 @@ ephy_shell_activate (GApplication *application)
* instance.
*/
typedef enum {
- CTX_STARTUP_FLAGS,
+ CTX_STARTUP_MODE,
CTX_SESSION_FILENAME,
CTX_ARGUMENTS,
CTX_USER_TIME
@@ -515,10 +516,10 @@ ephy_shell_add_platform_data (GApplication *application,
ctx_builder = g_variant_builder_new (G_VARIANT_TYPE_ARRAY);
ctx = app->local_startup_context;
- if (ctx->startup_flags)
+ if (ctx->startup_mode)
g_variant_builder_add (ctx_builder, "{iv}",
- CTX_STARTUP_FLAGS,
- g_variant_new_byte (ctx->startup_flags));
+ CTX_STARTUP_MODE,
+ g_variant_new_byte (ctx->startup_mode));
if (ctx->session_filename)
g_variant_builder_add (ctx_builder, "{iv}",
@@ -574,8 +575,8 @@ ephy_shell_before_emit (GApplication *application,
g_variant_iter_init (&ctx_iter, value);
while (g_variant_iter_loop (&ctx_iter, "{iv}", &ctx_key, &ctx_value)) {
switch (ctx_key) {
- case CTX_STARTUP_FLAGS:
- ctx->startup_flags = g_variant_get_byte (ctx_value);
+ case CTX_STARTUP_MODE:
+ ctx->startup_mode = g_variant_get_byte (ctx_value);
break;
case CTX_SESSION_FILENAME:
ctx->session_filename = g_variant_dup_string (ctx_value, NULL);
@@ -1079,10 +1080,10 @@ typedef struct {
} OpenURIsData;
static OpenURIsData *
-open_uris_data_new (EphyShell *shell,
- const char **uris,
- EphyStartupFlags startup_flags,
- guint32 user_time)
+open_uris_data_new (EphyShell *shell,
+ const char **uris,
+ EphyStartupMode startup_mode,
+ guint32 user_time)
{
OpenURIsData *data;
gboolean fullscreen_lockdown;
@@ -1097,7 +1098,7 @@ open_uris_data_new (EphyShell *shell,
fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
EPHY_PREFS_LOCKDOWN_FULLSCREEN);
- if ((startup_flags & EPHY_STARTUP_NEW_WINDOW) && !fullscreen_lockdown) {
+ if (startup_mode == EPHY_STARTUP_NEW_WINDOW && !fullscreen_lockdown) {
data->window = ephy_window_new ();
} else {
data->flags |= EPHY_NEW_TAB_JUMP;
@@ -1190,7 +1191,7 @@ ephy_shell_open_uris_idle_done (OpenURIsData *data)
void
ephy_shell_open_uris (EphyShell *shell,
const char **uris,
- EphyStartupFlags startup_flags,
+ EphyStartupMode startup_mode,
guint32 user_time)
{
OpenURIsData *data;
@@ -1198,7 +1199,7 @@ ephy_shell_open_uris (EphyShell *shell,
g_assert (EPHY_IS_SHELL (shell));
- data = open_uris_data_new (shell, uris, startup_flags, user_time);
+ data = open_uris_data_new (shell, uris, startup_mode, user_time);
id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
(GSourceFunc)ephy_shell_open_uris_idle,
data,
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 34240b707..2bef66a4d 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -67,13 +67,13 @@ typedef enum {
EPHY_NEW_TAB_JUMP = 1 << 4,
} EphyNewTabFlags;
-// FIXME: doesn't make sense to keep this with only one flag remaining.
typedef enum {
- EPHY_STARTUP_NEW_WINDOW = 1 << 0,
-} EphyStartupFlags;
+ EPHY_STARTUP_NEW_TAB,
+ EPHY_STARTUP_NEW_WINDOW
+} EphyStartupMode;
typedef struct {
- EphyStartupFlags startup_flags;
+ EphyStartupMode startup_mode;
char *session_filename;
char **arguments;
guint32 user_time;
@@ -118,13 +118,13 @@ void ephy_shell_try_quit (EphyShell *shell);
void ephy_shell_open_uris (EphyShell *shell,
const char **uris,
- EphyStartupFlags startup_flags,
+ EphyStartupMode startup_mode,
guint32 user_time);
void ephy_shell_set_startup_context (EphyShell *shell,
EphyShellStartupContext *ctx);
-EphyShellStartupContext *ephy_shell_startup_context_new (EphyStartupFlags startup_flags,
+EphyShellStartupContext *ephy_shell_startup_context_new (EphyStartupMode startup_mode,
char *session_filename,
char **arguments,
guint32 user_time);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]