mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-16 23:24:16 +00:00
GtkStyleSet: Add method to lookup property default settings.
This commit is contained in:
parent
7647deb417
commit
9971f386b0
@ -218,6 +218,56 @@ gtk_style_set_register_property (const gchar *property_name,
|
||||
g_array_insert_val (properties, i, new);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_style_set_lookup_property (const gchar *property_name,
|
||||
GType *type,
|
||||
GValue *default_value)
|
||||
{
|
||||
PropertyNode *node;
|
||||
GtkStyleSetClass *klass;
|
||||
GQuark quark;
|
||||
GType t;
|
||||
gint i;
|
||||
|
||||
g_return_val_if_fail (property_name != NULL, FALSE);
|
||||
|
||||
klass = g_type_class_ref (GTK_TYPE_STYLE_SET);
|
||||
quark = g_quark_try_string (property_name);
|
||||
|
||||
if (quark == 0)
|
||||
{
|
||||
g_type_class_unref (klass);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < properties->len; i++)
|
||||
{
|
||||
node = &g_array_index (properties, PropertyNode, i);
|
||||
|
||||
if (node->property_quark == quark)
|
||||
{
|
||||
if (type)
|
||||
*type = node->property_type;
|
||||
|
||||
if (default_value)
|
||||
{
|
||||
g_value_init (default_value, G_VALUE_TYPE (&node->default_value));
|
||||
g_value_copy (&node->default_value, default_value);
|
||||
}
|
||||
|
||||
g_type_class_unref (klass);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (node->property_quark > quark)
|
||||
break;
|
||||
}
|
||||
|
||||
g_type_class_unref (klass);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_style_set_register_property_color (const gchar *property_name,
|
||||
GdkColor *initial_value)
|
||||
|
@ -55,6 +55,9 @@ GType gtk_style_set_get_type (void) G_GNUC_CONST;
|
||||
void gtk_style_set_register_property (const gchar *property_name,
|
||||
GType type,
|
||||
const GValue *default_value);
|
||||
gboolean gtk_style_set_lookup_property (const gchar *property_name,
|
||||
GType *type,
|
||||
GValue *default_value);
|
||||
|
||||
void gtk_style_set_register_property_color (const gchar *property_name,
|
||||
GdkColor *default_value);
|
||||
|
Loading…
Reference in New Issue
Block a user