]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-application.c
Added F3 as a find-next accelerator key, bug 579072
[evince.git] / shell / ev-application.c
index 4164d0b92c57a26729e955a8033d6d1094ad6a66..56824e8e611cfa0132c2bf78646a15f4bbfecfa6 100644 (file)
@@ -28,7 +28,9 @@
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+#ifdef GDK_WINDOWING_X11
 #include <gdk/gdkx.h>
+#endif
 
 #include "totem-scrsaver.h"
 #include "eggsmclient.h"
@@ -36,7 +38,9 @@
 #include "ev-application.h"
 #include "ev-document-factory.h"
 #include "ev-file-helpers.h"
+#include "ev-metadata-manager.h"
 #include "ev-utils.h"
+#include "ev-stock-icons.h"
 
 #ifdef ENABLE_DBUS
 #include "ev-media-player-keys.h"
@@ -47,8 +51,7 @@
 #include "ev-application-service.h"
 #endif
 
-static void ev_application_add_icon_path_for_screen (GdkScreen     *screen);
-static void ev_application_save_print_settings      (EvApplication *application);
+static void ev_application_save_print_settings (EvApplication *application);
 
 struct _EvApplication {
        GObject base_instance;
@@ -78,6 +81,8 @@ struct _EvApplicationClass {
        GObjectClass base_class;
 };
 
+static EvApplication *instance;
+
 G_DEFINE_TYPE (EvApplication, ev_application, G_TYPE_OBJECT);
 
 #define APPLICATION_SERVICE_NAME "org.gnome.evince.ApplicationService"
@@ -134,7 +139,9 @@ ev_application_register_service (EvApplication *application)
                                              G_OBJECT (application));
        
        application->scr_saver = totem_scrsaver_new (connection);
-       
+
+        ev_metadata_manager_init ();
+
        return TRUE;
 }
 #endif /* ENABLE_DBUS */
@@ -149,8 +156,6 @@ ev_application_register_service (EvApplication *application)
 EvApplication *
 ev_application_get_instance (void)
 {
-       static EvApplication *instance;
-
        if (!instance) {
                instance = EV_APPLICATION (g_object_new (EV_TYPE_APPLICATION, NULL));
        }
@@ -380,48 +385,6 @@ get_find_string_from_args (GHashTable *args)
        return value ? g_value_get_string (value) : NULL;
 }
 
-/**
- * get_unlink_temp_file_from_args:
- * @args: a #GHashTable with data passed to the application.
- *
- * It does look if the unlink-temp-file option has been passed from the command
- * line returning it's boolean representation, otherwise it does return %FALSE.
- *
- * Returns: the boolean representation of the unlink-temp-file value or %FALSE
- *          in other case.
- */
-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;
-}
-
-static const gchar *
-get_print_settings_from_args (GHashTable *args)
-{
-       const gchar *print_settings = NULL;
-       GValue      *value = NULL;
-
-       g_assert (args != NULL);
-
-       value = g_hash_table_lookup (args, "print-settings");
-       if (value) {
-               print_settings = g_value_get_string (value);
-       }
-
-       return print_settings;
-}
-
 /**
  * ev_application_open_window:
  * @application: The instance of the application.
@@ -449,9 +412,9 @@ ev_application_open_window (EvApplication  *application,
        }
        
        if (screen) {
+               ev_stock_icons_add_icons_path_for_screen (screen);
                gtk_window_set_screen (GTK_WINDOW (new_window), screen);
        }
-       ev_application_add_icon_path_for_screen (screen);
 
        if (!GTK_WIDGET_REALIZED (new_window))
                gtk_widget_realize (new_window);
@@ -540,37 +503,6 @@ ev_application_get_uri_window (EvApplication *application, const char *uri)
        return uri_window;
 }
 
-static void
-ev_application_add_icon_path_for_screen (GdkScreen *screen)
-{
-       GtkIconTheme *icon_theme;
-
-       icon_theme = screen ? gtk_icon_theme_get_for_screen (screen) : gtk_icon_theme_get_default ();
-       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);
-       }       
-}
-
 /**
  * ev_application_open_uri_at_dest:
  * @application: The instance of the application.
@@ -578,7 +510,6 @@ ev_application_add_icon_path_for_screen (GdkScreen *screen)
  * @screen: Thee screen where the link will be shown.
  * @dest: The #EvLinkDest of the document.
  * @mode: The run mode of the window.
- * @unlink_temp_file: The unlink_temp_file option value.
  * @timestamp: Current time value.
  */
 void
@@ -588,16 +519,12 @@ ev_application_open_uri_at_dest (EvApplication  *application,
                                 EvLinkDest     *dest,
                                 EvWindowRunMode mode,
                                 const gchar    *search_string,
-                                gboolean        unlink_temp_file,
-                                const gchar    *print_settings, 
                                 guint           timestamp)
 {
        EvWindow *new_window;
 
        g_return_if_fail (uri != NULL);
        
-       ev_application_add_icon_path_for_screen (screen);
-
        new_window = ev_application_get_uri_window (application, uri);
        
        if (new_window == NULL) {
@@ -608,13 +535,14 @@ ev_application_open_uri_at_dest (EvApplication  *application,
                new_window = EV_WINDOW (ev_window_new ());
        }
 
-       if (screen)
+       if (screen) {
+               ev_stock_icons_add_icons_path_for_screen (screen);
                gtk_window_set_screen (GTK_WINDOW (new_window), screen);
+       }
 
        /* 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, search_string, 
-                           unlink_temp_file, print_settings);
+       ev_window_open_uri (new_window, uri, dest, mode, search_string);
 
        if (!GTK_WIDGET_REALIZED (GTK_WIDGET (new_window)))
                gtk_widget_realize (GTK_WIDGET (new_window));
@@ -652,8 +580,6 @@ ev_application_open_uri (EvApplication  *application,
        EvLinkDest      *dest = NULL;
        EvWindowRunMode  mode = EV_WINDOW_MODE_NORMAL;
        const gchar     *search_string = NULL;
-       gboolean         unlink_temp_file = FALSE;
-       const gchar     *print_settings = NULL;
        GdkScreen       *screen = NULL;
 
        if (args) {
@@ -661,15 +587,11 @@ ev_application_open_uri (EvApplication  *application,
                dest = get_destination_from_args (args);
                mode = get_window_run_mode_from_args (args);
                search_string = get_find_string_from_args (args);
-               unlink_temp_file = (mode == EV_WINDOW_MODE_PREVIEW &&
-                                   get_unlink_temp_file_from_args (args));
-               print_settings = get_print_settings_from_args (args);
        }
        
        ev_application_open_uri_at_dest (application, uri, screen,
                                         dest, mode, search_string,
-                                        unlink_temp_file,
-                                        print_settings, timestamp);
+                                        timestamp);
 
        if (dest)
                g_object_unref (dest);
@@ -688,7 +610,7 @@ 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,
                                                 screen, NULL, 0, NULL,
-                                                FALSE, NULL, timestamp);
+                                                timestamp);
        }
 }
 
@@ -732,12 +654,15 @@ ev_application_shutdown (EvApplication *application)
        }
 #endif /* ENABLE_DBUS */
        
+        ev_metadata_manager_shutdown ();
+
         g_free (application->dot_dir);
         application->dot_dir = NULL;
        g_free (application->last_chooser_uri);
         application->last_chooser_uri = NULL;
 
        g_object_unref (application);
+        instance = NULL;
        
        gtk_main_quit ();
 }
@@ -768,7 +693,7 @@ ev_application_init (EvApplication *ev_application)
        if (home_dir) {
                ev_application->accel_map_file = g_build_filename (home_dir,
                                                                   ".gnome2",
-                                                                  "accels"
+                                                                  "accels",
                                                                   "evince",
                                                                   NULL);
                gtk_accel_map_load (ev_application->accel_map_file);