diff options
author | Dave Davenport <qball@gmpclient.org> | 2017-03-28 17:13:38 +0200 |
---|---|---|
committer | Dave Davenport <qball@gmpclient.org> | 2017-03-28 17:13:38 +0200 |
commit | 14b43523bef26208b20593533dd60786d046c469 (patch) | |
tree | 7a2ed45b8fe26534b6805297bbd125e7ee628933 /source/xrmoptions.c | |
parent | 9210ce9aad0c9f6146f364dc2d1e173da2bac5d2 (diff) |
Merge the configuration loading into something more simple (2)
Diffstat (limited to 'source/xrmoptions.c')
-rw-r--r-- | source/xrmoptions.c | 67 |
1 files changed, 21 insertions, 46 deletions
diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 8b4e17e5..5a910b19 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -277,11 +277,31 @@ static void __config_parse_xresource_options ( xcb_xrm_database_t *xDB, enum Con g_free ( name ); } } +static void __config_parse_xresource_options_dynamic ( xcb_xrm_database_t *xDB, enum ConfigSource source ) +{ + const char * namePrefix = "rofi"; + + for ( unsigned int i = 0; i < num_extra_options; ++i ) { + char *name; + + name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name ); + char *xrmValue = NULL; + if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) { + config_parser_set ( &( extra_options[i] ), xrmValue, source ); + } + if ( xrmValue ) { + free ( xrmValue ); + } + + g_free ( name ); + } +} void config_parse_xresource_options ( xcb_stuff *xcb ) { xcb_xrm_database_t *xDB = xcb_xrm_database_from_default ( xcb->connection ); if ( xDB ) { __config_parse_xresource_options ( xDB, CONFIG_XRESOURCES ); + __config_parse_xresource_options_dynamic ( xDB, CONFIG_XRESOURCES ); xcb_xrm_database_free ( xDB ); } } @@ -296,6 +316,7 @@ void config_parse_xresource_options_file ( const char *filename ) return; } __config_parse_xresource_options ( xDB, CONFIG_FILE ); + __config_parse_xresource_options_dynamic ( xDB, CONFIG_FILE ); xcb_xrm_database_free ( xDB ); } @@ -358,35 +379,13 @@ void config_parse_cmd_options ( void ) XrmOption *op = &( xrmOptions[i] ); config_parse_cmd_option ( op ); } -} - -void config_parse_cmd_options_dynamic ( void ) -{ for ( unsigned int i = 0; i < num_extra_options; ++i ) { XrmOption *op = &( extra_options[i] ); config_parse_cmd_option ( op ); } } -static void __config_parse_xresource_options_dynamic ( xcb_xrm_database_t *xDB, enum ConfigSource source ) -{ - const char * namePrefix = "rofi"; - for ( unsigned int i = 0; i < num_extra_options; ++i ) { - char *name; - - name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name ); - char *xrmValue = NULL; - if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) { - config_parser_set ( &( extra_options[i] ), xrmValue, source ); - } - if ( xrmValue ) { - free ( xrmValue ); - } - - g_free ( name ); - } -} void config_parser_set_option ( char *option, char *value) { @@ -406,30 +405,6 @@ void config_parser_set_option ( char *option, char *value) } } -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 ); - if ( name ) { - xcb_xrm_database_t *xDB = xcb_xrm_database_from_string ( name ); - __config_parse_xresource_options_dynamic ( xDB, CONFIG_XRESOURCES ); - xcb_xrm_database_free ( xDB ); - g_free ( name ); - } -} -void config_parse_xresource_options_dynamic_file ( const char *filename ) -{ - if ( !filename ) { - return; - } - // Map Xresource entries to rofi config options. - xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename ); - if ( xDB == NULL ) { - return; - } - __config_parse_xresource_options_dynamic ( xDB, CONFIG_FILE ); - xcb_xrm_database_free ( xDB ); -} - void config_xresource_free ( void ) { for ( unsigned int i = 0; i < ( sizeof ( xrmOptions ) / sizeof ( *xrmOptions ) ); ++i ) { |