[gnumeric] Make even active sheets invisible. [#616474]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Make even active sheets invisible. [#616474]
- Date: Thu, 22 Apr 2010 17:47:17 +0000 (UTC)
commit 22df479e047635a9e759c4f4174186ce781d06a7
Author: Andreas J. Guelzow <aguelzow pyrshep ca>
Date: Thu Apr 22 11:42:40 2010 -0600
Make even active sheets invisible. [#616474]
2010-04-22 Andreas J. Guelzow <aguelzow pyrshep ca>
* dialog-sheet-order.c (cb_sheet_order_cnt_visible): simplify
(sheet_order_cnt_visible): ditto
(cb_toggled_visible): we are now ensuring that we are the only
modifier
(sheet_selection_can_toggle): new
(create_sheet_list): hook up sheet_selection_can_toggle
NEWS | 1 +
src/dialogs/ChangeLog | 11 +++++-
src/dialogs/dialog-sheet-order.c | 71 ++++++++++++++++++++------------------
3 files changed, 47 insertions(+), 36 deletions(-)
---
diff --git a/NEWS b/NEWS
index 7dd4a9e..ba6afb6 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.10.3
Andreas:
* Fix CHITEST for rectangular ranges. [#615920]
* Fix printing and preview of graph only sheets. [#616475]
+ * Make even active sheets invisible. [#616474]
Jean
* Implement graph only sheets. [#158170]
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 837adc1..d3216ab 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,6 +1,13 @@
-2010-04-21 Jean Brefort <jean brefort normalesup org>
+2010-03-31 Andreas J. Guelzow <aguelzow pyrshep ca>
- reviewed by: <delete if not using a buddy>
+ * dialog-sheet-order.c (cb_sheet_order_cnt_visible): simplify
+ (sheet_order_cnt_visible): ditto
+ (cb_toggled_visible): we are now ensuring that we are the only
+ modifier
+ (sheet_selection_can_toggle): new
+ (create_sheet_list): hook up sheet_selection_can_toggle
+
+2010-04-21 Jean Brefort <jean brefort normalesup org>
* dialog-printer-setup.c (cb_do_print_preview):
diff --git a/src/dialogs/dialog-sheet-order.c b/src/dialogs/dialog-sheet-order.c
index 2cb478d..fd2355b 100644
--- a/src/dialogs/dialog-sheet-order.c
+++ b/src/dialogs/dialog-sheet-order.c
@@ -1,4 +1,3 @@
-
/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* dialog-sheet-order.c: Dialog to change the order of sheets in the Gnumeric
@@ -536,38 +535,20 @@ cb_toggled_direction (G_GNUC_UNUSED GtkCellRendererToggle *cell,
update_undo (state, wbc);
}
-
-typedef struct {
- int i;
- SheetManager *state;
-} SheetManager_Vis_Counter;
-
static gboolean
cb_sheet_order_cnt_visible (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer data)
{
- SheetManager_Vis_Counter *svc = data;
+ gint *i = data;
gboolean is_visible;
- Sheet *this_sheet;
gtk_tree_model_get (model, iter,
SHEET_VISIBLE, &is_visible,
- SHEET_POINTER, &this_sheet,
-1);
- if (is_visible != (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE)) {
- gtk_list_store_set (GTK_LIST_STORE (model), iter,
- SHEET_VISIBLE, (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE),
- SHEET_VISIBLE_IMAGE, (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE
- ? svc->state->image_visible
- : NULL),
- -1);
- is_visible = (this_sheet->visibility == GNM_SHEET_VISIBILITY_VISIBLE);
- }
-
if (is_visible)
- (svc->i)++;
+ (*i)++;
return FALSE;
}
@@ -575,13 +556,15 @@ cb_sheet_order_cnt_visible (GtkTreeModel *model,
static gint
sheet_order_cnt_visible (SheetManager *state)
{
- SheetManager_Vis_Counter data = {0, state};
+ gint data = 0;
gtk_tree_model_foreach (GTK_TREE_MODEL (state->model),
cb_sheet_order_cnt_visible,
&data);
- return data.i;
+ return data;
}
+static void populate_sheet_list (SheetManager *state);
+
static void
cb_toggled_visible (G_GNUC_UNUSED GtkCellRendererToggle *cell,
gchar *path_string,
@@ -612,17 +595,10 @@ cb_toggled_visible (G_GNUC_UNUSED GtkCellRendererToggle *cell,
if (is_visible) {
cnt = sheet_order_cnt_visible (state);
if (cnt <= 1) {
- /* Note: sheet_order_cnt_visible may have changed whether this sheet is indeed */
- /* so we should not post a warning message if the sheet has become invisible. */
- gtk_tree_model_get (model, &iter,
- SHEET_VISIBLE, &is_visible,
- -1);
- if (is_visible) {
- go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
- _("At least one sheet must remain visible!"));
- gtk_tree_path_free (path);
- return;
- }
+ go_gtk_notice_dialog (GTK_WINDOW (state->dialog), GTK_MESSAGE_ERROR,
+ _("At least one sheet must remain visible!"));
+ gtk_tree_path_free (path);
+ return;
}
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
SHEET_VISIBLE, FALSE,
@@ -647,6 +623,30 @@ cb_toggled_visible (G_GNUC_UNUSED GtkCellRendererToggle *cell,
cmd_reorganize_sheets (wbc, old_state, this_sheet);
update_undo (state, wbc);
+
+ if (is_visible)
+ populate_sheet_list (state);
+}
+
+static gboolean
+sheet_selection_can_toggle(GtkTreeSelection *selection,
+ GtkTreeModel *model,
+ GtkTreePath *path,
+ gboolean path_currently_selected,
+ G_GNUC_UNUSED gpointer data)
+{
+ GtkTreeIter iter;
+ gboolean is_visible;
+
+ if (path_currently_selected ||
+ !gtk_tree_model_get_iter (model, &iter, path))
+ return TRUE;
+
+ gtk_tree_model_get (model, &iter,
+ SHEET_VISIBLE, &is_visible,
+ -1);
+
+ return is_visible;
}
static void
@@ -765,6 +765,9 @@ create_sheet_list (SheetManager *state)
g_signal_connect (selection,
"changed",
G_CALLBACK (cb_selection_changed), state);
+ gtk_tree_selection_set_select_function (selection,
+ sheet_selection_can_toggle,
+ NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (state->sheet_list));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]