[goffice] Add 'force exponent sign' checkbox to format selector. [#686481]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Add 'force exponent sign' checkbox to format selector. [#686481]
- Date: Sat, 10 Nov 2012 03:47:34 +0000 (UTC)
commit 4863fd8ffce891dc7b8a7be5ff5007584b468a71
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Fri Nov 9 20:47:01 2012 -0700
Add 'force exponent sign' checkbox to format selector. [#686481]
2012-11-09 Andreas J. Guelzow <aguelzow pyrshep ca>
* office/gtk/go-format-sel.c (cb_force_exponent_sign_toggle): new
(fmt_dialog_enable_widgets): add widget and handle F_FORCE_EXPONENT_SIGN_BUTTON
(nfs_init): add widget and connect cb_force_exponent_sign_toggle
* goffice/gtk/go-format-sel.ui: add checkbox
* goffice/utils/go-format.c (go_format_generate_scientific_str): use
exponent_sign_forced
(go_format_details_init): initialize exponent_sign_forced
(go_format_get_details): determine exponent_sign_forced
* goffice/utils/go-format.h: add exponent_sign_forced field to details
ChangeLog | 12 +++++++++++
NEWS | 1 +
goffice/gtk/go-format-sel.c | 24 +++++++++++++++++++++-
goffice/gtk/go-format-sel.ui | 44 +++++++++++++++++++++++++++--------------
goffice/utils/go-format.c | 9 ++++++-
goffice/utils/go-format.h | 2 +
6 files changed, 74 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1c79342..ac79504 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2012-11-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+ * office/gtk/go-format-sel.c (cb_force_exponent_sign_toggle): new
+ (fmt_dialog_enable_widgets): add widget and handle F_FORCE_EXPONENT_SIGN_BUTTON
+ (nfs_init): add widget and connect cb_force_exponent_sign_toggle
+ * goffice/gtk/go-format-sel.ui: add checkbox
+ * goffice/utils/go-format.c (go_format_generate_scientific_str): use
+ exponent_sign_forced
+ (go_format_details_init): initialize exponent_sign_forced
+ (go_format_get_details): determine exponent_sign_forced
+ * goffice/utils/go-format.h: add exponent_sign_forced field to details
+
+2012-11-09 Andreas J. Guelzow <aguelzow pyrshep ca>
+
* goffice/utils/go-format.c (go_format_execute): fix placement of minus sign
2012-11-09 Andreas J. Guelzow <aguelzow pyrshep ca>
diff --git a/NEWS b/NEWS
index ea04e4c..63aa107 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Andreas:
* Handle some more unusual formats in ODF export. [#683801]
* Fix some magic date handling. [#686575]
* Fix placement of minus sign. [#686575]
+ * Add 'force exponent sign' checkbox to format selector. [#686481]
Chris Leonard:
* Updated locales. [#682749]
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index af89715..1b38fc7 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -1,3 +1,4 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* go-format-sel.c: A widget to select a format
*
@@ -90,7 +91,9 @@ typedef enum {
F_SYMBOL_LABEL, F_SYMBOL,
F_ENTRY,
F_LIST_LABEL, F_LIST_SCROLL, F_LIST,
- F_DECIMAL_SPIN, F_ENGINEERING_BUTTON,
+ F_DECIMAL_SPIN,
+ F_FORCE_EXPONENT_SIGN_BUTTON,
+ F_ENGINEERING_BUTTON,
F_SUPERSCRIPT_BUTTON, F_SUPERSCRIPT_HIDE_1_BUTTON,
F_SI_BUTTON, F_SI_CUSTOM_UNIT_BUTTON,
F_SI_SI_UNIT_BUTTON, F_SI_UNIT_COMBO,
@@ -467,6 +470,15 @@ cb_separator_toggle (GtkWidget *w, GOFormatSel *gfs)
}
static void
+cb_force_exponent_sign_toggle (GtkWidget *w, GOFormatSel *gfs)
+{
+ gfs->format.details.exponent_sign_forced =
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
+
+ draw_format_preview (gfs, TRUE);
+}
+
+static void
cb_engineering_toggle (GtkWidget *w, GOFormatSel *gfs)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
@@ -790,6 +802,7 @@ fmt_dialog_enable_widgets (GOFormatSel *gfs, int page)
F_DECIMAL_GRID,
F_DECIMAL_LABEL,
F_DECIMAL_SPIN,
+ F_FORCE_EXPONENT_SIGN_BUTTON,
F_ENGINEERING_BUTTON,
F_SUPERSCRIPT_BUTTON,
F_SUPERSCRIPT_HIDE_1_BUTTON,
@@ -1043,6 +1056,12 @@ stays:
}
break;
+ case F_FORCE_EXPONENT_SIGN_BUTTON:
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (w),
+ gfs->format.details.exponent_sign_forced);
+ break;
+
case F_ENGINEERING_BUTTON:
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (w),
@@ -1419,6 +1438,7 @@ nfs_init (GOFormatSel *gfs)
"format_list_scroll",
"format_list",
"format_number_decimals",
+ "format_force_exponent_sign_button",
"format_engineering_button",
"format_superscript_button",
"format_superscript_hide_1_button",
@@ -1573,6 +1593,8 @@ nfs_init (GOFormatSel *gfs)
G_CALLBACK (cb_exp_digits_changed), gfs);
g_signal_connect (G_OBJECT (gfs->format.widget[F_SEPARATOR]), "toggled",
G_CALLBACK (cb_separator_toggle), gfs);
+ g_signal_connect (G_OBJECT (gfs->format.widget[F_FORCE_EXPONENT_SIGN_BUTTON]), "toggled",
+ G_CALLBACK (cb_force_exponent_sign_toggle), gfs);
g_signal_connect (G_OBJECT (gfs->format.widget[F_ENGINEERING_BUTTON]), "toggled",
G_CALLBACK (cb_engineering_toggle), gfs);
g_signal_connect (G_OBJECT (gfs->format.widget[F_SUPERSCRIPT_BUTTON]), "toggled",
diff --git a/goffice/gtk/go-format-sel.ui b/goffice/gtk/go-format-sel.ui
index 5be6b1f..a6c7389 100644
--- a/goffice/gtk/go-format-sel.ui
+++ b/goffice/gtk/go-format-sel.ui
@@ -975,6 +975,27 @@
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
+ <object class="GtkCheckButton" id="format_force_exponent_sign_button">
+ <property name="label" translatable="yes">Always show exponent si_gn</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="has_tooltip">FALSE</property>
+ <property name="margin_top">6</property>
+ <property name="use_underline">True</property>
+ <property name="valign">start</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkCheckButton" id="format_engineering_button">
<property name="label" translatable="yes">_Engineering notation</property>
<property name="use_action_appearance">False</property>
@@ -984,8 +1005,6 @@
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Restrict exponent to multiples of 3</property>
<property name="tooltip_text" translatable="yes">Restrict exponent to multiples of 3</property>
- <property name="margin_top">6</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="valign">start</property>
<property name="xalign">0</property>
@@ -993,7 +1012,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">0</property>
+ <property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1008,14 +1027,13 @@
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Use superscript for exponent (e.g. 4Ã10Â)</property>
<property name="tooltip_text" translatable="yes">Use superscript for exponent (e.g. 4Ã10Â)</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1031,21 +1049,20 @@
<property name="tooltip_markup" translatable="yes">When mantissa is equal to 1, only show exponent part (e.g. 10Â)</property>
<property name="tooltip_text" translatable="yes">When mantissa is equal to 1, only show exponent part (e.g. 10Â)</property>
<property name="margin_left">18</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">2</property>
+ <property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="format_SI_button">
- <property name="label" translatable="yes">Append SI prefix</property>
+ <property name="label" translatable="yes">Append SI _prefix</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -1053,14 +1070,13 @@
<property name="has_tooltip">True</property>
<property name="tooltip_markup" translatable="yes">Append an SI prefix (e.g. instead of 4Ã10â show 4M)</property>
<property name="tooltip_text" translatable="yes">Append an SI prefix (e.g. instead of 4Ã10â show 4M)</property>
- <property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">3</property>
+ <property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1073,7 +1089,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">18</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="image_position">top</property>
<property name="draw_indicator">True</property>
@@ -1081,7 +1096,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">4</property>
+ <property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1094,7 +1109,6 @@
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="margin_left">18</property>
- <property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="yalign">0.52999997138977051</property>
<property name="active">True</property>
@@ -1102,7 +1116,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
@@ -1117,7 +1131,7 @@
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index b788cdb..d387e46 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -108,6 +108,7 @@
* @force_quoted: force quotes use.
* @exponent_step: steps between allowed exponents in scientific notation.
* @exponent_digits: digits number in exponent.
+ * @exponent_sign_forced: whether the sign in the exponent is always shown.
* @use_markup: whether to use a markup.
* @simplify_mantissa: simplify the mantissa.
* @append_SI: append an SI unit.
@@ -6685,9 +6686,9 @@ go_format_generate_scientific_str (GString *dst, GOFormatDetails const *details)
if (details->append_SI)
g_string_append_len (dst, "SI", 2);
+ g_string_append_c (dst, details->exponent_sign_forced ? '+' : '-');
/* Maximum not terribly important. */
digits = CLAMP (details->exponent_digits, 1, 10);
- g_string_append_c (dst, '+');
go_string_append_c_n (dst, '0', digits);
if (details->append_SI && details->appended_SI_unit != NULL) {
@@ -7022,6 +7023,7 @@ go_format_details_init (GOFormatDetails *details, GOFormatFamily family)
details->thousands_sep = (family == GO_FORMAT_ACCOUNTING ||
family == GO_FORMAT_CURRENCY);
details->magic = GO_FORMAT_MAGIC_NONE;
+ details->exponent_sign_forced = FALSE;
details->exponent_step = 1;
details->exponent_digits = 2;
details->min_digits = (family == GO_FORMAT_FRACTION) ? 0 : 1;
@@ -7163,7 +7165,10 @@ go_format_get_details (GOFormat const *fmt,
epos++;
if (dst->append_SI)
epos += 2;
- if (epos[0] == '+' || epos[0] == '-')
+ if (epos[0] == '+') {
+ epos++;
+ dst->exponent_sign_forced = TRUE;
+ } else if (epos[0] == '-')
epos++;
while (epos[0] == '0' || epos[0] == '#' || epos[0] == '?') {
epos++;
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index 4f23910..435c962 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -1,3 +1,4 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* go-format.h :
*
@@ -102,6 +103,7 @@ typedef struct {
/* SCIENTIFIC: */
int exponent_step;
int exponent_digits;
+ gboolean exponent_sign_forced;
gboolean use_markup;
gboolean simplify_mantissa;
gboolean append_SI;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]