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.
This commit is contained in:
Lars Hamann 1999-02-02 01:57:11 +00:00 committed by Lars Hamann
parent fb00e9bbb8
commit a19e373baa
10 changed files with 247 additions and 53 deletions

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -1,3 +1,15 @@
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.
Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com> Mon Feb 1 16:47:55 1999 Owen Taylor <otaylor@redhat.com>
* gtk.m4: Pass gthread on to gtk-config. * gtk.m4: Pass gthread on to gtk-config.

View File

@ -2782,8 +2782,8 @@ real_insert_row (GtkCList *clist,
clist_row))->next; clist_row))->next;
else else
clist->row_list = g_list_insert (clist->row_list, clist_row, row); clist->row_list = g_list_insert (clist->row_list, clist_row, row);
}
}
clist->rows++; clist->rows++;
if (row < ROW_FROM_YPIXEL (clist, 0)) if (row < ROW_FROM_YPIXEL (clist, 0))
@ -2792,6 +2792,13 @@ real_insert_row (GtkCList *clist,
/* syncronize the selection list */ /* syncronize the selection list */
sync_selection (clist, row, SYNC_INSERT); sync_selection (clist, row, SYNC_INSERT);
if (clist->rows == 1)
{
clist->focus_row = 0;
if (clist->selection_mode == GTK_SELECTION_BROWSE)
gtk_clist_select_row (clist, 0, -1);
}
/* redraw the list if it isn't frozen */ /* redraw the list if it isn't frozen */
if (CLIST_UNFROZEN (clist)) if (CLIST_UNFROZEN (clist))
{ {
@ -3989,7 +3996,10 @@ resync_selection (GtkCList *clist,
} }
} }
for (list = g_list_nth (clist->row_list, i); i <= e; i++, list = list->next) if (clist->anchor < clist->drag_pos)
{
for (list = g_list_nth (clist->row_list, i); i <= e;
i++, list = list->next)
if (GTK_CLIST_ROW (list)->selectable) if (GTK_CLIST_ROW (list)->selectable)
{ {
if (g_list_find (clist->selection, GINT_TO_POINTER(i))) if (g_list_find (clist->selection, GINT_TO_POINTER(i)))
@ -3998,20 +4008,53 @@ resync_selection (GtkCList *clist,
{ {
GTK_CLIST_ROW (list)->state = GTK_STATE_SELECTED; GTK_CLIST_ROW (list)->state = GTK_STATE_SELECTED;
gtk_signal_emit (GTK_OBJECT (clist), gtk_signal_emit (GTK_OBJECT (clist),
clist_signals[UNSELECT_ROW], i, -1, event); clist_signals[UNSELECT_ROW],
clist->undo_selection = g_list_prepend (clist->undo_selection, i, -1, event);
clist->undo_selection =
g_list_prepend (clist->undo_selection,
GINT_TO_POINTER (i)); GINT_TO_POINTER (i));
} }
} }
else if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED) else if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED)
{ {
GTK_CLIST_ROW (list)->state = GTK_STATE_NORMAL; GTK_CLIST_ROW (list)->state = GTK_STATE_NORMAL;
clist->undo_unselection = g_list_prepend (clist->undo_unselection, clist->undo_unselection =
g_list_prepend (clist->undo_unselection,
GINT_TO_POINTER (i)); GINT_TO_POINTER (i));
} }
} }
}
else
{
for (list = g_list_nth (clist->row_list, e); i <= e;
e--, list = list->prev)
if (GTK_CLIST_ROW (list)->selectable)
{
if (g_list_find (clist->selection, GINT_TO_POINTER(e)))
{
if (GTK_CLIST_ROW (list)->state == GTK_STATE_NORMAL)
{
GTK_CLIST_ROW (list)->state = GTK_STATE_SELECTED;
gtk_signal_emit (GTK_OBJECT (clist),
clist_signals[UNSELECT_ROW],
e, -1, event);
clist->undo_selection =
g_list_prepend (clist->undo_selection,
GINT_TO_POINTER (e));
}
}
else if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED)
{
GTK_CLIST_ROW (list)->state = GTK_STATE_NORMAL;
clist->undo_unselection =
g_list_prepend (clist->undo_unselection,
GINT_TO_POINTER (e));
}
}
}
for (list = clist->undo_unselection; list; list = list->next) for (list = g_list_reverse (clist->undo_unselection); list;
list = list->next)
gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW], gtk_signal_emit (GTK_OBJECT (clist), clist_signals[SELECT_ROW],
GPOINTER_TO_INT (list->data), -1, event); GPOINTER_TO_INT (list->data), -1, event);

View File

@ -3684,6 +3684,14 @@ gtk_ctree_insert_node (GtkCTree *ctree,
column_auto_resize (clist, &(new_row->row), i, 0); column_auto_resize (clist, &(new_row->row), i, 0);
} }
if (clist->rows == 1)
{
clist->focus_row = 0;
if (clist->selection_mode == GTK_SELECTION_BROWSE)
gtk_ctree_select (ctree, node);
}
CLIST_REFRESH (clist); CLIST_REFRESH (clist);
return node; return node;
@ -5664,7 +5672,8 @@ resync_selection (GtkCList *clist, GdkEvent *event)
} }
} }
if (clist->anchor < clist->drag_pos)
{
for (node = GTK_CTREE_NODE (g_list_nth (clist->row_list, i)); i <= e; for (node = GTK_CTREE_NODE (g_list_nth (clist->row_list, i)); i <= e;
i++, node = GTK_CTREE_NODE_NEXT (node)) i++, node = GTK_CTREE_NODE_NEXT (node))
if (GTK_CTREE_ROW (node)->row.selectable) if (GTK_CTREE_ROW (node)->row.selectable)
@ -5675,19 +5684,45 @@ resync_selection (GtkCList *clist, GdkEvent *event)
{ {
GTK_CTREE_ROW (node)->row.state = GTK_STATE_SELECTED; GTK_CTREE_ROW (node)->row.state = GTK_STATE_SELECTED;
gtk_ctree_unselect (ctree, node); gtk_ctree_unselect (ctree, node);
clist->undo_selection = g_list_prepend (clist->undo_selection, clist->undo_selection =
node); g_list_prepend (clist->undo_selection, node);
} }
} }
else if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED) else if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED)
{ {
GTK_CTREE_ROW (node)->row.state = GTK_STATE_NORMAL; GTK_CTREE_ROW (node)->row.state = GTK_STATE_NORMAL;
clist->undo_unselection = g_list_prepend (clist->undo_unselection, clist->undo_unselection =
node); g_list_prepend (clist->undo_unselection, node);
}
}
}
else
{
for (node = GTK_CTREE_NODE (g_list_nth (clist->row_list, e)); i <= e;
e--, node = GTK_CTREE_NODE_PREV (node))
if (GTK_CTREE_ROW (node)->row.selectable)
{
if (g_list_find (clist->selection, node))
{
if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_NORMAL)
{
GTK_CTREE_ROW (node)->row.state = GTK_STATE_SELECTED;
gtk_ctree_unselect (ctree, node);
clist->undo_selection =
g_list_prepend (clist->undo_selection, node);
}
}
else if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED)
{
GTK_CTREE_ROW (node)->row.state = GTK_STATE_NORMAL;
clist->undo_unselection =
g_list_prepend (clist->undo_unselection, node);
}
} }
} }
for (list = clist->undo_unselection; list; list = list->next) for (list = g_list_reverse (clist->undo_unselection); list;
list = list->next)
gtk_ctree_select (ctree, list->data); gtk_ctree_select (ctree, list->data);
clist->anchor = -1; clist->anchor = -1;

View File

@ -1690,6 +1690,7 @@ gtk_list_end_selection (GtkList *list)
{ {
gint i; gint i;
gint e; gint e;
gboolean top_down;
GList *work; GList *work;
GtkWidget *item; GtkWidget *item;
gint item_index; gint item_index;
@ -1704,6 +1705,8 @@ gtk_list_end_selection (GtkList *list)
i = MIN (list->anchor, list->drag_pos); i = MIN (list->anchor, list->drag_pos);
e = MAX (list->anchor, list->drag_pos); e = MAX (list->anchor, list->drag_pos);
top_down = (list->anchor < list->drag_pos);
list->anchor = -1; list->anchor = -1;
list->drag_pos = -1; list->drag_pos = -1;
@ -1728,7 +1731,10 @@ gtk_list_end_selection (GtkList *list)
} }
} }
for (work = g_list_nth (list->children, i); i <= e; i++, work = work->next) if (top_down)
{
for (work = g_list_nth (list->children, i); i <= e;
i++, work = work->next)
{ {
item = work->data; item = work->data;
if (g_list_find (list->selection, item)) if (g_list_find (list->selection, item))
@ -1748,10 +1754,36 @@ gtk_list_end_selection (GtkList *list)
item); item);
} }
} }
}
else
{
for (work = g_list_nth (list->children, e); i <= e;
e--, work = work->prev)
{
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)); gtk_list_select_child (list, GTK_WIDGET (work->data));
} }
void void