[Xfce4-commits] <xfce4-panel:master> Preserve the current item selection when rebuilding the item store.
Andrzej
noreply at xfce.org
Tue Jan 7 03:24:01 CET 2014
Updating branch refs/heads/master
to 71fe77c4c5c433721854c88c1fa1667f880b38f2 (commit)
from d296ca76507bc5ffdbb8e77745568cf5063e069d (commit)
commit 71fe77c4c5c433721854c88c1fa1667f880b38f2
Author: Andrzej <ndrwrdck at gmail.com>
Date: Tue Jan 7 02:17:49 2014 +0000
Preserve the current item selection when rebuilding the item store.
panel/panel-preferences-dialog.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/panel/panel-preferences-dialog.c b/panel/panel-preferences-dialog.c
index 865d7f3..2721157 100644
--- a/panel/panel-preferences-dialog.c
+++ b/panel/panel-preferences-dialog.c
@@ -930,15 +930,22 @@ static void
panel_preferences_dialog_item_store_rebuild (GtkWidget *itembar,
PanelPreferencesDialog *dialog)
{
- GList *items, *li;
- guint i;
- PanelModule *module;
- gchar *tooltip, *display_name;
+ GList *items, *li;
+ guint i;
+ PanelModule *module;
+ gchar *tooltip, *display_name;
+ XfcePanelPluginProvider *selected_provider;
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GObject *treeview;
panel_return_if_fail (PANEL_IS_PREFERENCES_DIALOG (dialog));
panel_return_if_fail (GTK_IS_LIST_STORE (dialog->store));
panel_return_if_fail (PANEL_IS_ITEMBAR (itembar));
+ /* memorize selected item */
+ selected_provider = panel_preferences_dialog_item_get_selected (dialog, NULL);
+
gtk_list_store_clear (dialog->store);
g_signal_handlers_block_by_func (G_OBJECT (dialog->store),
@@ -977,7 +984,7 @@ panel_preferences_dialog_item_store_rebuild (GtkWidget *itembar,
xfce_panel_plugin_provider_get_unique_id (li->data));
}
- gtk_list_store_insert_with_values (dialog->store, NULL, i,
+ gtk_list_store_insert_with_values (dialog->store, &iter, i,
ITEM_COLUMN_ICON_NAME,
panel_module_get_icon_name (module),
ITEM_COLUMN_DISPLAY_NAME,
@@ -986,6 +993,16 @@ panel_preferences_dialog_item_store_rebuild (GtkWidget *itembar,
tooltip,
ITEM_COLUMN_PROVIDER, li->data, -1);
+ /* reconstruct selection */
+ if (selected_provider == li->data)
+ {
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (dialog->store), &iter);
+ treeview = gtk_builder_get_object (GTK_BUILDER (dialog), "item-treeview");
+ if (GTK_IS_WIDGET (treeview))
+ gtk_tree_view_set_cursor (GTK_TREE_VIEW (treeview), path, NULL, FALSE);
+ gtk_tree_path_free (path);
+ }
+
g_free (tooltip);
g_free (display_name);
}
More information about the Xfce4-commits
mailing list