mirror of
https://github.com/lbonn/rofi
synced 2024-11-15 08:37:17 +00:00
Add 'Configuration' section to rasi format that parses config option.
This commit is contained in:
parent
5186dab1b8
commit
b91a9fb0c0
4 changed files with 65 additions and 1 deletions
|
@ -158,5 +158,14 @@ void print_help_msg ( const char *option, const char *type, const char*text, con
|
||||||
*/
|
*/
|
||||||
char ** config_parser_return_display_help ( unsigned int *length );
|
char ** config_parser_return_display_help ( unsigned int *length );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Set config option.
|
||||||
|
*
|
||||||
|
* Sets both the static as dynamic config option.
|
||||||
|
*
|
||||||
|
* @param option Option to set.
|
||||||
|
* @param value Value to set it too
|
||||||
|
*/
|
||||||
|
void config_parser_set_option ( char *option, char *value);
|
||||||
/* @}*/
|
/* @}*/
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -141,6 +141,8 @@ LS_SOLID "solid"
|
||||||
|
|
||||||
INCLUDE "@import"
|
INCLUDE "@import"
|
||||||
|
|
||||||
|
CONFIGURATION "Configuration"
|
||||||
|
|
||||||
%x INCLUDE
|
%x INCLUDE
|
||||||
%x PROPERTIES
|
%x PROPERTIES
|
||||||
%x NAMESTR
|
%x NAMESTR
|
||||||
|
@ -257,6 +259,12 @@ if ( queue == NULL ){
|
||||||
/**
|
/**
|
||||||
* Handle defaults: * { ... }
|
* Handle defaults: * { ... }
|
||||||
*/
|
*/
|
||||||
|
<INITIAL>{CONFIGURATION} {
|
||||||
|
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
|
||||||
|
BEGIN(DEFAULTS);
|
||||||
|
return CONFIGURATION;
|
||||||
|
|
||||||
|
}
|
||||||
<INITIAL>{ASTERIX} {
|
<INITIAL>{ASTERIX} {
|
||||||
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
|
g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) );
|
||||||
BEGIN(DEFAULTS);
|
BEGIN(DEFAULTS);
|
||||||
|
|
|
@ -89,6 +89,7 @@ int yylex (YYSTYPE *, YYLTYPE *);
|
||||||
%token NAME_PREFIX "Element section ('# {name} { ... }')"
|
%token NAME_PREFIX "Element section ('# {name} { ... }')"
|
||||||
%token WHITESPACE "White space"
|
%token WHITESPACE "White space"
|
||||||
%token PDEFAULTS "Default settings section ( '* { ... }')"
|
%token PDEFAULTS "Default settings section ( '* { ... }')"
|
||||||
|
%token CONFIGURATION "Configuration block"
|
||||||
|
|
||||||
%type <ival> highlight_styles
|
%type <ival> highlight_styles
|
||||||
%type <sval> entry
|
%type <sval> entry
|
||||||
|
@ -131,6 +132,32 @@ NAME_PREFIX name_path BOPEN optional_properties BCLOSE
|
||||||
PDEFAULTS BOPEN optional_properties BCLOSE {
|
PDEFAULTS BOPEN optional_properties BCLOSE {
|
||||||
rofi_theme_widget_add_properties ( rofi_theme, $3);
|
rofi_theme_widget_add_properties ( rofi_theme, $3);
|
||||||
}
|
}
|
||||||
|
| CONFIGURATION BOPEN optional_properties BCLOSE {
|
||||||
|
GHashTableIter iter;
|
||||||
|
g_hash_table_iter_init ( &iter, $3 );
|
||||||
|
gpointer key,value;
|
||||||
|
while ( g_hash_table_iter_next ( &iter, &key, &value ) ) {
|
||||||
|
Property *p = (Property *) value;
|
||||||
|
switch ( p ->type )
|
||||||
|
{
|
||||||
|
case P_STRING:
|
||||||
|
config_parser_set_option ( p->name, p->value.s);
|
||||||
|
break;
|
||||||
|
case P_BOOLEAN:
|
||||||
|
config_parser_set_option ( p->name, p->value.b?"true":"false");
|
||||||
|
break;
|
||||||
|
case P_INTEGER:
|
||||||
|
{
|
||||||
|
char *str = g_strdup_printf("%d", p->value.i);
|
||||||
|
config_parser_set_option ( p->name, str );
|
||||||
|
g_free(str);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -49,6 +49,7 @@ const char * const ConfigSourceStr[] = {
|
||||||
"Default",
|
"Default",
|
||||||
"XResources",
|
"XResources",
|
||||||
"File",
|
"File",
|
||||||
|
"Rasi File",
|
||||||
"Commandline",
|
"Commandline",
|
||||||
};
|
};
|
||||||
/** Enumerator of different sources of configuration. */
|
/** Enumerator of different sources of configuration. */
|
||||||
|
@ -57,7 +58,8 @@ enum ConfigSource
|
||||||
CONFIG_DEFAULT = 0,
|
CONFIG_DEFAULT = 0,
|
||||||
CONFIG_XRESOURCES = 1,
|
CONFIG_XRESOURCES = 1,
|
||||||
CONFIG_FILE = 2,
|
CONFIG_FILE = 2,
|
||||||
CONFIG_CMDLINE = 3
|
CONFIG_FILE_THEME = 3,
|
||||||
|
CONFIG_CMDLINE = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -386,6 +388,24 @@ static void __config_parse_xresource_options_dynamic ( xcb_xrm_database_t *xDB,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void config_parser_set_option ( char *option, char *value)
|
||||||
|
{
|
||||||
|
for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) {
|
||||||
|
XrmOption *op = &( xrmOptions[i] );
|
||||||
|
if ( g_strcmp0 ( op->name, option) == 0 ) {
|
||||||
|
config_parser_set ( op, value, CONFIG_FILE_THEME);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
|
||||||
|
XrmOption *op = &( extra_options[i] );
|
||||||
|
if ( g_strcmp0 ( op->name, option) == 0 ) {
|
||||||
|
config_parser_set ( op, value, CONFIG_FILE_THEME);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
|
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
|
||||||
{
|
{
|
||||||
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
|
||||||
|
|
Loading…
Reference in a new issue