]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Don't use libgnome to open help, instead call Yelp directly.
[evince.git] / shell / ev-window.c
index f584d99573319e181d7626417f49726ff4fbe6ab..b18abe7625ce1af8df1c51166c1f8e5543f6f327 100644 (file)
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <gnome.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <libgnomevfs/gnome-vfs-async-ops.h>
 #include <gconf/gconf-client.h>
 
+#include <errno.h>
+#include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 char *xdg_user_dir_lookup (char *type);
 
@@ -849,7 +851,7 @@ setup_sidebar_from_metadata (EvWindow *window, EvDocument *document)
                } else if (strcmp (page_id, THUMBNAILS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (thumbs), document)) {
                        ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
                } else if (strcmp (page_id, ATTACHMENTS_SIDEBAR_ID) && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (attachments), document)) {
-                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), thumbs);
+                       ev_sidebar_set_page (EV_SIDEBAR (sidebar), attachments);
                }
                g_value_unset (&sidebar_page);
        } else if (document && ev_sidebar_page_support_document (EV_SIDEBAR_PAGE (links), document)) {
@@ -1058,22 +1060,14 @@ ev_window_set_icon_from_thumbnail (EvJobThumbnail *job,
        ev_window_clear_thumbnail_job (ev_window);
 }
 
-static void
+static gboolean
 ev_window_setup_document (EvWindow *ev_window)
 {
        const EvDocumentInfo *info;
-       EvDocument *document;
-       EvView *view = EV_VIEW (ev_window->priv->view);
+       EvDocument *document = ev_window->priv->document;
        EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
        GtkAction *action;
-
-       document = ev_window->priv->document;
-       ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
-       g_signal_connect (ev_window->priv->page_cache, "page-changed",
-                         G_CALLBACK (page_changed_cb), ev_window);
-       g_signal_connect (ev_window->priv->page_cache, "history-changed",
-                         G_CALLBACK (history_changed_cb), ev_window);
-
+       
        if (EV_IS_DOCUMENT_FIND (document)) {
                g_signal_connect_object (G_OBJECT (document),
                                         "find_changed",
@@ -1102,16 +1096,12 @@ ev_window_setup_document (EvWindow *ev_window)
                g_object_unref (rc);
        }
 
-       ev_sidebar_set_document (sidebar, document);
-
-       if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
-               ev_view_set_document (view, document);
-       }
        ev_window_set_page_mode (ev_window, PAGE_MODE_DOCUMENT);
-
        ev_window_title_set_document (ev_window->priv->title, document);
        ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
 
+       ev_sidebar_set_document (sidebar, document);
+
        action = gtk_action_group_get_action (ev_window->priv->action_group, PAGE_SELECTOR_ACTION);
        ev_page_action_set_document (EV_PAGE_ACTION (action), document);
        ev_window_setup_action_sensitivity (ev_window);
@@ -1127,12 +1117,36 @@ ev_window_setup_document (EvWindow *ev_window)
                                                   ev_window->priv->document);
        }
        
+       info = ev_page_cache_get_info (ev_window->priv->page_cache);
+       update_document_mode (ev_window, info->mode);
+
+       return FALSE;
+}
+
+static void
+ev_window_set_document (EvWindow *ev_window, EvDocument *document)
+{
+       EvView *view = EV_VIEW (ev_window->priv->view);
+
+       if (ev_window->priv->document)
+               g_object_unref (ev_window->priv->document);
+       ev_window->priv->document = g_object_ref (document);
+       
+       ev_window->priv->page_cache = ev_page_cache_get (ev_window->priv->document);
+       g_signal_connect (ev_window->priv->page_cache, "page-changed",
+                         G_CALLBACK (page_changed_cb), ev_window);
+       g_signal_connect (ev_window->priv->page_cache, "history-changed",
+                         G_CALLBACK (history_changed_cb), ev_window);
+
        setup_size_from_metadata (ev_window);
-       setup_document_from_metadata (ev_window);
        setup_sidebar_from_metadata (ev_window, document);
+       setup_document_from_metadata (ev_window);
 
-       info = ev_page_cache_get_info (ev_window->priv->page_cache);
-       update_document_mode (ev_window, info->mode);
+       if (ev_page_cache_get_n_pages (ev_window->priv->page_cache) > 0) {
+               ev_view_set_document (view, document);
+       }
+
+       g_idle_add ((GSourceFunc)ev_window_setup_document, ev_window);
 }
 
 static void
@@ -1278,10 +1292,8 @@ ev_window_load_job_cb  (EvJobLoad *job,
 
        /* Success! */
        if (job->error == NULL) {
-               if (ev_window->priv->document)
-                       g_object_unref (ev_window->priv->document);
-               ev_window->priv->document = g_object_ref (document);
-
+               ev_window_set_document (ev_window, document);
+               
                if (job->mode != EV_WINDOW_MODE_PREVIEW) {
                        setup_view_from_metadata (ev_window);
                }
@@ -1290,8 +1302,6 @@ ev_window_load_job_cb  (EvJobLoad *job,
                        ev_window_add_recent (ev_window, ev_window->priv->uri);
                }
 
-               ev_window_setup_document (ev_window);
-
                if (job->dest) {
                        EvLink *link;
                        EvLinkAction *link_action;
@@ -1676,8 +1686,10 @@ ev_window_cmd_recent_file_activate (GtkAction *action,
 
        uri = egg_recent_item_get_uri (item);
 
-       ev_application_open_uri (EV_APP, uri, NULL,
-                                GDK_CURRENT_TIME, NULL);
+       ev_application_open_uri_at_dest (EV_APP, uri,
+                                        gtk_window_get_screen (GTK_WINDOW (ev_window)),
+                                        NULL, 0, FALSE,
+                                        GDK_CURRENT_TIME);
        
        g_free (uri);
 }
@@ -3120,15 +3132,45 @@ static void
 ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
 {
        GError *error = NULL;
+       char *command;
+       const char *lang;
+       char *uri = NULL;
 
-        g_return_if_fail (EV_IS_WINDOW (ev_window));
+       int i;
 
-       gnome_help_display ("evince.xml", NULL, &error);
+       const char * const * langs = g_get_language_names ();
 
-       if(error != NULL) {
+       for (i = 0; langs[i]; i++) {
+               lang = langs[i];
+               if (strchr (lang, '.')) {
+                       continue;
+               }
+
+               uri = g_build_filename(GNOMEDATADIR,
+                                      "/gnome/help/" PACKAGE,
+                                      lang,
+                                      "/evince.xml",
+                                      NULL);
+                                       
+               if (g_file_test (uri, G_FILE_TEST_EXISTS)) {
+                       break;
+               }
+       }
+
+       if (uri == NULL) {
+               g_warning ("Cannot find help");
+               return;
+       }
+       
+       command = g_strconcat ("gnome-help ghelp://", uri,  NULL);
+       g_free (uri);
+       
+       g_spawn_command_line_async (command, &error);
+       if (error != NULL) {
                g_warning (error->message);
                g_error_free (error);
        }
+       g_free (command);
 }
 
 static void