]> www.fi.muni.cz Git - evince.git/commitdiff
Make the whole EvWindow the destination of a drag and drop operation.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Sun, 18 Jan 2009 09:41:32 +0000 (09:41 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Sun, 18 Jan 2009 09:41:32 +0000 (09:41 +0000)
2009-01-17  Carlos Garcia Campos  <carlosgc@gnome.org>

* shell/ev-view.c: (ev_view_drag_data_received),
(ev_view_class_init), (ev_view_init):
* shell/ev-window.c: (ev_window_drag_data_received),
(ev_window_class_init), (ev_window_init):

Make the whole EvWindow the destination of a drag and drop
operation.

svn path=/trunk/; revision=3345

ChangeLog
shell/ev-view.c
shell/ev-window.c

index aca9f43b55e6bd4b346f3f07b59c13227b717f16..319aefa3b130e05700bdad29cf98c48eced17755 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2009-01-17  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * shell/ev-view.c: (ev_view_drag_data_received),
+       (ev_view_class_init), (ev_view_init):
+       * shell/ev-window.c: (ev_window_drag_data_received),
+       (ev_window_class_init), (ev_window_init):
+
+       Make the whole EvWindow the destination of a drag and drop
+       operation.
+       
 2009-01-16  Carlos Garcia Campos  <carlosgc@gnome.org>
 
        * shell/ev-window.c: (window_open_file_copy_progress_cb):
index ce5d0579465d12c05d71ae60b69f065706d54f00..b8964b1844f41ef3b5716cf4700e410913e23394 100644 (file)
@@ -28,7 +28,6 @@
 #include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
 
-#include "ev-application.h"
 #include "ev-document-forms.h"
 #include "ev-document-images.h"
 #include "ev-document-links.h"
@@ -88,10 +87,6 @@ static const GtkTargetEntry clipboard_targets[] = {
        { "UTF8_STRING", 0, TARGET_UTF8_STRING },
 };
 
-static const GtkTargetEntry view_drop_targets[] = {
-       { "text/uri-list", 0, 0 }
-};
-
 static guint signals[N_SIGNALS];
 
 typedef enum {
@@ -2793,39 +2788,6 @@ ev_view_drag_motion (GtkWidget      *widget,
        return TRUE;
 }
                     
-static void
-ev_view_drag_data_received (GtkWidget          *widget,
-                           GdkDragContext     *context,
-                           gint                x,
-                           gint                y,
-                           GtkSelectionData   *selection_data,
-                           guint               info,
-                           guint               time)
-{
-       gchar  **uris;
-       gint     i = 0;
-       GSList  *uri_list = NULL;
-
-       uris = gtk_selection_data_get_uris (selection_data);
-       if (!uris) {
-               gtk_drag_finish (context, FALSE, FALSE, time);
-               return;
-       }
-
-       for (i = 0; uris[i]; i++) {
-               uri_list = g_slist_prepend (uri_list, (gpointer) uris[i]);
-       }
-       
-       ev_application_open_uri_list (EV_APP, uri_list,
-                                     gtk_widget_get_screen (widget),
-                                     0);
-       gtk_drag_finish (context, TRUE, FALSE, time);
-       
-       g_strfreev (uris);
-       g_slist_free (uri_list);
-}
-
-
 static gboolean
 selection_update_idle_cb (EvView *view)
 {
@@ -3977,7 +3939,6 @@ ev_view_class_init (EvViewClass *class)
        widget_class->style_set = ev_view_style_set;
        widget_class->drag_data_get = ev_view_drag_data_get;
        widget_class->drag_motion = ev_view_drag_motion;
-       widget_class->drag_data_received = ev_view_drag_data_received;
        widget_class->popup_menu = ev_view_popup_menu;
        widget_class->query_tooltip = ev_view_query_tooltip;
 
@@ -4144,12 +4105,6 @@ ev_view_init (EvView *view)
 
        gtk_layout_set_hadjustment (GTK_LAYOUT (view), NULL);
        gtk_layout_set_vadjustment (GTK_LAYOUT (view), NULL);
-
-       gtk_drag_dest_set (GTK_WIDGET (view),
-                          GTK_DEST_DEFAULT_ALL,
-                          view_drop_targets,
-                          G_N_ELEMENTS (view_drop_targets),
-                          GDK_ACTION_COPY);
 }
 
 /*** Callbacks ***/
index 9c63904774bf00070884299bd39fa8c82608f6c1..eb606ef9c1779abffcd827d65927bd5168102c50 100644 (file)
@@ -238,6 +238,10 @@ static const gchar *document_print_settings[] = {
        GTK_PRINT_SETTINGS_OUTPUT_URI
 };
 
+static const GtkTargetEntry ev_window_drop_targets[] = {
+       { "text/uri-list", 0, 0 }
+};
+
 static void    ev_window_update_actions                (EvWindow         *ev_window);
 static void     ev_window_sidebar_visibility_changed_cb (EvSidebar        *ev_sidebar,
                                                         GParamSpec       *pspec,
@@ -4683,6 +4687,40 @@ zoom_control_changed_cb (EphyZoomAction *action,
        }
 }
 
+static void
+ev_window_drag_data_received (GtkWidget        *widget,
+                             GdkDragContext   *context,
+                             gint              x,
+                             gint              y,
+                             GtkSelectionData *selection_data,
+                             guint             info,
+                             guint             time)
+
+{
+       EvWindow *window = EV_WINDOW (widget);
+       gchar   **uris;
+       gint      i = 0;
+       GSList   *uri_list = NULL;
+
+       uris = gtk_selection_data_get_uris (selection_data);
+       if (!uris) {
+               gtk_drag_finish (context, FALSE, FALSE, time);
+               return;
+       }
+
+       for (i = 0; uris[i]; i++) {
+               uri_list = g_slist_prepend (uri_list, (gpointer) uris[i]);
+       }
+
+       ev_application_open_uri_list (EV_APP, uri_list,
+                                     gtk_window_get_screen (GTK_WINDOW (window)),
+                                     0);
+       gtk_drag_finish (context, TRUE, FALSE, time);
+
+       g_strfreev (uris);
+       g_slist_free (uri_list);
+}
+
 static void
 ev_window_finalize (GObject *object)
 {
@@ -4899,6 +4937,7 @@ ev_window_class_init (EvWindowClass *ev_window_class)
 
        widget_class->screen_changed = ev_window_screen_changed;
        widget_class->window_state_event = ev_window_state_event;
+       widget_class->drag_data_received = ev_window_drag_data_received;
 
        g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
 }
@@ -6194,6 +6233,13 @@ ev_window_init (EvWindow *ev_window)
 
         ev_window_sizing_mode_changed_cb (EV_VIEW (ev_window->priv->view), NULL, ev_window);
        ev_window_setup_action_sensitivity (ev_window);
+
+       /* Drag and Drop */
+       gtk_drag_dest_set (GTK_WIDGET (ev_window),
+                          GTK_DEST_DEFAULT_ALL,
+                          ev_window_drop_targets,
+                          G_N_ELEMENTS (ev_window_drop_targets),
+                          GDK_ACTION_COPY);
 }
 
 /**