]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-application.c
[shell] Pass the GDBusConnection to TotemScrsaver
[evince.git] / shell / ev-application.c
index 050b396f6c8539775aa9678757a34ada0b8cb9d2..191c6fb94274356955bc322aa5552b36bb9ac206 100644 (file)
@@ -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,
@@ -350,14 +366,14 @@ ev_application_register_uri (EvApplication *application,
                return TRUE;
 
         /* FIXME: Don't make sync dbus calls, they block the UI! */
-        value = g_dbus_connection_invoke_method_sync
+        value = g_dbus_connection_call_sync
                    (application->connection,
                     "org.gnome.evince.Daemon",
                     "/org/gnome/evince/Daemon",
                     "org.gnome.evince.Daemon",
                     "RegisterDocument",
                     g_variant_new ("(s)", uri),
-                    G_DBUS_INVOKE_METHOD_FLAGS_NONE,
+                    G_DBUS_CALL_FLAGS_NONE,
                     -1,
                     NULL,
                     &error);
@@ -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;
         }
@@ -404,20 +423,21 @@ ev_application_register_uri (EvApplication *application,
 
         g_variant_builder_add (&builder, "u", timestamp);
 
-        value2 = g_dbus_connection_invoke_method_sync
+        value2 = g_dbus_connection_call_sync
                     (application->connection,
                      owner,
                      APPLICATION_DBUS_OBJECT_PATH,
                      APPLICATION_DBUS_INTERFACE,
                      "OpenURI",
                      g_variant_builder_end (&builder),
-                     G_DBUS_INVOKE_METHOD_FLAGS_NONE,
+                     G_DBUS_CALL_FLAGS_NONE,
                      -1,
                      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);
@@ -438,14 +458,14 @@ ev_application_unregister_uri (EvApplication *application,
                return;
 
         /* FIXME: Don't make sync dbus calls, they block the UI! */
-        value = g_dbus_connection_invoke_method_sync
+        value = g_dbus_connection_call_sync
                    (application->connection,
                     "org.gnome.evince.Daemon",
                     "/org/gnome/evince/Daemon",
                     "org.gnome.evince.Daemon",
                     "UnregisterDocument",
                     g_variant_new ("(s)", uri),
-                    G_DBUS_INVOKE_METHOD_FLAGS_NONE,
+                    G_DBUS_CALL_FLAGS_NO_AUTO_START,
                     -1,
                     NULL,
                     &error);
@@ -821,8 +841,6 @@ ev_application_init (EvApplication *ev_application)
 
        ev_application_accel_map_load (ev_application);
 
-       ev_application->scr_saver = totem_scrsaver_new ();
-
 #ifdef ENABLE_DBUS
 {
         static const char introspection_xml[] =
@@ -868,8 +886,12 @@ ev_application_init (EvApplication *ev_application)
                 g_error_free (error);
         }
 
-       ev_application->keys = ev_media_player_keys_new ();
+       ev_application->keys = ev_media_player_keys_new (ev_application->connection);
+
+       ev_application->scr_saver = totem_scrsaver_new (ev_application->connection);
 }
+#else
+        ev_application->scr_saver = totem_scrsaver_new ();
 #endif /* ENABLE_DBUS */
 }