[goffice] Font Selector: start adding support for picking more font attributes.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] Font Selector: start adding support for picking more font attributes.
- Date: Sun, 17 Mar 2013 20:25:10 +0000 (UTC)
commit 7e4f4799cebf4daa74b3fa0d808f846fa09dbce5
Author: Morten Welinder <terra gnome org>
Date: Sun Mar 17 16:24:49 2013 -0400
Font Selector: start adding support for picking more font attributes.
goffice/gtk/go-font-sel.c | 129 +++++++++++++++++++++++++++++++++++++++-----
goffice/gtk/go-font-sel.ui | 102 ++++++++++++++++++++++++++++++++++
2 files changed, 218 insertions(+), 13 deletions(-)
---
diff --git a/goffice/gtk/go-font-sel.c b/goffice/gtk/go-font-sel.c
index cf87d40..eb508f5 100644
--- a/goffice/gtk/go-font-sel.c
+++ b/goffice/gtk/go-font-sel.c
@@ -48,6 +48,15 @@ struct _GOFontSel {
GtkWidget *size_picker;
GSList *font_sizes;
+ gboolean show_color;
+ GtkWidget *color_picker;
+
+ gboolean show_strikethrough;
+ GtkWidget *strikethrough_button;
+
+ gboolean show_script;
+ GtkWidget *script_picker;
+
gboolean show_preview_entry;
GtkWidget *preview_label;
char *preview_text;
@@ -68,6 +77,9 @@ typedef struct {
enum {
PROP_0,
PROP_SHOW_STYLE,
+ PROP_SHOW_COLOR,
+ PROP_SHOW_SCRIPT,
+ PROP_SHOW_STRIKETHROUGH,
GFS_GTK_FONT_CHOOSER_PROP_FIRST = 0x4000,
GFS_GTK_FONT_CHOOSER_PROP_FONT,
@@ -573,6 +585,18 @@ gfs_init (GOFontSel *gfs)
gfs->font_sizes = go_fonts_list_sizes ();
}
+static void
+remove_row_containing (GtkWidget *w)
+{
+ int row;
+ GtkGrid *grid = GTK_GRID (gtk_widget_get_parent (w));
+ gtk_container_child_get (GTK_CONTAINER (grid), w,
+ "top-attach", &row,
+ NULL);
+ go_gtk_grid_remove_row (grid, row);
+}
+
+
static GObject*
gfs_constructor (GType type,
guint n_construct_properties,
@@ -624,14 +648,8 @@ gfs_constructor (GType type,
"changed",
G_CALLBACK (cb_face_changed),
gfs);
- } else {
- int row;
- GtkGrid *grid = GTK_GRID (gtk_widget_get_parent (gfs->face_picker));
- gtk_container_child_get (GTK_CONTAINER (grid), gfs->face_picker,
- "top-attach", &row,
- NULL);
- go_gtk_grid_remove_row (grid, row);
- }
+ } else
+ remove_row_containing (gfs->face_picker);
/* ---------------------------------------- */
@@ -647,6 +665,40 @@ gfs_constructor (GType type,
/* ---------------------------------------- */
+ placeholder = go_gtk_builder_get_widget
+ (gfs->gui, "color-picker-placeholder");
+ gfs->color_picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ g_object_ref_sink (gfs->color_picker);
+ gtk_widget_show_all (gfs->color_picker);
+ go_gtk_widget_replace (placeholder, gfs->color_picker);
+ if (gfs->show_color) {
+ } else
+ remove_row_containing (gfs->color_picker);
+
+ /* ---------------------------------------- */
+
+ placeholder = go_gtk_builder_get_widget
+ (gfs->gui, "script-picker-placeholder");
+ gfs->script_picker = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ g_object_ref_sink (gfs->script_picker);
+ gtk_widget_show_all (gfs->script_picker);
+ go_gtk_widget_replace (placeholder, gfs->script_picker);
+ if (gfs->show_script) {
+ } else
+ remove_row_containing (gfs->script_picker);
+
+ /* ---------------------------------------- */
+
+ gfs->strikethrough_button = go_gtk_builder_get_widget
+ (gfs->gui, "strikethrough-button");
+ g_object_ref_sink (gfs->strikethrough_button);
+ gtk_widget_show_all (gfs->strikethrough_button);
+ if (gfs->show_strikethrough) {
+ } else
+ remove_row_containing (gfs->strikethrough_button);
+
+ /* ---------------------------------------- */
+
gtk_widget_show_all (fontsel);
gfs_screen_changed (GTK_WIDGET (gfs), NULL);
@@ -670,11 +722,11 @@ gfs_dispose (GObject *obj)
{
GOFontSel *gfs = GO_FONT_SEL (obj);
- if (gfs->face_picker) {
- /* We actually own a ref. */
- g_object_unref (gfs->face_picker);
- gfs->face_picker = NULL;
- }
+ /* We actually own a ref to these. */
+ g_clear_object (&gfs->face_picker);
+ g_clear_object (&gfs->color_picker);
+ g_clear_object (&gfs->script_picker);
+ g_clear_object (&gfs->strikethrough_button);
if (gfs->gui) {
g_object_unref (gfs->gui);
@@ -713,6 +765,18 @@ gfs_get_property (GObject *object,
g_value_set_boolean (value, gfs->show_style);
break;
+ case PROP_SHOW_COLOR:
+ g_value_set_boolean (value, gfs->show_color);
+ break;
+
+ case PROP_SHOW_SCRIPT:
+ g_value_set_boolean (value, gfs->show_script);
+ break;
+
+ case PROP_SHOW_STRIKETHROUGH:
+ g_value_set_boolean (value, gfs->show_strikethrough);
+ break;
+
case GFS_GTK_FONT_CHOOSER_PROP_FONT: {
PangoFontDescription *desc = go_font_sel_get_font_desc (gfs);
g_value_take_string (value, pango_font_description_to_string (desc));
@@ -751,6 +815,18 @@ gfs_set_property (GObject *object,
gfs->show_style = g_value_get_boolean (value);
break;
+ case PROP_SHOW_COLOR:
+ gfs->show_color = g_value_get_boolean (value);
+ break;
+
+ case PROP_SHOW_SCRIPT:
+ gfs->show_script = g_value_get_boolean (value);
+ break;
+
+ case PROP_SHOW_STRIKETHROUGH:
+ gfs->show_strikethrough = g_value_get_boolean (value);
+ break;
+
case GFS_GTK_FONT_CHOOSER_PROP_FONT: {
PangoFontDescription *desc = pango_font_description_from_string
(g_value_get_string (value));
@@ -802,6 +878,33 @@ gfs_class_init (GObjectClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property
+ (klass, PROP_SHOW_COLOR,
+ g_param_spec_boolean ("show-color",
+ _("Show Color"),
+ _("Whether color is part of the font being selected"),
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (klass, PROP_SHOW_SCRIPT,
+ g_param_spec_boolean ("show-script",
+ _("Show Script"),
+ _("Whether subscript/superscript is part of the font being selected"),
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property
+ (klass, PROP_SHOW_STRIKETHROUGH,
+ g_param_spec_boolean ("show-strikethrough",
+ _("Show Strikethrough"),
+ _("Whether strikethrough is part of the font being selected"),
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_override_property (klass,
GFS_GTK_FONT_CHOOSER_PROP_FONT,
"font");
diff --git a/goffice/gtk/go-font-sel.ui b/goffice/gtk/go-font-sel.ui
index 45dbcb8..aeec894 100644
--- a/goffice/gtk/go-font-sel.ui
+++ b/goffice/gtk/go-font-sel.ui
@@ -17,6 +17,7 @@
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Select the font family</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Font:</property>
<property name="justify">center</property>
@@ -47,6 +48,7 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Select the size</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Size:</property>
<property name="justify">center</property>
@@ -62,6 +64,7 @@
<object class="GtkLabel" id="face-label">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Select the font face</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Style:</property>
<property name="justify">center</property>
@@ -108,6 +111,105 @@
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Select the size</property>
+ <property name="tooltip_text" translatable="yes">Select the size</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Strikethrough:</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="strikethrough-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Select the size</property>
+ <property name="tooltip_text" translatable="yes">Select the font color</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Color:</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="color-picker-placeholder">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Select the size</property>
+ <property name="tooltip_text" translatable="yes">Select whether the font should be modified for
use as subscript or superscript</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Script:</property>
+ <property name="justify">center</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="script-picker-placeholder">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]