[gnumeric] Add menu items to remove and add manual page breaks.
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add menu items to remove and add manual page breaks.
- Date: Thu, 7 Oct 2010 21:10:04 +0000 (UTC)
commit a6931e05f9887632d239f628787168fd777de4e4
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Oct 7 15:10:04 2010 -0600
Add menu items to remove and add manual page breaks.
2010-10-07 Andreas J. Guelzow <aguelzow pyrshep ca>
* component/Gnumeric-embed.xml.in: add menu items
* src/GNOME_Gnumeric-gtk.xml.in: add menu items
* src/HILDON_Gnumeric-gtk.xml.in: add menu items
* src/commands.c(cmd_page_breaks_clear): new
(cmd_page_break_toggle): new
(cmd_page_breaks_set_breaks): new
* src/commands.h (cmd_page_breaks_clear): new
(cmd_page_break_toggle): new
* src/print-info.c (print_info_has_manual_breaks): new
* src/print-info.h (print_info_has_manual_breaks): new
* src/sheet-view.c (sv_update): add MS_PAGE_BREAKS
* src/wbc-gtk-actions.c (cb_file_print_area_toggle_col): new
(cb_file_print_area_toggle_row): new
(cb_file_print_area_clear_pagebreaks): new
(permanent_actions): change meu item title
(actions): connect the above
* src/wbc-gtk.c (wbcg_menu_state_update): handle MS_PAGE_BREAKS
* src/workbook-control.h (MS_PAGE_BREAKS): new
ChangeLog | 21 ++++++++
NEWS | 1 +
component/Gnumeric-embed.xml.in | 3 +
src/GNOME_Gnumeric-gtk.xml.in | 3 +
src/HILDON_Gnumeric-gtk.xml.in | 3 +
src/commands.c | 100 +++++++++++++++++++++++++++++++++++++++
src/commands.h | 2 +
src/print-info.c | 8 +++
src/print-info.h | 2 +
src/sheet-view.c | 3 +-
src/wbc-gtk-actions.c | 29 +++++++++++-
src/wbc-gtk.c | 35 ++++++++++++++
src/workbook-control.h | 11 ++--
13 files changed, 214 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 044510d..91cff0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,26 @@
2010-10-07 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * component/Gnumeric-embed.xml.in: add menu items
+ * src/GNOME_Gnumeric-gtk.xml.in: add menu items
+ * src/HILDON_Gnumeric-gtk.xml.in: add menu items
+ * src/commands.c(cmd_page_breaks_clear): new
+ (cmd_page_break_toggle): new
+ (cmd_page_breaks_set_breaks): new
+ * src/commands.h (cmd_page_breaks_clear): new
+ (cmd_page_break_toggle): new
+ * src/print-info.c (print_info_has_manual_breaks): new
+ * src/print-info.h (print_info_has_manual_breaks): new
+ * src/sheet-view.c (sv_update): add MS_PAGE_BREAKS
+ * src/wbc-gtk-actions.c (cb_file_print_area_toggle_col): new
+ (cb_file_print_area_toggle_row): new
+ (cb_file_print_area_clear_pagebreaks): new
+ (permanent_actions): change meu item title
+ (actions): connect the above
+ * src/wbc-gtk.c (wbcg_menu_state_update): handle MS_PAGE_BREAKS
+ * src/workbook-control.h (MS_PAGE_BREAKS): new
+
+2010-10-07 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* src/print-info.c (print_info_set_paper_orientation): correct
argument description
* src/print-info.h (page_breaks): add comment
diff --git a/NEWS b/NEWS
index 85c30b0..9b7498c 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Andreas:
* Add option to sheet object lists and combos to enter values
rather than index. [#629333]
* Fix manual pagebreak handling when printing. [#631570]
+ * Add menu items to remove and add manual page breaks.
--------------------------------------------------------------------------
Gnumeric 1.10.11
diff --git a/component/Gnumeric-embed.xml.in b/component/Gnumeric-embed.xml.in
index 71fbbc1..1a660d3 100644
--- a/component/Gnumeric-embed.xml.in
+++ b/component/Gnumeric-embed.xml.in
@@ -15,6 +15,9 @@
<menuitem action="FilePrintAreaSet"/>
<menuitem action="FilePrintAreaClear"/>
<menuitem action="FilePrintAreaShow"/>
+ <menuitem action="FilePrintAreaToggleColPageBreak"/>
+ <menuitem action="FilePrintAreaToggleRowPageBreak"/>
+ <menuitem action="FilePrintAreaClearAllPageBreak"/>
</menu>
<menuitem action="FilePrintPreview"/>
<menuitem action="FilePrint"/>
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index 9aaf114..7563005 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -15,6 +15,9 @@
<menuitem action="FilePrintAreaSet"/>
<menuitem action="FilePrintAreaClear"/>
<menuitem action="FilePrintAreaShow"/>
+ <menuitem action="FilePrintAreaToggleColPageBreak"/>
+ <menuitem action="FilePrintAreaToggleRowPageBreak"/>
+ <menuitem action="FilePrintAreaClearAllPageBreak"/>
</menu>
<menuitem action="FilePrintPreview"/>
<menuitem action="FilePrint"/>
diff --git a/src/HILDON_Gnumeric-gtk.xml.in b/src/HILDON_Gnumeric-gtk.xml.in
index ed37812..2c253fe 100644
--- a/src/HILDON_Gnumeric-gtk.xml.in
+++ b/src/HILDON_Gnumeric-gtk.xml.in
@@ -12,6 +12,9 @@
<menuitem action="FilePrintAreaSet"/>
<menuitem action="FilePrintAreaClear"/>
<menuitem action="FilePrintAreaShow"/>
+ <menuitem action="FilePrintAreaToggleColPageBreak"/>
+ <menuitem action="FilePrintAreaToggleRowPageBreak"/>
+ <menuitem action="FilePrintAreaClearAllPageBreak"/>
</menu>
<!--
<menuitem action="FilePageSetup"/>
diff --git a/src/commands.c b/src/commands.c
index fe677ba..7c81658 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -7895,11 +7895,111 @@ gboolean cmd_autofilter_set_condition (WorkbookControl *wbc,
}
+/******************************************************************/
+
+static void
+cmd_page_breaks_set_breaks (Sheet *sheet,
+ GnmPageBreaks const *breaks)
+{
+ print_info_set_breaks (sheet->print_info, gnm_page_breaks_dup (breaks));
+
+ SHEET_FOREACH_CONTROL (sheet, sv, sc, wb_control_menu_state_update (sc_wbc (sc), MS_PAGE_BREAKS););
+}
+
+gboolean
+cmd_page_breaks_clear (WorkbookControl *wbc, Sheet *sheet)
+{
+ GOUndo *undo = NULL;
+ GOUndo *redo = NULL;
+
+ g_return_val_if_fail (IS_WORKBOOK_CONTROL (wbc), TRUE);
+ g_return_val_if_fail (sheet != NULL, TRUE);
+ if (sheet->print_info->page_breaks.v != NULL) {
+ redo = go_undo_binary_new
+ (sheet,
+ gnm_page_breaks_new (TRUE),
+ (GOUndoBinaryFunc) cmd_page_breaks_set_breaks,
+ NULL,
+ (GFreeFunc) gnm_page_breaks_free);
+ undo = go_undo_binary_new
+ (sheet,
+ gnm_page_breaks_dup
+ (sheet->print_info->page_breaks.v),
+ (GOUndoBinaryFunc) cmd_page_breaks_set_breaks,
+ NULL,
+ (GFreeFunc) gnm_page_breaks_free);
+ }
+ if (sheet->print_info->page_breaks.h != NULL) {
+ redo = go_undo_combine
+ (redo,
+ go_undo_binary_new
+ (sheet,
+ gnm_page_breaks_new (FALSE),
+ (GOUndoBinaryFunc) cmd_page_breaks_set_breaks,
+ NULL,
+ (GFreeFunc) gnm_page_breaks_free));
+
+ undo = go_undo_combine
+ (undo,
+ go_undo_binary_new
+ (sheet,
+ gnm_page_breaks_dup
+ (sheet->print_info->page_breaks.h),
+ (GOUndoBinaryFunc) cmd_page_breaks_set_breaks,
+ NULL,
+ (GFreeFunc) gnm_page_breaks_free));
+ }
+
+ if (undo != NULL)
+ return cmd_generic (wbc, _("Clear All Page Breaks"), undo, redo);
+ else
+ return TRUE;
+}
+gboolean
+cmd_page_break_toggle (WorkbookControl *wbc, Sheet *sheet, gboolean is_vert)
+{
+ SheetView const *sv = wb_control_cur_sheet_view (wbc);
+ gint col = sv->edit_pos.col;
+ gint row = sv->edit_pos.row;
+ int rc = is_vert ? col : row;
+ GnmPageBreaks *old, *new, *target;
+ GnmPageBreakType type;
+ char const *label;
+ GOUndo *undo;
+ GOUndo *redo;
+ target = is_vert ? sheet->print_info->page_breaks.v
+ : sheet->print_info->page_breaks.h;
+ old = (target == NULL) ? gnm_page_breaks_new (is_vert)
+ : gnm_page_breaks_dup (target);
+ new = gnm_page_breaks_dup (old);
+ if (gnm_page_breaks_get_break (new, rc) != GNM_PAGE_BREAK_MANUAL) {
+ type = GNM_PAGE_BREAK_MANUAL;
+ label = is_vert ? _("Remove Column Page Break") : _("Remove Row Page Break");
+ } else {
+ type = GNM_PAGE_BREAK_NONE;
+ label = is_vert ? _("Add Column Page Break") : _("Add Row Page Break");
+ }
+
+ gnm_page_breaks_set_break (new, rc, type);
+
+ redo = go_undo_binary_new
+ (sheet, new,
+ (GOUndoBinaryFunc) cmd_page_breaks_set_breaks,
+ NULL,
+ (GFreeFunc) gnm_page_breaks_free);
+ undo = go_undo_binary_new
+ (sheet, old,
+ (GOUndoBinaryFunc) cmd_page_breaks_set_breaks,
+ NULL,
+ (GFreeFunc) gnm_page_breaks_free);
+
+ return cmd_generic (wbc, label, undo, redo);
+}
/******************************************************************/
diff --git a/src/commands.h b/src/commands.h
index ce38405..78a2b6a 100644
--- a/src/commands.h
+++ b/src/commands.h
@@ -222,6 +222,8 @@ gboolean cmd_so_set_adjustment (WorkbookControl *wbc, SheetObject *so,
int step, int page,
char const *undo_label);
+gboolean cmd_page_breaks_clear (WorkbookControl *wbc, Sheet *sheet);
+gboolean cmd_page_break_toggle (WorkbookControl *wbc, Sheet *sheet, gboolean is_vert);
/********************************************************************************/
diff --git a/src/print-info.c b/src/print-info.c
index c5464ce..0e83605 100644
--- a/src/print-info.c
+++ b/src/print-info.c
@@ -1231,6 +1231,14 @@ print_info_set_breaks (PrintInformation *pi,
*target = breaks;
}
+gboolean
+print_info_has_manual_breaks (PrintInformation *pi)
+{
+ if (gnm_page_breaks_get_next_manual_break (pi->page_breaks.v, 0) > -1)
+ return TRUE;
+ return (gnm_page_breaks_get_next_manual_break (pi->page_breaks.h, 0) > -1);
+}
+
/********************************************************************
* Simple data structure to store page breaks defined as a wrapper in case we
* need something more extensive later. */
diff --git a/src/print-info.h b/src/print-info.h
index 83c7187..fc15a69 100644
--- a/src/print-info.h
+++ b/src/print-info.h
@@ -172,6 +172,8 @@ void print_info_set_edge_to_below_header (PrintInformation *pi,
double e_h);
void print_info_set_breaks (PrintInformation *pi, GnmPageBreaks *breaks);
+gboolean print_info_has_manual_breaks (PrintInformation *pi);
+
GnmPageBreaks *gnm_page_breaks_new (gboolean is_vert);
GnmPageBreaks *gnm_page_breaks_dup (GnmPageBreaks const *src);
void gnm_page_breaks_free (GnmPageBreaks *breaks);
diff --git a/src/sheet-view.c b/src/sheet-view.c
index 3060d16..0cd4ada 100644
--- a/src/sheet-view.c
+++ b/src/sheet-view.c
@@ -643,7 +643,8 @@ sv_update (SheetView *sv)
wb_view_selection_desc (sv->sv_wbv, TRUE, NULL);
SHEET_VIEW_FOREACH_CONTROL
(sv, sc, wb_control_menu_state_update
- (sc_wbc (sc), MS_COMMENT_LINKS););
+ (sc_wbc (sc),
+ MS_COMMENT_LINKS | MS_PAGE_BREAKS););
}
}
diff --git a/src/wbc-gtk-actions.c b/src/wbc-gtk-actions.c
index b900898..4f71c58 100644
--- a/src/wbc-gtk-actions.c
+++ b/src/wbc-gtk-actions.c
@@ -276,6 +276,24 @@ static GNM_ACTION_DEF (cb_file_print_area_show)
}
}
+static GNM_ACTION_DEF (cb_file_print_area_toggle_col)
+{
+ cmd_page_break_toggle (WORKBOOK_CONTROL (wbcg),
+ wbcg_cur_sheet (wbcg),
+ TRUE);
+}
+static GNM_ACTION_DEF (cb_file_print_area_toggle_row)
+{
+ cmd_page_break_toggle (WORKBOOK_CONTROL (wbcg),
+ wbcg_cur_sheet (wbcg),
+ FALSE);
+}
+
+static GNM_ACTION_DEF (cb_file_print_area_clear_pagebreaks)
+{
+ cmd_page_breaks_clear (WORKBOOK_CONTROL (wbcg), wbcg_cur_sheet (wbcg));
+}
+
static GNM_ACTION_DEF (cb_file_print)
{
gnm_print_sheet (WORKBOOK_CONTROL (wbcg),
@@ -1930,7 +1948,7 @@ static GtkActionEntry const permanent_actions[] = {
{ "FileSend", "Gnumeric_Link_EMail", N_("Sen_d To..."),
NULL, N_("Send the current file via email"),
G_CALLBACK (cb_file_sendto) },
- { "FilePrintArea", NULL, N_("Print Area")},
+ { "FilePrintArea", NULL, N_("Print Area & Breaks")},
#ifdef HAVE_GTK_ADJUSTMENT_CONFIGURE
/* gtk_adjustment_configure implies gtk 2.14 or later */
/* that is required for GTK_STOCK_PAGE_SETUP */
@@ -2023,6 +2041,15 @@ static GtkActionEntry const actions[] = {
{ "FilePrintAreaShow", NULL, N_("Show Print Area"),
NULL, N_("Select the print area"),
G_CALLBACK (cb_file_print_area_show)},
+ { "FilePrintAreaToggleColPageBreak", NULL, N_("Set Column Page Break"),
+ NULL, N_("Split the page to the left of this column"),
+ G_CALLBACK (cb_file_print_area_toggle_col)},
+ { "FilePrintAreaToggleRowPageBreak", NULL, N_("Set Row Page Break"),
+ NULL, N_("Split the page above this row"),
+ G_CALLBACK (cb_file_print_area_toggle_row)},
+ { "FilePrintAreaClearAllPageBreak", NULL, N_("Clear All Page Breaks"),
+ NULL, N_("Remove all manual pagebreaks from this sheet"),
+ G_CALLBACK (cb_file_print_area_clear_pagebreaks)},
/* Edit -> Clear */
{ "EditClearAll", GTK_STOCK_CLEAR, N_("_All"),
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 0977cbf..48a1120 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -60,6 +60,7 @@
#include "dead-kittens.h"
#include "tools/analysis-auto-expression.h"
#include "sheet-object-cell-comment.h"
+#include "print-info.h"
#include <goffice/goffice.h>
#include <gsf/gsf-impl-utils.h>
@@ -1555,6 +1556,40 @@ wbcg_menu_state_update (WorkbookControl *wbc, int flags)
wbc_gtk_set_action_sensitivity (wbcg, "FilePrintAreaClear", has_print_area);
wbc_gtk_set_action_sensitivity (wbcg, "FilePrintAreaShow", has_print_area);
}
+ if (MS_PAGE_BREAKS & flags) {
+ gint col = sv->edit_pos.col;
+ gint row = sv->edit_pos.row;
+ PrintInformation *pi = sheet->print_info;
+ char const* new_label = NULL;
+ char const *new_tip = NULL;
+
+ if (pi->page_breaks.v != NULL &&
+ gnm_page_breaks_get_break (pi->page_breaks.v, col) == GNM_PAGE_BREAK_MANUAL) {
+ new_label = _("Remove Column Page Break");
+ new_tip = _("Remove the page break to the left of the current column");
+ } else {
+ new_label = _("Add Column Page Break");
+ new_tip = _("Add a page break to the left of the current column");
+ }
+ wbc_gtk_set_action_label (wbcg, "FilePrintAreaToggleColPageBreak",
+ NULL, new_label, new_tip);
+ if (pi->page_breaks.h != NULL &&
+ gnm_page_breaks_get_break (pi->page_breaks.h, col) == GNM_PAGE_BREAK_MANUAL) {
+ new_label = _("Remove Row Page Break");
+ new_tip = _("Remove the page break above the current row");
+ } else {
+ new_label = _("Add Row Page Break");
+ new_tip = _("Add a page break above current row");
+ }
+ wbc_gtk_set_action_label (wbcg, "FilePrintAreaToggleRowPageBreak",
+ NULL, new_label, new_tip);
+ wbc_gtk_set_action_sensitivity (wbcg, "FilePrintAreaToggleRowPageBreak",
+ row != 0);
+ wbc_gtk_set_action_sensitivity (wbcg, "FilePrintAreaToggleColPageBreak",
+ col != 0);
+ wbc_gtk_set_action_sensitivity (wbcg, "FilePrintAreaClearAllPageBreak",
+ print_info_has_manual_breaks (sheet->print_info));
+ }
if (MS_SELECT_OBJECT & flags) {
wbc_gtk_set_action_sensitivity (wbcg, "EditSelectObject",
sheet->sheet_objects != NULL);
diff --git a/src/workbook-control.h b/src/workbook-control.h
index 45611f9..71226c4 100644
--- a/src/workbook-control.h
+++ b/src/workbook-control.h
@@ -55,10 +55,11 @@ enum {
MS_FREEZE_VS_THAW = 1 << 9,
MS_ADD_VS_REMOVE_FILTER = 1 << 10,
MS_SHOW_PRINTAREA = 1 << 11,
- MS_SELECT_OBJECT = 1 << 12,
- MS_FILTER_STATE_CHANGED = 1 << 13,
- MS_COMMENT_LINKS_RANGE = 1 << 14,
- MS_COMMENT_LINKS = 1 << 15
+ MS_PAGE_BREAKS = 1 << 12,
+ MS_SELECT_OBJECT = 1 << 13,
+ MS_FILTER_STATE_CHANGED = 1 << 14,
+ MS_COMMENT_LINKS_RANGE = 1 << 15,
+ MS_COMMENT_LINKS = 1 << 16
};
#define MS_ALL \
@@ -66,7 +67,7 @@ enum {
MS_SHOWHIDE_DETAIL | MS_PASTE_SPECIAL | \
MS_PRINT_SETUP | MS_SEARCH_REPLACE | MS_DEFINE_NAME | MS_CONSOLIDATE | \
MS_FREEZE_VS_THAW | MS_ADD_VS_REMOVE_FILTER | MS_SHOW_PRINTAREA | \
- MS_SELECT_OBJECT | MS_FILTER_STATE_CHANGED)
+ MS_PAGE_BREAKS | MS_SELECT_OBJECT | MS_FILTER_STATE_CHANGED)
#define MS_GURU_MENU_ITEMS \
(MS_PRINT_SETUP | MS_SEARCH_REPLACE | MS_DEFINE_NAME | MS_CONSOLIDATE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]