Ejemplo n.º 1
0
static void
gtk_css_shorthand_property_set_property (GObject      *object,
                                         guint         prop_id,
                                         const GValue *value,
                                         GParamSpec   *pspec)
{
  GtkCssShorthandProperty *property = GTK_CSS_SHORTHAND_PROPERTY (object);
  const char **subproperties;
  guint i;

  switch (prop_id)
    {
    case PROP_SUBPROPERTIES:
      subproperties = g_value_get_boxed (value);
      g_assert (subproperties);
      for (i = 0; subproperties[i] != NULL; i++)
        {
          GtkStyleProperty *subproperty = _gtk_style_property_lookup (subproperties[i]);
          g_assert (GTK_IS_CSS_STYLE_PROPERTY (subproperty));
          g_ptr_array_add (property->subproperties, subproperty);
        }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Ejemplo n.º 2
0
/**
 * gtk_style_properties_register_property: (skip)
 * @parse_func: parsing function to use, or %NULL
 * @pspec: the #GParamSpec for the new property
 *
 * Registers a property so it can be used in the CSS file format.
 * This function is the low-level equivalent of
 * gtk_theming_engine_register_property(), if you are implementing
 * a theming engine, you want to use that function instead.
 *
 * Since: 3.0
 *
 * Deprecated: 3.8: Code should use the default properties provided by CSS.
 **/
void
gtk_style_properties_register_property (GtkStylePropertyParser  parse_func,
                                        GParamSpec             *pspec)
{
  GtkCssCustomProperty *node;
  GtkCssValue *initial;

  g_return_if_fail (G_IS_PARAM_SPEC (pspec));

  /* This also initializes the default properties */
  if (_gtk_style_property_lookup (pspec->name))
    {
      g_warning ("a property with name '%s' already exists", pspec->name);
      return;
    }
  
  initial = gtk_css_custom_property_create_initial_value (pspec);

  node = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY,
                       "initial-value", initial,
                       "name", pspec->name,
                       "value-type", pspec->value_type,
                       NULL);
  node->pspec = pspec;
  node->property_parse_func = parse_func;

  _gtk_css_value_unref (initial);
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
static void
transition_infos_set (TransitionInfo  infos[GTK_CSS_PROPERTY_N_PROPERTIES],
                      GtkCssValue    *transitions)
{
    guint i;

    for (i = 0; i < _gtk_css_array_value_get_n_values (transitions); i++)
    {
        GtkStyleProperty *property;
        GtkCssValue *prop_value;

        prop_value = _gtk_css_array_value_get_nth (transitions, i);
        if (g_ascii_strcasecmp (_gtk_css_ident_value_get (prop_value), "all") == 0)
            property = NULL;
        else
        {
            property = _gtk_style_property_lookup (_gtk_css_ident_value_get (prop_value));
            if (property == NULL)
                continue;
        }

        transition_info_add (infos, property, i);
    }
}