Commit 17d1046f authored by Andreas J. Guelzow 's avatar Andreas J. Guelzow

Permit choice whether to print sheet objejcts.

2010-10-01  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* sheet-object-widget.c (sheet_widget_button_init_full: disable
	  printing by default
	(sheet_widget_adjustment_init_full): ditto
	(sheet_widget_list_base_init): ditto
	* sheet-object.c (sheet_object_set_print_flag): new
	* sheet-object.h (sheet_object_set_print_flag): new
	* xml-sax-read.c (xml_sax_read_obj): read print flag
	* xml-sax-write.c (xml_write_objects): write print flag

2010-10-01  Andreas J. Guelzow <aguelzow@pyrshep.ca>

	* sheetobject-size.glade: add "Do not print" checkbox
	* dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
	  handle do-not-print
	(cb_dialog_so_size_apply_clicked): ditto
	(cb_dialog_so_size_ok_clicked): ditto
	(cb_dialog_so_size_print_check_toggled): new
	(set_print_flag): new
	(dialog_so_size): connect do-not-print checkbox
parent f4b3de79
2010-10-01 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* sheet-object-widget.c (sheet_widget_button_init_full: disable
printing by default
(sheet_widget_adjustment_init_full): ditto
(sheet_widget_list_base_init): ditto
* sheet-object.c (sheet_object_set_print_flag): new
* sheet-object.h (sheet_object_set_print_flag): new
* xml-sax-read.c (xml_sax_read_obj): read print flag
* xml-sax-write.c (xml_write_objects): write print flag
2010-09-30 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* src/sheet-object-widget.c (sheet_widget_draw_cairo): warn always
......
......@@ -11,6 +11,7 @@ Andreas:
* Set ODF files to save by default as ODF files. [#629962]
* Fix ssconvert crash on form controls. [#630335]
* Improve printing of the form controls.
* Permit choice whether to print sheet objejcts.
Jean:
* Export/import tick label rotation angle. [#629675]
......
2010-10-01 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* sheetobject-size.glade: add "Do not print" checkbox
* dialog-sheetobject-size.c (dialog_so_size_button_sensitivity):
handle do-not-print
(cb_dialog_so_size_apply_clicked): ditto
(cb_dialog_so_size_ok_clicked): ditto
(cb_dialog_so_size_print_check_toggled): new
(set_print_flag): new
(dialog_so_size): connect do-not-print checkbox
2010-09-15 Andreas J. Guelzow <aguelzow@pyrshep.ca>
* dialog-sheet-order.c (cb_color_changed_fore): handle multiple
......
......@@ -39,6 +39,7 @@
#include <application.h>
#include <workbook-cmd-format.h>
#include <sheet-object-widget.h>
#include <sheet-object-impl.h>
#include <sheet-control-gui.h>
#include <glade/glade.h>
......@@ -65,6 +66,7 @@ typedef struct {
GtkWidget *ypoints;
GtkSpinButton *yspin;
GtkEntry *nameentry;
GtkWidget *print_check;
SheetObject *so;
SheetObjectAnchor *old_anchor;
......@@ -74,6 +76,7 @@ typedef struct {
gboolean so_size_needs_restore;
gboolean so_pos_needs_restore;
gboolean so_name_changed;
gboolean so_print_check_changed;
} SOSizeState;
static void
......@@ -92,7 +95,8 @@ dialog_so_size_button_sensitivity (SOSizeState *state)
{
gboolean sensitive = state->so_size_needs_restore ||
state->so_pos_needs_restore ||
state->so_name_changed;
state->so_name_changed ||
state->so_print_check_changed;
gtk_widget_set_sensitive
(state->ok_button, sensitive);
gtk_widget_set_sensitive
......@@ -192,11 +196,26 @@ set_params (SheetObject *so, char *name)
g_object_unref, g_free);
}
static GOUndo *
set_print_flag (SheetObject *so, gboolean print)
{
gboolean *p_print = g_new (gboolean, 1);
*p_print = print;
return go_undo_binary_new
(g_object_ref (G_OBJECT (so)), p_print,
(GOUndoBinaryFunc)sheet_object_set_print_flag,
g_object_unref, g_free);
}
static void
cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
SOSizeState *state)
{
char const *name;
GOUndo *undo = NULL, *redo = NULL;
char const *undo_name = NULL;
int cnt = 0;
if (state->so_size_needs_restore || state->so_pos_needs_restore) {
char const *label = state->so_pos_needs_restore ?
......@@ -215,21 +234,34 @@ cb_dialog_so_size_apply_clicked (G_GNUC_UNUSED GtkWidget *button,
if (name == NULL)
name = "";
if (strcmp (name, state->old_name) != 0) {
GOUndo *undo, *redo;
char *old_name, *new_name;
g_object_get (G_OBJECT (state->so), "name", &old_name, NULL);
undo = set_params (state->so, old_name);
undo = go_undo_combine (undo, set_params (state->so, old_name));
new_name = (*name == '\0') ? NULL : g_strdup (name);
redo = set_params (state->so, new_name);
redo = go_undo_combine (redo, set_params (state->so, new_name));
state->so_name_changed
= cmd_generic (WORKBOOK_CONTROL (state->wbcg),
_("Set Object Name"),
undo, redo);
undo_name = _("Set Object Name");
cnt++;
}
if (state->so_print_check_changed) {
gboolean val = ((state->so->flags & SHEET_OBJECT_PRINT) != 0);
undo = go_undo_combine (undo, set_print_flag
(state->so, val));
redo = go_undo_combine (redo, set_print_flag
(state->so, !val));
undo_name = _("Set Object Print Property");
cnt++;
}
if (cnt > 0) {
if (cnt > 1)
undo_name = _("Set Object Properties");
state->so_name_changed = state->so_print_check_changed =
cmd_generic (WORKBOOK_CONTROL (state->wbcg),
undo_name, undo, redo);
}
dialog_so_size_button_sensitivity (state);
return;
......@@ -240,7 +272,7 @@ cb_dialog_so_size_ok_clicked (GtkWidget *button, SOSizeState *state)
{
cb_dialog_so_size_apply_clicked (button, state);
if (!state->so_size_needs_restore && !state->so_pos_needs_restore &&
!state->so_name_changed)
!state->so_name_changed && !state->so_print_check_changed)
gtk_widget_destroy (state->dialog);
return;
}
......@@ -259,6 +291,18 @@ cb_dialog_so_size_name_changed (GtkEntry *entry,
return FALSE;
}
static void
cb_dialog_so_size_print_check_toggled (GtkToggleButton *togglebutton,
SOSizeState *state)
{
gboolean new_print = !gtk_toggle_button_get_active (togglebutton);
gboolean old_print = ((state->so->flags & SHEET_OBJECT_PRINT) != 0);
state->so_print_check_changed
= (new_print != old_print);
dialog_so_size_button_sensitivity (state);
return;
}
void
dialog_so_size (WBCGtk *wbcg, GObject *so)
......@@ -299,6 +343,7 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
"focus-out-event",
G_CALLBACK (cb_dialog_so_size_name_changed),
state);
state->so_print_check_changed = FALSE;
state->wpoints = GTK_WIDGET (glade_xml_get_widget (state->gui, "w-pts-label"));
state->wspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "w-spin"));
......@@ -308,9 +353,11 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
state->xspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "x-spin"));
state->ypoints = GTK_WIDGET (glade_xml_get_widget (state->gui, "y-pts-label"));
state->yspin = GTK_SPIN_BUTTON (glade_xml_get_widget (state->gui, "y-spin"));
state->print_check = GTK_WIDGET (glade_xml_get_widget (state->gui,
"print-check"));
dialog_so_size_load (state);
state->active_anchor = sheet_object_anchor_dup (sheet_object_get_anchor (state->so));
state->active_anchor = sheet_object_anchor_dup (sheet_object_get_anchor
(state->so));
width = state->coords[2] - state->coords[0];
height = state->coords[3] - state->coords[1];
......@@ -318,6 +365,8 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
gtk_spin_button_set_value (state->hspin, (height < 0) ? - height : height);
gtk_spin_button_set_value (state->xspin, 0.);
gtk_spin_button_set_value (state->yspin, 0.);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (state->print_check),
!(state->so->flags & SHEET_OBJECT_PRINT));
g_signal_connect (G_OBJECT (state->wspin),
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
......@@ -334,6 +383,11 @@ dialog_so_size (WBCGtk *wbcg, GObject *so)
"value-changed",
G_CALLBACK (cb_dialog_so_size_value_changed_update_points),
state->ypoints);
g_signal_connect (G_OBJECT (state->print_check),
"toggled",
G_CALLBACK (cb_dialog_so_size_print_check_toggled),
state);
cb_dialog_so_size_value_changed_update_points (state->wspin, GTK_LABEL (state->wpoints));
cb_dialog_so_size_value_changed_update_points (state->hspin, GTK_LABEL (state->hpoints));
cb_dialog_so_size_value_changed_update_points (state->xspin, GTK_LABEL (state->xpoints));
......
......@@ -10,13 +10,12 @@
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<widget class="GtkTable" id="main_table">
<property name="visible">True</property>
<property name="border_width">8</property>
<property name="n_rows">9</property>
<property name="n_rows">10</property>
<property name="n_columns">4</property>
<property name="column_spacing">12</property>
<property name="row_spacing">5</property>
......@@ -162,8 +161,8 @@
<property name="mnemonic_widget">name-entry</property>
</widget>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
......@@ -178,8 +177,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">4</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
......@@ -346,12 +345,28 @@
</widget>
<packing>
<property name="right_attach">4</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="print-check">
<property name="label" translatable="yes">Do not print</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip" translatable="yes">Sheet objects with this property do not print with the remainder of the sheet.</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="right_attach">4</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
......
......@@ -742,6 +742,9 @@ sheet_widget_button_init_full (SheetWidgetButton *swb,
char const *text,
PangoAttrList *markup)
{
SheetObject *so = SHEET_OBJECT (swb);
so->flags &= ~SHEET_OBJECT_PRINT;
swb->label = g_strdup (text);
swb->markup = markup;
swb->value = FALSE;
......@@ -1366,7 +1369,11 @@ sheet_widget_adjustment_init_full (SheetWidgetAdjustment *swa,
GnmCellRef const *ref,
gboolean horizontal)
{
SheetObject *so;
g_return_if_fail (swa != NULL);
so = SHEET_OBJECT (swa);
so->flags &= ~SHEET_OBJECT_PRINT;
swa->adjustment = GTK_ADJUSTMENT (gtk_adjustment_new (0., 0., 100., 1., 10., 0.));
g_object_ref_sink (swa->adjustment);
......@@ -3370,6 +3377,9 @@ static void
sheet_widget_list_base_init (SheetObjectWidget *sow)
{
SheetWidgetListBase *swl = SHEET_WIDGET_LIST_BASE (sow);
SheetObject *so = SHEET_OBJECT (sow);
so->flags &= ~SHEET_OBJECT_PRINT;
swl->content_dep.sheet = NULL;
swl->content_dep.flags = list_content_get_dep_type ();
......
......@@ -63,6 +63,16 @@ static GObjectClass *parent_klass;
static GQuark sov_so_quark;
static GQuark sov_container_quark;
void
sheet_object_set_print_flag (SheetObject *so, gboolean *print)
{
if (*print)
so->flags = (so->flags | SHEET_OBJECT_PRINT);
else
so->flags = (so->flags & ~SHEET_OBJECT_PRINT);
}
static void
cb_so_size_position (SheetObject *so, SheetControl *sc)
{
......
......@@ -66,6 +66,7 @@ Sheet *sheet_object_get_sheet (SheetObject const *so);
void sheet_object_clear_sheet (SheetObject *so);
void sheet_object_set_name (SheetObject *so, const char *name);
void sheet_object_set_print_flag (SheetObject *so, gboolean *print);
SheetObject *sheet_object_dup (SheetObject const *so);
gboolean sheet_object_can_print (SheetObject const *so);
......
......@@ -2325,12 +2325,15 @@ xml_sax_read_obj (GsfXMLIn *xin, gboolean needs_cleanup,
anchor_offset = f_tmp;
else if (gnm_xml_attr_int (attrs+i, "Direction", &tmp_int))
anchor_dir = tmp_int;
else if (gnm_xml_attr_int (attrs+i, "Print", &tmp_int)) {
gboolean b = (tmp_int != 0);
sheet_object_set_print_flag (so, &b);
}
#if 0
/* Deprecated in 1.7.7 */
else if (attr_eq (attrs[i], "ObjectAnchorType"))
else if (attr_eq (attrs[i], "ObjectAnchorType")) {
}
/* There may be extra attributes that are handled by the objects */
else
unknown_attr (xin, attrs+i);
#endif
}
......
......@@ -1159,6 +1159,10 @@ xml_write_objects (GnmOutputXML *state, GSList *objects)
gsf_xml_out_add_int (state->output, "Direction",
so->anchor.base.direction);
gsf_xml_out_add_int
(state->output, "Print",
((so->flags & SHEET_OBJECT_PRINT) != 0 )
? 1 : 0);
(*klass->write_xml_sax) (so, state->output, state->convs);
......
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