]> www.fi.muni.cz Git - evince.git/commitdiff
[windows] Make evince relocatable on windows - GUI
authorHib Eris <hib@hiberis.nl>
Tue, 9 Jun 2009 13:10:50 +0000 (15:10 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 9 Jun 2009 13:10:50 +0000 (15:10 +0200)
shell/ev-application.c
shell/ev-application.h
shell/ev-window.c

index 6a3367f712546e6b93fe7f7326e69e9e3694e7b1..3d4afb1b56dc378e877d709bec024c9c43443249 100644 (file)
@@ -57,6 +57,7 @@ struct _EvApplication {
        GObject base_instance;
 
        gchar *dot_dir;
+       gchar *data_dir;
        gchar *accel_map_file;
        gchar *toolbars_file;
        gchar *crashed_file;
@@ -787,6 +788,8 @@ ev_application_shutdown (EvApplication *application)
 
         g_free (application->dot_dir);
         application->dot_dir = NULL;
+        g_free (application->data_dir);
+        application->data_dir = NULL;
        g_free (application->filechooser_open_uri);
         application->filechooser_open_uri = NULL;
        g_free (application->filechooser_save_uri);
@@ -808,6 +811,7 @@ ev_application_init (EvApplication *ev_application)
 {
        gint i;
        const gchar *home_dir;
+       gchar *toolbar_path;
 
         ev_application->dot_dir = g_build_filename (g_get_home_dir (),
                                                     ".gnome2",
@@ -818,6 +822,18 @@ ev_application_init (EvApplication *ev_application)
         if (!ev_dir_ensure_exists (ev_application->dot_dir, 0700))
                 exit (1);
 
+#ifdef G_OS_WIN32
+{
+       gchar *dir;
+
+       dir = g_win32_get_package_installation_directory_of_module (NULL);
+       ev_application->data_dir = g_build_filename (dir, "share", "evince", NULL);
+       g_free (dir);
+}
+#else
+       ev_application->data_dir = g_strdup (DATADIR);
+#endif
+
        ev_application_init_session (ev_application);
 
        home_dir = g_get_home_dir ();
@@ -835,14 +851,17 @@ ev_application_init (EvApplication *ev_application)
        ev_application->toolbars_file = g_build_filename
                        (ev_application->dot_dir, "evince_toolbar.xml", NULL);
 
+       toolbar_path = g_build_filename (ev_application->data_dir,
+                                        "evince-toolbar.xml", NULL);
        egg_toolbars_model_load_names (ev_application->toolbars_model,
-                                      DATADIR "/evince-toolbar.xml");
+                                      toolbar_path);
 
        if (!egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
                                               ev_application->toolbars_file)) {
                egg_toolbars_model_load_toolbars (ev_application->toolbars_model,
-                                                 DATADIR"/evince-toolbar.xml");
+                                                 toolbar_path);
        }
+       g_free (toolbar_path);
 
        /* Open item doesn't exist anymore,
         * convert it to OpenRecent for compatibility
@@ -1114,3 +1133,9 @@ ev_application_get_dot_dir (EvApplication   *application)
 {
        return application->dot_dir;
 }
+
+const gchar *
+ev_application_get_data_dir (EvApplication   *application)
+{
+       return application->data_dir;
+}
index 184927b111457996dfc53b24fd4c5d90e0283344..2ae2a8a05f245037e4d68d444d45498c7962c344 100644 (file)
@@ -93,6 +93,7 @@ GtkPageSetup     *ev_application_get_page_setup      (EvApplication   *applicati
 void              ev_application_set_page_setup      (EvApplication   *application,
                                                      GtkPageSetup    *page_setup);
 const gchar      *ev_application_get_dot_dir         (EvApplication   *application);
+const gchar      *ev_application_get_data_dir         (EvApplication   *application);
 
 G_END_DECLS
 
index a1dadb7fc84298d4ddef5329fa0252b19fbcc240..7984cabb1df5c9bc7508e7d16061155e377f07a1 100644 (file)
@@ -5883,6 +5883,7 @@ ev_window_init (EvWindow *ev_window)
        GError *error = NULL;
        GtkWidget *sidebar_widget;
        GObject *mpkeys;
+       gchar *ui_path;
 
        g_signal_connect (ev_window, "configure_event",
                          G_CALLBACK (window_configure_event_cb), NULL);
@@ -5937,12 +5938,15 @@ ev_window_init (EvWindow *ev_window)
        gtk_ui_manager_insert_action_group (ev_window->priv->ui_manager,
                                            action_group, 0);
 
-       if (!gtk_ui_manager_add_ui_from_file (ev_window->priv->ui_manager,
-                                             DATADIR"/evince-ui.xml",
-                                             &error)) {
+       ui_path = g_build_filename (ev_application_get_data_dir (EV_APP),
+                                   "evince-ui.xml", NULL);
+       if (!gtk_ui_manager_add_ui_from_file (
+               ev_window->priv->ui_manager, ui_path, &error))
+       {
                g_warning ("building menus failed: %s", error->message);
                g_error_free (error);
        }
+       g_free (ui_path);
        
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
        ev_window->priv->recent_action_group = NULL;