[gnumeric] Check with user before hiding all rows or columns. [#316976]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Check with user before hiding all rows or columns. [#316976]
- Date: Wed, 16 Jun 2010 17:34:12 +0000 (UTC)
commit b4293f9294ae228809a128c818050f46fdab5969
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Wed Jun 16 11:33:21 2010 -0600
Check with user before hiding all rows or columns. [#316976]
2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/colrow.h (colrow_index_list_destroy): turn into a define
(colrow_state_list_destroy) : ditto
(colrow_vis_list_destroy): ditto
(colrow_vis_list_length): new
* src/colrow.c (colrow_index_list_destroy): delete
(colrow_state_list_destroy) : ditto
(colrow_vis_list_destroy): ditto
(colrow_vis_list_length): new
(cb_colrow_index_counter): new
* src/commands.c (cmd_selection_colrow_hide): check whether this
would hide the whole sheet.
2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
* filter.c (filter_show_all): fix the colrow_foreach call
ChangeLog | 14 ++++++++++++
NEWS | 2 +
src/colrow.c | 45 ++++++++++++++-----------------------
src/colrow.h | 8 ++++--
src/commands.c | 60 ++++++++++++++++++++++++++++++++++++++++++++------
src/tools/ChangeLog | 4 +++
src/tools/filter.c | 2 +-
7 files changed, 95 insertions(+), 40 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 623dc63..b173084 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/colrow.h (colrow_index_list_destroy): turn into a define
+ (colrow_state_list_destroy) : ditto
+ (colrow_vis_list_destroy): ditto
+ (colrow_vis_list_length): new
+ * src/colrow.c (colrow_index_list_destroy): delete
+ (colrow_state_list_destroy) : ditto
+ (colrow_vis_list_destroy): ditto
+ (colrow_vis_list_length): new
+ (cb_colrow_index_counter): new
+ * src/commands.c (cmd_selection_colrow_hide): check whether this
+ would hide the whole sheet.
+
2010-06-16 Morten Welinder <terra gnome org>
* src/dependent.c (dependent_managed_init): Zero the right amount
diff --git a/NEWS b/NEWS
index 683f8cc..57cf4e6 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ Andreas:
tables. [#621227]
* Show all ranges while editing. [#166653]
* Provide a tool tip showing function syntax. [#56172]
+ * Provide more navigation options. [#15010]
+ * Check with user before hiding all rows or columns. [#316976]
Jean:
* Do not ungrab a not grabbed item. [#620369]
diff --git a/src/colrow.c b/src/colrow.c
index 13a38f4..57e124e 100644
--- a/src/colrow.c
+++ b/src/colrow.c
@@ -1,4 +1,4 @@
-/* vim: set sw=8: */
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* colrow.c: Utilities for Rows and Columns
*
@@ -34,6 +34,7 @@
#include "cell.h"
#include "cellspan.h"
#include "rendered-value.h"
+#include <goffice/goffice.h>
double
colrow_compute_pixel_scale (Sheet const *sheet, gboolean horizontal)
@@ -194,14 +195,22 @@ typedef struct _ColRowIndex {
int first, last;
} ColRowIndex;
-ColRowStateList *
-colrow_state_list_destroy (ColRowStateList *list)
+
+static void
+cb_colrow_index_counter (gpointer data, gpointer user_data)
{
- ColRowStateList *ptr;
- for (ptr = list; ptr != NULL; ptr = ptr->next)
- g_free (ptr->data);
- g_slist_free (list);
- return NULL;
+ ColRowIndex *index = data;
+ gint *count = user_data;
+ if (data != NULL)
+ *count += index->last - index->first + 1;
+}
+
+gint
+colrow_vis_list_length (ColRowVisList *list)
+{
+ gint count = 0;
+ g_slist_foreach (list, cb_colrow_index_counter, &count);
+ return count;
}
ColRowStateGroup *
@@ -214,16 +223,6 @@ colrow_state_group_destroy (ColRowStateGroup *group)
return NULL;
}
-ColRowIndexList *
-colrow_index_list_destroy (ColRowIndexList *list)
-{
- ColRowIndexList *ptr;
- for (ptr = list; ptr != NULL ; ptr = ptr->next)
- g_free (ptr->data);
- g_list_free (list);
- return NULL;
-}
-
static gint
colrow_index_compare (ColRowIndex const * a, ColRowIndex const * b)
{
@@ -873,16 +872,6 @@ colrow_get_visiblity_toggle (SheetView *sv, gboolean is_cols,
return closure.elements;
}
-ColRowVisList *
-colrow_vis_list_destroy (ColRowVisList *list)
-{
- ColRowVisList *ptr;
- for (ptr = list; ptr != NULL ; ptr = ptr->next)
- g_free (ptr->data);
- g_slist_free (list);
- return NULL;
-}
-
/*
* colrow_set_visibility_list :
*
diff --git a/src/colrow.h b/src/colrow.h
index 863404e..6f085ad 100644
--- a/src/colrow.h
+++ b/src/colrow.h
@@ -93,14 +93,15 @@ gboolean colrow_foreach (ColRowCollection const *infos,
void colrow_resize (ColRowCollection *infos, int size);
-ColRowIndexList *colrow_index_list_destroy (ColRowIndexList *list);
+#define colrow_index_list_destroy(l) go_list_free_custom ((l), g_free)
+
GString *colrow_index_list_to_string (ColRowIndexList *list,
gboolean is_cols,
gboolean *is_single);
ColRowIndexList *colrow_get_index_list (int first, int last,
ColRowIndexList *list);
-ColRowStateList *colrow_state_list_destroy (ColRowStateList *list);
+#define colrow_state_list_destroy(l) (go_slist_free_custom ((l), g_free), NULL)
ColRowStateList *colrow_get_states (Sheet *sheet, gboolean is_cols,
int first, int last);
@@ -127,7 +128,8 @@ void colrow_set_visibility (Sheet *sheet, gboolean is_cols,
gboolean visible, int first, int last);
void colrow_get_global_outline (Sheet const *sheet, gboolean is_cols, int depth,
ColRowVisList **show, ColRowVisList **hide);
-ColRowVisList *colrow_vis_list_destroy (ColRowVisList *list);
+#define colrow_vis_list_destroy(l) (go_slist_free_custom ((l), g_free), NULL)
+gint colrow_vis_list_length (ColRowVisList *list);
void colrow_set_visibility_list (Sheet *sheet, gboolean is_cols,
gboolean visible,
ColRowVisList *list);
diff --git a/src/commands.c b/src/commands.c
index 39816cc..81e6c07 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -2172,18 +2172,62 @@ cmd_selection_colrow_hide (WorkbookControl *wbc,
{
CmdColRowHide *me;
SheetView *sv = wb_control_cur_sheet_view (wbc);
+ int n;
+ Sheet *sheet;
+ GSList *show = NULL, *hide = NULL;
- me = g_object_new (CMD_COLROW_HIDE_TYPE, NULL);
-
- me->is_cols = is_cols;
- me->hide = me->show = NULL;
if (visible)
- me->show = colrow_get_visiblity_toggle (sv, is_cols, TRUE);
+ show = colrow_get_visiblity_toggle (sv, is_cols, TRUE);
else
- me->hide = colrow_get_visiblity_toggle (sv, is_cols, FALSE);
+ hide = colrow_get_visiblity_toggle (sv, is_cols, FALSE);
+ n = colrow_vis_list_length (hide) + colrow_vis_list_length (show);
+ sheet = sv_sheet (sv);
- me->cmd.sheet = sv_sheet (sv);
- me->cmd.size = 1 + g_slist_length (me->hide) + g_slist_length (me->show);
+ if (!visible) {
+ /* If these are the last colrows to hide, check with the user */
+ int count = 0;
+ if (is_cols) {
+ int i, max = gnm_sheet_get_max_cols (sheet);
+ ColRowInfo *ci;
+ for (i = 0 ; i < max ; i++)
+ if (NULL ==
+ (ci = sheet_col_get (sheet, i)) ||
+ (ci->visible))
+ count++;
+ } else {
+ int i, max = gnm_sheet_get_max_rows (sheet);
+ ColRowInfo *ci;
+ for (i = 0 ; i < max ; i++)
+ if (NULL ==
+ (ci = sheet_row_get (sheet, i)) ||
+ (ci->visible))
+ count++;
+ }
+ if (count <= n) {
+ gchar const *text = is_cols ?
+ _("Are you sure that you want to hide all columns? "
+ "If you do so you can unhide them with the "
+ "'Format\xe2\x86\x92""Column\xe2\x86\x92Unhide' "
+ "menu item.") :
+ _("Are you sure that you want to hide all rows? "
+ "If you do so you can unhide them with the "
+ "'Format\xe2\x86\x92Row\xe2\x86\x92Unhide' "
+ "menu item.");
+ if (!go_gtk_query_yes_no (wbcg_toplevel (WBC_GTK (wbc)),
+ FALSE, "%s", text)) {
+ colrow_vis_list_destroy (show);
+ colrow_vis_list_destroy (hide);
+ return TRUE;
+ }
+ }
+ }
+
+ me = g_object_new (CMD_COLROW_HIDE_TYPE, NULL);
+ me->show = show;
+ me->hide = hide;
+ me->is_cols = is_cols;
+ me->cmd.sheet = sheet;
+ me->cmd.size = 1 + g_slist_length (hide) + g_slist_length (show);
me->cmd.cmd_descriptor = g_strdup (is_cols
? (visible ? _("Unhide columns") : _("Hide columns"))
: (visible ? _("Unhide rows") : _("Hide rows")));
diff --git a/src/tools/ChangeLog b/src/tools/ChangeLog
index 56a1302..fcf0d58 100644
--- a/src/tools/ChangeLog
+++ b/src/tools/ChangeLog
@@ -1,3 +1,7 @@
+2010-06-16 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * filter.c (filter_show_all): fix the colrow_foreach call
+
2010-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
* analysis-chi-squared.c (analysis_tool_chi_squared_engine_run):
diff --git a/src/tools/filter.c b/src/tools/filter.c
index 46bd27d..d292438 100644
--- a/src/tools/filter.c
+++ b/src/tools/filter.c
@@ -175,7 +175,7 @@ filter_show_all (WorkbookControl *wbc)
/* FIXME: This is slow. We should probably have a linked list
* containing the filtered rows in the sheet structure. */
- colrow_foreach (&sheet->rows, FALSE, gnm_sheet_get_max_rows (sheet),
+ colrow_foreach (&sheet->rows, 0, gnm_sheet_get_last_row (sheet),
(ColRowHandler) cb_show_all, sheet);
sheet->has_filtered_rows = FALSE;
sheet_redraw_all (sheet, TRUE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]