[goffice] goffice-gtk: don't expose internal goffice directories.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] goffice-gtk: don't expose internal goffice directories.
- Date: Mon, 17 Oct 2011 20:52:17 +0000 (UTC)
commit 7fa16b6909ad2b5e428dedd6057413b1350da725
Author: Morten Welinder <terra gnome org>
Date: Mon Oct 17 16:21:14 2011 -0400
goffice-gtk: don't expose internal goffice directories.
ChangeLog | 7 +++++++
goffice/graph/gog-3d-box.c | 2 +-
goffice/graph/gog-axis-line.c | 2 +-
goffice/graph/gog-axis.c | 2 +-
goffice/graph/gog-chart.c | 2 +-
goffice/graph/gog-equation.c | 2 +-
goffice/graph/gog-error-bar.c | 2 +-
goffice/graph/gog-graph.c | 2 +-
goffice/graph/gog-guru.c | 4 ++--
goffice/graph/gog-label.c | 2 +-
goffice/graph/gog-object.c | 2 +-
goffice/graph/gog-reg-curve.c | 2 +-
goffice/graph/gog-series-labels.c | 2 +-
goffice/graph/gog-series.c | 4 ++--
goffice/gtk/go-3d-rotation-sel.c | 2 +-
goffice/gtk/go-font-sel.c | 2 +-
goffice/gtk/go-format-sel.c | 2 +-
goffice/gtk/go-image-sel.c | 2 +-
goffice/gtk/go-rotation-sel.c | 2 +-
goffice/gtk/goffice-gtk.c | 37 ++++++++++++++++++++++++++-----------
goffice/gtk/goffice-gtk.h | 2 ++
goffice/utils/go-style.c | 6 +++---
22 files changed, 58 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 00ad4b7..a484fa6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-17 Morten Welinder <terra gnome org>
+
+ * goffice/gtk/goffice-gtk.c (go_gtk_builder_new): Move
+ default-directory code from here...
+ (go_gtk_builder_new_internal): ...to here.
+ * */*.c: change to use go_gtk_builder_new_internal as appropriate.
+
2011-10-13 Jean Brefort <jean brefort normalesup org>
* goffice/app/go-plugin.c: removed deprecated go_plugins_add().
diff --git a/goffice/graph/gog-3d-box.c b/goffice/graph/gog-3d-box.c
index da5fc1d..1fe95af 100644
--- a/goffice/graph/gog-3d-box.c
+++ b/goffice/graph/gog-3d-box.c
@@ -165,7 +165,7 @@ gog_3d_box_populate_editor (GogObject *gobj,
go_3d_rotation_sel_set_fov (GO_3D_ROTATION_SEL (g3d), box->fov);
go_editor_add_page (editor, g3d, _("Rotation"));
- gui = go_gtk_builder_new ("gog-3d-box-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-3d-box-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
diff --git a/goffice/graph/gog-axis-line.c b/goffice/graph/gog-axis-line.c
index 95dc8ff..2836831 100644
--- a/goffice/graph/gog-axis-line.c
+++ b/goffice/graph/gog-axis-line.c
@@ -507,7 +507,7 @@ gog_axis_base_populate_editor (GogObject *gobj,
return;
}
- gui = go_gtk_builder_new ("gog-axis-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-axis-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL) {
(GOG_OBJECT_CLASS(gab_parent_klass)->populate_editor) (gobj, editor, dalloc, cc);
return;
diff --git a/goffice/graph/gog-axis.c b/goffice/graph/gog-axis.c
index 21d1b6f..7af2ba5 100644
--- a/goffice/graph/gog-axis.c
+++ b/goffice/graph/gog-axis.c
@@ -2532,7 +2532,7 @@ gog_axis_populate_editor (GogObject *gobj,
GogDataset *set = GOG_DATASET (gobj);
GtkBuilder *gui;
- gui = go_gtk_builder_new ("gog-axis-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-axis-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
diff --git a/goffice/graph/gog-chart.c b/goffice/graph/gog-chart.c
index e1c0a7b..0e6bd7e 100644
--- a/goffice/graph/gog-chart.c
+++ b/goffice/graph/gog-chart.c
@@ -319,7 +319,7 @@ gog_chart_populate_editor (GogObject *gobj,
g_return_if_fail (chart != NULL);
- gui = go_gtk_builder_new ("gog-plot-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-plot-prefs.ui", GETTEXT_PACKAGE, cc);
g_return_if_fail (gui != NULL);
(GOG_OBJECT_CLASS(chart_parent_klass)->populate_editor) (gobj, editor, dalloc, cc);
diff --git a/goffice/graph/gog-equation.c b/goffice/graph/gog-equation.c
index 5abb617..b0ffc89 100644
--- a/goffice/graph/gog-equation.c
+++ b/goffice/graph/gog-equation.c
@@ -83,7 +83,7 @@ gog_equation_populate_editor (GogObject *obj,
GtkTextBuffer *buffer;
static guint equation_pref_page = 0;
- gui = go_gtk_builder_new ("gog-equation-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-equation-prefs.ui", GETTEXT_PACKAGE, cc);
g_return_if_fail (gui != NULL);
widget = go_gtk_builder_get_widget (gui, "equation_text");
diff --git a/goffice/graph/gog-error-bar.c b/goffice/graph/gog-error-bar.c
index c5c29cf..9e9b132 100644
--- a/goffice/graph/gog-error-bar.c
+++ b/goffice/graph/gog-error-bar.c
@@ -240,7 +240,7 @@ gog_error_bar_prefs (GogSeries *series,
}
set = GOG_DATASET (series);
- gui = go_gtk_builder_new ("gog-error-bar-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-error-bar-prefs.ui", GETTEXT_PACKAGE, cc);
/* Style properties */
diff --git a/goffice/graph/gog-graph.c b/goffice/graph/gog-graph.c
index 707e7fd..89e49b3 100644
--- a/goffice/graph/gog-graph.c
+++ b/goffice/graph/gog-graph.c
@@ -222,7 +222,7 @@ gog_graph_populate_editor (GogObject *gobj,
GSList *theme_names;
static guint graph_pref_page = 0;
- gui = go_gtk_builder_new ("gog-graph-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-graph-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
diff --git a/goffice/graph/gog-guru.c b/goffice/graph/gog-guru.c
index 938f73b..237669f 100644
--- a/goffice/graph/gog-guru.c
+++ b/goffice/graph/gog-guru.c
@@ -1145,7 +1145,7 @@ graph_guru_type_selector_new (GraphGuruState *s)
GtkBuilder *gui;
GOStyle *style;
- gui = go_gtk_builder_new ("gog-guru-type-selector.ui", GETTEXT_PACKAGE, s->cc);
+ gui = go_gtk_builder_new_internal ("gog-guru-type-selector.ui", GETTEXT_PACKAGE, s->cc);
typesel = g_new0 (GraphGuruTypeSelector, 1);
typesel->state = s;
@@ -1235,7 +1235,7 @@ graph_guru_type_selector_new (GraphGuruState *s)
static gboolean
graph_guru_init (GraphGuruState *s)
{
- s->gui = go_gtk_builder_new ("gog-guru.ui", GETTEXT_PACKAGE, s->cc);
+ s->gui = go_gtk_builder_new_internal ("gog-guru.ui", GETTEXT_PACKAGE, s->cc);
if (s->gui == NULL)
return TRUE;
diff --git a/goffice/graph/gog-label.c b/goffice/graph/gog-label.c
index 41089c0..45e958d 100644
--- a/goffice/graph/gog-label.c
+++ b/goffice/graph/gog-label.c
@@ -426,7 +426,7 @@ gog_reg_eqn_populate_editor (GogObject *gobj,
GtkBuilder *gui;
GogRegEqn *reg_eqn = GOG_REG_EQN (gobj);
- gui = go_gtk_builder_new ("gog-reg-eqn-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-reg-eqn-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
diff --git a/goffice/graph/gog-object.c b/goffice/graph/gog-object.c
index ef16d1d..248f916 100644
--- a/goffice/graph/gog-object.c
+++ b/goffice/graph/gog-object.c
@@ -414,7 +414,7 @@ gog_object_populate_editor (GogObject *gobj,
if (!(allowable_positions & (GOG_POSITION_MANUAL | GOG_POSITION_COMPASS)))
return;
- gui = go_gtk_builder_new ("gog-object-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-object-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
diff --git a/goffice/graph/gog-reg-curve.c b/goffice/graph/gog-reg-curve.c
index 9102d75..1b2c708 100644
--- a/goffice/graph/gog-reg-curve.c
+++ b/goffice/graph/gog-reg-curve.c
@@ -62,7 +62,7 @@ gog_reg_curve_populate_editor (GogObject *gobj,
GtkBuilder *gui;
GogDataset *set = GOG_DATASET (gobj);
- gui = go_gtk_builder_new ("gog-reg-curve-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-reg-curve-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
diff --git a/goffice/graph/gog-series-labels.c b/goffice/graph/gog-series-labels.c
index d5e904f..076090d 100644
--- a/goffice/graph/gog-series-labels.c
+++ b/goffice/graph/gog-series-labels.c
@@ -355,7 +355,7 @@ gog_series_labels_populate_editor (GogObject *gobj,
char const *custom_lbl;
gboolean supports_percent;
- gui = go_gtk_builder_new ("gog-series-labels-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-series-labels-prefs.ui", GETTEXT_PACKAGE, cc);
labels_prefs = go_gtk_builder_get_widget (gui, "series-labels-prefs");
state->labels = gobj;
diff --git a/goffice/graph/gog-series.c b/goffice/graph/gog-series.c
index 758e78c..8e5f196 100644
--- a/goffice/graph/gog-series.c
+++ b/goffice/graph/gog-series.c
@@ -558,7 +558,7 @@ gog_series_populate_editor (GogObject *gobj,
GtkBuilder *gui;
GtkWidget *widget;
- gui = go_gtk_builder_new ("gog-series-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-series-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui != NULL) {
int i;
GogAxisSet set = gog_plot_axis_set_pref (gog_series_get_plot (series));
@@ -614,7 +614,7 @@ gog_series_populate_editor (GogObject *gobj,
GtkBuilder *gui;
GtkWidget *widget;
- gui = go_gtk_builder_new ("gog-series-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("gog-series-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui != NULL) {
widget = go_gtk_builder_get_widget (gui, "fill_type_combo");
gog_series_populate_fill_type_combo (GOG_SERIES (series), GTK_COMBO_BOX (widget));
diff --git a/goffice/gtk/go-3d-rotation-sel.c b/goffice/gtk/go-3d-rotation-sel.c
index d7493ac..4730c55 100644
--- a/goffice/gtk/go-3d-rotation-sel.c
+++ b/goffice/gtk/go-3d-rotation-sel.c
@@ -329,7 +329,7 @@ g3d_init (GO3DRotationSel *g3d)
{
GtkWidget *w;
- g3d->gui = go_gtk_builder_new ("go-3d-rotation-sel.ui",
+ g3d->gui = go_gtk_builder_new_internal ("go-3d-rotation-sel.ui",
GETTEXT_PACKAGE, NULL);
if (g3d->gui == NULL)
return;
diff --git a/goffice/gtk/go-font-sel.c b/goffice/gtk/go-font-sel.c
index 6a3ba67..ac42f5e 100644
--- a/goffice/gtk/go-font-sel.c
+++ b/goffice/gtk/go-font-sel.c
@@ -339,7 +339,7 @@ gfs_init (GOFontSel *gfs)
{
GtkWidget *w;
- gfs->gui = go_gtk_builder_new ("go-font-sel.ui", GETTEXT_PACKAGE, NULL);
+ gfs->gui = go_gtk_builder_new_internal ("go-font-sel.ui", GETTEXT_PACKAGE, NULL);
if (gfs->gui == NULL)
return;
diff --git a/goffice/gtk/go-format-sel.c b/goffice/gtk/go-format-sel.c
index e254527..1fd8a46 100644
--- a/goffice/gtk/go-format-sel.c
+++ b/goffice/gtk/go-format-sel.c
@@ -1431,7 +1431,7 @@ nfs_init (GOFormatSel *gfs)
gfs->show_format_with_markup = FALSE;
gfs->locale = NULL;
- gfs->gui = go_gtk_builder_new ("go-format-sel.ui", GETTEXT_PACKAGE, NULL);
+ gfs->gui = go_gtk_builder_new_internal ("go-format-sel.ui", GETTEXT_PACKAGE, NULL);
if (gfs->gui == NULL)
return;
diff --git a/goffice/gtk/go-image-sel.c b/goffice/gtk/go-image-sel.c
index 1aed6fc..55c967a 100644
--- a/goffice/gtk/go-image-sel.c
+++ b/goffice/gtk/go-image-sel.c
@@ -212,7 +212,7 @@ go_image_sel_new (GODoc *doc, GOCmdContext *cc, GOImage **image)
state->doc = doc;
state->cc = cc;
state->result = image;
- state->gui = go_gtk_builder_new ("go-image-sel.ui", GETTEXT_PACKAGE, state->cc);
+ state->gui = go_gtk_builder_new_internal ("go-image-sel.ui", GETTEXT_PACKAGE, state->cc);
if (state->gui == NULL) {
g_free (state);
return NULL;
diff --git a/goffice/gtk/go-rotation-sel.c b/goffice/gtk/go-rotation-sel.c
index c8d1dcf..5561e1a 100644
--- a/goffice/gtk/go-rotation-sel.c
+++ b/goffice/gtk/go-rotation-sel.c
@@ -206,7 +206,7 @@ grs_init (GORotationSel *grs)
{
GtkWidget *w;
- grs->gui = go_gtk_builder_new ("go-rotation-sel.ui", GETTEXT_PACKAGE, NULL);
+ grs->gui = go_gtk_builder_new_internal ("go-rotation-sel.ui", GETTEXT_PACKAGE, NULL);
if (grs->gui == NULL)
return;
diff --git a/goffice/gtk/goffice-gtk.c b/goffice/gtk/goffice-gtk.c
index 5be302d..14c5194 100644
--- a/goffice/gtk/goffice-gtk.c
+++ b/goffice/gtk/goffice-gtk.c
@@ -118,20 +118,14 @@ go_gtk_builder_new (char const *uifile,
char const *domain, GOCmdContext *gcc)
{
GtkBuilder *gui;
- char *f;
GError *error = NULL;
g_return_val_if_fail (uifile != NULL, NULL);
- if (!g_path_is_absolute (uifile))
- f = g_build_filename (go_sys_data_dir (), "ui", uifile, NULL);
- else
- f = g_strdup (uifile);
-
gui = gtk_builder_new ();
if (domain)
gtk_builder_set_translation_domain (gui, domain);
- if (!gtk_builder_add_from_file (gui, f, &error)) {
+ if (!gtk_builder_add_from_file (gui, uifile, &error)) {
g_object_unref (gui);
gui = NULL;
}
@@ -141,16 +135,37 @@ go_gtk_builder_new (char const *uifile,
msg = g_strdup (error->message);
g_error_free (error);
} else
- msg = g_strdup_printf (_("Unable to open file '%s'"), f);
+ msg = g_strdup_printf (_("Unable to open file '%s'"), uifile);
go_cmd_context_error_system (gcc, msg);
g_free (msg);
} else if (error)
g_error_free (error);
- g_free (f);
return gui;
}
+/*
+ * Variant of go_gtk_builder_new that searchs goffice directories
+ * for files.
+ */
+GtkBuilder *
+go_gtk_builder_new_internal (char const *uifile,
+ char const *domain, GOCmdContext *gcc)
+{
+ char *f;
+ GtkBuilder *res;
+
+ if (g_path_is_absolute (uifile))
+ return go_gtk_builder_new (uifile, domain, gcc);
+
+ f = g_build_filename (go_sys_data_dir (), "ui", uifile, NULL);
+ res = go_gtk_builder_new (f, domain, gcc);
+ g_free (f);
+
+ return res;
+}
+
+
/**
* go_gtk_builder_signal_connect :
* @gui : #GtkBuilder
@@ -753,8 +768,8 @@ go_gui_get_image_save_info (GtkWindow *toplevel, GSList *supported_formats,
g_object_set (G_OBJECT (fsel), "title", _("Save as"), NULL);
- gui = go_gtk_builder_new ("go-image-save-dialog-extra.ui",
- GETTEXT_PACKAGE, NULL);
+ gui = go_gtk_builder_new_internal ("go-image-save-dialog-extra.ui",
+ GETTEXT_PACKAGE, NULL);
if (gui != NULL) {
GtkWidget *widget;
diff --git a/goffice/gtk/goffice-gtk.h b/goffice/gtk/goffice-gtk.h
index d309d8c..ff18df9 100644
--- a/goffice/gtk/goffice-gtk.h
+++ b/goffice/gtk/goffice-gtk.h
@@ -57,6 +57,8 @@ G_BEGIN_DECLS
void go_gtk_editable_enters (GtkWindow *window, GtkWidget *w);
+GtkBuilder *go_gtk_builder_new_internal (char const *uifile,
+ char const *domain, GOCmdContext *gcc);
GtkBuilder *go_gtk_builder_new (char const *uifile,
char const *domain, GOCmdContext *gcc);
gulong go_gtk_builder_signal_connect (GtkBuilder *gui,
diff --git a/goffice/utils/go-style.c b/goffice/utils/go-style.c
index c00cd54..0dc3d3f 100644
--- a/goffice/utils/go-style.c
+++ b/goffice/utils/go-style.c
@@ -742,7 +742,7 @@ marker_init (StylePrefState *state, gboolean enable, GOEditor *editor, GOCmdCont
if (!enable)
return;
- gui = go_gtk_builder_new ("go-style-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("go-style-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
@@ -856,7 +856,7 @@ font_init (StylePrefState *state, guint32 enable, GOEditor *editor, GOCmdContext
g_return_if_fail (style->font.font != NULL);
- gui = go_gtk_builder_new ("go-style-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("go-style-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL)
return;
@@ -1032,7 +1032,7 @@ go_style_populate_editor (GOStyle *style,
state->doc = NULL;
if ((enable & (GO_STYLE_OUTLINE | GO_STYLE_LINE | GO_STYLE_FILL)) != 0) {
- gui = go_gtk_builder_new ("go-style-prefs.ui", GETTEXT_PACKAGE, cc);
+ gui = go_gtk_builder_new_internal ("go-style-prefs.ui", GETTEXT_PACKAGE, cc);
if (gui == NULL) {
g_free (state);
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]