Commit 86dcb3ff authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Add menu items to allow clearing of filtered rows only.

2010-07-24  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* component/Gnumeric-embed.xml.in: add "clear filtered" menu items
	* src/GNOME_Gnumeric-gtk.xml.in: ditto
	* src/HILDON_Gnumeric-gtk.xml.in: ditto
	* src/commands.c (cmd_selection_clear_row_handler): new
	(cmd_selection_clear): adjust selection if only considering filtered rows
	* src/ranges.c (range_fragment_free): delete
	* src/ranges.h (range_fragment_free): change into a define using
	  go_slist_custom
	* src/sheet.h (SheetClearFlags): add CLEAR_FILTERED_ONLY
	* src/wbc-gtk-actions.c (cb_edit_clear_*_filtered): new
	(EditClear*Filtered): new actions
parent 01e300ce
2010-07-24 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* component/Gnumeric-embed.xml.in: add "clear filtered" menu items
* src/GNOME_Gnumeric-gtk.xml.in: ditto
* src/HILDON_Gnumeric-gtk.xml.in: ditto
* src/commands.c (cmd_selection_clear_row_handler): new
(cmd_selection_clear): adjust selection if only considering filtered rows
* src/ranges.c (range_fragment_free): delete
* src/ranges.h (range_fragment_free): change into a define using
go_slist_custom
* src/sheet.h (SheetClearFlags): add CLEAR_FILTERED_ONLY
* src/wbc-gtk-actions.c (cb_edit_clear_*_filtered): new
(EditClear*Filtered): new actions
2010-07-23 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/clipboard.c (cb_clipboard_copy_range_undo): paste everything back
......
......@@ -46,6 +46,7 @@ Andreas:
* Add preference settings whether to show function name and/or
argument tooltips.
* Fix undo of Clear->All and Clear->Comments. [#625151]
* Add menu items to allow clearing of filtered rows only.
Jean:
* Fix strong/weak cursor display. [#623241]
......
......@@ -40,7 +40,13 @@
<menu name="Clear" action="MenuEditClear">
<menuitem action="EditClearAll"/>
<menuitem action="EditClearFormats"/>
<menuitem action="EditClearComments"/>
<menuitem action="EditClearContent"/>
<separator name="clear-sep1"/>
<menuitem action="EditClearAllFiltered"/>
<menuitem action="EditClearFormatsFiltered"/>
<menuitem action="EditClearCommentsFiltered"/>
<menuitem action="EditClearContentFiltered"/>
</menu>
<menu name="Delete" action="MenuEditDelete">
<menuitem action="EditDeleteColumns"/>
......
......@@ -41,7 +41,13 @@
<menu name="Clear" action="MenuEditClear">
<menuitem action="EditClearAll"/>
<menuitem action="EditClearFormats"/>
<menuitem action="EditClearComments"/>
<menuitem action="EditClearContent"/>
<separator name="clear-sep1"/>
<menuitem action="EditClearAllFiltered"/>
<menuitem action="EditClearFormatsFiltered"/>
<menuitem action="EditClearCommentsFiltered"/>
<menuitem action="EditClearContentFiltered"/>
</menu>
<menu name="Delete" action="MenuEditDelete">
<menuitem action="EditDeleteColumns"/>
......
......@@ -52,7 +52,13 @@
<menu name="Clear" action="MenuEditClear">
<menuitem action="EditClearAll"/>
<menuitem action="EditClearFormats"/>
<menuitem action="EditClearComments"/>
<menuitem action="EditClearContent"/>
<separator name="clear-sep1"/>
<menuitem action="EditClearAllFiltered"/>
<menuitem action="EditClearFormatsFiltered"/>
<menuitem action="EditClearCommentsFiltered"/>
<menuitem action="EditClearContentFiltered"/>
</menu>
<menu name="Delete" action="MenuEditDelete">
<menuitem action="EditDeleteColumns"/>
......
......@@ -1417,6 +1417,22 @@ cmd_delete_rows (WorkbookControl *wbc,
/******************************************************************/
typedef struct {
GSList *selection;
GnmRange const *r;
} cmd_selection_clear_row_handler_t;
static gboolean
cmd_selection_clear_row_handler (GnmColRowIter const *iter,
cmd_selection_clear_row_handler_t *data)
{
if ((!iter->cri->in_filter) || iter->cri->visible) {
GnmRange *r = gnm_range_dup (data->r);
r->start.row = r->end.row = iter->pos;
data->selection = g_slist_prepend (data->selection, r);
}
return FALSE;
}
gboolean
cmd_selection_clear (WorkbookControl *wbc, int clear_flags)
......@@ -1432,6 +1448,25 @@ cmd_selection_clear (WorkbookControl *wbc, int clear_flags)
GOUndo *redo = NULL;
GSList *ranges;
if ((clear_flags & CLEAR_FILTERED_ONLY) != 0 && sheet->filters != NULL) {
/* We need to modify the selection to only include filtered rows. */
cmd_selection_clear_row_handler_t data;
data.selection = selection;
for (ranges = selection; ranges != NULL ; ranges = ranges->next) {
GnmFilter *filter;
data.r = ranges->data;
filter = gnm_sheet_filter_intersect_rows
(sheet, data.r->start.row, data.r->end.row);
if (filter) {
colrow_foreach (&sheet->rows, data.r->start.row, data.r->end.row,
(ColRowHandler) cmd_selection_clear_row_handler, &data);
g_free (ranges->data);
ranges->data = NULL;
}
}
selection = g_slist_remove_all (data.selection, NULL);
}
/* We should first determine whether we break anything by clearing */
/* Check for array subdivision *//* Check for locked cells */
if (sheet_ranges_split_region (sheet, selection,
......
......@@ -466,17 +466,6 @@ range_fragment (GnmRange const *a, GnmRange const *b)
return ans;
}
void
range_fragment_free (GSList *fragments)
{
GSList *l = fragments;
for (l = fragments; l; l = l->next)
g_free (l->data);
g_slist_free (fragments);
}
/**
* range_intersection:
* @r: intersection range
......
......@@ -61,6 +61,8 @@ guint gnm_range_hash (GnmRange const *r);
#define range_valid(r) ((r)->start.col <= (r)->end.col && \
(r)->start.row <= (r)->end.row)
#define range_fragment_free(f) go_slist_free_custom ((f), g_free)
GnmRange *range_init_full_sheet (GnmRange *r, Sheet const *sheet);
GnmRange *range_init_cols (GnmRange *r, Sheet const *sheet,
int start_col, int end_col);
......@@ -102,7 +104,6 @@ void range_dump (GnmRange const *r, char const *suffix);
GSList *range_split_ranges (GnmRange const *hard, GnmRange const *soft);
GSList *range_fragment (GnmRange const *a, GnmRange const *b);
void range_fragment_free (GSList *fragments);
GnmSheetRange *gnm_sheet_range_new (Sheet *sheet, GnmRange const *r);
void gnm_sheet_range_free (GnmSheetRange *r);
......
......@@ -359,7 +359,8 @@ typedef enum {
CLEAR_NORESPAN = 0x10,
CLEAR_RECALC_DEPS = 0x20,
CLEAR_MERGES = 0x40,
CLEAR_OBJECTS = 0x80
CLEAR_OBJECTS = 0x80,
CLEAR_FILTERED_ONLY = 0x100
} SheetClearFlags;
void sheet_clear_region (Sheet *sheet,
......
......@@ -321,6 +321,18 @@ static GNM_ACTION_DEF (cb_edit_clear_comments)
{ cmd_selection_clear (WORKBOOK_CONTROL (wbcg), CLEAR_COMMENTS); }
static GNM_ACTION_DEF (cb_edit_clear_content)
{ cmd_selection_clear (WORKBOOK_CONTROL (wbcg), CLEAR_VALUES); }
static GNM_ACTION_DEF (cb_edit_clear_all_filtered)
{
cmd_selection_clear (WORKBOOK_CONTROL (wbcg),
CLEAR_VALUES | CLEAR_FORMATS | CLEAR_OBJECTS | CLEAR_COMMENTS | CLEAR_FILTERED_ONLY);
}
static GNM_ACTION_DEF (cb_edit_clear_formats_filtered)
{ cmd_selection_clear (WORKBOOK_CONTROL (wbcg), CLEAR_FORMATS | CLEAR_FILTERED_ONLY); }
static GNM_ACTION_DEF (cb_edit_clear_comments_filtered)
{ cmd_selection_clear (WORKBOOK_CONTROL (wbcg), CLEAR_COMMENTS | CLEAR_FILTERED_ONLY); }
static GNM_ACTION_DEF (cb_edit_clear_content_filtered)
{ cmd_selection_clear (WORKBOOK_CONTROL (wbcg), CLEAR_VALUES | CLEAR_FILTERED_ONLY); }
static GNM_ACTION_DEF (cb_edit_delete_rows)
{
......@@ -1935,12 +1947,27 @@ static GtkActionEntry const actions[] = {
{ "EditClearAll", GTK_STOCK_CLEAR, N_("_All"),
NULL, N_("Clear the selected cells' formats, comments, and contents"),
G_CALLBACK (cb_edit_clear_all) },
{ "EditClearFormats", NULL, N_("_Formats"),
NULL, N_("Clear the selected cells' formats"),
{ "EditClearFormats", NULL, N_("_Formats & Hyperlinks"),
NULL, N_("Clear the selected cells' formats and hyperlinks"),
G_CALLBACK (cb_edit_clear_formats) },
{ "EditClearComments", "Gnumeric_CommentDelete", N_("Co_mments"),
NULL, N_("Delete the selected cells' comments"),
G_CALLBACK (cb_edit_clear_comments) },
{ "EditClearContent", GTK_STOCK_CLEAR, N_("_Contents"),
NULL, N_("Clear the selected cells' contents"),
G_CALLBACK (cb_edit_clear_content) },
{ "EditClearAllFiltered", GTK_STOCK_CLEAR, N_("A_ll Filtered Rows"),
NULL, N_("Clear the selected cells' formats, comments, and contents in the filtered rows"),
G_CALLBACK (cb_edit_clear_all_filtered) },
{ "EditClearFormatsFiltered", NULL, N_("F_ormats & Hyperlinks in Filtered Rows"),
NULL, N_("Clear the selected cells' formats and hyperlinks in the filtered rows"),
G_CALLBACK (cb_edit_clear_formats_filtered) },
{ "EditClearCommentsFiltered", "Gnumeric_CommentDelete", N_("Comme_nts in Filtered Rows"),
NULL, N_("Delete the selected cells' comments in the filtered rows"),
G_CALLBACK (cb_edit_clear_comments_filtered) },
{ "EditClearContentFiltered", GTK_STOCK_CLEAR, N_("Content_s of Filtered Rows"),
NULL, N_("Clear the selected cells' contents in the filtered rows"),
G_CALLBACK (cb_edit_clear_content_filtered) },
/* Edit -> Delete */
{ "EditDeleteRows", "Gnumeric_RowDelete", N_("_Rows"),
......@@ -1952,9 +1979,6 @@ static GtkActionEntry const actions[] = {
{ "EditDeleteCells", NULL, N_("C_ells..."),
"<control>minus", N_("Delete the selected cells, shifting others into their place"),
G_CALLBACK (cb_edit_delete_cells) },
{ "EditClearComments", "Gnumeric_CommentDelete", N_("Co_mments"),
NULL, N_("Delete the selected cells' comments"),
G_CALLBACK (cb_edit_clear_comments) },
{ "EditClearHyperlinks", "Gnumeric_Link_Delete", N_("_Hyperlinks"),
NULL, N_("Delete the selected cells' hyperlinks"),
G_CALLBACK (cb_edit_delete_links) },
......
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