[gnome-control-center] Avoid losing the selection



commit 64150f145890143316fa3aefbbd322f3698369de
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jul 17 00:00:16 2012 -0400

    Avoid losing the selection
    
    When the active input sources list is changed in any way (add or
    remove or reorder a source), we write the list to the setting,
    and then we get a changed signal for the setting, and rebuild
    the list from the setting. Doing so loses the selection, unless
    we take extra precaution to keep it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=680027

 panels/region/gnome-region-panel-input.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/panels/region/gnome-region-panel-input.c b/panels/region/gnome-region-panel-input.c
index 5ff6455..9630bec 100644
--- a/panels/region/gnome-region-panel-input.c
+++ b/panels/region/gnome-region-panel-input.c
@@ -814,11 +814,26 @@ input_sources_changed (GSettings  *settings,
 {
   GtkWidget *treeview;
   GtkTreeModel *store;
+  GtkTreePath *path;
+  GtkTreeIter iter;
+  GtkTreeModel *model;
 
   treeview = WID("active_input_sources");
   store = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
+
+  if (get_selected_iter (builder, &model, &iter))
+    path = gtk_tree_model_get_path (model, &iter);
+  else
+    path = NULL;
+
   gtk_list_store_clear (GTK_LIST_STORE (store));
   populate_with_active_sources (GTK_LIST_STORE (store));
+
+  if (path)
+    {
+      set_selected_path (builder, path);
+      gtk_tree_path_free (path);
+    }
 }
 
 static void



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