[gtk/dnd-gestures-2: 20/29] wip: filechooser conversion
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 20/29] wip: filechooser conversion
- Date: Fri, 3 Jan 2020 06:52:30 +0000 (UTC)
commit b2e00d06d1cdbc3af8687406c96e9be76ad191cf
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jan 2 08:46:30 2020 -0500
wip: filechooser conversion
This does not work yet.
gtk/gtkfilechooserwidget.c | 44 +++++++++++++++++++-----------------------
gtk/ui/gtkfilechooserwidget.ui | 3 ---
2 files changed, 20 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index ef0b4a0d2f..9191b7edc4 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -1982,13 +1982,14 @@ out:
}
static void
-file_list_drag_data_received_cb (GtkWidget *widget,
- GdkDrop *drop,
+file_list_drag_data_received_cb (GtkDropTarget *dest,
GtkSelectionData *selection_data,
gpointer user_data)
{
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (user_data);
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
+ GtkWidget *widget = gtk_drop_target_get_target (dest);
+ GdkDrop *drop = gtk_drop_target_get_drop (dest);
gchar **uris;
char *uri;
GFile *file;
@@ -2026,18 +2027,17 @@ file_list_drag_data_received_cb (GtkWidget *widget,
data);
}
- g_signal_stop_emission_by_name (widget, "drag-data-received");
+ g_signal_stop_emission_by_name (dest, "drag-data-received");
}
/* Don't do anything with the drag_drop signal */
static gboolean
-file_list_drag_drop_cb (GtkWidget *widget,
- GdkDrop *drop,
- gint x,
- gint y,
+file_list_drag_drop_cb (GtkDropTarget *dest,
+ int x,
+ int y,
GtkFileChooserWidget *impl)
{
- g_signal_stop_emission_by_name (widget, "drag-drop");
+ g_signal_stop_emission_by_name (dest, "drag-drop");
return TRUE;
}
@@ -2054,13 +2054,12 @@ file_list_drag_begin_cb (GtkDragSource *source,
/* Disable the normal tree drag motion handler, it makes it look like you're
dropping the dragged item onto a tree item */
static gboolean
-file_list_drag_motion_cb (GtkWidget *widget,
- GdkDrop *drop,
- gint x,
- gint y,
+file_list_drag_motion_cb (GtkDropTarget *dest,
+ int x,
+ int y,
GtkFileChooserWidget *impl)
{
- g_signal_stop_emission_by_name (widget, "drag-motion");
+ g_signal_stop_emission_by_name (dest, "drag-motion");
return TRUE;
}
@@ -8463,14 +8462,9 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, box);
/* And a *lot* of callbacks to bind ... */
- gtk_widget_class_bind_template_callback (widget_class, file_list_drag_drop_cb);
- gtk_widget_class_bind_template_callback (widget_class, file_list_drag_data_received_cb);
gtk_widget_class_bind_template_callback (widget_class, list_popup_menu_cb);
gtk_widget_class_bind_template_callback (widget_class, file_list_query_tooltip_cb);
gtk_widget_class_bind_template_callback (widget_class, list_row_activated);
- gtk_widget_class_bind_template_callback (widget_class, file_list_drag_begin_cb);
- gtk_widget_class_bind_template_callback (widget_class, file_list_drag_motion_cb);
- gtk_widget_class_bind_template_callback (widget_class, file_list_drag_end_cb);
gtk_widget_class_bind_template_callback (widget_class, list_selection_changed);
gtk_widget_class_bind_template_callback (widget_class, list_cursor_changed);
gtk_widget_class_bind_template_callback (widget_class, browse_files_tree_view_keynav_failed_cb);
@@ -8506,6 +8500,7 @@ post_process_ui (GtkFileChooserWidget *impl)
GList *cells;
GFile *file;
GtkDragSource *source;
+ GtkDropTarget *dest;
GdkContentFormats *formats;
/* Setup file list treeview */
@@ -8519,15 +8514,16 @@ post_process_ui (GtkFileChooserWidget *impl)
GDK_BUTTON1_MASK,
formats,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gdk_content_formats_unref (formats);
g_signal_connect (source, "drag-begin", G_CALLBACK (file_list_drag_begin_cb), impl);
g_signal_connect (source, "drag-end", G_CALLBACK (file_list_drag_end_cb), impl);
- gtk_drag_dest_set (priv->browse_files_tree_view,
- GTK_DEST_DEFAULT_ALL,
- NULL,
- GDK_ACTION_COPY | GDK_ACTION_MOVE);
- gtk_drag_dest_add_uri_targets (priv->browse_files_tree_view);
+
+ dest = gtk_drop_target_new (GTK_DEST_DEFAULT_ALL, formats, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ g_signal_connect (dest, "drag-motion", G_CALLBACK (file_list_drag_motion_cb), impl);
+ g_signal_connect (dest, "drag-drop", G_CALLBACK (file_list_drag_drop_cb), impl);
+ g_signal_connect (dest, "drag-data-received", G_CALLBACK (file_list_drag_data_received_cb), impl);
+ gtk_drop_target_attach (dest, priv->browse_files_tree_view);
+ gdk_content_formats_unref (formats);
/* File browser treemodel columns are shared between GtkFileChooser implementations,
* so we don't set cell renderer attributes in GtkBuilder, but rather keep that
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index cf82bee991..a1ee4f8573 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -156,9 +156,6 @@
<signal name="key-pressed" handler="treeview_key_press_cb"
swapped="no"/>
</object>
</child>
- <signal name="drag-data-received"
handler="file_list_drag_data_received_cb" swapped="no"/>
- <signal name="drag-drop" handler="file_list_drag_drop_cb"
swapped="no"/>
- <signal name="drag-motion" handler="file_list_drag_motion_cb"
swapped="no"/>
<signal name="popup-menu" handler="list_popup_menu_cb"
swapped="no"/>
<signal name="query-tooltip"
handler="file_list_query_tooltip_cb" swapped="no"/>
<signal name="row-activated" handler="list_row_activated"
swapped="no"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]