summaryrefslogtreecommitdiff
path: root/gtk/gtklist.c
diff options
context:
space:
mode:
authorLars Hamann <lars@gtk.org>1999-02-02 01:57:11 +0000
committerLars Hamann <lars@src.gnome.org>1999-02-02 01:57:11 +0000
commita19e373baa6545c104fee06b572f795591fec81a (patch)
treec9b07b1b9801eb4a2947f0ff4aa76c4cca1f5177 /gtk/gtklist.c
parentfb00e9bbb82e2491254cc447ab54803b8150828a (diff)
downloadgtk+-a19e373baa6545c104fee06b572f795591fec81a.tar.gz
in case of GTK_SELECTION_BROWSE select first inserted row.
Tue Feb 2 00:28:44 1999 Lars Hamann <lars@gtk.org> * gtk/gtkctree.c (gtk_ctree_insert_node): in case of GTK_SELECTION_BROWSE select first inserted row. (resync_selection): select rows in correct order. * gtk/gtkclist.c (real_insert_row): in case of GTK_SELECTION_BROWSE select first inserted row. (resync_selection): select rows in correct order. * gtk/gtklist.c (gtk_list_end_selection): select rows in correct order.
Diffstat (limited to 'gtk/gtklist.c')
-rw-r--r--gtk/gtklist.c68
1 files changed, 50 insertions, 18 deletions
diff --git a/gtk/gtklist.c b/gtk/gtklist.c
index 1f59758a92..c18431d4be 100644
--- a/gtk/gtklist.c
+++ b/gtk/gtklist.c
@@ -1690,6 +1690,7 @@ gtk_list_end_selection (GtkList *list)
{
gint i;
gint e;
+ gboolean top_down;
GList *work;
GtkWidget *item;
gint item_index;
@@ -1703,10 +1704,12 @@ gtk_list_end_selection (GtkList *list)
i = MIN (list->anchor, list->drag_pos);
e = MAX (list->anchor, list->drag_pos);
-
+
+ top_down = (list->anchor < list->drag_pos);
+
list->anchor = -1;
list->drag_pos = -1;
-
+
if (list->undo_selection)
{
work = list->selection;
@@ -1728,30 +1731,59 @@ gtk_list_end_selection (GtkList *list)
}
}
- for (work = g_list_nth (list->children, i); i <= e; i++, work = work->next)
+ if (top_down)
{
- item = work->data;
- if (g_list_find (list->selection, item))
- {
- if (item->state == GTK_STATE_NORMAL)
- {
- gtk_widget_set_state (item, GTK_STATE_SELECTED);
- gtk_list_unselect_child (list, item);
- list->undo_selection = g_list_prepend (list->undo_selection,
+ for (work = g_list_nth (list->children, i); i <= e;
+ i++, work = work->next)
+ {
+ item = work->data;
+ if (g_list_find (list->selection, item))
+ {
+ if (item->state == GTK_STATE_NORMAL)
+ {
+ gtk_widget_set_state (item, GTK_STATE_SELECTED);
+ gtk_list_unselect_child (list, item);
+ list->undo_selection = g_list_prepend (list->undo_selection,
+ item);
+ }
+ }
+ else if (item->state == GTK_STATE_SELECTED)
+ {
+ gtk_widget_set_state (item, GTK_STATE_NORMAL);
+ list->undo_unselection = g_list_prepend (list->undo_unselection,
item);
- }
- }
- else if (item->state == GTK_STATE_SELECTED)
+ }
+ }
+ }
+ else
+ {
+ for (work = g_list_nth (list->children, e); i <= e;
+ e--, work = work->prev)
{
- gtk_widget_set_state (item, GTK_STATE_NORMAL);
- list->undo_unselection = g_list_prepend (list->undo_unselection,
- item);
+ item = work->data;
+ if (g_list_find (list->selection, item))
+ {
+ if (item->state == GTK_STATE_NORMAL)
+ {
+ gtk_widget_set_state (item, GTK_STATE_SELECTED);
+ gtk_list_unselect_child (list, item);
+ list->undo_selection = g_list_prepend (list->undo_selection,
+ item);
+ }
+ }
+ else if (item->state == GTK_STATE_SELECTED)
+ {
+ gtk_widget_set_state (item, GTK_STATE_NORMAL);
+ list->undo_unselection = g_list_prepend (list->undo_unselection,
+ item);
+ }
}
}
- for (work = list->undo_unselection; work; work = work->next)
+ for (work = g_list_reverse (list->undo_unselection); work; work = work->next)
gtk_list_select_child (list, GTK_WIDGET (work->data));
+
}
void