mirror of https://github.com/GNOME/gimp.git
added auto-scrolling when DND-hovering close to the widget's top or bottom
2003-10-10 Michael Natterer <mitch@gimp.org> * app/widgets/gimpcontainertreeview-dnd.c: added auto-scrolling when DND-hovering close to the widget's top or bottom border. Fixes bug #124231. * app/widgets/gimpcontainertreeview.h: added some auto-scroll state to the GimpContainerTreeView struct. * app/widgets/gimpcontainertreeview.c: remove the auto-scroll timeout in GtkWidget::unmap().
This commit is contained in:
parent
0b40992080
commit
a28bb1942e
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2003-10-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpcontainertreeview-dnd.c: added auto-scrolling
|
||||
when DND-hovering close to the widget's top or bottom border.
|
||||
Fixes bug #124231.
|
||||
|
||||
* app/widgets/gimpcontainertreeview.h: added some auto-scroll state
|
||||
to the GimpContainerTreeView struct.
|
||||
|
||||
* app/widgets/gimpcontainertreeview.c: remove the auto-scroll
|
||||
timeout in GtkWidget::unmap().
|
||||
|
||||
2003-10-09 Tor Lillqvist <tml@iki.fi>
|
||||
|
||||
* gimp-zip.in: New file, shell script used to build zipfiles for
|
||||
|
|
|
@ -122,12 +122,58 @@ gimp_container_tree_view_drop_status (GimpContainerTreeView *tree_view,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
#define SCROLL_DISTANCE 30
|
||||
#define SCROLL_STEP 10
|
||||
#define SCROLL_INTERVAL 5
|
||||
/* #define SCROLL_DEBUG 1 */
|
||||
|
||||
static gboolean
|
||||
gimp_container_tree_view_scroll_timeout (gpointer data)
|
||||
{
|
||||
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (data);
|
||||
GtkAdjustment *adj;
|
||||
gdouble new_value;
|
||||
|
||||
adj = gtk_tree_view_get_vadjustment (GTK_TREE_VIEW (tree_view->view));
|
||||
|
||||
#ifdef SCROLL_DEBUG
|
||||
g_print ("scroll_timeout: scrolling by %d\n", SCROLL_STEP);
|
||||
#endif
|
||||
|
||||
if (tree_view->scroll_dir == GDK_SCROLL_UP)
|
||||
new_value = adj->value - SCROLL_STEP;
|
||||
else
|
||||
new_value = adj->value + SCROLL_STEP;
|
||||
|
||||
new_value = CLAMP (new_value, adj->lower, adj->upper - adj->page_size);
|
||||
|
||||
gtk_adjustment_set_value (adj, new_value);
|
||||
|
||||
if (tree_view->scroll_timeout_id)
|
||||
{
|
||||
g_source_remove (tree_view->scroll_timeout_id);
|
||||
|
||||
tree_view->scroll_timeout_id =
|
||||
g_timeout_add (tree_view->scroll_timeout_interval,
|
||||
gimp_container_tree_view_scroll_timeout,
|
||||
tree_view);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_container_tree_view_drag_leave (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
guint time,
|
||||
GimpContainerTreeView *tree_view)
|
||||
{
|
||||
if (tree_view->scroll_timeout_id)
|
||||
{
|
||||
g_source_remove (tree_view->scroll_timeout_id);
|
||||
tree_view->scroll_timeout_id = 0;
|
||||
}
|
||||
|
||||
gtk_tree_view_unset_rows_drag_dest (tree_view->view);
|
||||
}
|
||||
|
||||
|
@ -142,6 +188,40 @@ gimp_container_tree_view_drag_motion (GtkWidget *widget,
|
|||
GtkTreePath *path;
|
||||
GtkTreeViewDropPosition drop_pos;
|
||||
|
||||
if (y < SCROLL_DISTANCE || y > (widget->allocation.height - SCROLL_DISTANCE))
|
||||
{
|
||||
gint distance;
|
||||
|
||||
if (y < SCROLL_DISTANCE)
|
||||
{
|
||||
tree_view->scroll_dir = GDK_SCROLL_UP;
|
||||
distance = MIN (-y, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
tree_view->scroll_dir = GDK_SCROLL_DOWN;
|
||||
distance = MAX (widget->allocation.height - y, 1);
|
||||
}
|
||||
|
||||
tree_view->scroll_timeout_interval = SCROLL_INTERVAL * ABS (distance);
|
||||
|
||||
#ifdef SCROLL_DEBUG
|
||||
g_print ("drag_motion: scroll_distance = %d scroll_interval = %d\n",
|
||||
distance, tree_view->scroll_timeout_interval);
|
||||
#endif
|
||||
|
||||
if (! tree_view->scroll_timeout_id)
|
||||
tree_view->scroll_timeout_id =
|
||||
g_timeout_add (tree_view->scroll_timeout_interval,
|
||||
gimp_container_tree_view_scroll_timeout,
|
||||
tree_view);
|
||||
}
|
||||
else if (tree_view->scroll_timeout_id)
|
||||
{
|
||||
g_source_remove (tree_view->scroll_timeout_id);
|
||||
tree_view->scroll_timeout_id = 0;
|
||||
}
|
||||
|
||||
if (gimp_container_tree_view_drop_status (tree_view,
|
||||
context, x, y, time,
|
||||
&path, NULL, NULL, &drop_pos))
|
||||
|
@ -169,6 +249,12 @@ gimp_container_tree_view_drag_drop (GtkWidget *widget,
|
|||
GimpViewable *dest_viewable;
|
||||
GtkTreeViewDropPosition drop_pos;
|
||||
|
||||
if (tree_view->scroll_timeout_id)
|
||||
{
|
||||
g_source_remove (tree_view->scroll_timeout_id);
|
||||
tree_view->scroll_timeout_id = 0;
|
||||
}
|
||||
|
||||
if (gimp_container_tree_view_drop_status (tree_view,
|
||||
context, x, y, time,
|
||||
NULL, &src_viewable, &dest_viewable,
|
||||
|
|
|
@ -58,6 +58,8 @@ static void gimp_container_tree_view_init (GimpContainerTreeView
|
|||
static GObject *gimp_container_tree_view_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
|
||||
static void gimp_container_tree_view_unmap (GtkWidget *widget);
|
||||
static gboolean gimp_container_tree_view_popup_menu (GtkWidget *widget);
|
||||
static void gimp_container_tree_view_set_container (GimpContainerView *view,
|
||||
GimpContainer *container);
|
||||
|
@ -138,6 +140,7 @@ gimp_container_tree_view_class_init (GimpContainerTreeViewClass *klass)
|
|||
|
||||
object_class->constructor = gimp_container_tree_view_constructor;
|
||||
|
||||
widget_class->unmap = gimp_container_tree_view_unmap;
|
||||
widget_class->popup_menu = gimp_container_tree_view_popup_menu;
|
||||
|
||||
container_view_class->set_container = gimp_container_tree_view_set_container;
|
||||
|
@ -257,6 +260,20 @@ gimp_container_tree_view_constructor (GType type,
|
|||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_tree_view_unmap (GtkWidget *widget)
|
||||
{
|
||||
GimpContainerTreeView *tree_view = GIMP_CONTAINER_TREE_VIEW (widget);
|
||||
|
||||
if (tree_view->scroll_timeout_id)
|
||||
{
|
||||
g_source_remove (tree_view->scroll_timeout_id);
|
||||
tree_view->scroll_timeout_id = 0;
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->unmap (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_container_tree_view_menu_position (GtkMenu *menu,
|
||||
gint *x,
|
||||
|
|
|
@ -63,6 +63,10 @@ struct _GimpContainerTreeView
|
|||
GQuark name_changed_handler_id;
|
||||
|
||||
GimpViewable *dnd_viewable;
|
||||
|
||||
guint scroll_timeout_id;
|
||||
guint scroll_timeout_interval;
|
||||
GdkScrollDirection scroll_dir;
|
||||
};
|
||||
|
||||
struct _GimpContainerTreeViewClass
|
||||
|
|
Loading…
Reference in New Issue