[goffice] GOFontSel: work on script selector; add color-default attribute.



commit 85a24aad8016e8aa5ae7d805fb22198caafbd0ab
Author: Morten Welinder <terra gnome org>
Date:   Wed Mar 20 23:07:22 2013 -0400

    GOFontSel: work on script selector; add color-default attribute.

 goffice/gtk/go-font-sel.c |   43 ++++++++++++++++++++++++++++++++++++++++++-
 goffice/gtk/go-font-sel.h |    1 +
 2 files changed, 43 insertions(+), 1 deletions(-)
---
diff --git a/goffice/gtk/go-font-sel.c b/goffice/gtk/go-font-sel.c
index 6d8cf30..2aa7216 100644
--- a/goffice/gtk/go-font-sel.c
+++ b/goffice/gtk/go-font-sel.c
@@ -54,6 +54,7 @@ struct _GOFontSel {
        GtkWidget       *color_picker;
        GOColorGroup    *color_group;
        char            *color_unset_text;
+       GOColor          color_default;
 
        gboolean        show_strikethrough;
        GtkWidget       *strikethrough_button;
@@ -86,6 +87,7 @@ enum {
        PROP_SHOW_STRIKETHROUGH,
        PROP_COLOR_UNSET_TEXT,
        PROP_COLOR_GROUP,
+       PROP_COLOR_DEFAULT,
 
        GFS_GTK_FONT_CHOOSER_PROP_FIRST           = 0x4000,
        GFS_GTK_FONT_CHOOSER_PROP_FONT,
@@ -776,6 +778,7 @@ gfs_init (GOFontSel *gfs)
        gfs->show_preview_entry = TRUE;
        gfs->preview_text = g_strdup (pango_language_get_sample_string (NULL));
        gfs->font_sizes = go_fonts_list_sizes ();
+       gfs->color_default = GO_COLOR_BLACK;
 }
 
 static void
@@ -861,7 +864,7 @@ gfs_constructor (GType type,
                gfs->color_group = go_color_group_fetch (NULL, gfs);
        gfs->color_picker =
                go_combo_color_new (NULL, gfs->color_unset_text,
-                                   GO_COLOR_BLACK,
+                                   gfs->color_default,
                                    gfs->color_group);
        g_object_ref_sink (gfs->color_picker);
        gtk_widget_show_all (gfs->color_picker);
@@ -1010,6 +1013,10 @@ gfs_get_property (GObject         *object,
                g_value_set_object (value, gfs->color_group);
                break;
 
+       case PROP_COLOR_DEFAULT:
+               g_value_set_uint (value, gfs->color_default);
+               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));
@@ -1070,6 +1077,10 @@ gfs_set_property (GObject         *object,
                gfs->color_group = g_value_dup_object (value);
                break;
 
+       case PROP_COLOR_DEFAULT:
+               gfs->color_default = g_value_get_uint (value);
+               break;
+
        case GFS_GTK_FONT_CHOOSER_PROP_FONT: {
                PangoFontDescription *desc = pango_font_description_from_string
                        (g_value_get_string (value));
@@ -1166,6 +1177,17 @@ gfs_class_init (GObjectClass *klass)
                                      G_PARAM_READWRITE |
                                      G_PARAM_CONSTRUCT_ONLY));
 
+       g_object_class_install_property
+               (klass, PROP_COLOR_DEFAULT,
+                g_param_spec_uint ("color-default",
+                                   _("Color Default"),
+                                   _("The color to show for an unset color"),
+                                   GO_COLOR_FROM_RGBA (0,0,0,0),
+                                   GO_COLOR_FROM_RGBA (0xff,0xff,0xff,0xff),
+                                   GO_COLOR_BLACK,
+                                   G_PARAM_READWRITE |
+                                   G_PARAM_CONSTRUCT_ONLY));
+
        g_object_class_override_property (klass,
                                          GFS_GTK_FONT_CHOOSER_PROP_FONT,
                                          "font");
@@ -1417,6 +1439,25 @@ go_font_sel_set_strikethrough (GOFontSel *fs, gboolean strikethrough)
        update_preview (fs);
 }
 
+void
+go_font_sel_set_script (GOFontSel *fs, GOFontScript script)
+{
+       GOOptionMenu *om = GO_OPTION_MENU (fs->script_picker);
+       GtkMenuShell *ms = GTK_MENU_SHELL (go_option_menu_get_menu (om));
+       GList *children = gtk_container_get_children (GTK_CONTAINER (ms));
+       GList *l;
+
+       for (l = children; l; l = l->next) {
+               GtkMenuItem *item = GTK_MENU_ITEM (l->data);
+               GOFontScript s = GPOINTER_TO_INT
+                       (g_object_get_data (G_OBJECT (item), "script"));
+               if (s == script)
+                       go_option_menu_select_item (om, item);
+       }
+
+       g_list_free (children);
+}
+
 static void
 go_font_sel_set_uline (GOFontSel *gfs, int uline)
 {
diff --git a/goffice/gtk/go-font-sel.h b/goffice/gtk/go-font-sel.h
index 85a0c33..a0db48a 100644
--- a/goffice/gtk/go-font-sel.h
+++ b/goffice/gtk/go-font-sel.h
@@ -47,6 +47,7 @@ void go_font_sel_set_style         (GOFontSel *fs,
 void go_font_sel_set_strikethrough (GOFontSel *fs, gboolean strikethrough);
 void go_font_sel_set_color         (GOFontSel *gfs, GOColor c,
                                    gboolean is_default);
+void go_font_sel_set_script        (GOFontSel *fs, GOFontScript script);
 
 void go_font_sel_set_font_desc     (GOFontSel *fs, PangoFontDescription *desc);
 PangoFontDescription *go_font_sel_get_font_desc (GOFontSel *fs);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]