[goffice] Format: namespace cleanups.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Format: namespace cleanups.
- Date: Mon, 22 Oct 2012 00:09:28 +0000 (UTC)
commit d192e920c5e0472b753cd9a25c16d6b271df0b98
Author: Morten Welinder <terra gnome org>
Date: Sun Oct 21 20:09:13 2012 -0400
Format: namespace cleanups.
NEWS | 3 +
goffice/gtk/go-format-sel.c | 142 ++++++++++++++++++-------------------------
goffice/utils/go-format.c | 39 ++++++++++++-
goffice/utils/go-format.h | 7 +-
4 files changed, 104 insertions(+), 87 deletions(-)
---
diff --git a/NEWS b/NEWS
index dd0130f..333a69c 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,9 @@ Jean:
* Fixed position of rotated label frame. [#686478]
* Fixed image clipping. [#686490]
+Morten:
+ * Namespace cleanup. [#686501]
+
--------------------------------------------------------------------------
goffice 0.9.6:
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index 8cd51b2..af89715 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -780,10 +780,8 @@ fmt_dialog_enable_widgets (GOFormatSel *gfs, int page)
F_FRACTION_MIN_DENOM_DIGITS_LABEL,
F_FRACTION_MAX_DENOM_DIGITS,
F_FRACTION_MIN_DENOM_DIGITS,
-#ifdef ALLOW_PI_SLASH
F_FRACTION_PI_SCALE,
F_BASE_SEPARATOR,
-#endif
F_MAX_WIDGET
},
/* Scientific */
@@ -797,12 +795,10 @@ fmt_dialog_enable_widgets (GOFormatSel *gfs, int page)
F_SUPERSCRIPT_HIDE_1_BUTTON,
F_EXP_DIGITS,
F_EXP_DIGITS_LABEL,
-#ifdef ALLOW_SI_APPEND
F_SI_BUTTON,
F_SI_CUSTOM_UNIT_BUTTON,
F_SI_SI_UNIT_BUTTON,
F_SI_UNIT_COMBO,
-#endif
F_MAX_WIDGET
},
/* Text */
@@ -944,24 +940,19 @@ stays:
break;
case F_SUPERSCRIPT_BUTTON:
-#ifdef ALLOW_EE_MARKUP
if (gfs->show_format_with_markup) {
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
gfs->format.details.use_markup);
} else
-#endif
show_widget = FALSE;
break;
case F_SUPERSCRIPT_HIDE_1_BUTTON:
-#ifdef ALLOW_EE_MARKUP
if (gfs->show_format_with_markup) {
-
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w),
gfs->format.details.simplify_mantissa);
gtk_widget_set_sensitive (w, gfs->format.details.use_markup);
} else
-#endif
show_widget = FALSE;
break;
@@ -980,88 +971,77 @@ stays:
break;
case F_SI_BUTTON:
-#ifdef ALLOW_SI_APPEND
+ show_widget = go_format_allow_si ();
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON (w),
- gfs->format.details.append_SI);
-#else
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (w), FALSE);
- show_widget = FALSE;
-#endif
+ show_widget && gfs->format.details.append_SI);
break;
case F_SI_CUSTOM_UNIT_BUTTON:
-#ifdef ALLOW_SI_APPEND
- gtk_widget_set_sensitive (w, gfs->format.details.append_SI);
+ show_widget = go_format_allow_si ();
+ gtk_widget_set_sensitive
+ (w,
+ show_widget && gfs->format.details.append_SI);
/* This is set through F_SI_UNIT_COMBO */
-#else
- show_widget = FALSE;
-#endif
break;
case F_SI_SI_UNIT_BUTTON:
-#ifdef ALLOW_SI_APPEND
- gtk_widget_set_sensitive (w, gfs->format.details.append_SI);
+ show_widget = go_format_allow_si ();
+ gtk_widget_set_sensitive
+ (w,
+ show_widget && gfs->format.details.append_SI);
/* This is set through F_SI_UNIT_COMBO */
-#else
- show_widget = FALSE;
-#endif
break;
- case F_SI_UNIT_COMBO: {
-#ifdef ALLOW_SI_APPEND
- gint row = -1;
- guint ii;
-
- gtk_widget_set_sensitive (w, gfs->format.details.append_SI);
- if (gfs->format.details.appended_SI_unit != NULL) {
- char const *unit = gfs->format.details.appended_SI_unit;
- if (unit[0] == 'g' && unit[1] == 0)
- unit = "kg";
- for (ii = 0; ii < G_N_ELEMENTS (si_units); ii++)
- if (0 == strcmp (si_units[ii].unit, unit)) {
- row = (gint)ii;
- break;
- }
- }
-
- if (row == -1) {
- if (gfs->format.details.appended_SI_unit == NULL) {
- gtk_button_set_label
- (GTK_BUTTON (gfs->format.widget[F_SI_CUSTOM_UNIT_BUTTON]),
- _("Append no further unit."));
- g_free (gfs->format.default_si_unit);
- gfs->format.default_si_unit = NULL;
- } else {
- gchar *label;
- gfs->format.default_si_unit
- = g_strdup (gfs->format.details.appended_SI_unit);
- label = g_strdup_printf (_("Append \'%s\'."),
- gfs->format.default_si_unit);
- gtk_button_set_label
- (GTK_BUTTON (gfs->format.widget[F_SI_CUSTOM_UNIT_BUTTON]),
- label);
- g_free (label);
+ case F_SI_UNIT_COMBO:
+ show_widget = go_format_allow_si ();
+ if (show_widget) {
+ gint row = -1;
+ guint ii;
+
+ gtk_widget_set_sensitive (w, gfs->format.details.append_SI);
+ if (gfs->format.details.appended_SI_unit != NULL) {
+ char const *unit = gfs->format.details.appended_SI_unit;
+ if (unit[0] == 'g' && unit[1] == 0)
+ unit = "kg";
+ for (ii = 0; ii < G_N_ELEMENTS (si_units); ii++)
+ if (0 == strcmp (si_units[ii].unit, unit)) {
+ row = (gint)ii;
+ break;
+ }
}
- } else
- gtk_combo_box_set_active_id (GTK_COMBO_BOX (w), si_units[row].unit);
-
- if (row >= 0)
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (gfs->format.widget[F_SI_SI_UNIT_BUTTON]),
- TRUE);
- else
- gtk_toggle_button_set_active
- (GTK_TOGGLE_BUTTON (gfs->format.widget[F_SI_CUSTOM_UNIT_BUTTON]),
- TRUE);
-
-#else
- show_widget = FALSE;
-#endif
+ if (row == -1) {
+ if (gfs->format.details.appended_SI_unit == NULL) {
+ gtk_button_set_label
+ (GTK_BUTTON (gfs->format.widget[F_SI_CUSTOM_UNIT_BUTTON]),
+ _("Append no further unit."));
+ g_free (gfs->format.default_si_unit);
+ gfs->format.default_si_unit = NULL;
+ } else {
+ gchar *label;
+ gfs->format.default_si_unit
+ = g_strdup (gfs->format.details.appended_SI_unit);
+ label = g_strdup_printf (_("Append \'%s\'."),
+ gfs->format.default_si_unit);
+ gtk_button_set_label
+ (GTK_BUTTON (gfs->format.widget[F_SI_CUSTOM_UNIT_BUTTON]),
+ label);
+ g_free (label);
+ }
+ } else
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (w), si_units[row].unit);
+
+ if (row >= 0)
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (gfs->format.widget[F_SI_SI_UNIT_BUTTON]),
+ TRUE);
+ else
+ gtk_toggle_button_set_active
+ (GTK_TOGGLE_BUTTON (gfs->format.widget[F_SI_CUSTOM_UNIT_BUTTON]),
+ TRUE);
+ }
break;
- }
case F_ENGINEERING_BUTTON:
gtk_toggle_button_set_active
@@ -1132,13 +1112,10 @@ stays:
break;
case F_FRACTION_PI_SCALE:
+ show_widget = go_format_allow_pi_slash ();
gtk_toggle_button_set_active
-#ifdef ALLOW_PI_SLASH
(GTK_TOGGLE_BUTTON (w),
- gfs->format.details.pi_scale);
-#else
- (GTK_TOGGLE_BUTTON (w), FALSE);
-#endif
+ show_widget && gfs->format.details.pi_scale);
break;
default:
@@ -1790,7 +1767,8 @@ go_format_sel_new_full (gboolean use_markup)
gfs = g_object_new (GO_TYPE_FORMAT_SEL, NULL);
if (gfs != NULL)
- gfs->show_format_with_markup = use_markup;
+ gfs->show_format_with_markup =
+ go_format_allow_ee_markup () && use_markup;
return (GtkWidget *) gfs;
}
diff --git a/goffice/utils/go-format.c b/goffice/utils/go-format.c
index a11c53f..c52d9bc 100644
--- a/goffice/utils/go-format.c
+++ b/goffice/utils/go-format.c
@@ -133,7 +133,9 @@
/* Define ALLOW_NO_SIGN_AFTER_E to permit formats such as '00E00' and '00E +00' */
#undef ALLOW_NO_SIGN_AFTER_E
-/* Note that the header file contains ALLOW_EE_MARKUP ALLOW_SI_APPEND ALLOW_PI_SLASH */
+#define ALLOW_EE_MARKUP
+#define ALLOW_SI_APPEND
+#define ALLOW_PI_SLASH
/* ------------------------------------------------------------------------- */
@@ -488,6 +490,37 @@ typedef struct {
#define UTF8_FULLWIDTH_MINUS "\357\274\215"
#define UTF8_FULLWIDTH_PLUS "\357\274\213"
+gboolean
+go_format_allow_ee_markup (void)
+{
+#ifdef ALLOW_EE_MARKUP
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+gboolean
+go_format_allow_si (void)
+{
+#ifdef ALLOW_SI_APPEND
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+gboolean
+go_format_allow_pi_slash (void)
+{
+#ifdef ALLOW_PI_SLASH
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+
GOFormatFamily
go_format_get_family (GOFormat const *fmt)
{
@@ -2188,6 +2221,7 @@ go_format_parse_number_fraction (GOFormatParseState *pstate)
return NULL;
scale += pstate->scale;
+#ifdef ALLOW_PI_SLASH
if (pi_scale) {
/* ADD_OPuc (OP_CHAR, UNICODE_THINSPACE); */
ADD_OPuc (OP_CHAR, UNICODE_PI); /* "pi" */
@@ -2196,6 +2230,7 @@ go_format_parse_number_fraction (GOFormatParseState *pstate)
ADD_OP (OP_NUM_FRACTION_SIGN);
ADD_OPuc (OP_CHAR, UNICODE_THINSPACE);
}
+#endif
}
@@ -4438,6 +4473,7 @@ SUFFIX(go_format_execute) (PangoLayout *layout, GString *dst,
}
break;
+#ifdef ALLOW_PI_SLASH
case OP_NUM_FRACTION_PI_SUM_START:
fraction.pi_sum_start = dst->len;
break;
@@ -4452,6 +4488,7 @@ SUFFIX(go_format_execute) (PangoLayout *layout, GString *dst,
}
}
break;
+#endif
case OP_NUM_FRACTION_BLANK_WHOLE:
if (!fraction.blanked && fraction.w == 0) {
diff --git a/goffice/utils/go-format.h b/goffice/utils/go-format.h
index 2fcb7b4..4f23910 100644
--- a/goffice/utils/go-format.h
+++ b/goffice/utils/go-format.h
@@ -125,10 +125,9 @@ typedef struct {
GType go_format_details_get_type (void);
/*************************************************************************/
-/* We need these in the format selector */
-#define ALLOW_EE_MARKUP
-#define ALLOW_SI_APPEND
-#define ALLOW_PI_SLASH
+gboolean go_format_allow_ee_markup (void);
+gboolean go_format_allow_si (void);
+gboolean go_format_allow_pi_slash (void);
/*************************************************************************/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]