[gnome-control-center] region: keep selection when moving layout up/down



commit 9c4821bf87cf5003770e175ee0b212797ab06d68
Author: Sergey V. Udaltsov <svu gnome org>
Date:   Sat Aug 6 03:19:27 2011 +0100

    region: keep selection when moving layout up/down
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654880

 panels/region/gnome-region-panel-xkblt.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/panels/region/gnome-region-panel-xkblt.c b/panels/region/gnome-region-panel-xkblt.c
index 21574b3..3360233 100644
--- a/panels/region/gnome-region-panel-xkblt.c
+++ b/panels/region/gnome-region-panel-xkblt.c
@@ -57,6 +57,17 @@ get_selected_iter (GtkBuilder    *dialog,
 	return gtk_tree_selection_get_selected (selection, model, iter);
 }
 
+static void
+set_selected_path (GtkBuilder    *dialog,
+		   GtkTreePath   *path)
+{
+	GtkTreeSelection *selection;
+
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (WID ("xkb_layouts_selected")));
+
+	gtk_tree_selection_select_path (selection, path);
+}
+
 static gint
 find_selected_layout_idx (GtkBuilder *dialog)
 {
@@ -379,6 +390,7 @@ move_up_selected_layout (GtkWidget * button, GtkBuilder * dialog)
 {
 	GtkTreeModel *model;
 	GtkTreeIter iter, prev;
+	GtkTreePath *path;
 
 	if (get_selected_iter (dialog, &model, &iter) == FALSE)
 		return;
@@ -387,9 +399,15 @@ move_up_selected_layout (GtkWidget * button, GtkBuilder * dialog)
 	if (!gtk_tree_model_iter_previous (model, &prev))
 		return;
 
+	path = gtk_tree_model_get_path (model, &prev);
+	
 	gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &prev);
 
 	update_layouts_list (model, dialog);
+	
+	set_selected_path (dialog, path);
+
+	gtk_tree_path_free (path);	
 }
 
 static void
@@ -397,6 +415,7 @@ move_down_selected_layout (GtkWidget * button, GtkBuilder * dialog)
 {
 	GtkTreeModel *model;
 	GtkTreeIter iter, next;
+	GtkTreePath *path;
 
 	if (get_selected_iter (dialog, &model, &iter) == FALSE)
 		return;
@@ -405,9 +424,15 @@ move_down_selected_layout (GtkWidget * button, GtkBuilder * dialog)
 	if (!gtk_tree_model_iter_next (model, &next))
 		return;
 
+	path = gtk_tree_model_get_path (model, &next);
+
 	gtk_list_store_swap (GTK_LIST_STORE (model), &iter, &next);
 
 	update_layouts_list (model, dialog);
+
+	set_selected_path (dialog, path);
+
+	gtk_tree_path_free (path);	
 }
 
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]