}
FileInfo f;
+ f.parent = op->url;
f.name = strdup(ent->d_name);
if(!fstatat(fd, ent->d_name, &s, 0)) {
FilesSection *section = malloc(sizeof(FilesSection));
memset(section, 0, sizeof(FilesSection));
section->files = op->result;
+ section->parent_url = op->url;
op->result = NULL;
+ op->url = NULL;
// update_grid takes ownership of section
op->browser->update_grid(op->browser, section, 1, op->browser->update_grid_data);
}
cxListFree(op->result);
-
free(op->url);
free(op);
}
#include <sys/stat.h>
#include <sys/types.h>
+#include <libidav/utils.h>
+
G_DEFINE_TYPE(MzFilesView, mz_files_view, GTK_TYPE_WIDGET)
gdouble y,
gpointer user_data);
+static GdkContentProvider* dnd_prepare(
+ GtkDragSource* self,
+ gdouble x,
+ gdouble y,
+ gpointer user_data);
+
+static void dnd_begin(
+ GtkDragSource* self,
+ GdkDrag* drag,
+ gpointer user_data);
+
static void motion_cb(
GtkEventControllerMotion* self,
gdouble x,
self->highlight_row = -1;
// event handler
+ GtkDragSource *dnd_source = gtk_drag_source_new();
+ g_signal_connect(dnd_source, "prepare", G_CALLBACK(dnd_prepare), self);
+ g_signal_connect(dnd_source, "drag-begin", G_CALLBACK(dnd_begin), self);
+ gtk_widget_add_controller(GTK_WIDGET(self), GTK_EVENT_CONTROLLER(dnd_source));
+
GtkGesture *drag = gtk_gesture_drag_new();
g_signal_connect(drag, "drag-begin", G_CALLBACK(drag_begin_cb), self);
g_signal_connect(drag, "drag-end", G_CALLBACK(drag_end_cb), self);
/* -------------------------- event handler -------------------------- */
+static GdkContentProvider* dnd_prepare(
+ GtkDragSource *self,
+ gdouble x,
+ gdouble y,
+ gpointer user_data)
+{
+ MzFilesView *view = user_data;
+ if(view->drag_item) {
+ char *path = util_concat_path(view->drag_file->parent, view->drag_file->name);
+ printf("dnd file: %s\n", path);
+ GFile *file = g_file_new_for_path(path);
+ free(path);
+ GdkContentProvider *provider = gdk_content_provider_new_typed(G_TYPE_FILE, file);
+ return provider;
+ }
+ return NULL;
+}
+
+static void dnd_begin(
+ GtkDragSource* self,
+ GdkDrag* drag,
+ gpointer user_data)
+{
+ printf("dnd_begin\n");
+}
+
static void drag_begin_cb(
GtkGestureDrag* self,
gdouble start_x,