Commit a6931e05 authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

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
parent 65e2595b
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
......
......@@ -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
......
......@@ -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"/>
......
......@@ -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"/>
......
......@@ -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"/>
......
......@@ -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);
}
/******************************************************************/
......@@ -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);
/********************************************************************************/
......
......@@ -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. */
......
......@@ -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);
......
......@@ -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););
}
}
......
......@@ -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"),
......
......@@ -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);
......
......@@ -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)
......
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