Exemple #1
0
static GtkCssValue *
gtk_css_value_initial_compute (GtkCssValue             *value,
                               guint                    property_id,
                               GtkStyleProviderPrivate *provider,
                               GtkCssStyle             *style,
                               GtkCssStyle             *parent_style)
{
  GtkSettings *settings;

  switch (property_id)
    {
    case GTK_CSS_PROPERTY_DPI:
      settings = _gtk_style_provider_private_get_settings (provider);
      if (settings)
        {
          GdkScreen *screen = _gtk_settings_get_screen (settings);
          double resolution = gdk_screen_get_resolution (screen);

          if (resolution > 0.0)
            return _gtk_css_number_value_new (resolution, GTK_CSS_NUMBER);
        }
      break;

    case GTK_CSS_PROPERTY_FONT_FAMILY:
      settings = _gtk_style_provider_private_get_settings (provider);
      if (settings)
        {
          PangoFontDescription *description;
          char *font_name;
          GtkCssValue *value;

          g_object_get (settings, "gtk-font-name", &font_name, NULL);
          description = pango_font_description_from_string (font_name);
          g_free (font_name);
          if (description == NULL)
            break;

          if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_FAMILY)
            {
              value = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (description)));
              pango_font_description_free (description);
              return value;
            }
 
          pango_font_description_free (description);
        }
      break;

    default:
      break;
    }

  return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
                                 property_id,
                                 provider,
                                 style,
                                 parent_style);
}
Exemple #2
0
static void
_gtk_css_style_property_query (GtkStyleProperty   *property,
                               GValue             *value,
                               GtkStyleQueryFunc   query_func,
                               gpointer            query_data)
{
  GtkCssStyleProperty *style_property = GTK_CSS_STYLE_PROPERTY (property);
  GtkCssValue *css_value;

  css_value = (* query_func) (GTK_CSS_STYLE_PROPERTY (property)->id, query_data);
  if (css_value == NULL)
    css_value =_gtk_css_style_property_get_initial_value (style_property);

  style_property->query_value (style_property, css_value, value);
}
Exemple #3
0
static void
gtk_css_custom_property_query (GtkStyleProperty   *property,
                               GValue             *value,
                               GtkStyleQueryFunc   query_func,
                               gpointer            query_data)
{
  GtkCssStyleProperty *style = GTK_CSS_STYLE_PROPERTY (property);
  GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property);
  GtkCssValue *css_value;
  
  css_value = (* query_func) (_gtk_css_style_property_get_id (style), query_data);
  if (css_value == NULL)
    css_value = _gtk_css_style_property_get_initial_value (style);

  g_value_init (value, custom->pspec->value_type);
  g_value_copy (_gtk_css_typed_value_get (css_value), value);
}