]> www.fi.muni.cz Git - evince.git/commitdiff
[shell] Add ev_window_open_document()
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 24 Aug 2009 13:29:34 +0000 (15:29 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 15 Sep 2009 13:59:15 +0000 (15:59 +0200)
It allows open an already loaded document in an EvWindow

shell/ev-window.c
shell/ev-window.h

index 82425dc27d649c9c1f0d5a14f0981f1669e6f4ec..b2a1c8050e2dc9637dabe8f8f08b455c3701422f 100644 (file)
@@ -1855,6 +1855,75 @@ ev_window_open_uri (EvWindow       *ev_window,
        }
 }
 
+void
+ev_window_open_document (EvWindow       *ev_window,
+                        EvDocument     *document,
+                        EvLinkDest     *dest,
+                        EvWindowRunMode mode,
+                        const gchar    *search_string)
+{
+       if (document == ev_window->priv->document)
+               return;
+
+       ev_window_close_dialogs (ev_window);
+       ev_window_clear_load_job (ev_window);
+       ev_window_clear_local_uri (ev_window);
+
+       if (ev_window->priv->monitor) {
+               g_object_unref (ev_window->priv->monitor);
+               ev_window->priv->monitor = NULL;
+       }
+
+       if (ev_window->priv->uri)
+               g_free (ev_window->priv->uri);
+       ev_window->priv->uri = g_strdup (ev_document_get_uri (document));
+
+       setup_size_from_metadata (ev_window);
+       setup_model_from_metadata (ev_window);
+
+       ev_document_model_set_document (ev_window->priv->model, document);
+
+       setup_document_from_metadata (ev_window);
+       setup_view_from_metadata (ev_window);
+
+       if (dest) {
+               EvLink *link;
+               EvLinkAction *link_action;
+
+               link_action = ev_link_action_new_dest (dest);
+               link = ev_link_new (NULL, link_action);
+               ev_view_handle_link (EV_VIEW (ev_window->priv->view), link);
+               /* FIXME: link action should inc dest ref counting
+                * or not unref it at all
+                */
+               g_object_ref (dest);
+               g_object_unref (link);
+       }
+
+       switch (mode) {
+       case EV_WINDOW_MODE_FULLSCREEN:
+               ev_window_run_fullscreen (ev_window);
+               break;
+       case EV_WINDOW_MODE_PRESENTATION:
+               ev_window_run_presentation (ev_window);
+               break;
+       default:
+               break;
+       }
+
+       if (search_string && EV_IS_DOCUMENT_FIND (document)) {
+               ev_window_cmd_edit_find (NULL, ev_window);
+               egg_find_bar_set_search_string (EGG_FIND_BAR (ev_window->priv->find_bar),
+                                               search_string);
+       }
+
+       /* Create a monitor for the document */
+       ev_window->priv->monitor = ev_file_monitor_new (ev_window->priv->uri);
+       g_signal_connect_swapped (ev_window->priv->monitor, "changed",
+                                 G_CALLBACK (ev_window_document_changed),
+                                 ev_window);
+}
+
 static void
 ev_window_reload_local (EvWindow *ev_window)
 {
index c95c1a4419b55be112b75c5c183b706a3d4fa457..044e9a888260f5c8e56ec58fd728498d398325cc 100644 (file)
@@ -68,18 +68,23 @@ struct _EvWindowClass {
        GtkWindowClass          base_class;
 };
 
-GType          ev_window_get_type        (void);
-GtkWidget      *ev_window_new             (void);
-const char     *ev_window_get_uri         (EvWindow       *ev_window);
-void           ev_window_open_uri        (EvWindow       *ev_window,
-                                          const char     *uri,
-                                          EvLinkDest     *dest,
-                                          EvWindowRunMode mode,
-                                          const gchar    *search_string);
-gboolean       ev_window_is_empty        (const EvWindow *ev_window);
-void           ev_window_print_range     (EvWindow       *ev_window,
-                                          int             first_page,
-                                          int             last_page);
+GType          ev_window_get_type      (void) G_GNUC_CONST;
+GtkWidget      *ev_window_new           (void);
+const char     *ev_window_get_uri       (EvWindow       *ev_window);
+void           ev_window_open_uri      (EvWindow       *ev_window,
+                                        const char     *uri,
+                                        EvLinkDest     *dest,
+                                        EvWindowRunMode mode,
+                                        const gchar    *search_string);
+void           ev_window_open_document (EvWindow       *ev_window,
+                                        EvDocument     *document,
+                                        EvLinkDest     *dest,
+                                        EvWindowRunMode mode,
+                                        const gchar    *search_string);
+gboolean       ev_window_is_empty      (const EvWindow *ev_window);
+void           ev_window_print_range   (EvWindow       *ev_window,
+                                        int             first_page,
+                                        int             last_page);
 
 G_END_DECLS