[gthumb] grid view: show the drop destination even when the list is empty
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] grid view: show the drop destination even when the list is empty
- Date: Sun, 20 Mar 2022 11:01:52 +0000 (UTC)
commit b23d95c1de0539a89bc4b11c27bf7b4a2d92f77b
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Mar 20 11:48:39 2022 +0100
grid view: show the drop destination even when the list is empty
gthumb/gth-grid-view.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/gthumb/gth-grid-view.c b/gthumb/gth-grid-view.c
index 7d199d89..999c4336 100644
--- a/gthumb/gth-grid-view.c
+++ b/gthumb/gth-grid-view.c
@@ -1650,10 +1650,21 @@ _gth_grid_view_draw_drop_target (GthGridView *self,
GthGridViewItem *item;
int x;
- if ((self->priv->drop_item < 0) || (self->priv->drop_item >= self->priv->n_items))
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
+
+ /* Special case: dropping on an empty list. */
+ if ((self->priv->drop_item == 0) && (self->priv->n_items == 0)) {
+ gtk_render_focus (style_context,
+ cr,
+ self->priv->cell_padding,
+ self->priv->cell_padding,
+ 2,
+ self->priv->cell_size - (self->priv->cell_padding * 2));
return;
+ }
- style_context = gtk_widget_get_style_context (GTK_WIDGET (self));
+ if ((self->priv->drop_item < 0) || (self->priv->drop_item >= self->priv->n_items))
+ return;
item = g_ptr_array_index (self->priv->itemv, self->priv->drop_item);
@@ -1718,11 +1729,11 @@ gth_grid_view_draw (GtkWidget *widget,
if (self->priv->selecting || self->priv->multi_selecting_with_keyboard)
_gth_grid_view_draw_rubberband (self, cr);
-
- if (self->priv->drop_pos != GTH_DROP_POSITION_NONE)
- _gth_grid_view_draw_drop_target (self, cr);
}
+ if (self->priv->drop_pos != GTH_DROP_POSITION_NONE)
+ _gth_grid_view_draw_drop_target (self, cr);
+
cairo_restore (cr);
return TRUE;
@@ -2542,7 +2553,7 @@ gth_grid_view_set_drag_dest_pos (GthFileView *file_view,
drop_pos = GTH_DROP_POSITION_LEFT;
}
else if (drop_image >= self->priv->n_items) {
- drop_image = self->priv->n_items - 1;
+ drop_image = (self->priv->n_items > 0) ? self->priv->n_items - 1 : 0;
drop_pos = GTH_DROP_POSITION_RIGHT;
}
else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]