Exemplo n.º 1
0
/**
 * gtk_style_properties_lookup_property: (skip)
 * @property_name: property name to look up
 * @parse_func: (out): return location for the parse function
 * @pspec: (out) (transfer none): return location for the #GParamSpec
 *
 * Returns %TRUE if a property has been registered, if @pspec or
 * @parse_func are not %NULL, the #GParamSpec and parsing function
 * will be respectively returned.
 *
 * Returns: %TRUE if the property is registered, %FALSE otherwise
 *
 * Since: 3.0
 *
 * Deprecated: 3.8: This code could only look up custom properties and
 *     those are deprecated.
 **/
gboolean
gtk_style_properties_lookup_property (const gchar             *property_name,
                                      GtkStylePropertyParser  *parse_func,
                                      GParamSpec             **pspec)
{
  GtkStyleProperty *node;
  gboolean found = FALSE;

  g_return_val_if_fail (property_name != NULL, FALSE);

  node = _gtk_style_property_lookup (property_name);

  if (GTK_IS_CSS_CUSTOM_PROPERTY (node))
    {
      GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (node);

      if (pspec)
        *pspec = custom->pspec;

      if (parse_func)
        *parse_func = custom->property_parse_func;

      found = TRUE;
    }

  return found;
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
static GtkCssValue *
gtk_css_custom_property_parse_value (GtkStyleProperty *property,
                                     GtkCssParser     *parser)
{
  GtkCssCustomProperty *custom = GTK_CSS_CUSTOM_PROPERTY (property);
  GValue value = G_VALUE_INIT;
  gboolean success;

  if (custom->property_parse_func)
    {
      GError *error = NULL;
      char *value_str;
      
      g_value_init (&value, _gtk_style_property_get_value_type (property));

      value_str = _gtk_css_parser_read_value (parser);
      if (value_str != NULL)
        {
          success = (* custom->property_parse_func) (value_str, &value, &error);
          g_free (value_str);
        }
      else
        success = FALSE;
    }
  else
    {
      g_value_init (&value, gtk_css_custom_property_get_specified_type (custom->pspec));

      success = _gtk_css_style_parse_value (&value, parser);
    }

  if (!success)
    {
      g_value_unset (&value);
      return NULL;
    }

  return _gtk_css_typed_value_new_take (&value);
}