Commit 8eb99f2e authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Preserve selection for sheet object lists when we change content. [#631327]

2010-10-04  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* src/sheet-object-widget.c (cb_list_model_changed): save current
	  selection and flag selection as saved.
	(cb_selection_changed): don't bother if the selection was saved
	(sheet_widget_list_create_widget): try to set the selection only if
	  we have one.
parent d104f7f3
2010-10-04 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object-widget.c (cb_list_model_changed): save current
selection and flag selection as saved.
(cb_selection_changed): don't bother if the selection was saved
(sheet_widget_list_create_widget): try to set the selection only if
we have one.
2010-10-04 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object-widget.c (sheet_widget_list_create_widget): set the
......
......@@ -4,6 +4,8 @@ Andreas:
* Add argument to FOURIER to separate parts.
* Extend TREND function to handle multiple regression. [#630085]
* Fix selection for sheet object lists and combos. [#631322]
* Preserve selection for sheet object lists when we change
content. [#631327]
--------------------------------------------------------------------------
Gnumeric 1.10.11
......
......@@ -3570,7 +3570,10 @@ cb_list_selection_changed (SheetWidgetListBase *swl,
static void
cb_list_model_changed (SheetWidgetListBase *swl, GtkTreeView *list)
{
int old_selection = swl->selection;
swl->selection = -1;
gtk_tree_view_set_model (GTK_TREE_VIEW (list), swl->model);
sheet_widget_list_base_set_selection (swl, old_selection, NULL);
}
static void
cb_selection_changed (GtkTreeSelection *selection,
......@@ -3580,15 +3583,18 @@ cb_selection_changed (GtkTreeSelection *selection,
GtkTreeModel *model;
GtkTreeIter iter;
int pos = 0;
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
if (NULL != path) {
pos = *gtk_tree_path_get_indices (path) + 1;
gtk_tree_path_free (path);
if (swl->selection != -1) {
if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
if (NULL != path) {
pos = *gtk_tree_path_get_indices (path) + 1;
gtk_tree_path_free (path);
}
}
sheet_widget_list_base_set_selection
(swl, pos,
scg_wbc (GNM_SIMPLE_CANVAS (view->parent->parent->parent)->scg));
}
sheet_widget_list_base_set_selection (swl, pos,
scg_wbc (GNM_SIMPLE_CANVAS (view->parent->parent->parent)->scg));
}
static GtkWidget *
......@@ -3618,7 +3624,7 @@ sheet_widget_list_create_widget (SheetObjectWidget *sow)
G_CALLBACK (cb_list_model_changed), list, 0);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list));
if ((swl->model != NULL) &&
if ((swl->model != NULL) && (swl->selection > 0) &&
gtk_tree_model_iter_nth_child (swl->model, &iter, NULL, swl->selection - 1))
gtk_tree_selection_select_iter (selection, &iter);
g_signal_connect_object (G_OBJECT (swl), "selection-changed",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment