]> Pileus Git - ~andy/gtk/commitdiff
in case of GTK_SELECTION_BROWSE select first inserted row.
authorLars Hamann <lars@gtk.org>
Tue, 2 Feb 1999 01:57:11 +0000 (01:57 +0000)
committerLars Hamann <lars@src.gnome.org>
Tue, 2 Feb 1999 01:57:11 +0000 (01:57 +0000)
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.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkclist.c
gtk/gtkctree.c
gtk/gtklist.c

index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index a849596cc53ff985edb12aa797bc43ea0469c71c..4fc06a9709835e2445663bc4ed03d7f00e665d8f 100644 (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>
 
        * gtk.m4: Pass gthread on to gtk-config.
index fe7515bffe043cc0ee6f6d32980773c3e09c5e2d..327f873e98840ac6044a214b9847dc291d846a04 100644 (file)
@@ -2782,8 +2782,8 @@ real_insert_row (GtkCList *clist,
                                              clist_row))->next;
       else
        clist->row_list = g_list_insert (clist->row_list, clist_row, row);
+
     }
-  
   clist->rows++;
 
   if (row < ROW_FROM_YPIXEL (clist, 0))
@@ -2792,6 +2792,13 @@ real_insert_row (GtkCList *clist,
   /* syncronize the selection list */
   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 */
   if (CLIST_UNFROZEN (clist))
     {
@@ -3989,29 +3996,65 @@ resync_selection (GtkCList *clist,
        }
     }    
 
-  for (list = g_list_nth (clist->row_list, i); i <= e; i++, list = list->next)
-    if (GTK_CLIST_ROW (list)->selectable)
-      {
-       if (g_list_find (clist->selection, GINT_TO_POINTER(i)))
+  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)->state == GTK_STATE_NORMAL)
+           if (g_list_find (clist->selection, GINT_TO_POINTER(i)))
              {
-               GTK_CLIST_ROW (list)->state = GTK_STATE_SELECTED;
-               gtk_signal_emit (GTK_OBJECT (clist),
-                                clist_signals[UNSELECT_ROW], i, -1, event);
-               clist->undo_selection = g_list_prepend (clist->undo_selection,
-                                                       GINT_TO_POINTER (i));
+               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],
+                                    i, -1, event);
+                   clist->undo_selection =
+                     g_list_prepend (clist->undo_selection,
+                                     GINT_TO_POINTER (i));
+                 }
+             }
+           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 (i));
              }
          }
-       else if (GTK_CLIST_ROW (list)->state == GTK_STATE_SELECTED)
+    }
+  else
+    {
+      for (list = g_list_nth (clist->row_list, e); i <= e;
+          e--, list = list->prev)
+       if (GTK_CLIST_ROW (list)->selectable)
          {
-           GTK_CLIST_ROW (list)->state = GTK_STATE_NORMAL;
-           clist->undo_unselection = g_list_prepend (clist->undo_unselection,
-                                                     GINT_TO_POINTER (i));
+           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],
                     GPOINTER_TO_INT (list->data), -1, event);
 
index 9b855a60792d840f9bd49891db1c2fe2ea8375d3..da4b2c6610749522673a2b81483fb68488d38a33 100644 (file)
@@ -3684,6 +3684,14 @@ gtk_ctree_insert_node (GtkCTree     *ctree,
          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);
 
   return node;
@@ -5664,30 +5672,57 @@ resync_selection (GtkCList *clist, GdkEvent *event)
        }
     }    
 
-
-  for (node = GTK_CTREE_NODE (g_list_nth (clist->row_list, i)); i <= e;
-       i++, node = GTK_CTREE_NODE_NEXT (node))
-    if (GTK_CTREE_ROW (node)->row.selectable)
-      {
-       if (g_list_find (clist->selection, node))
+  if (clist->anchor < clist->drag_pos)
+    {
+      for (node = GTK_CTREE_NODE (g_list_nth (clist->row_list, i)); i <= e;
+          i++, node = GTK_CTREE_NODE_NEXT (node))
+       if (GTK_CTREE_ROW (node)->row.selectable)
          {
-           if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_NORMAL)
+           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_SELECTED;
-               gtk_ctree_unselect (ctree, node);
-               clist->undo_selection = g_list_prepend (clist->undo_selection,
-                                                       node);
+               GTK_CTREE_ROW (node)->row.state = GTK_STATE_NORMAL;
+               clist->undo_unselection =
+                 g_list_prepend (clist->undo_unselection, node);
              }
          }
-       else if (GTK_CTREE_ROW (node)->row.state == GTK_STATE_SELECTED)
+    }
+  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)
          {
-           GTK_CTREE_ROW (node)->row.state = GTK_STATE_NORMAL;
-           clist->undo_unselection = g_list_prepend (clist->undo_unselection,
-                                                     node);
+           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);
 
   clist->anchor = -1;
index 1f59758a9286629b0810c60dabd10a731e2a9996..c18431d4be41b9bce0b240433af1519bb7a59a56 100644 (file)
@@ -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