summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-03-28 17:13:38 +0200
committerDave Davenport <qball@gmpclient.org>2017-03-28 17:13:38 +0200
commit14b43523bef26208b20593533dd60786d046c469 (patch)
tree7a2ed45b8fe26534b6805297bbd125e7ee628933
parent9210ce9aad0c9f6146f364dc2d1e173da2bac5d2 (diff)
Merge the configuration loading into something more simple (2)
-rw-r--r--include/xrmoptions.h24
-rw-r--r--source/rofi.c4
-rw-r--r--source/xrmoptions.c67
3 files changed, 21 insertions, 74 deletions
diff --git a/include/xrmoptions.h b/include/xrmoptions.h
index 87b9f15c..e1c47893 100644
--- a/include/xrmoptions.h
+++ b/include/xrmoptions.h
@@ -77,30 +77,6 @@ void config_parse_xresource_options_file ( const char *filename );
void config_parse_cmd_options ( void );
/**
- * Parse dynamic commandline options.
- * @ingroup CONFCommandline
- */
-void config_parse_cmd_options_dynamic ( void );
-
-/**
- * @param xcb Handler object that holds connection to X11 server to fetch the settings from.
- *
- * Parse the rofi related X resource options of the
- * connected X server.
- *
- * @ingroup CONFXServer
- */
-void config_parse_xresource_options_dynamic ( xcb_stuff *xcb );
-
-/**
- * @param filename The xresources file to parse
- *
- * Parses filename and updates the config. For dynamic options.
- * @ingroup CONFFile
- */
-void config_parse_xresource_options_dynamic_file ( const char *filename );
-
-/**
* Free any allocated memory.
*
* @ingroup CONFXResources
diff --git a/source/rofi.c b/source/rofi.c
index 3bf42b58..37feead9 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -1045,14 +1045,11 @@ int main ( int argc, char *argv[] )
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( etc );
- config_parse_xresource_options_dynamic_file ( etc );
}
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options ( xcb );
- config_parse_xresource_options_dynamic ( xcb );
config_parse_xresource_options_file ( config_path );
- config_parse_xresource_options_dynamic_file ( config_path );
find_arg_str ( "-theme", &(config.theme));
if ( config.theme ) {
@@ -1067,7 +1064,6 @@ int main ( int argc, char *argv[] )
}
// Parse command line for settings, independent of other -no-config.
config_parse_cmd_options ( );
- config_parse_cmd_options_dynamic ( );
TICK_N ( "Load cmd config " );
if ( !dmenu_mode ) {
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 ) {