summaryrefslogtreecommitdiffstats
path: root/source/theme.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-12-16 09:28:13 +0100
committerDave Davenport <qball@gmpclient.org>2016-12-16 09:28:13 +0100
commitb8e58b0342d267fc88a4649b45bc702ed82e91ab (patch)
treeca87a7b019081f4d9776c17a04700dc0e7e040f7 /source/theme.c
parentefd1e07755c7e6b2f3e66eed73fc4c932851d529 (diff)
Make parser more flexible, allow global properties to be anywhere in file and allow multiple similar entries.
Diffstat (limited to 'source/theme.c')
-rw-r--r--source/theme.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/source/theme.c b/source/theme.c
index bce3c419..f555e0de 100644
--- a/source/theme.c
+++ b/source/theme.c
@@ -52,7 +52,7 @@ void rofi_theme_free ( Widget *widget )
g_hash_table_destroy ( widget->properties );
}
for ( unsigned int i = 0; i < widget->num_widgets; i++ ){
- rofi_theme_free ( widget->widgets[i] );
+ rofi_theme_free ( widget->widgets[i] );
}
g_free ( widget->widgets );
g_free ( widget->name );
@@ -68,10 +68,10 @@ static void rofi_theme_print_property_index ( int depth, Property *p )
switch ( p->type )
{
case P_STRING:
- printf("\"%s\"", p->value.s);
+ printf("\"%s\"", p->value.s);
break;
case P_INTEGER:
- printf("%d", p->value.i);
+ printf("%d", p->value.i);
break;
case P_DOUBLE:
printf("%.2f", p->value.f);
@@ -122,6 +122,27 @@ void yyerror(YYLTYPE *yylloc, const char* s) {
fprintf(stderr, "From line %d column %d to line %d column %d\n", yylloc->first_line, yylloc->first_column, yylloc->last_line, yylloc->last_column);
exit(EXIT_FAILURE);
}
+
+static gboolean rofi_theme_steal_property_int ( gpointer key, gpointer value, gpointer user_data)
+{
+ GHashTable *table = (GHashTable*)user_data;
+ g_hash_table_replace ( table, key, value);
+ return TRUE;
+}
+void rofi_theme_widget_add_properties ( Widget *widget, GHashTable *table )
+{
+ if ( table == NULL ) {
+ return;
+ }
+ if ( widget->properties == NULL ){
+ widget->properties = table;
+ return;
+ }
+ g_hash_table_foreach_steal ( table, rofi_theme_steal_property_int, widget->properties );
+ g_hash_table_destroy ( table );
+}
+
+
/**
* Public API
*/
@@ -159,7 +180,7 @@ static Widget *rofi_theme_find ( Widget *widget , const char *name )
widget = f;
found = TRUE;
}
- }
+ }
g_strfreev(names);
return widget;
}
@@ -172,7 +193,7 @@ static Property *rofi_theme_find_property ( Widget *widget, PropertyType type, c
if ( p->type == type ){
return p;
}
- }
+ }
widget = widget->parent;
}
return NULL;
@@ -260,7 +281,7 @@ double rofi_theme_get_double ( const char *wclass, const char *name, const char
}
return def;
}
-void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d)
+void rofi_theme_get_color ( const char *wclass, const char *name, const char *state, const char *property, cairo_t *d)
{
if ( rofi_theme == NULL ) {
return ;