Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/ev-view.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <carlosgc@gnome.org>2007-01-07 12:20:03 (GMT)
committer Carlos Garcia Campos <carlosgc@src.gnome.org>2007-01-07 12:20:03 (GMT)
commita6b906afdaaf66cef8c7ababc5e89a5c26c49ed1 (patch)
tree02a3764efba57a335456d89a5326a942ae947a37 /shell/ev-view.c
parent29038054752cd193452e6ce080656818b4bf8a63 (diff)
Move view drag and drop stuff to ev-view.
2007-01-07 Carlos Garcia Campos <carlosgc@gnome.org> * shell/ev-window.c: (drag_data_received_cb), (ev_window_init): * shell/ev-view.c: (ev_view_drag_data_received), (ev_view_class_init), (ev_view_init): Move view drag and drop stuff to ev-view. svn path=/trunk/; revision=2192
Diffstat (limited to 'shell/ev-view.c')
-rw-r--r--shell/ev-view.c53
1 files changed, 49 insertions, 4 deletions
diff --git a/shell/ev-view.c b/shell/ev-view.c
index d83f572..f353f47 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -43,6 +43,7 @@
#include "ev-page-cache.h"
#include "ev-pixbuf-cache.h"
#include "ev-tooltip.h"
+#include "ev-application.h"
#define EV_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass))
#define EV_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_VIEW))
@@ -79,13 +80,17 @@ enum {
TARGET_TEXT_BUFFER_CONTENTS
};
-static const GtkTargetEntry targets[] = {
+static const GtkTargetEntry clipboard_targets[] = {
{ "STRING", 0, TARGET_STRING },
{ "TEXT", 0, TARGET_TEXT },
{ "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT },
{ "UTF8_STRING", 0, TARGET_UTF8_STRING },
};
+static const GtkTargetEntry view_drop_targets[] = {
+ { "text/uri-list", 0, 0 }
+};
+
static guint signals[N_SIGNALS];
typedef enum {
@@ -1687,7 +1692,6 @@ ev_view_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
-
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -1960,6 +1964,7 @@ ev_view_button_press_event (GtkWidget *widget,
return FALSE;
}
+/*** Drag and Drop ***/
static void
ev_view_drag_data_get (GtkWidget *widget,
GdkDragContext *context,
@@ -1981,6 +1986,39 @@ ev_view_drag_data_get (GtkWidget *widget,
}
}
+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)
{
@@ -2965,6 +3003,7 @@ ev_view_class_init (EvViewClass *class)
widget_class->leave_notify_event = ev_view_leave_notify_event;
widget_class->style_set = ev_view_style_set;
widget_class->drag_data_get = ev_view_drag_data_get;
+ widget_class->drag_data_received = ev_view_drag_data_received;
widget_class->popup_menu = ev_view_popup_menu;
gtk_object_class->destroy = ev_view_destroy;
@@ -3132,6 +3171,12 @@ ev_view_init (EvView *view)
view->sizing_mode = EV_SIZING_FIT_WIDTH;
view->pending_scroll = SCROLL_TO_KEEP_POSITION;
view->jump_to_find_result = TRUE;
+
+ gtk_drag_dest_set (GTK_WIDGET (view),
+ GTK_DEST_DEFAULT_ALL,
+ view_drop_targets,
+ G_N_ELEMENTS (view_drop_targets),
+ GDK_ACTION_COPY);
}
/*** Callbacks ***/
@@ -4502,8 +4547,8 @@ ev_view_update_primary_selection (EvView *ev_view)
if (ev_view->selection_info.selections) {
if (!gtk_clipboard_set_with_owner (clipboard,
- targets,
- G_N_ELEMENTS (targets),
+ clipboard_targets,
+ G_N_ELEMENTS (clipboard_targets),
ev_view_primary_get_cb,
ev_view_primary_clear_cb,
G_OBJECT (ev_view)))