[evince] [daemon] Return "" from RegisterDocument on new documents
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] [daemon] Return "" from RegisterDocument on new documents
- Date: Tue, 25 May 2010 07:45:01 +0000 (UTC)
commit 5bd752a3831fbb99cdcef0055707bd624fb9e30c
Author: Christian Persch <chpe gnome org>
Date: Mon May 10 14:52:46 2010 +0200
[daemon] Return "" from RegisterDocument on new documents
So we can distinguish this case in ev_application_register_uri().
shell/ev-application.c | 24 ++++++++++++++++++++++--
shell/ev-daemon.c | 40 +++++++++++++++++++++-------------------
2 files changed, 43 insertions(+), 21 deletions(-)
---
diff --git a/shell/ev-application.c b/shell/ev-application.c
index 050b396..454a2ee 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -332,6 +332,22 @@ ev_application_get_empty_window (EvApplication *application,
#ifdef ENABLE_DBUS
+/*
+ * ev_application_register_uri:
+ * @application:
+ * @uri:
+ * @screen:
+ * @dest:
+ * @mode:
+ * @search_string:
+ * @timestamp:
+ *
+ * Registers @uri with evince-daemon.
+ *
+ * Returns: %TRUE to continue by opening @uri in this instance,
+ * or %FALSE if the request was forwarded to an existing evince
+ * instance for @uri
+ */
static gboolean
ev_application_register_uri (EvApplication *application,
const gchar *uri,
@@ -369,7 +385,10 @@ ev_application_register_uri (EvApplication *application,
g_variant_get (value, "(&s)", &owner);
- if (owner[0] != ':') {
+ /* This means that the document wasn't already registered; go
+ * ahead with opening it.
+ */
+ if (owner[0] == '\0') {
g_variant_unref (value);
return TRUE;
}
@@ -416,8 +435,9 @@ ev_application_register_uri (EvApplication *application,
NULL,
&error);
if (value2 == NULL) {
- g_warning ("%s", error->message);
+ g_warning ("Failed to OpenURI: %s", error->message);
g_error_free (error);
+ return FALSE;
}
g_variant_unref (value);
diff --git a/shell/ev-daemon.c b/shell/ev-daemon.c
index b304dfc..b30238a 100644
--- a/shell/ev-daemon.c
+++ b/shell/ev-daemon.c
@@ -254,28 +254,30 @@ method_call_cb (GDBusConnection *connection,
g_variant_get (parameters, "(&s)", &uri);
doc = ev_daemon_find_doc (uri);
- if (doc == NULL) {
- ev_daemon_stop_killtimer ();
-
- doc = g_new (EvDoc, 1);
- doc->dbus_name = g_strdup (sender);
- doc->uri = g_strdup (uri);
-
- doc->watch_id = g_bus_watch_name (G_BUS_TYPE_STARTER,
- sender,
- G_BUS_NAME_WATCHER_FLAGS_NONE,
- name_appeared_cb,
- name_vanished_cb,
- user_data, NULL);
-
- LOG ("RegisterDocument registered owner '%s' for URI '%s'\n", doc->dbus_name, uri);
- ev_daemon_docs = g_list_prepend (ev_daemon_docs, doc);
- } else {
+ if (doc != NULL) {
LOG ("RegisterDocument found owner '%s' for URI '%s'\n", doc->dbus_name, uri);
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(s)", doc->dbus_name));
+ return;
}
+
+ ev_daemon_stop_killtimer ();
+
+ doc = g_new (EvDoc, 1);
+ doc->dbus_name = g_strdup (sender);
+ doc->uri = g_strdup (uri);
+
+ doc->watch_id = g_bus_watch_name (G_BUS_TYPE_STARTER,
+ sender,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ name_appeared_cb,
+ name_vanished_cb,
+ user_data, NULL);
+
+ LOG ("RegisterDocument registered owner '%s' for URI '%s'\n", doc->dbus_name, uri);
+ ev_daemon_docs = g_list_prepend (ev_daemon_docs, doc);
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(s)", doc->dbus_name));
+ g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", ""));
return;
} else if (g_strcmp0 (method_name, "UnregisterDocument") == 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]