[goffice] Move stuff around.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Move stuff around.
- Date: Thu, 14 Mar 2013 13:45:48 +0000 (UTC)
commit 2c0b49e307c71448850ec992d120e0605260e4f1
Author: Morten Welinder <terra gnome org>
Date: Thu Mar 14 09:45:19 2013 -0400
Move stuff around.
ChangeLog | 8 ++++++
goffice/gtk/go-font-sel-dialog.c | 2 +-
goffice/gtk/go-font-sel.c | 3 +-
goffice/gtk/goffice-gtk.c | 46 +++++++++++++++++--------------------
goffice/gtk/goffice-gtk.h | 6 +---
goffice/utils/go-pango-extras.c | 26 +++++++++++++++++++++
goffice/utils/go-pango-extras.h | 3 ++
7 files changed, 62 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3660000..c8189c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2013-03-14 Morten Welinder <terra gnome org>
+ * goffice/gtk/go-font-sel.c (gfs_class_init): Default show-style
+ to FALSE.
+
+ * goffice/gtk/goffice-gtk.c (go_gtk_widget_replace): New function.
+
+ * goffice/utils/go-pango-extras.c (go_pango_measure_string): Move
+ from goffice/gtk/goffice-gtk.c
+
* goffice/gtk/go-font-sel.c (gfs_class_init): Add constructor
since we depend on construction parameters.
diff --git a/goffice/gtk/go-font-sel-dialog.c b/goffice/gtk/go-font-sel-dialog.c
index 0cc8499..f218b09 100644
--- a/goffice/gtk/go-font-sel-dialog.c
+++ b/goffice/gtk/go-font-sel-dialog.c
@@ -106,7 +106,7 @@ static void
gfsd_init (GOFontSelDialog *gfsd)
{
GtkDialog *dialog = GTK_DIALOG (gfsd);
- GtkWidget *gfs = go_font_sel_new ();
+ GtkWidget *gfs = g_object_new (GO_TYPE_FONT_SEL, NULL);
gfsd->gfs = GO_FONT_SEL (gfs);
gtk_widget_show (gfs);
gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)),
diff --git a/goffice/gtk/go-font-sel.c b/goffice/gtk/go-font-sel.c
index cb58b4a..5beddad 100644
--- a/goffice/gtk/go-font-sel.c
+++ b/goffice/gtk/go-font-sel.c
@@ -376,7 +376,6 @@ canvas_size_changed (G_GNUC_UNUSED GtkWidget *widget,
static void
gfs_init (GOFontSel *gfs)
{
- gfs->show_style = TRUE;
}
static GObject*
@@ -507,7 +506,7 @@ gfs_class_init (GObjectClass *klass)
g_param_spec_boolean ("show-style",
_("Show Style"),
_("Whether style is part of the font being selected"),
- TRUE,
+ FALSE,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
diff --git a/goffice/gtk/goffice-gtk.c b/goffice/gtk/goffice-gtk.c
index e4eccd2..65a53f5 100644
--- a/goffice/gtk/goffice-gtk.c
+++ b/goffice/gtk/goffice-gtk.c
@@ -498,6 +498,27 @@ go_gtk_editable_enters (GtkWindow *window, GtkWidget *w)
G_CALLBACK (cb_activate_default), window);
}
+void
+go_gtk_widget_replace (GtkWidget *victim, GtkWidget *replacement)
+{
+ GtkWidget *parent = gtk_widget_get_parent (victim);
+
+ if (GTK_IS_GRID (parent)) {
+ int col, row, width, height;
+ gtk_container_child_get (GTK_CONTAINER (parent),
+ victim,
+ "left-attach", &col,
+ "top-attach", &row,
+ "width", &width,
+ "height", &height,
+ NULL);
+ gtk_grid_attach (GTK_GRID (parent), replacement,
+ col, row, width, height);
+ } else {
+ g_error ("Unsupported container");
+ }
+}
+
/**
* go_gtk_widget_disable_focus:
* @w: #GtkWidget
@@ -513,31 +534,6 @@ go_gtk_widget_disable_focus (GtkWidget *w)
gtk_widget_set_can_focus (w, FALSE);
}
-/**
- * go_pango_measure_string:
- * @context: #PangoContext
- * @font_desc: #PangoFontDescription
- * @str: The text to measure.
- *
- * A utility function to measure text.
- *
- * Returns: the pixel length of @str according to @context.
- **/
-int
-go_pango_measure_string (PangoContext *context, PangoFontDescription const *font_desc, char const *str)
-{
- PangoLayout *layout = pango_layout_new (context);
- int width;
-
- pango_layout_set_text (layout, str, -1);
- pango_layout_set_font_description (layout, font_desc);
- pango_layout_get_pixel_size (layout, &width, NULL);
-
- g_object_unref (layout);
-
- return width;
-}
-
static void
cb_parent_mapped (GtkWidget *parent, GtkWindow *window)
{
diff --git a/goffice/gtk/goffice-gtk.h b/goffice/gtk/goffice-gtk.h
index e25a399..35d1c0e 100644
--- a/goffice/gtk/goffice-gtk.h
+++ b/goffice/gtk/goffice-gtk.h
@@ -88,10 +88,6 @@ void go_gtk_combo_box_remove_text (GtkComboBox *combo, int position);
int go_gtk_builder_group_value (GtkBuilder *gui,
char const * const group[]);
-int go_pango_measure_string (PangoContext *context,
- PangoFontDescription const *font_desc,
- char const *str);
-
gint go_gtk_dialog_run (GtkDialog *dialog, GtkWindow *parent);
GtkWidget *go_gtk_dialog_add_button (GtkDialog *dialog, char const *text,
char const *stock_id,
@@ -111,6 +107,8 @@ GOFFICE_DEPRECATED_FOR(go_gtk_button_build_with_stock)
GtkWidget *go_gtk_button_new_with_stock (char const *text,
char const *stock_id);
#endif
+void go_gtk_widget_replace (GtkWidget *victim,
+ GtkWidget *replacement);
void go_gtk_widget_disable_focus (GtkWidget *w);
void go_gtk_window_set_transient (GtkWindow *toplevel, GtkWindow *window);
void go_gtk_help_button_init (GtkWidget *w, char const *data_dir,
diff --git a/goffice/utils/go-pango-extras.c b/goffice/utils/go-pango-extras.c
index 67cf12e..9b8e59b 100644
--- a/goffice/utils/go-pango-extras.c
+++ b/goffice/utils/go-pango-extras.c
@@ -1046,3 +1046,29 @@ go_pango_attrs_to_markup (PangoAttrList *attrs, char const *text)
}
+/**
+ * go_pango_measure_string:
+ * @context: #PangoContext
+ * @font_desc: #PangoFontDescription
+ * @str: The text to measure.
+ *
+ * A utility function to measure text.
+ *
+ * Returns: the pixel length of @str according to @context.
+ **/
+int
+go_pango_measure_string (PangoContext *context,
+ PangoFontDescription const *font_desc,
+ char const *str)
+{
+ PangoLayout *layout = pango_layout_new (context);
+ int width;
+
+ pango_layout_set_text (layout, str, -1);
+ pango_layout_set_font_description (layout, font_desc);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+
+ g_object_unref (layout);
+
+ return width;
+}
diff --git a/goffice/utils/go-pango-extras.h b/goffice/utils/go-pango-extras.h
index 1db7491..7059d55 100644
--- a/goffice/utils/go-pango-extras.h
+++ b/goffice/utils/go-pango-extras.h
@@ -50,6 +50,9 @@ PangoAttrType go_pango_attr_superscript_get_type (void);
char *go_pango_attrs_to_markup (PangoAttrList *attrs, char const *text);
+int go_pango_measure_string (PangoContext *context,
+ PangoFontDescription const *font_desc,
+ char const *str);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]