From b35e4d73e01f9f013a14066bf2e6bbaba0cb25a4 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Mon, 24 Jan 2022 23:37:06 +0100 Subject: Merge list and array into one. --- doc/rofi-theme.5 | 17 ++++++++++ doc/rofi-theme.5.markdown | 7 ++-- doc/rofi.1 | 29 +++++++++++++++++ include/rofi-types.h | 2 -- include/theme.h | 17 ++-------- lexer/theme-lexer.l | 43 ++++++++---------------- lexer/theme-parser.y | 34 +++++++------------ source/rofi-types.c | 2 -- source/theme.c | 83 ++++++++++++++--------------------------------- source/view.c | 34 ++++++++++++++----- source/widgets/listview.c | 17 ++++++---- source/widgets/textbox.c | 5 +-- source/xrmoptions.c | 5 +-- test/theme-parser-test.c | 40 ++--------------------- 14 files changed, 144 insertions(+), 191 deletions(-) diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5 index 780ceadb..07be4cd7 100644 --- a/doc/rofi-theme.5 +++ b/doc/rofi-theme.5 @@ -319,6 +319,8 @@ a cursor .IP \(bu 2 a list of keywords .IP \(bu 2 +an array of values +.IP \(bu 2 an environment variable .IP \(bu 2 Inherit @@ -866,6 +868,16 @@ Format: \fB\fC[ keyword, keyword ]\fR A list starts with a '[' and ends with a ']'. The entries in the list are comma\-separated. The \fB\fCkeyword\fR in the list refers to an widget name. +.SH List of values +.RS +.IP \(bu 2 +Format: \fB\fC[ value, value, ... ]\fR + +.RE + +.PP +An list starts with a '[' and ends with a ']'. The entries in the list are comma\-separated. + .SH Environment variable .RS .IP \(bu 2 @@ -1251,6 +1263,11 @@ This option is only available on the \fB\fCelement\-text\fR widget. \fBblink\fP: Enable/Disable blinking on an input textbox (Boolean). .IP \(bu 2 \fBmarkup\fP: Force markup on, beware that only valid pango markup strings are shown. +.IP \(bu 2 +\fBtab\-stops\fP: array of distances +Set the location of tab stops by their distance from the beginning of the line. +Each distance should be greater than the previous one. +The text appears to the right of the tab stop position (other alignments are not supported yet). .RE diff --git a/doc/rofi-theme.5.markdown b/doc/rofi-theme.5.markdown index b7ad5ef1..11b0d424 100644 --- a/doc/rofi-theme.5.markdown +++ b/doc/rofi-theme.5.markdown @@ -535,12 +535,11 @@ Specify the type of mouse cursor that is set when the mouse pointer is over the A list starts with a '[' and ends with a ']'. The entries in the list are comma-separated. The `keyword` in the list refers to an widget name. -## Array of values +## List of values -* Format: `{ value, value, ... }` +* Format: `[ value, value, ... ]` -An array starts with a '{' and ends with a '}'. The entries in the array are comma-separated. -Currently, only the integer and distance types are supported as array values. +An list starts with a '[' and ends with a ']'. The entries in the list are comma-separated. ## Environment variable diff --git a/doc/rofi.1 b/doc/rofi.1 index f930b656..97612d09 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -920,6 +920,35 @@ rofi \-show combi \-combi\-modi "window,run,ssh" \-modi combi \fBNOTE\fP: The i3 window manager dislikes commas in the command when specifying an exec command. For that case, \fB\fC#\fR can be used as a separator. +.PP +\fB\fC\-combi\-display\-format\fR + +.PP +The format string for entries in the \fB\fCcombi\fR dialog: + +.RS +.IP \(bu 2 +\fBmode\fP: the mode display name +.IP \(bu 2 +\fBtext\fP: the entry text + +.RE + +.PP +Pango markup can be used to formatting the output. + +.PP +.RS + +.nf +Default: {mode} {text} + +.fi +.RE + +.PP +Note: This setting is ignored if \fB\fCcombi\-hide\-mode\-prefix\fR is eanbled. + .SS History and Sorting .PP \fB\fC\-disable\-history\fR diff --git a/include/rofi-types.h b/include/rofi-types.h index 3f3da28e..48de8f78 100644 --- a/include/rofi-types.h +++ b/include/rofi-types.h @@ -32,8 +32,6 @@ typedef enum { P_HIGHLIGHT, /** List */ P_LIST, - /** Array */ - P_ARRAY, /** Orientation */ P_ORIENTATION, /** Cursor */ diff --git a/include/theme.h b/include/theme.h index 384f920d..d8d7a6e6 100644 --- a/include/theme.h +++ b/include/theme.h @@ -392,19 +392,6 @@ ThemeWidget *rofi_config_find_widget(const char *name, const char *state, Property *rofi_theme_find_property(ThemeWidget *widget, PropertyType type, const char *property, gboolean exact); -/** - * @param widget The widget to query - * @param property The property to query. - * @param defaults The default value. - * - * Obtain list of elements (strings) of the widget. - * - * @returns a GList holding the names in the list of this property for this - * widget. - */ -GList *rofi_theme_get_list(const widget *widget, const char *property, - const char *defaults); - /** * Reset the current theme. */ @@ -471,6 +458,6 @@ void rofi_theme_print_parsed_files(int is_term); * Returns a list of allocated RofiDistance objects that should be * freed. */ -GList *rofi_theme_get_array_distance(const widget *widget, - const char *property); +GList *rofi_theme_get_list_distance(const widget *widget, const char *property); +GList *rofi_theme_get_list_strings(const widget *widget, const char *property); #endif diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l index 0b83342c..4ff67a90 100644 --- a/lexer/theme-lexer.l +++ b/lexer/theme-lexer.l @@ -161,7 +161,7 @@ static double rofi_theme_parse_convert_hex ( char high, char low) ASC [\x00-\x7f] ASCN [\x00-\t\v-\x7f] -ASCNP [\x00-\t\v-\x21\x23-\x7f] +ASCNP [\x00-\t\v-\x21\x23-\x7f] U [\x80-\xbf] U2 [\xc2-\xdf] U3 [\xe0-\xef] @@ -176,6 +176,7 @@ UANYNP {ASCNP}|{U2}{U}|{U3}{U}{U}|{U4}{U}{U}{U} WHITESPACE [[:blank:]] WSO [[:blank:]]* WORD [[:alnum:]-]+ +WORD_ELEMENT [[:alpha:]][[:alnum:]-]* WORD_ENV [[:alpha:]_][[:alnum:]_]* MEDIA_NAME [[:alpha:]-]+ COLOR_NAME [[:alpha:]]+ @@ -272,11 +273,8 @@ CALC (?i:calc) COMMA , FORWARD_SLASH \/ -LIST_OPEN \[ -LIST_CLOSE \] - -ARRAY_OPEN \{ -ARRAY_CLOSE \} +LIST_OPEN [\[] +LIST_CLOSE [\]] VAR_START "var" ENV_START "env" @@ -299,7 +297,6 @@ CONFIGURATION (?i:configuration) %x PROPERTIES_VAR %x PROPERTIES_ENV_VAR %x PROPERTIES_VAR_DEFAULT -%x PROPERTIES_LIST %x PROPERTIES_ARRAY %x NAMESTR %x SECTION @@ -496,18 +493,18 @@ if ( queue == NULL ) { /* Alias color to text-color */
"color" { yylval->sval = g_strdup("text-color"); return T_PROP_NAME;}
{WORD} { yylval->sval = g_strdup(yytext); return T_PROP_NAME;} -{WORD} { yylval->sval = g_strdup(yytext); return T_NAME_ELEMENT;} +{WORD_ELEMENT} { yylval->sval = g_strdup(yytext); return T_NAME_ELEMENT;} /* After Namestr/Classstr we want to go to state str, then to { */ {WHITESPACE}+ ; // ignore all whitespace -{WHITESPACE}+ ; // ignore all whitespace +{WHITESPACE}+ ; // ignore all whitespace
":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; } ";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;} (true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} {PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} {PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} -{STRING} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;} +{STRING_LIST} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;} {CHAR} { yytext[yyleng-1] = '\0'; yylval->cval = g_strcompress(&yytext[1])[0]; return T_CHAR;} @{WORD} { @@ -674,25 +671,16 @@ if ( queue == NULL ) { } {S_T_PARENT_LEFT} { return T_PARENT_LEFT; } {S_T_PARENT_RIGHT} { return T_PARENT_RIGHT; } -{COMMA} { return T_COMMA; } +{COMMA} { return T_COMMA; } {LIST_OPEN} { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); - BEGIN(PROPERTIES_LIST); + BEGIN(PROPERTIES_ARRAY); return T_LIST_OPEN; } -{LIST_CLOSE} { +{LIST_CLOSE} { BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue ))); return T_LIST_CLOSE; } -{ARRAY_OPEN} { - g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); - BEGIN(PROPERTIES_ARRAY); - return T_ARRAY_OPEN; -} -{ARRAY_CLOSE} { - BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue ))); - return T_ARRAY_CLOSE; -} {FORWARD_SLASH} { return T_FORWARD_SLASH; } /* Position */ {CENTER} { return T_POS_CENTER; } @@ -819,7 +807,7 @@ if ( queue == NULL ) { * If we just encounter a word, we assume it is a Widget name. * This makes include,theme, configuration a reserved keyword. */ -{WORD} { +{WORD_ELEMENT} { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(NAMESTR); yylval->sval = g_strdup(yytext); @@ -834,17 +822,12 @@ if ( queue == NULL ) { fprintf(stderr,"section found: |%s|\n", yytext); return T_ERROR_SECTION; } -{WORD} { +{WORD_ELEMENT} { yylval->sval = g_strdup(yytext); return T_ELEMENT; } -{STRING_LIST} { - yytext[yyleng-1] = '\0'; - yylval->sval = g_strdup(yytext+1); - return T_ELEMENT; -} -. { +. { yytext[yyleng-1] = '\0'; return T_ERROR_PROPERTY; } diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index 07588fa0..6754cd9d 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -231,12 +231,10 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b ) %token T_OPTIONAL_COMMA "Optional comma separator (',')" %token T_FORWARD_SLASH "forward slash ('/')" %token T_PERCENT "Percent sign ('%')" + %token T_LIST_OPEN "List open ('[')" %token T_LIST_CLOSE "List close (']')" -%token T_ARRAY_OPEN "Set open ('{')" -%token T_ARRAY_CLOSE "Set close ('}')" - %token T_MODIFIER_ADD "Add ('+')" %token T_MODIFIER_SUBTRACT "Subtract ('-')" %token T_MODIFIER_MULTIPLY "Multiply ('*')" @@ -306,8 +304,6 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b ) %type t_property_highlight_styles %type t_property_highlight_style %type t_property_line_style -%type t_property_element_list -%type t_property_element_list_optional %type t_property_element_set %type t_property_element_set_optional %type t_property_orientation @@ -581,14 +577,10 @@ t_property_element $$ = rofi_theme_property_create ( P_COLOR ); $$->value.color = $1; } -| T_LIST_OPEN t_property_element_list_optional T_LIST_CLOSE { +| T_LIST_OPEN t_property_element_set_optional T_LIST_CLOSE { $$ = rofi_theme_property_create ( P_LIST ); $$->value.list = $2; } -| T_ARRAY_OPEN t_property_element_set_optional T_ARRAY_CLOSE { - $$ = rofi_theme_property_create ( P_ARRAY ); - $$->value.list = $2; -} | t_property_orientation { $$ = rofi_theme_property_create ( P_ORIENTATION ); $$->value.i = $1; @@ -654,18 +646,6 @@ t_color_list ; -/** List of elements */ -t_property_element_list_optional -: %empty { $$ = NULL; } -| t_property_element_list { $$ = $1; } -; - -t_property_element_list -: T_ELEMENT { $$ = g_list_append ( NULL, $1); } -| t_property_element_list T_COMMA T_ELEMENT { - $$ = g_list_append ( $1, $3 ); -} -; /** List of elements */ t_property_element_set_optional : %empty { $$ = NULL; } @@ -674,6 +654,16 @@ t_property_element_set_optional t_property_element_set : t_property_element { $$ = g_list_append ( NULL, $1); } +| T_ELEMENT { + Property *p = rofi_theme_property_create ( P_STRING ); + p->value.s = $1; + $$ = g_list_append ( NULL, p); +} +| t_property_element_set T_COMMA T_ELEMENT { + Property *p = rofi_theme_property_create ( P_STRING ); + p->value.s = $3; + $$ = g_list_append ( $1, p); +} | t_property_element_set T_COMMA t_property_element { $$ = g_list_append ( $1, $3 ); } diff --git a/source/rofi-types.c b/source/rofi-types.c index 013a29c2..b9f752e2 100644 --- a/source/rofi-types.c +++ b/source/rofi-types.c @@ -28,8 +28,6 @@ const char *const PropertyTypeName[P_NUM_TYPES] = { "Highlight", /** List */ "List", - /** Array */ - "Array", /** Orientation */ "Orientation", /** Cursor */ diff --git a/source/theme.c b/source/theme.c index 1d530fd3..03bbb46d 100644 --- a/source/theme.c +++ b/source/theme.c @@ -134,10 +134,6 @@ Property *rofi_theme_property_copy(const Property *p) { retv->value.s = g_strdup(p->value.s); break; case P_LIST: - retv->value.list = - g_list_copy_deep(p->value.list, rofi_g_list_strdup, NULL); - break; - case P_ARRAY: retv->value.list = g_list_copy_deep( p->value.list, (GCopyFunc)rofi_theme_property_copy, NULL); break; @@ -208,9 +204,6 @@ void rofi_theme_property_free(Property *p) { if (p->type == P_STRING) { g_free(p->value.s); } else if (p->type == P_LIST) { - g_list_free_full(p->value.list, g_free); - p->value.list = 0; - } else if (p->type == P_ARRAY) { g_list_free_full(p->value.list, (GDestroyNotify)rofi_theme_property_free); p->value.list = 0; } else if (p->type == P_LINK) { @@ -367,23 +360,13 @@ static void int_rofi_theme_print_property(Property *p) { switch (p->type) { case P_LIST: printf("[ "); - for (GList *iter = p->value.list; iter != NULL; iter = g_list_next(iter)) { - printf("%s", (char *)(iter->data)); - if (iter->next != NULL) { - printf(","); - } - } - printf(" ]"); - break; - case P_ARRAY: - printf("{ "); for (GList *iter = p->value.list; iter != NULL; iter = g_list_next(iter)) { int_rofi_theme_print_property((Property *)iter->data); if (iter->next != NULL) { printf(","); } } - printf(" }"); + printf(" ]"); break; case P_ORIENTATION: printf("%s", (p->value.i == ROFI_ORIENTATION_HORIZONTAL) ? "horizontal" @@ -1229,7 +1212,7 @@ RofiPadding rofi_theme_get_padding(const widget *widget, const char *property, static GList *rofi_theme_get_list_inside(Property *p, const widget *widget, const char *property, - const char *defaults) { + PropertyType child_type) { if (p) { if (p->type == P_INHERIT) { if (widget->parent) { @@ -1238,55 +1221,20 @@ static GList *rofi_theme_get_list_inside(Property *p, const widget *widget, Property *pv = rofi_theme_find_property(parent, P_LIST, property, FALSE); return rofi_theme_get_list_inside(pv, widget->parent, property, - defaults); + child_type); } } else if (p->type == P_LIST) { - return g_list_copy_deep(p->value.list, rofi_g_list_strdup, NULL); - } - } - char **r = defaults ? g_strsplit(defaults, ",", 0) : NULL; - if (r) { - GList *l = NULL; - for (int i = 0; r[i] != NULL; i++) { - l = g_list_append(l, r[i]); - } - g_free(r); - return l; - } - return NULL; -} -GList *rofi_theme_get_list(const widget *widget, const char *property, - const char *defaults) { - ThemeWidget *wid2 = rofi_theme_find_widget(widget->name, widget->state, TRUE); - Property *p = rofi_theme_find_property(wid2, P_LIST, property, TRUE); - return rofi_theme_get_list_inside(p, widget, property, defaults); -} - -static GList *rofi_theme_get_array_inside(Property *p, const widget *widget, - const char *property, - PropertyType child_type) { - if (p) { - if (p->type == P_INHERIT) { - if (widget->parent) { - ThemeWidget *parent = - rofi_theme_find_widget(widget->parent->name, widget->state, FALSE); - Property *pv = - rofi_theme_find_property(parent, P_ARRAY, property, FALSE); - return rofi_theme_get_array_inside(pv, widget->parent, property, - child_type); - } - } else if (p->type == P_ARRAY) { return p->value.list; } } return NULL; } -GList *rofi_theme_get_array_distance(const widget *widget, - const char *property) { +GList *rofi_theme_get_list_distance(const widget *widget, + const char *property) { ThemeWidget *wid2 = rofi_theme_find_widget(widget->name, widget->state, FALSE); - Property *p = rofi_theme_find_property(wid2, P_ARRAY, property, FALSE); - GList *list = rofi_theme_get_array_inside(p, widget, property, P_PADDING); + Property *p = rofi_theme_find_property(wid2, P_LIST, property, FALSE); + GList *list = rofi_theme_get_list_inside(p, widget, property, P_PADDING); GList *retv = NULL; for (GList *iter = g_list_first(list); iter != NULL; iter = g_list_next(iter)) { @@ -1309,6 +1257,23 @@ GList *rofi_theme_get_array_distance(const widget *widget, } return retv; } +GList *rofi_theme_get_list_strings(const widget *widget, const char *property) { + ThemeWidget *wid2 = + rofi_theme_find_widget(widget->name, widget->state, FALSE); + Property *p = rofi_theme_find_property(wid2, P_LIST, property, FALSE); + GList *list = rofi_theme_get_list_inside(p, widget, property, P_STRING); + GList *retv = NULL; + for (GList *iter = g_list_first(list); iter != NULL; + iter = g_list_next(iter)) { + Property *prop = (Property *)(iter->data); + if (prop->type == P_STRING) { + retv = g_list_append(retv, g_strdup(prop->value.s)); + } else { + g_warning("Invalid type detected in list."); + } + } + return retv; +} static RofiHighlightColorStyle rofi_theme_get_highlight_inside(Property *p, widget *widget, diff --git a/source/view.c b/source/view.c index 9a2f4130..eacc4943 100644 --- a/source/view.c +++ b/source/view.c @@ -1951,11 +1951,22 @@ static void rofi_view_add_widget(RofiViewState *state, widget *parent_widget, // g_error("The widget %s does not exists. Invalid layout.", name); } if (wid) { - GList *list = rofi_theme_get_list(wid, "children", defaults); - for (const GList *iter = list; iter != NULL; iter = g_list_next(iter)) { - rofi_view_add_widget(state, wid, (const char *)iter->data); + GList *list = rofi_theme_get_list_strings(wid, "children"); + if (list == NULL) { + if (defaults) { + char **a = g_strsplit(defaults, ",", 0); + for (int i = 0; a && a[i]; i++) { + rofi_view_add_widget(state, wid, a[i]); + } + g_strfreev(a); + } + } else { + for (const GList *iter = g_list_first(list); iter != NULL; + iter = g_list_next(iter)) { + rofi_view_add_widget(state, wid, (const char *)iter->data); + } + g_list_free_full(list, g_free); } - g_list_free_full(list, g_free); } } @@ -2011,12 +2022,17 @@ RofiViewState *rofi_view_create(Mode *sw, const char *input, state->main_window = box_create(NULL, "window", ROFI_ORIENTATION_VERTICAL); // Get children. GList *list = - rofi_theme_get_list(WIDGET(state->main_window), "children", "mainbox"); - for (const GList *iter = list; iter != NULL; iter = g_list_next(iter)) { - rofi_view_add_widget(state, WIDGET(state->main_window), - (const char *)iter->data); + rofi_theme_get_list_strings(WIDGET(state->main_window), "children"); + if (list == NULL) { + rofi_view_add_widget(state, WIDGET(state->main_window), "mainbox"); + } else { + // rofi_theme_get_list(WIDGET(state->main_window), "children", "mainbox"); + for (const GList *iter = list; iter != NULL; iter = g_list_next(iter)) { + rofi_view_add_widget(state, WIDGET(state->main_window), + (const char *)iter->data); + } + g_list_free_full(list, g_free); } - g_list_free_full(list, g_free); if (state->text && input) { textbox_text(state->text, input); diff --git a/source/widgets/listview.c b/source/widgets/listview.c index b5c02231..36a2676b 100644 --- a/source/widgets/listview.c +++ b/source/widgets/listview.c @@ -176,7 +176,9 @@ static void listview_add_widget(listview *lv, _listview_row *row, widget *wid, } else { widget *wid2 = (widget *)box_create(wid, label, ROFI_ORIENTATION_VERTICAL); box_add((box *)wid, WIDGET(wid2), TRUE); - GList *list = rofi_theme_get_list(WIDGET(wid2), "children", ""); + GList *list = rofi_theme_get_list_strings( + WIDGET(wid2), + "children"); // rofi_theme_get_list(WIDGET(wid2), "children", ""); for (GList *iter = g_list_first(list); iter != NULL; iter = g_list_next(iter)) { listview_add_widget(lv, row, wid2, (const char *)iter->data); @@ -188,11 +190,14 @@ static void listview_create_row(listview *lv, _listview_row *row) { row->box = box_create(WIDGET(lv), "element", ROFI_ORIENTATION_HORIZONTAL); widget_set_type(WIDGET(row->box), WIDGET_TYPE_LISTVIEW_ELEMENT); GList *list = NULL; - if (config.show_icons) { - list = rofi_theme_get_list(WIDGET(row->box), "children", - "element-icon,element-text"); - } else { - list = rofi_theme_get_list(WIDGET(row->box), "children", "element-text"); + list = rofi_theme_get_list_strings(WIDGET(row->box), "children"); + if (list == NULL) { + if (config.show_icons) { + list = g_list_append(list, g_strdup("element-icon")); + list = g_list_append(list, g_strdup("element-text")); + } else { + list = g_list_append(list, g_strdup("element-text")); + } } row->textbox = NULL; diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index 0d42b04c..e211b733 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -164,13 +164,14 @@ static void textbox_initialize_font(textbox *tb) { } static void textbox_tab_stops(textbox *tb) { - GList *dists = rofi_theme_get_array_distance(WIDGET(tb), "tab-stops"); + GList *dists = rofi_theme_get_list_distance(WIDGET(tb), "tab-stops"); if (dists != NULL) { PangoTabArray *tabs = pango_tab_array_new(g_list_length(dists), TRUE); int i = 0, ppx = 0; - for (const GList *iter = g_list_first(dists); iter != NULL; iter = g_list_next(iter), i++) { + for (const GList *iter = g_list_first(dists); iter != NULL; + iter = g_list_next(iter), i++) { const RofiDistance *dist = iter->data; int px = distance_get_pixel(*dist, ROFI_ORIENTATION_HORIZONTAL); diff --git a/source/xrmoptions.c b/source/xrmoptions.c index ccd0aa04..c702b398 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -612,10 +612,11 @@ static gboolean __config_parser_set_property(XrmOption *option, if (p->type == P_LIST) { for (GList *iter = p->value.list; iter != NULL; iter = g_list_next(iter)) { + Property *p = (Property *)iter->data; if (value == NULL) { - value = g_strdup((char *)(iter->data)); + value = g_strdup((char *)(p->value.s)); } else { - char *nv = g_strjoin(",", value, (char *)(iter->data), NULL); + char *nv = g_strjoin(",", value, (char *)(p->value.s), NULL); g_free(value); value = nv; } diff --git a/test/theme-parser-test.c b/test/theme-parser-test.c index b16dcc43..e79438a4 100644 --- a/test/theme-parser-test.c +++ b/test/theme-parser-test.c @@ -1147,34 +1147,6 @@ START_TEST(test_properties_cursor_case) { ROFI_CURSOR_TEXT); } END_TEST -START_TEST(test_properties_list) { - widget wid; - wid.name = "blaat"; - wid.state = NULL; - rofi_theme_parse_string( - "#blaat { liste: []; list1: [ one ]; list2: [ one, two ];}"); - GList *list = rofi_theme_get_list(&wid, "liste", NULL); - ck_assert_ptr_null(list); - list = rofi_theme_get_list(&wid, "list1", NULL); - ck_assert_ptr_nonnull(list); - ck_assert_str_eq((char *)list->data, "one"); - g_list_free_full(list, (GDestroyNotify)g_free); - list = rofi_theme_get_list(&wid, "list2", NULL); - ck_assert_ptr_nonnull(list); - ck_assert_int_eq(g_list_length(list), 2); - ck_assert_str_eq((char *)list->data, "one"); - ck_assert_str_eq((char *)list->next->data, "two"); - g_list_free_full(list, (GDestroyNotify)g_free); - - list = rofi_theme_get_list(&wid, "blaat", "aap,noot,mies"); - ck_assert_ptr_nonnull(list); - ck_assert_int_eq(g_list_length(list), 3); - ck_assert_str_eq((char *)list->data, "aap"); - ck_assert_str_eq((char *)list->next->data, "noot"); - ck_assert_str_eq((char *)list->next->next->data, "mies"); - g_list_free_full(list, (GDestroyNotify)g_free); -} -END_TEST START_TEST(test_configuration) { rofi_theme_parse_string("configuration { font: \"blaat€\"; yoffset: 4; }"); @@ -1262,13 +1234,13 @@ START_TEST(test_prepare_array) { widget wid; wid.name = "element-text"; wid.state = "normal.normal"; - rofi_theme_parse_string("element-text { tabs: { 10, 20px, 30px, 40px };}"); + rofi_theme_parse_string("element-text { tabs: [ 10, 20px, 30px, 40px ];}"); ck_assert_ptr_nonnull(rofi_theme); // ck_assert_ptr_null ( rofi_theme->widgets ); ck_assert_ptr_null(rofi_theme->properties); ck_assert_ptr_null(rofi_theme->parent); ck_assert_str_eq(rofi_theme->name, "Root"); - GList *l = rofi_theme_get_array_distance(&wid, "tabs"); + GList *l = rofi_theme_get_list_distance(&wid, "tabs"); ck_assert_int_eq(g_list_length(l), 4); @@ -1318,7 +1290,6 @@ START_TEST(test_properties_types_names) { ck_assert_str_eq(PropertyTypeName[P_POSITION], "Position"); ck_assert_str_eq(PropertyTypeName[P_HIGHLIGHT], "Highlight"); ck_assert_str_eq(PropertyTypeName[P_LIST], "List"); - ck_assert_str_eq(PropertyTypeName[P_ARRAY], "Array"); ck_assert_str_eq(PropertyTypeName[P_ORIENTATION], "Orientation"); } END_TEST @@ -1455,13 +1426,6 @@ static Suite *theme_parser_suite(void) { tcase_add_test(tc_prop_cursor, test_properties_cursor_case); suite_add_tcase(s, tc_prop_cursor); } - { - TCase *tc_prop_list = tcase_create("Propertieslist"); - tcase_add_checked_fixture(tc_prop_list, theme_parser_setup, - theme_parser_teardown); - tcase_add_test(tc_prop_list, test_properties_list); - suite_add_tcase(s, tc_prop_list); - } { TCase *tc_prop_configuration = tcase_create("Configuration"); tcase_add_checked_fixture(tc_prop_configuration, theme_parser_setup, -- cgit v1.2.3