Esempio n. 1
0
void
gtk_css_style_print (GtkCssStyle *style,
                     GString     *string)
{
  guint i;

  g_return_if_fail (GTK_IS_CSS_STYLE (style));
  g_return_if_fail (string != NULL);

  for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
    {
      GtkCssSection *section = gtk_css_style_get_section (style, i);
      g_string_append (string, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i))));
      g_string_append (string, ": ");
      _gtk_css_value_print (gtk_css_style_get_value (style, i), string);
      g_string_append (string, ";");
      if (section)
        {
          g_string_append (string, " /* ");
          _gtk_css_section_print (section, string);
          g_string_append (string, " */");
        }
      g_string_append (string, "\n");
    }
}
Esempio n. 2
0
void
gtk_css_computed_values_print (GtkCssComputedValues *values,
                               GString              *string)
{
  guint i;

  g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
  g_return_if_fail (string != NULL);

  for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
    {
      GtkCssSection *section = _gtk_css_computed_values_get_section (values, i);
      g_string_append (string, _gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (i))));
      g_string_append (string, ": ");
      _gtk_css_value_print (_gtk_css_computed_values_get_value (values, i), string);
      g_string_append (string, ";");
      if (section)
        {
          g_string_append (string, " /* ");
          _gtk_css_section_print (section, string);
          g_string_append (string, " */");
        }
      g_string_append (string, "\n");
    }
}
Esempio n. 3
0
char *
_gtk_css_section_to_string (const GtkCssSection *section)
{
  GString *string;

  gtk_internal_return_val_if_fail (section != NULL, NULL);

  string = g_string_new (NULL);
  _gtk_css_section_print (section, string);

  return g_string_free (string, FALSE);
}
Esempio n. 4
0
/*
 * gtk_css_style_print:
 * @style: a #GtkCssStyle
 * @string: the #GString to print to
 * @indent: level of indentation to use
 * @skip_initial: %TRUE to skip properties that have their initial value
 *
 * Print the @style to @string, in CSS format. Every property is printed
 * on a line by itself, indented by @indent spaces. If @skip_initial is
 * %TRUE, properties are only printed if their value in @style is different
 * from the initial value of the property.
 *
 * Returns: %TRUE is any properties have been printed
 */
gboolean
gtk_css_style_print (GtkCssStyle *style,
                     GString     *string,
                     guint        indent,
                     gboolean     skip_initial)
{
    guint i;
    gboolean retval = FALSE;

    g_return_val_if_fail (GTK_IS_CSS_STYLE (style), FALSE);
    g_return_val_if_fail (string != NULL, FALSE);

    for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
    {
        GtkCssSection *section;
        GtkCssStyleProperty *prop;
        GtkCssValue *value;
        const char *name;

        section = gtk_css_style_get_section (style, i);
        if (!section && skip_initial)
            continue;

        prop = _gtk_css_style_property_lookup_by_id (i);
        name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop));
        value = gtk_css_style_get_value (style, i);

        g_string_append_printf (string, "%*s%s: ", indent, "", name);
        _gtk_css_value_print (value, string);
        g_string_append_c (string, ';');

        if (section)
        {
            g_string_append (string, " /* ");
            _gtk_css_section_print (section, string);
            g_string_append (string, " */");
        }

        g_string_append_c (string, '\n');

        retval = TRUE;
    }

    return retval;
}