mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Merge List and Array type into one. (#1572)
* Merge list and array into one. * [Lexer] Only use string without " in list * Some cleanups * Cleanups based on feedback.
This commit is contained in:
parent
6e3feee179
commit
85c6545a43
14 changed files with 154 additions and 178 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
29
doc/rofi.1
29
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
|
||||
|
|
|
@ -32,8 +32,6 @@ typedef enum {
|
|||
P_HIGHLIGHT,
|
||||
/** List */
|
||||
P_LIST,
|
||||
/** Array */
|
||||
P_ARRAY,
|
||||
/** Orientation */
|
||||
P_ORIENTATION,
|
||||
/** Cursor */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:]]+
|
||||
|
@ -275,9 +276,6 @@ FORWARD_SLASH \/
|
|||
LIST_OPEN \[
|
||||
LIST_CLOSE \]
|
||||
|
||||
ARRAY_OPEN \{
|
||||
ARRAY_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,19 @@ if ( queue == NULL ) {
|
|||
/* Alias color to text-color */
|
||||
<SECTION>"color" { yylval->sval = g_strdup("text-color"); return T_PROP_NAME;}
|
||||
<SECTION>{WORD} { yylval->sval = g_strdup(yytext); return T_PROP_NAME;}
|
||||
<NAMESTR>{WORD} { yylval->sval = g_strdup(yytext); return T_NAME_ELEMENT;}
|
||||
<NAMESTR>{WORD_ELEMENT} { yylval->sval = g_strdup(yytext); return T_NAME_ELEMENT;}
|
||||
|
||||
/* After Namestr/Classstr we want to go to state str, then to { */
|
||||
<INITIAL,SECTION>{WHITESPACE}+ ; // ignore all whitespace
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_LIST,PROPERTIES_ARRAY,PROPERTIES_ENV_VAR,PROPERTIES_VAR,MEDIA_CONTENT>{WHITESPACE}+ ; // ignore all whitespace
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_ARRAY,PROPERTIES_ENV_VAR,PROPERTIES_VAR,MEDIA_CONTENT>{WHITESPACE}+ ; // ignore all whitespace
|
||||
|
||||
<SECTION>":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; }
|
||||
<PROPERTIES>";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;}
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{PNNUMBER}\.{NUMBER}+ { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;}
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{PNNUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;}
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{STRING} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;}
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{STRING} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;}
|
||||
<PROPERTIES_ARRAY>{STRING_LIST} { yytext[yyleng-1] = '\0'; yylval->sval = g_strcompress(&yytext[1]); return T_STRING;}
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CHAR} { yytext[yyleng-1] = '\0'; yylval->cval = g_strcompress(&yytext[1])[0]; return T_CHAR;}
|
||||
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>@{WORD} {
|
||||
|
@ -674,25 +672,16 @@ if ( queue == NULL ) {
|
|||
}
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{S_T_PARENT_LEFT} { return T_PARENT_LEFT; }
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{S_T_PARENT_RIGHT} { return T_PARENT_RIGHT; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_LIST>{COMMA} { return T_COMMA; }
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{COMMA} { return T_COMMA; }
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{LIST_OPEN} {
|
||||
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
|
||||
BEGIN(PROPERTIES_LIST);
|
||||
BEGIN(PROPERTIES_ARRAY);
|
||||
return T_LIST_OPEN;
|
||||
}
|
||||
<PROPERTIES_LIST>{LIST_CLOSE} {
|
||||
<PROPERTIES_ARRAY>{LIST_CLOSE} {
|
||||
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
||||
return T_LIST_CLOSE;
|
||||
}
|
||||
<PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{ARRAY_OPEN} {
|
||||
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
|
||||
BEGIN(PROPERTIES_ARRAY);
|
||||
return T_ARRAY_OPEN;
|
||||
}
|
||||
<PROPERTIES_ARRAY>{ARRAY_CLOSE} {
|
||||
BEGIN(GPOINTER_TO_INT(g_queue_pop_head ( queue )));
|
||||
return T_ARRAY_CLOSE;
|
||||
}
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{FORWARD_SLASH} { return T_FORWARD_SLASH; }
|
||||
/* Position */
|
||||
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>{CENTER} { return T_POS_CENTER; }
|
||||
|
@ -819,7 +808,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.
|
||||
*/
|
||||
<INITIAL>{WORD} {
|
||||
<INITIAL>{WORD_ELEMENT} {
|
||||
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
|
||||
BEGIN(NAMESTR);
|
||||
yylval->sval = g_strdup(yytext);
|
||||
|
@ -834,17 +823,12 @@ if ( queue == NULL ) {
|
|||
fprintf(stderr,"section found: |%s|\n", yytext);
|
||||
return T_ERROR_SECTION;
|
||||
}
|
||||
<PROPERTIES_LIST,PROPERTIES_VAR>{WORD} {
|
||||
<PROPERTIES_ARRAY,PROPERTIES_VAR>{WORD_ELEMENT} {
|
||||
yylval->sval = g_strdup(yytext);
|
||||
return T_ELEMENT;
|
||||
}
|
||||
<PROPERTIES_LIST>{STRING_LIST} {
|
||||
yytext[yyleng-1] = '\0';
|
||||
yylval->sval = g_strdup(yytext+1);
|
||||
return T_ELEMENT;
|
||||
}
|
||||
|
||||
<PROPERTIES_ENV_VAR,PROPERTIES_VAR,PROPERTIES_ARRAY,PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,PROPERTIES_LIST>. {
|
||||
<PROPERTIES_ENV_VAR,PROPERTIES_VAR,PROPERTIES_ARRAY,PROPERTIES,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT>. {
|
||||
yytext[yyleng-1] = '\0';
|
||||
return T_ERROR_PROPERTY;
|
||||
}
|
||||
|
|
|
@ -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 ('*')"
|
||||
|
@ -308,8 +306,6 @@ static ThemeColor hwb_to_rgb ( double h, double w, double b )
|
|||
%type <ival> t_property_line_style
|
||||
%type <list> t_property_element_list
|
||||
%type <list> t_property_element_list_optional
|
||||
%type <list> t_property_element_set
|
||||
%type <list> t_property_element_set_optional
|
||||
%type <ival> t_property_orientation
|
||||
%type <ival> t_property_cursor
|
||||
%type <ival> t_name_prefix_optional
|
||||
|
@ -585,10 +581,6 @@ t_property_element
|
|||
$$ = 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;
|
||||
|
@ -661,20 +653,18 @@ t_property_element_list_optional
|
|||
;
|
||||
|
||||
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; }
|
||||
| t_property_element_set { $$ = $1; }
|
||||
;
|
||||
|
||||
t_property_element_set
|
||||
: t_property_element { $$ = g_list_append ( NULL, $1); }
|
||||
| t_property_element_set T_COMMA t_property_element {
|
||||
| T_ELEMENT {
|
||||
Property *p = rofi_theme_property_create ( P_STRING );
|
||||
p->value.s = $1;
|
||||
$$ = g_list_append ( NULL, p);
|
||||
}
|
||||
| t_property_element_list T_COMMA T_ELEMENT {
|
||||
Property *p = rofi_theme_property_create ( P_STRING );
|
||||
p->value.s = $3;
|
||||
$$ = g_list_append ( $1, p);
|
||||
}
|
||||
| t_property_element_list T_COMMA t_property_element {
|
||||
$$ = g_list_append ( $1, $3 );
|
||||
}
|
||||
;
|
||||
|
|
|
@ -28,8 +28,6 @@ const char *const PropertyTypeName[P_NUM_TYPES] = {
|
|||
"Highlight",
|
||||
/** List */
|
||||
"List",
|
||||
/** Array */
|
||||
"Array",
|
||||
/** Orientation */
|
||||
"Orientation",
|
||||
/** Cursor */
|
||||
|
|
|
@ -70,11 +70,6 @@ static gboolean distance_compare(RofiDistance d, RofiDistance e) {
|
|||
d.style == e.style;
|
||||
}
|
||||
|
||||
static gpointer rofi_g_list_strdup(gconstpointer data,
|
||||
G_GNUC_UNUSED gpointer user_data) {
|
||||
return g_strdup(data);
|
||||
}
|
||||
|
||||
ThemeWidget *rofi_theme_find_or_create_name(ThemeWidget *base,
|
||||
const char *name) {
|
||||
for (unsigned int i = 0; i < base->num_widgets; i++) {
|
||||
|
@ -134,10 +129,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 +199,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 +355,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 +1207,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 +1216,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);
|
||||
}
|
||||
} 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) {
|
||||
} else if (p->type == P_LIST) {
|
||||
return p->value.list;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
GList *rofi_theme_get_array_distance(const widget *widget,
|
||||
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 +1252,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,
|
||||
|
|
|
@ -1951,13 +1951,24 @@ 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)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rofi_view_ping_mouse(RofiViewState *state) {
|
||||
xcb_query_pointer_cookie_t pointer_cookie =
|
||||
|
@ -2011,12 +2022,16 @@ 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");
|
||||
rofi_theme_get_list_strings(WIDGET(state->main_window), "children");
|
||||
if (list == NULL) {
|
||||
rofi_view_add_widget(state, WIDGET(state->main_window), "mainbox");
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
if (state->text && input) {
|
||||
textbox_text(state->text, input);
|
||||
|
|
|
@ -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;
|
||||
list = rofi_theme_get_list_strings(WIDGET(row->box), "children");
|
||||
if (list == NULL) {
|
||||
if (config.show_icons) {
|
||||
list = rofi_theme_get_list(WIDGET(row->box), "children",
|
||||
"element-icon,element-text");
|
||||
list = g_list_append(list, g_strdup("element-icon"));
|
||||
list = g_list_append(list, g_strdup("element-text"));
|
||||
} else {
|
||||
list = rofi_theme_get_list(WIDGET(row->box), "children", "element-text");
|
||||
list = g_list_append(list, g_strdup("element-text"));
|
||||
}
|
||||
}
|
||||
|
||||
row->textbox = NULL;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -1153,29 +1153,22 @@ START_TEST(test_properties_list) {
|
|||
wid.state = NULL;
|
||||
rofi_theme_parse_string(
|
||||
"#blaat { liste: []; list1: [ one ]; list2: [ one, two ];}");
|
||||
GList *list = rofi_theme_get_list(&wid, "liste", NULL);
|
||||
GList *list = rofi_theme_get_list_strings(&wid, "liste");
|
||||
ck_assert_ptr_null(list);
|
||||
list = rofi_theme_get_list(&wid, "list1", NULL);
|
||||
list = rofi_theme_get_list_strings(&wid, "list1");
|
||||
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);
|
||||
|
||||
list = rofi_theme_get_list_strings(&wid, "list2");
|
||||
ck_assert_ptr_nonnull(list);
|
||||
ck_assert_int_eq(g_list_length(list), 2);
|
||||
list = g_list_first(list);
|
||||
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; }");
|
||||
ck_assert_int_eq(g_utf8_collate(config.menu_font, "blaat€"), 0);
|
||||
|
@ -1262,13 +1255,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 +1311,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 +1447,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,
|
||||
|
@ -1469,6 +1454,13 @@ static Suite *theme_parser_suite(void) {
|
|||
tcase_add_test(tc_prop_configuration, test_configuration);
|
||||
suite_add_tcase(s, tc_prop_configuration);
|
||||
}
|
||||
{
|
||||
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_parse_file = tcase_create("ParseFile");
|
||||
tcase_add_checked_fixture(tc_prop_parse_file, theme_parser_setup,
|
||||
|
|
Loading…
Reference in a new issue