[epiphany/mcatanzaro/cli: 5/8] shell: Replace EphyStartupFlags with EphyStartupMode
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/mcatanzaro/cli: 5/8] shell: Replace EphyStartupFlags with EphyStartupMode
- Date: Thu, 3 Jan 2019 22:49:26 +0000 (UTC)
commit fd506b1dd6c0910b14abbafe8fe8e20aac26281a
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 48f05728f..738c95d48 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -171,7 +171,6 @@ main (int argc,
guint32 user_time;
gboolean arbitrary_url;
EphyShellStartupContext *ctx;
- EphyStartupFlags startup_flags;
EphyEmbedShellMode mode;
int status;
EphyFileHelpersFlags flags;
@@ -365,8 +364,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;
@@ -400,7 +397,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 034efce31..7d1ffda5d 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);
}
}
@@ -444,7 +445,7 @@ ephy_shell_activate (GApplication *application)
* instance.
*/
typedef enum {
- CTX_STARTUP_FLAGS,
+ CTX_STARTUP_MODE,
CTX_SESSION_FILENAME,
CTX_ARGUMENTS,
CTX_USER_TIME
@@ -473,10 +474,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}",
@@ -532,8 +533,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);
@@ -1037,10 +1038,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;
@@ -1055,7 +1056,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;
@@ -1148,7 +1149,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;
@@ -1156,7 +1157,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]