[Xfce4-commits] [xfce/xfdesktop] 01/01: Highlight drag target when hovering it (Bug #12695)
noreply at xfce.org
noreply at xfce.org
Mon Jun 17 23:36:03 CEST 2019
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository xfce/xfdesktop.
commit 26252ee801e4fe5d73ea9dcdd8f68351b320a3b5
Author: Theo Linkspfeifer <lastonestanding at tutanota.com>
Date: Mon Jun 17 21:35:21 2019 +0200
Highlight drag target when hovering it (Bug #12695)
---
src/xfdesktop-icon-view.c | 65 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 61 insertions(+), 4 deletions(-)
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 10ac6f4..e94ec27 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -238,6 +238,9 @@ static gboolean xfdesktop_icon_view_drag_motion(GtkWidget *widget,
gint x,
gint y,
guint time_);
+static void xfdesktop_icon_view_drag_leave(GtkWidget *widget,
+ GdkDragContext *context,
+ guint time_);
static gboolean xfdesktop_icon_view_drag_drop(GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -389,8 +392,6 @@ static const gint icon_view_n_targets = 1;
static guint __signals[SIG_N_SIGNALS] = { 0, };
-static GQuark xfdesktop_cell_highlight_quark = 0;
-
G_DEFINE_TYPE_WITH_PRIVATE(XfdesktopIconView, xfdesktop_icon_view, GTK_TYPE_WIDGET)
@@ -414,6 +415,7 @@ xfdesktop_icon_view_class_init(XfdesktopIconViewClass *klass)
widget_class->draw = xfdesktop_icon_view_draw;
widget_class->drag_begin = xfdesktop_icon_view_drag_begin;
widget_class->drag_motion = xfdesktop_icon_view_drag_motion;
+ widget_class->drag_leave = xfdesktop_icon_view_drag_leave;
widget_class->drag_drop = xfdesktop_icon_view_drag_drop;
widget_class->drag_data_get = xfdesktop_icon_view_drag_data_get;
widget_class->drag_data_received = xfdesktop_icon_view_drag_data_received;
@@ -644,8 +646,6 @@ xfdesktop_icon_view_class_init(XfdesktopIconViewClass *klass)
xfdesktop_icon_view_add_move_binding(binding_set, GDK_KEY_KP_Left, 0,
GTK_MOVEMENT_VISUAL_POSITIONS, -1);
- xfdesktop_cell_highlight_quark = g_quark_from_static_string("xfdesktop-icon-view-cell-highlight");
-
gtk_widget_class_set_css_name (widget_class, "XfdesktopIconView");
}
@@ -1426,6 +1426,47 @@ xfdesktop_xy_to_rowcol(XfdesktopIconView *icon_view,
*col = (x - icon_view->priv->xorigin - icon_view->priv->xmargin) / (CELL_SIZE + icon_view->priv->xspacing);
}
+static inline void
+xfdesktop_icon_view_clear_drag_highlight(XfdesktopIconView *icon_view)
+{
+ XfdesktopIcon *icon;
+
+ /* remove highlight from icon */
+ if(icon_view->priv->item_under_pointer) {
+ icon = icon_view->priv->item_under_pointer;
+ icon_view->priv->item_under_pointer = NULL;
+
+ xfdesktop_icon_view_invalidate_icon_pixbuf(icon_view, icon);
+ }
+}
+
+static inline void
+xfdesktop_icon_view_draw_drag_highlight(XfdesktopIconView *icon_view,
+ guint16 row,
+ guint16 col)
+{
+ XfdesktopIcon *icon;
+
+ icon = xfdesktop_icon_view_icon_in_cell(icon_view, row, col);
+
+ if(!icon && icon_view->priv->item_under_pointer) {
+ /* clear previous highlight */
+ xfdesktop_icon_view_clear_drag_highlight(icon_view);
+ }
+
+ if(icon && icon_view->priv->item_under_pointer != icon) {
+ if(icon_view->priv->item_under_pointer) {
+ /* clear previous highlight */
+ xfdesktop_icon_view_clear_drag_highlight(icon_view);
+ }
+
+ /* highlight icon */
+ icon_view->priv->item_under_pointer = icon;
+
+ xfdesktop_icon_view_invalidate_icon_pixbuf(icon_view, icon);
+ }
+}
+
static gboolean
xfdesktop_icon_view_drag_motion(GtkWidget *widget,
GdkDragContext *context,
@@ -1490,6 +1531,7 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
if(xfdesktop_icon_get_position(sel_icon, &sel_row, &sel_col)
&& sel_row == hover_row && sel_col == hover_col)
{
+ xfdesktop_icon_view_clear_drag_highlight(icon_view);
return FALSE;
}
}
@@ -1548,6 +1590,14 @@ xfdesktop_icon_view_drag_motion(GtkWidget *widget,
}
static void
+xfdesktop_icon_view_drag_leave(GtkWidget *widget,
+ GdkDragContext *context,
+ guint time_)
+{
+ xfdesktop_icon_view_clear_drag_highlight(XFDESKTOP_ICON_VIEW(widget));
+}
+
+static void
xfdesktop_next_slot(XfdesktopIconView *icon_view,
gint16 *col,
gint16 *row,
@@ -1784,6 +1834,13 @@ xfdesktop_icon_view_drag_data_received(GtkWidget *widget,
info);
}
+ if(action == 0)
+ xfdesktop_icon_view_clear_drag_highlight(icon_view);
+ else
+ xfdesktop_icon_view_draw_drag_highlight(icon_view,
+ icon_view->priv->hover_row,
+ icon_view->priv->hover_col);
+
gdk_drag_status(context, action, time_);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list