aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-22 23:04:27 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-06-30 00:42:19 +0800
commit9a2cffb0570bbde009ef45ae19c00059a9804e02 (patch)
tree5c04da6305e1aef66921295d9c318d9a577f19dd /shell
parentdf724f165213ea60a5a8dd45c3e7b6ca829d4dac (diff)
downloadgsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.tar
gsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.tar.gz
gsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.tar.bz2
gsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.tar.lz
gsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.tar.xz
gsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.tar.zst
gsoc2013-evolution-9a2cffb0570bbde009ef45ae19c00059a9804e02.zip
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.
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-utils.c4
-rw-r--r--shell/e-shell-utils.h2
-rw-r--r--shell/e-shell.c70
-rw-r--r--shell/e-shell.h2
-rw-r--r--shell/main.c2
5 files changed, 34 insertions, 46 deletions
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
@@ -236,6 +236,19 @@ shell_action_new_window_cb (GSimpleAction *action,
}
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,
EShell *shell)
@@ -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",
@@ -811,29 +832,6 @@ shell_activate (GApplication *application)
}
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)
{
/* XXX Don't allow GApplication to quit the main loop.
@@ -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;