]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
Move view drag and drop stuff to ev-view.
[evince.git] / shell / ev-window.c
index 19ad581b3b64ba30b50c73a4845f09407dc366fa..ec979874bdba626c640959973a1e75d2e7f18358 100644 (file)
@@ -188,11 +188,6 @@ struct _EvWindowPrivate {
 #endif
 };
 
-static const GtkTargetEntry ev_drop_types[] = {
-       { "text/uri-list", 0, 0 }
-};
-
-
 #define EV_WINDOW_GET_PRIVATE(object) \
        (G_TYPE_INSTANCE_GET_PRIVATE ((object), EV_TYPE_WINDOW, EvWindowPrivate))
 
@@ -664,10 +659,18 @@ setup_document_from_metadata (EvWindow *window)
 {
        char *uri = window->priv->uri;
        GValue page = { 0, };
+       gint n_pages;
        gint new_page;
 
+       /* View the previously shown page, but make sure to not open a document on
+        * the last page, since closing it on the last page most likely means the
+        * user was finished reading the document. In that case, reopening should
+        * show the first page. */
        if (uri && ev_metadata_manager_get (uri, "page", &page, TRUE)) {
-               new_page = CLAMP (g_value_get_int (&page), 0, ev_page_cache_get_n_pages (window->priv->page_cache) - 1);
+               n_pages = ev_page_cache_get_n_pages (window->priv->page_cache);
+               new_page = CLAMP (g_value_get_int (&page), 0, n_pages - 1);
+               if (new_page == n_pages - 1)
+                       new_page = 0;
                ev_page_cache_set_current_page (window->priv->page_cache,
                                                new_page);
                g_value_unset (&page);
@@ -2086,7 +2089,9 @@ ev_window_cmd_file_properties (GtkAction *action, EvWindow *ev_window)
                                              GTK_WINDOW (ev_window));
        }
 
+       ev_document_fc_mutex_lock ();
        gtk_widget_show (ev_window->priv->properties);
+       ev_document_fc_mutex_unlock ();
 }
                                        
 static void
@@ -3854,35 +3859,6 @@ static const GtkActionEntry attachment_popup_entries [] = {
          NULL, G_CALLBACK (ev_attachment_popup_cmd_save_attachment_as) },
 };
 
-static void
-drag_data_received_cb (GtkWidget *widget, GdkDragContext *context,
-                      gint x, gint y, GtkSelectionData *selection_data,
-                      guint info, guint time, gpointer gdata)
-{
-       GList  *uri_list = NULL;
-       GSList *uris = NULL;
-       gchar  *uri;
-
-       uri_list = gnome_vfs_uri_list_parse ((gchar *) selection_data->data);
-
-       if (uri_list) {
-               while (uri_list) {
-                       uri = gnome_vfs_uri_to_string (uri_list->data, GNOME_VFS_URI_HIDE_NONE);
-                       uris = g_slist_append (uris, (gpointer) uri);
-                       
-                       uri_list = g_list_next (uri_list);
-               }
-
-               gnome_vfs_uri_list_free (uri_list);
-               
-               ev_application_open_uri_list (EV_APP, uris,
-                                             gtk_widget_get_screen (widget),
-                                             0);
-               
-               g_slist_free (uris);
-       }
-}
-
 static void
 activate_link_cb (EvPageAction *page_action, EvLink *link, EvWindow *window)
 {
@@ -4138,14 +4114,7 @@ launch_action (EvWindow *window, EvLinkAction *action)
 static void
 launch_external_uri (EvWindow *window, EvLinkAction *action)
 {
-       const char *uri;
-       char *escaped;
-
-       uri = ev_link_action_get_uri (action);
-       escaped = gnome_vfs_escape_host_and_path_string (uri);
-
-       gnome_vfs_url_show (escaped);
-       g_free (escaped);
+       gnome_vfs_url_show (ev_link_action_get_uri (action));
 }
 
 static void
@@ -4666,19 +4635,7 @@ ev_window_init (EvWindow *ev_window)
        /* Give focus to the document view */
        gtk_widget_grab_focus (ev_window->priv->view);
 
-       /* Drag and Drop */
-       gtk_drag_dest_unset (GTK_WIDGET (ev_window->priv->view));
-       gtk_drag_dest_set (GTK_WIDGET (ev_window->priv->view),
-                          GTK_DEST_DEFAULT_ALL,
-                          ev_drop_types,
-                          sizeof (ev_drop_types) / sizeof (ev_drop_types[0]),
-                          GDK_ACTION_COPY);
-       g_signal_connect_swapped (G_OBJECT (ev_window->priv->view), "drag-data-received",
-                                 G_CALLBACK (drag_data_received_cb),
-                                 ev_window);
-
        /* Set it user interface params */
-
        ev_window_setup_recent (ev_window);
 
        setup_chrome_from_metadata (ev_window);