summaryrefslogtreecommitdiffstats
path: root/lexer/theme-parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'lexer/theme-parser.y')
-rw-r--r--lexer/theme-parser.y102
1 files changed, 101 insertions, 1 deletions
diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y
index 23b0a5dc..c85a5bbe 100644
--- a/lexer/theme-parser.y
+++ b/lexer/theme-parser.y
@@ -172,6 +172,8 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token T_POS_NORTH "North"
%token T_POS_SOUTH "South"
+%token T_MEDIA "@media"
+
%token T_NONE "None"
%token T_BOLD "Bold"
%token T_ITALIC "Italic"
@@ -223,8 +225,17 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b)
%token T_INHERIT "Inherit"
+%token T_MEDIA_WIDTH "Width"
+%token T_MEDIA_HEIGHT "Height"
+
+%token T_MEDIA_MIN "Min"
+%token T_MEDIA_MONITOR_ID "Monitor-ID"
+%token T_MEDIA_MAX "Max"
+%token T_MEDIA_SEP "-"
+
%type <sval> t_entry
%type <theme> t_entry_list
+%type <theme> t_media_entry_list
%type <list> t_entry_name_path
%type <list> t_entry_name_path_selectors
%type <property> t_property
@@ -280,6 +291,56 @@ t_entry_list:
}
;
+t_media_entry_list:
+t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optional T_BCLOSE {
+ ThemeWidget *widget = $$ = g_slice_new0 ( ThemeWidget );
+ for ( GList *liter = g_list_first ( $2); liter; liter = g_list_next ( liter ) ) {
+ for ( GList *iter = g_list_first ( (GList*)liter->data ); widget && iter ; iter = g_list_next ( iter ) ) {
+ widget = rofi_theme_find_or_create_name ( widget, iter->data );
+ }
+ g_list_free_full ( (GList*)liter->data, g_free );
+ widget->set = TRUE;
+ rofi_theme_widget_add_properties ( widget, $4);
+ }
+ if ( $4 ) {
+ g_hash_table_destroy ( $4 );
+ }
+ g_list_free ( $2 );
+}
+| T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE {
+ ThemeWidget *widget = $$ = g_slice_new0( ThemeWidget ) ;
+ widget = rofi_theme_find_or_create_name ( widget, "*" );
+ widget->set = TRUE;
+ rofi_theme_widget_add_properties ( widget, $3);
+ if ( $3 ) {
+ g_hash_table_destroy ( $3 );
+ }
+}
+| t_media_entry_list T_PDEFAULTS T_BOPEN t_property_list_optional T_BCLOSE {
+ ThemeWidget *widget = $$ = $1 ;
+ widget = rofi_theme_find_or_create_name ( widget, "*" );
+ widget->set = TRUE;
+ rofi_theme_widget_add_properties ( widget, $4);
+ if ( $4 ) {
+ g_hash_table_destroy ( $4 );
+ }
+}
+| t_media_entry_list t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optional T_BCLOSE {
+ ThemeWidget *widget = $$ = $1 ;
+ for ( GList *liter = g_list_first ( $3); liter; liter = g_list_next ( liter ) ) {
+ for ( GList *iter = g_list_first ( (GList*)liter->data ); widget && iter ; iter = g_list_next ( iter ) ) {
+ widget = rofi_theme_find_or_create_name ( widget, iter->data );
+ }
+ g_list_free_full ( (GList*)liter->data, g_free );
+ widget->set = TRUE;
+ rofi_theme_widget_add_properties ( widget, $5);
+ }
+ if ( $5 ) {
+ g_hash_table_destroy ( $5 );
+ }
+ g_list_free ( $3 );
+};
+
/**
* Small dummy object to make the prefix optional.
*/
@@ -293,7 +354,7 @@ t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optio
{
for ( GList *liter = g_list_first ( $2); liter; liter = g_list_next ( liter ) ) {
ThemeWidget *widget = rofi_theme;
- for ( GList *iter = g_list_first ( (GList*)liter->data ); iter ; iter = g_list_next ( iter ) ) {
+ for ( GList *iter = g_list_first ( (GList*)liter->data ); widget && iter ; iter = g_list_next ( iter ) ) {
widget = rofi_theme_find_or_create_name ( widget, iter->data );
}
g_list_free_full ( (GList*)liter->data, g_free );
@@ -312,6 +373,45 @@ t_name_prefix_optional t_entry_name_path_selectors T_BOPEN t_property_list_optio
g_hash_table_destroy ( $3 );
}
}
+| T_MEDIA T_PARENT_LEFT T_STRING T_PSEP T_INT T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE {
+ gchar *name = g_strdup_printf("@media ( %s: %d )",$3, $5);
+ ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, name );
+ widget->set = TRUE;
+ widget->media = g_malloc0(sizeof(ThemeMedia));
+ widget->media->type = rofi_theme_parse_media_type ( $3 );
+ widget->media->value = (double)$5;
+ for ( unsigned int i = 0; i < $8->num_widgets;i++) {
+ ThemeWidget *d = $8->widgets[i];
+ rofi_theme_parse_merge_widgets(widget, d);
+ }
+ g_free ( name );
+}
+| T_MEDIA T_PARENT_LEFT T_STRING T_PSEP T_DOUBLE T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE {
+ gchar *name = g_strdup_printf("@media ( %s: %f )",$3, $5);
+ ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, name );
+ widget->set = TRUE;
+ widget->media = g_malloc0(sizeof(ThemeMedia));
+ widget->media->type = rofi_theme_parse_media_type ( $3 );
+ widget->media->value = $5;
+ for ( unsigned int i = 0; i < $8->num_widgets;i++) {
+ ThemeWidget *d = $8->widgets[i];
+ rofi_theme_parse_merge_widgets(widget, d);
+ }
+ g_free ( name );
+}
+| T_MEDIA T_PARENT_LEFT T_STRING T_PSEP T_INT T_UNIT_PX T_PARENT_RIGHT T_BOPEN t_media_entry_list T_BCLOSE {
+ gchar *name = g_strdup_printf("@media ( %s: %d px )",$3, $5);
+ ThemeWidget *widget = rofi_theme_find_or_create_name ( rofi_theme, name );
+ widget->set = TRUE;
+ widget->media = g_malloc0(sizeof(ThemeMedia));
+ widget->media->type = rofi_theme_parse_media_type ( $3 );
+ widget->media->value = (double)$5;
+ for ( unsigned int i = 0; i < $9->num_widgets;i++) {
+ ThemeWidget *d = $9->widgets[i];
+ rofi_theme_parse_merge_widgets(widget, d);
+ }
+ g_free ( name );
+}
;
t_config_property_list_optional