[Xfce4-commits] <xfce4-panel:master> Bug #10582 scroll the items list automatically to keep the moved item visible at the new position

Andrzej noreply at xfce.org
Tue Jan 7 03:28:01 CET 2014


Updating branch refs/heads/master
         to 5551513dbb18c73809cc945c1d1649f041d29511 (commit)
       from 71fe77c4c5c433721854c88c1fa1667f880b38f2 (commit)

commit 5551513dbb18c73809cc945c1d1649f041d29511
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Tue Jan 7 02:26:50 2014 +0000

    Bug #10582 scroll the items list automatically to keep the moved item
    visible at the new position
    
    (Raphael Groner <projects.rg{at}smart.ms>)
    
    + some cleanup.

 panel/panel-preferences-dialog.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 2721157..e756dd5 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -1042,6 +1042,7 @@ panel_preferences_dialog_item_move (GtkWidget              *button,
       itembar = gtk_bin_get_child (GTK_BIN (dialog->active));
       position = panel_itembar_get_child_index (PANEL_ITEMBAR (itembar),
                                                 GTK_WIDGET (provider));
+      path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->store), &iter_a);
 
       if (G_LIKELY (position != -1))
         {
@@ -1067,20 +1068,20 @@ panel_preferences_dialog_item_move (GtkWidget              *button,
               /* swap the items in the list */
               iter_b = iter_a;
               if (gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->store), &iter_b))
-                gtk_list_store_swap (dialog->store, &iter_a, &iter_b);
+                {
+                  gtk_list_store_swap (dialog->store, &iter_a, &iter_b);
+                  gtk_tree_path_next (path);
+                }
             }
           else
             {
               /* get the previous item in the list */
-              path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->store), &iter_a);
               if (gtk_tree_path_prev (path))
                 {
                   /* swap the items in the list */
                   gtk_tree_model_get_iter (GTK_TREE_MODEL (dialog->store), &iter_b, path);
                   gtk_list_store_swap (dialog->store, &iter_a, &iter_b);
                 }
-
-              gtk_tree_path_free (path);
             }
 
           /* fake update the selection */
@@ -1088,7 +1089,13 @@ panel_preferences_dialog_item_move (GtkWidget              *button,
           panel_return_if_fail (GTK_IS_WIDGET (treeview));
           selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
           panel_preferences_dialog_item_selection_changed (selection, dialog);
+
+          /* make the new selected position visible if moved out of area */
+          gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (treeview), path, NULL, FALSE, 0, 0);
+          gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview), path, NULL, FALSE);
+
         }
+      gtk_tree_path_free (path);
     }
 }
 


More information about the Xfce4-commits mailing list