summaryrefslogtreecommitdiffstats
path: root/source/theme.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-09-06 23:11:03 +0200
committerDave Davenport <qball@gmpclient.org>2017-09-06 23:11:03 +0200
commit7c1ecb470773843d72a49adb462becb05af299df (patch)
tree30ad8c78c01578bfa53864f658c5aea5876a2685 /source/theme.c
parentae452271ac49e9fc25b2ada02531860d526cebdc (diff)
Add support for multiple selectors. #dummy0, dummy1 {}
Diffstat (limited to 'source/theme.c')
-rw-r--r--source/theme.c34
1 files changed, 27 insertions, 7 deletions
diff --git a/source/theme.c b/source/theme.c
index 05156600..a335db10 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -74,6 +74,28 @@ Property *rofi_theme_property_create ( PropertyType type )
retv->type = type;
return retv;
}
+Property* rofi_theme_property_copy ( Property *p)
+{
+ Property *retv = rofi_theme_property_create ( p->type );
+ retv->name = g_strdup ( p->name );
+
+ switch ( p->type ) {
+ case P_STRING:
+ retv->value.s = g_strdup ( p->value.s );
+ break;
+ case P_LIST:
+ retv->value.list = g_list_copy_deep ( p->value.list, (GCopyFunc)g_strdup, NULL );
+ break;
+ case P_LINK:
+ retv->value.link.name = g_strdup ( p->value.link.name );
+ retv->value.link.ref = NULL;
+ break;
+ default:
+ retv->value = p->value;
+ }
+ return retv;
+}
+
void rofi_theme_property_free ( Property *p )
{
if ( p == NULL ) {
@@ -332,11 +354,11 @@ void yyerror ( YYLTYPE *yylloc, const char *what, const char* s )
rofi_add_error_message ( str );
}
-static gboolean rofi_theme_steal_property_int ( gpointer key, gpointer value, gpointer user_data )
+static void rofi_theme_copy_property_int ( gpointer key, gpointer value, gpointer user_data )
{
GHashTable *table = (GHashTable *) user_data;
- g_hash_table_replace ( table, key, value );
- return TRUE;
+ Property *p = rofi_theme_property_copy( (Property*) value);
+ g_hash_table_replace ( table, p->name, p );
}
void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
{
@@ -344,11 +366,9 @@ void rofi_theme_widget_add_properties ( ThemeWidget *widget, GHashTable *table )
return;
}
if ( widget->properties == NULL ) {
- widget->properties = table;
- return;
+ widget->properties = g_hash_table_new_full ( g_str_hash, g_str_equal, NULL, (GDestroyNotify)rofi_theme_property_free );
}
- g_hash_table_foreach_steal ( table, rofi_theme_steal_property_int, widget->properties );
- g_hash_table_destroy ( table );
+ g_hash_table_foreach ( table, rofi_theme_copy_property_int, widget->properties );
}
/**