示例#1
0
static void
st_entry_style_changed (StWidget *self)
{
  StEntryPrivate *priv = ST_ENTRY_PRIV (self);
  StThemeNode *theme_node;
  ClutterColor color;
  const PangoFontDescription *font;
  gchar *font_string;
  gdouble size;

  theme_node = st_widget_get_theme_node (self);
 
  st_theme_node_get_foreground_color (theme_node, &color);
  clutter_text_set_color (CLUTTER_TEXT (priv->entry), &color);

  if (st_theme_node_lookup_length (theme_node, "caret-size", TRUE, &size))
    clutter_text_set_cursor_size (CLUTTER_TEXT (priv->entry), (int)(.5 + size));

  if (st_theme_node_lookup_color (theme_node, "caret-color", TRUE, &color))
    clutter_text_set_cursor_color (CLUTTER_TEXT (priv->entry), &color);

  if (st_theme_node_lookup_color (theme_node, "selection-background-color", TRUE, &color))
    clutter_text_set_selection_color (CLUTTER_TEXT (priv->entry), &color);

  if (st_theme_node_lookup_color (theme_node, "selected-color", TRUE, &color))
    clutter_text_set_selected_text_color (CLUTTER_TEXT (priv->entry), &color);

  font = st_theme_node_get_font (theme_node);
  font_string = pango_font_description_to_string (font);
  clutter_text_set_font_name (CLUTTER_TEXT (priv->entry), font_string);
  g_free (font_string);

  ST_WIDGET_CLASS (st_entry_parent_class)->style_changed (self);
}
示例#2
0
/**
 * _st_set_text_from_style:
 * @text: Target #ClutterText
 * @theme_node: Source #StThemeNode
 *
 * Set various GObject properties of the @text object using
 * CSS information from @theme_node.
 */
void
_st_set_text_from_style (ClutterText *text,
                         StThemeNode *theme_node)
{

    ClutterColor color;
    StTextDecoration decoration;
    PangoAttrList *attribs = NULL;
    const PangoFontDescription *font;
    StTextAlign align;

    st_theme_node_get_foreground_color (theme_node, &color);
    clutter_text_set_color (text, &color);

    font = st_theme_node_get_font (theme_node);
    clutter_text_set_font_description (text, (PangoFontDescription *) font);

    decoration = st_theme_node_get_text_decoration (theme_node);
    if (decoration)
    {
        attribs = pango_attr_list_new ();

        if (decoration & ST_TEXT_DECORATION_UNDERLINE)
        {
            PangoAttribute *underline = pango_attr_underline_new (PANGO_UNDERLINE_SINGLE);
            pango_attr_list_insert (attribs, underline);
        }
        if (decoration & ST_TEXT_DECORATION_LINE_THROUGH)
        {
            PangoAttribute *strikethrough = pango_attr_strikethrough_new (TRUE);
            pango_attr_list_insert (attribs, strikethrough);
        }
        /* Pango doesn't have an equivalent attribute for _OVERLINE, and we deliberately
         * skip BLINK (for now...)
         */
    }

    clutter_text_set_attributes (text, attribs);

    if (attribs)
        pango_attr_list_unref (attribs);

    align = st_theme_node_get_text_align (theme_node);
    if (align == ST_TEXT_ALIGN_JUSTIFY)
    {
        clutter_text_set_justify (text, TRUE);
        clutter_text_set_line_alignment (text, PANGO_ALIGN_LEFT);
    }
    else
    {
        clutter_text_set_justify (text, FALSE);
        clutter_text_set_line_alignment (text, (PangoAlignment) align);
    }
}