]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-application.c
Do not connect selection changed signal more than once. Fixes bug #349433.
[evince.git] / shell / ev-application.c
index 4bbec37cd1d1348a63903a316fd317662084d590..53d284f1fad805d28f234b1fe91de26edce896e7 100644 (file)
@@ -75,7 +75,6 @@ ev_application_register_service (EvApplication *application)
                                                  DBUS_PATH_DBUS,
                                                  DBUS_INTERFACE_DBUS);
 
                                                  DBUS_PATH_DBUS,
                                                  DBUS_INTERFACE_DBUS);
 
-#if DBUS_VERSION >= 60 
        if (!org_freedesktop_DBus_request_name (driver_proxy,
                                                APPLICATION_SERVICE_NAME,
                                                DBUS_NAME_FLAG_DO_NOT_QUEUE,
        if (!org_freedesktop_DBus_request_name (driver_proxy,
                                                APPLICATION_SERVICE_NAME,
                                                DBUS_NAME_FLAG_DO_NOT_QUEUE,
@@ -83,14 +82,6 @@ ev_application_register_service (EvApplication *application)
                g_warning ("Service registration failed.");
                g_clear_error (&err);
        }
                g_warning ("Service registration failed.");
                g_clear_error (&err);
        }
-#else
-       if (!org_freedesktop_DBus_request_name (driver_proxy,
-                                               APPLICATION_SERVICE_NAME,
-                                               0, &request_name_result, &err)) {
-               g_warning ("Service registration failed.");
-               g_clear_error (&err);
-       }
-#endif 
 
        g_object_unref (driver_proxy);
        
 
        g_object_unref (driver_proxy);
        
@@ -98,18 +89,14 @@ ev_application_register_service (EvApplication *application)
                return FALSE;
        }
 
                return FALSE;
        }
 
-#if DBUS_VERSION == 33
-       dbus_g_object_class_install_info (G_OBJECT_GET_CLASS (application),
-                                         &dbus_glib_ev_application_object_info);
-#else
        dbus_g_object_type_install_info (EV_TYPE_APPLICATION,
                                         &dbus_glib_ev_application_object_info);
        dbus_g_object_type_install_info (EV_TYPE_APPLICATION,
                                         &dbus_glib_ev_application_object_info);
-#endif
-
        dbus_g_connection_register_g_object (connection,
                                             "/org/gnome/evince/Evince",
                                              G_OBJECT (application));
        dbus_g_connection_register_g_object (connection,
                                             "/org/gnome/evince/Evince",
                                              G_OBJECT (application));
-
+       
+       application->scr_saver = totem_scrsaver_new (connection);
+       
        return TRUE;
 }
 #endif /* ENABLE_DBUS */
        return TRUE;
 }
 #endif /* ENABLE_DBUS */
@@ -260,6 +247,22 @@ get_destination_from_args (GHashTable *args)
        return dest;
 }
 
        return dest;
 }
 
+static gboolean
+get_unlink_temp_file_from_args (GHashTable *args)
+{
+       gboolean unlink_temp_file = FALSE;
+       GValue  *value = NULL;
+
+       g_assert (args != NULL);
+
+       value = g_hash_table_lookup (args, "unlink-temp-file");
+       if (value) {
+               unlink_temp_file = g_value_get_boolean (value);
+       }
+       
+       return unlink_temp_file;
+}
+
 gboolean
 ev_application_open_window (EvApplication  *application,
                            GHashTable     *args,
 gboolean
 ev_application_open_window (EvApplication  *application,
                            GHashTable     *args,
@@ -339,12 +342,39 @@ ev_application_open_uri_at_dest (EvApplication  *application,
                                 GdkScreen      *screen,
                                 EvLinkDest     *dest,
                                 EvWindowRunMode mode,
                                 GdkScreen      *screen,
                                 EvLinkDest     *dest,
                                 EvWindowRunMode mode,
+                                gboolean        unlink_temp_file,
                                 guint           timestamp)
 {
                                 guint           timestamp)
 {
-       EvWindow *new_window;
+       EvWindow     *new_window;
+       GtkIconTheme *icon_theme;
 
        g_return_if_fail (uri != NULL);
 
 
        g_return_if_fail (uri != NULL);
 
+       icon_theme = gtk_icon_theme_get_for_screen (screen);
+       if (icon_theme) {
+               gchar **path = NULL;
+               gint    n_paths;
+               gint    i;
+               gchar  *ev_icons_path;
+
+               /* GtkIconTheme will then look in Evince custom hicolor dir
+                * for icons as well as the standard search paths
+                */
+               ev_icons_path = g_build_filename (DATADIR, "icons", NULL);
+               gtk_icon_theme_get_search_path (icon_theme, &path, &n_paths);
+               for (i = n_paths - 1; i >= 0; i--) {
+                       if (g_ascii_strcasecmp (ev_icons_path, path[i]) == 0)
+                               break;
+               }
+
+               if (i < 0)
+                       gtk_icon_theme_append_search_path (icon_theme,
+                                                          ev_icons_path);
+
+               g_free (ev_icons_path);
+               g_strfreev (path);
+       }       
+
        new_window = ev_application_get_uri_window (application, uri);
        
        if (new_window == NULL) {
        new_window = ev_application_get_uri_window (application, uri);
        
        if (new_window == NULL) {
@@ -360,9 +390,11 @@ ev_application_open_uri_at_dest (EvApplication  *application,
 
        /* We need to load uri before showing the window, so
           we can restore window size without flickering */     
 
        /* We need to load uri before showing the window, so
           we can restore window size without flickering */     
-       ev_window_open_uri (new_window, uri, dest, mode);
+       ev_window_open_uri (new_window, uri, dest, mode, unlink_temp_file);
 
 
+       ev_document_fc_mutex_lock ();
        gtk_widget_show (GTK_WIDGET (new_window));
        gtk_widget_show (GTK_WIDGET (new_window));
+       ev_document_fc_mutex_unlock ();
 
        gtk_window_present_with_time (GTK_WINDOW (new_window),
                                      timestamp);
 
        gtk_window_present_with_time (GTK_WINDOW (new_window),
                                      timestamp);
@@ -377,16 +409,20 @@ ev_application_open_uri (EvApplication  *application,
 {
        EvLinkDest      *dest = NULL;
        EvWindowRunMode  mode = EV_WINDOW_MODE_NORMAL;
 {
        EvLinkDest      *dest = NULL;
        EvWindowRunMode  mode = EV_WINDOW_MODE_NORMAL;
+       gboolean         unlink_temp_file = FALSE;
        GdkScreen       *screen = NULL;
 
        if (args) {
                screen = get_screen_from_args (args);
                dest = get_destination_from_args (args);
                mode = get_window_run_mode_from_args (args);
        GdkScreen       *screen = NULL;
 
        if (args) {
                screen = get_screen_from_args (args);
                dest = get_destination_from_args (args);
                mode = get_window_run_mode_from_args (args);
+               unlink_temp_file = (mode == EV_WINDOW_MODE_PREVIEW &&
+                                   get_unlink_temp_file_from_args (args));
        }
        
        ev_application_open_uri_at_dest (application, uri, screen,
        }
        
        ev_application_open_uri_at_dest (application, uri, screen,
-                                        dest, mode, timestamp);
+                                        dest, mode, unlink_temp_file, 
+                                        timestamp);
 
        if (dest)
                g_object_unref (dest);
 
        if (dest)
                g_object_unref (dest);
@@ -404,7 +440,8 @@ ev_application_open_uri_list (EvApplication *application,
 
        for (l = uri_list; l != NULL; l = l->next) {
                ev_application_open_uri_at_dest (application, (char *)l->data,
 
        for (l = uri_list; l != NULL; l = l->next) {
                ev_application_open_uri_at_dest (application, (char *)l->data,
-                                                screen, NULL, 0, timestamp);
+                                                screen, NULL, 0, FALSE, 
+                                                timestamp);
        }
 }
 
        }
 }
 
@@ -529,3 +566,14 @@ const gchar* ev_application_get_chooser_uri (EvApplication *application)
        return application->last_chooser_uri;
 }
 
        return application->last_chooser_uri;
 }
 
+void ev_application_screensaver_enable  (EvApplication   *application)
+{
+       if (application->scr_saver)
+               totem_scrsaver_enable (application->scr_saver); 
+}
+
+void ev_application_screensaver_disable (EvApplication   *application)
+{
+       if (application->scr_saver)
+               totem_scrsaver_disable (application->scr_saver);        
+}