From cec324e80ae88463e97e79ce16806127b512f931 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sun, 22 May 2011 11:04:27 -0400 Subject: Bug 650491 - Shell handles forwarding uris to existing process wrong This adds a "handle-uris" GAction which takes a string array argument, so the URIs can be passed to the primary process verbatim. --- shell/e-shell-utils.c | 4 +-- shell/e-shell-utils.h | 2 +- shell/e-shell.c | 70 +++++++++++++++++++++------------------------------ shell/e-shell.h | 2 +- shell/main.c | 2 +- 5 files changed, 34 insertions(+), 46 deletions(-) (limited to 'shell') diff --git a/shell/e-shell-utils.c b/shell/e-shell-utils.c index 4676a2d2e9..43ddd0562c 100644 --- a/shell/e-shell-utils.c +++ b/shell/e-shell-utils.c @@ -282,7 +282,7 @@ exit: **/ guint e_shell_utils_import_uris (EShell *shell, - gchar **uris) + const gchar * const *uris) { GtkWindow *parent; GtkWidget *assistant; @@ -308,7 +308,7 @@ e_shell_utils_import_uris (EShell *shell, } else g_warning ("Cannot import any of the given URIs"); - return g_strv_length (uris); + return g_strv_length ((gchar **) uris); } /** diff --git a/shell/e-shell-utils.h b/shell/e-shell-utils.h index 178c26d20f..897981e0d0 100644 --- a/shell/e-shell-utils.h +++ b/shell/e-shell-utils.h @@ -44,7 +44,7 @@ GFile * e_shell_run_save_dialog (EShell *shell, gpointer customize_data); guint e_shell_utils_import_uris (EShell *shell, - gchar **uris); + const gchar * const *uris); void e_shell_hide_widgets_for_express_mode (EShell *shell, diff --git a/shell/e-shell.c b/shell/e-shell.c index d9c3508161..eb3cb8e407 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -235,6 +235,19 @@ shell_action_new_window_cb (GSimpleAction *action, e_shell_create_shell_window (shell, view_name); } +static void +shell_action_handle_uris_cb (GSimpleAction *action, + GVariant *parameter, + EShell *shell) +{ + const gchar **uris; + + /* Do not use g_strfreev() here. */ + uris = g_variant_get_strv (parameter, NULL); + e_shell_handle_uris (shell, uris, FALSE); + g_free (uris); +} + static void shell_action_quit_cb (GSimpleAction *action, GVariant *parameter, @@ -261,6 +274,14 @@ shell_add_actions (GApplication *application) g_simple_action_group_insert (action_group, G_ACTION (action)); g_object_unref (action); + action = g_simple_action_new ( + "handle-uris", G_VARIANT_TYPE_STRING_ARRAY); + g_signal_connect ( + action, "activate", + G_CALLBACK (shell_action_handle_uris_cb), application); + g_simple_action_group_insert (action_group, G_ACTION (action)); + g_object_unref (action); + action = g_simple_action_new ("quit", NULL); g_signal_connect ( action, "activate", @@ -810,29 +831,6 @@ shell_activate (GApplication *application) e_shell_create_shell_window (shell, NULL); } -static void -shell_open (GApplication *application, - GFile **files, - gint n_files, - const gchar *hint) -{ - EShell *shell; - gchar **uris; - gint ii; - - /* Do not chain up. Default method just emits a warning. */ - - shell = E_SHELL (application); - uris = g_new0 (gchar *, n_files + 1); - - for (ii = 0; ii < n_files; ii++) - uris[ii] = g_file_get_uri (files[ii]); - - e_shell_handle_uris (shell, uris, FALSE); - - g_strfreev (uris); -} - static void shell_quit_mainloop (GApplication *application) { @@ -878,7 +876,6 @@ e_shell_class_init (EShellClass *class) application_class = G_APPLICATION_CLASS (class); application_class->startup = shell_startup; application_class->activate = shell_activate; - application_class->open = shell_open; application_class->quit_mainloop = shell_quit_mainloop; class->window_destroyed = shell_window_destroyed; @@ -1516,7 +1513,7 @@ remote: /* Send a message to the other Evolution process. */ if (view_name != NULL) { g_action_group_activate_action ( - shell->priv->action_group, "new-window", + G_ACTION_GROUP (shell), "new-window", g_variant_new_string (view_name)); } else g_application_activate (G_APPLICATION (shell)); @@ -1536,12 +1533,11 @@ remote: /* Send a message to the other Evolution process. */ **/ guint e_shell_handle_uris (EShell *shell, - gchar **uris, + const gchar * const *uris, gboolean do_import) { - GFile **files; guint n_handled = 0; - guint length, ii; + guint ii; g_return_val_if_fail (E_IS_SHELL (shell), FALSE); g_return_val_if_fail (uris != NULL, FALSE); @@ -1569,21 +1565,13 @@ e_shell_handle_uris (EShell *shell, remote: /* Send a message to the other Evolution process. */ - length = g_strv_length (uris); - - files = g_new0 (GFile *, length + 1); - for (ii = 0; ii < length; ii++) - files[ii] = g_file_new_for_uri (uris[ii]); - - g_application_open (G_APPLICATION (shell), files, length, ""); - - for (ii = 0; ii < length; ii++) - g_object_unref (files[ii]); - g_free (files); + g_action_group_activate_action ( + G_ACTION_GROUP (shell), "handle-uris", + g_variant_new_strv (uris, -1)); /* As far as we're concerned, all URIs have been handled. */ - return length; + return g_strv_length ((gchar **) uris); } /** @@ -1995,7 +1983,7 @@ e_shell_quit (EShell *shell, remote: /* Send a message to the other Evolution process. */ g_action_group_activate_action ( - shell->priv->action_group, "quit", NULL); + G_ACTION_GROUP (shell), "quit", NULL); return TRUE; } diff --git a/shell/e-shell.h b/shell/e-shell.h index bbb11467fc..ede071e2e3 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -126,7 +126,7 @@ GConfClient * e_shell_get_gconf_client (EShell *shell); GtkWidget * e_shell_create_shell_window (EShell *shell, const gchar *view_name); guint e_shell_handle_uris (EShell *shell, - gchar **uris, + const gchar * const *uris, gboolean do_import); void e_shell_submit_alert (EShell *shell, EAlert *alert); diff --git a/shell/main.c b/shell/main.c index e1b768187d..95dc1b9ff4 100644 --- a/shell/main.c +++ b/shell/main.c @@ -246,7 +246,7 @@ show_development_warning (void) /* This is for doing stuff that requires the GTK+ loop to be running already. */ static gboolean -idle_cb (gchar **uris) +idle_cb (const gchar * const *uris) { EShell *shell; -- cgit v1.2.3