[gnumeric] Preserve selection for sheet object lists when we change content. [#631327]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Preserve selection for sheet object lists when we change content. [#631327]
- Date: Mon, 4 Oct 2010 18:56:55 +0000 (UTC)
commit 8eb99f2e9aa86fe9fb517194a57739a1f8f981ed
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Mon Oct 4 12:55:48 2010 -0600
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.
ChangeLog | 8 ++++++++
NEWS | 2 ++
src/sheet-object-widget.c | 22 ++++++++++++++--------
3 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dcfc8e9..50697ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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
correct selection
(sheet_widget_combo_create_widget): ditto
diff --git a/NEWS b/NEWS
index b107d74..37944de 100644
--- a/NEWS
+++ b/NEWS
@@ -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
diff --git a/src/sheet-object-widget.c b/src/sheet-object-widget.c
index 6060099..c25d6c7 100644
--- a/src/sheet-object-widget.c
+++ b/src/sheet-object-widget.c
@@ -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",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]