aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2022-02-17 10:38:32 +0100
committerPřemysl Eric Janouch <p@janouch.name>2022-02-17 10:57:05 +0100
commit5d019e20b5df00ba400c1c6ba0dc81c9eb44a040 (patch)
tree03c7cae518f4b3484999a8ce1b8cc8b70b56766b
parent03d1798e237f2c68d2281627ddbcdfe953c17d80 (diff)
downloadfiv-5d019e20b5df00ba400c1c6ba0dc81c9eb44a040.tar.gz
fiv-5d019e20b5df00ba400c1c6ba0dc81c9eb44a040.tar.xz
fiv-5d019e20b5df00ba400c1c6ba0dc81c9eb44a040.zip
Make the view a drop target
-rw-r--r--fiv.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fiv.c b/fiv.c
index f505e40..f85f830 100644
--- a/fiv.c
+++ b/fiv.c
@@ -928,6 +928,26 @@ on_open_location(G_GNUC_UNUSED GtkPlacesSidebar *sidebar, GFile *location,
}
static void
+on_view_drag_data_received(G_GNUC_UNUSED GtkWidget *widget,
+ GdkDragContext *context, G_GNUC_UNUSED gint x, G_GNUC_UNUSED gint y,
+ GtkSelectionData *data, G_GNUC_UNUSED guint info, guint time,
+ G_GNUC_UNUSED gpointer user_data)
+{
+ gchar **uris = gtk_selection_data_get_uris(data);
+ if (!uris) {
+ gtk_drag_finish(context, FALSE, FALSE, time);
+ return;
+ }
+
+ // TODO(p): Once we're able to open a virtual directory, open all of them.
+ GFile *file = g_file_new_for_uri(uris[0]);
+ open_any_file(file, FALSE);
+ g_object_unref(file);
+ gtk_drag_finish(context, TRUE, FALSE, time);
+ g_strfreev(uris);
+}
+
+static void
on_toolbar_zoom(G_GNUC_UNUSED GtkButton *button, gpointer user_data)
{
FivThumbnailSize size = FIV_THUMBNAIL_SIZE_COUNT;
@@ -1818,10 +1838,14 @@ main(int argc, char *argv[])
GtkWidget *view_scroller = gtk_scrolled_window_new(NULL, NULL);
g.view = g_object_new(FIV_TYPE_VIEW, NULL);
+ gtk_drag_dest_set(g.view, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_dest_add_uri_targets(g.view);
g_signal_connect(g.view, "key-press-event",
G_CALLBACK(on_key_press_view), NULL);
g_signal_connect(g.view, "button-press-event",
G_CALLBACK(on_button_press_view), NULL);
+ g_signal_connect(g.view, "drag-data-received",
+ G_CALLBACK(on_view_drag_data_received), NULL);
gtk_container_add(GTK_CONTAINER(view_scroller), g.view);
// We need to hide it together with the separator.