[gtk+] dnd: Just pass iconhelper instead of whole DragSourceSite
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] dnd: Just pass iconhelper instead of whole DragSourceSite
- Date: Wed, 25 Nov 2015 15:34:10 +0000 (UTC)
commit 2bee73c1f941fe0fcd11d0f639deeab6fc03d2e1
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 22 05:08:34 2015 +0100
dnd: Just pass iconhelper instead of whole DragSourceSite
Simplifies the code.
gtk/gtkdnd-quartz.c | 14 +++++++-------
gtk/gtkdnd.c | 31 +++++++++++--------------------
2 files changed, 18 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index f7f5182..594a76c 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -1196,9 +1196,9 @@ gtk_drag_begin_idle (gpointer arg)
- (GdkWindow *)gdkWindow;
@end
-static GdkDragContext *
+GdkDragContext *
gtk_drag_begin_internal (GtkWidget *widget,
- GtkDragSourceSite *site,
+ GtkIconHelper *icon_helper,
GtkTargetList *target_list,
GdkDragAction actions,
gint button,
@@ -1293,25 +1293,25 @@ gtk_drag_begin_internal (GtkWidget *widget,
*/
if (!info->icon_surface)
{
- if (!site || site->icon_type == GTK_IMAGE_EMPTY)
+ if (!icon_helper || _gtk_icon_helper_get_is_empty (icon_helper))
gtk_drag_set_icon_default (context);
else
{
- switch (site->icon_type)
+ switch (_gtk_icon_helper_get_storage_type (icon_helper))
{
case GTK_IMAGE_PIXBUF:
gtk_drag_set_icon_pixbuf (context,
- site->icon_data.pixbuf.pixbuf,
+ _gtk_icon_helper_peek_pixbuf (icon_helper),
-2, -2);
break;
case GTK_IMAGE_STOCK:
gtk_drag_set_icon_stock (context,
- site->icon_data.stock.stock_id,
+ _gtk_icon_helper_get_stock_id (icon_helper),
-2, -2);
break;
case GTK_IMAGE_ICON_NAME:
gtk_drag_set_icon_name (context,
- site->icon_data.name.icon_name,
+ _gtk_icon_helper_get_icon_name (icon_helper),
-2, -2);
break;
case GTK_IMAGE_EMPTY:
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index fca901b..b1da25e 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -2351,28 +2351,12 @@ gtk_drag_dest_drop (GtkWidget *widget,
* Source side *
***************/
-static GtkIconHelper *
-gtk_drag_source_site_get_icon_helper (GtkDragSourceSite *site)
-{
- GtkIconHelper *helper;
-
- if (site)
- helper = g_object_ref (site->icon_helper);
- else
- helper = _gtk_icon_helper_new ();
-
- if (_gtk_icon_helper_get_is_empty (helper))
- _gtk_icon_helper_set_icon_name (helper, "text-x-generic", GTK_ICON_SIZE_DND);
-
- return helper;
-}
-
-/* Like gtk_drag_begin(), but also takes a GtkDragSourceSite,
+/* Like gtk_drag_begin(), but also takes a GtkIconHelper
* so that we can set the icon from the source site information
*/
static GdkDragContext *
gtk_drag_begin_internal (GtkWidget *widget,
- GtkDragSourceSite *site,
+ GtkIconHelper *icon_helper,
GtkTargetList *target_list,
GdkDragAction actions,
gint button,
@@ -2518,7 +2502,14 @@ gtk_drag_begin_internal (GtkWidget *widget,
*/
if (!info->icon_window && !info->icon_helper)
{
- info->icon_helper = gtk_drag_source_site_get_icon_helper (site);
+ if (icon_helper)
+ info->icon_helper = g_object_ref (icon_helper);
+ else
+ info->icon_helper = _gtk_icon_helper_new ();
+
+ if (_gtk_icon_helper_get_is_empty (info->icon_helper))
+ _gtk_icon_helper_set_icon_name (info->icon_helper, "text-x-generic", GTK_ICON_SIZE_DND);
+
set_icon_helper (info->context, info->icon_helper, 0, 0, FALSE);
}
@@ -3786,7 +3777,7 @@ gtk_drag_source_event_cb (GtkWidget *widget,
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (site->drag_gesture));
gtk_event_controller_reset (GTK_EVENT_CONTROLLER (site->drag_gesture));
- gtk_drag_begin_internal (widget, site, site->target_list,
+ gtk_drag_begin_internal (widget, site->icon_helper, site->target_list,
site->actions, button, last_event,
start_x, start_y);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]