aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-04 09:02:04 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 10:04:01 (GMT)
commitd76bdcca7a8a70dd47eda5200d312173c302b7b9 (patch)
tree67f0cece58d2d9e2d972f19acce9b8ebf2c42690 /util
parent476f845dcda2ff239616ec075521ab6826805245 (diff)
downloadfluxbox_paul-d76bdcca7a8a70dd47eda5200d312173c302b7b9.zip
fluxbox_paul-d76bdcca7a8a70dd47eda5200d312173c302b7b9.tar.bz2
Move most of the resource loading code into ResourceManager_base
I mostly do this to avoid code duplication between fluxbox and fluxbox-update_configs.
Diffstat (limited to 'util')
-rw-r--r--util/fluxbox-update_configs.cc45
1 files changed, 21 insertions, 24 deletions
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc
index 9062b57..cbc0d73 100644
--- a/util/fluxbox-update_configs.cc
+++ b/util/fluxbox-update_configs.cc
@@ -74,7 +74,7 @@ void save_all_files();
74/*------------------------------------------------------------------*\ 74/*------------------------------------------------------------------*\
75\*------------------------------------------------------------------*/ 75\*------------------------------------------------------------------*/
76 76
77void update_add_mouse_evens_to_keys(FbTk::ResourceManager& rm, 77void update_add_mouse_evens_to_keys(FbTk::ResourceManager_base& rm,
78 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 78 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
79 79
80 string whole_keyfile = read_file(keyfilename); 80 string whole_keyfile = read_file(keyfilename);
@@ -111,7 +111,7 @@ void update_add_mouse_evens_to_keys(FbTk::ResourceManager& rm,
111} 111}
112 112
113 113
114void update_move_groups_entries_to_apps_file(FbTk::ResourceManager& rm, 114void update_move_groups_entries_to_apps_file(FbTk::ResourceManager_base& rm,
115 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 115 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
116 116
117 FbTk::StringResource rc_groupfile(rm, "~/.fluxbox/groups", 117 FbTk::StringResource rc_groupfile(rm, "~/.fluxbox/groups",
@@ -148,7 +148,7 @@ void update_move_groups_entries_to_apps_file(FbTk::ResourceManager& rm,
148} 148}
149 149
150 150
151void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager& rm, 151void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager_base& rm,
152 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 152 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
153 153
154 string whole_keyfile = read_file(keyfilename); 154 string whole_keyfile = read_file(keyfilename);
@@ -187,7 +187,7 @@ void update_move_toolbar_wheeling_to_keys_file(FbTk::ResourceManager& rm,
187 187
188 188
189 189
190void update_move_modkey_to_keys_file(FbTk::ResourceManager& rm, 190void update_move_modkey_to_keys_file(FbTk::ResourceManager_base& rm,
191 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 191 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
192 string whole_keyfile = read_file(keyfilename); 192 string whole_keyfile = read_file(keyfilename);
193 string new_keyfile = ""; 193 string new_keyfile = "";
@@ -222,7 +222,7 @@ void update_move_modkey_to_keys_file(FbTk::ResourceManager& rm,
222 222
223 223
224 224
225void update_window_patterns_for_iconbar(FbTk::ResourceManager& rm, 225void update_window_patterns_for_iconbar(FbTk::ResourceManager_base& rm,
226 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 226 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
227 227
228 // this needs to survive after going out of scope 228 // this needs to survive after going out of scope
@@ -251,7 +251,7 @@ void update_window_patterns_for_iconbar(FbTk::ResourceManager& rm,
251} 251}
252 252
253 253
254void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager& rm, 254void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager_base& rm,
255 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 255 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
256 string whole_keyfile = read_file(keyfilename); 256 string whole_keyfile = read_file(keyfilename);
257 string new_keyfile = ""; 257 string new_keyfile = "";
@@ -288,7 +288,7 @@ void update_move_titlebar_actions_to_keys_file(FbTk::ResourceManager& rm,
288} 288}
289 289
290 290
291void update_added_starttabbing_command(FbTk::ResourceManager& rm, 291void update_added_starttabbing_command(FbTk::ResourceManager_base& rm,
292 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 292 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
293 string whole_keyfile = read_file(keyfilename); 293 string whole_keyfile = read_file(keyfilename);
294 string new_keyfile = ""; 294 string new_keyfile = "";
@@ -302,7 +302,7 @@ void update_added_starttabbing_command(FbTk::ResourceManager& rm,
302 302
303 303
304 304
305void update_disable_icons_in_tabs_for_backwards_compatibility(FbTk::ResourceManager& rm, 305void update_disable_icons_in_tabs_for_backwards_compatibility(FbTk::ResourceManager_base& rm,
306 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 306 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
307 307
308 FbTk::BoolResource *show = 308 FbTk::BoolResource *show =
@@ -316,7 +316,7 @@ void update_disable_icons_in_tabs_for_backwards_compatibility(FbTk::ResourceMana
316 316
317 317
318 318
319void update_change_format_of_split_placement_menu(FbTk::ResourceManager& rm, 319void update_change_format_of_split_placement_menu(FbTk::ResourceManager_base& rm,
320 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 320 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
321 321
322 FbTk::StringResource *placement = 322 FbTk::StringResource *placement =
@@ -344,7 +344,7 @@ void update_change_format_of_split_placement_menu(FbTk::ResourceManager& rm,
344 344
345 345
346 346
347void update_update_keys_file_for_nextwindow_syntax_changes(FbTk::ResourceManager& rm, 347void update_update_keys_file_for_nextwindow_syntax_changes(FbTk::ResourceManager_base& rm,
348 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 348 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
349 349
350 string whole_keyfile = read_file(keyfilename); 350 string whole_keyfile = read_file(keyfilename);
@@ -401,7 +401,7 @@ void update_update_keys_file_for_nextwindow_syntax_changes(FbTk::ResourceManager
401 401
402 402
403 403
404void update_keys_for_ongrip_onwindowborder(FbTk::ResourceManager& rm, 404void update_keys_for_ongrip_onwindowborder(FbTk::ResourceManager_base& rm,
405 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 405 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
406 406
407 string whole_keyfile = read_file(keyfilename); 407 string whole_keyfile = read_file(keyfilename);
@@ -421,7 +421,7 @@ void update_keys_for_ongrip_onwindowborder(FbTk::ResourceManager& rm,
421 421
422 422
423 423
424void update_keys_for_activetab(FbTk::ResourceManager& rm, 424void update_keys_for_activetab(FbTk::ResourceManager_base& rm,
425 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 425 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
426 426
427 string whole_file = read_file(keyfilename); 427 string whole_file = read_file(keyfilename);
@@ -439,7 +439,7 @@ void update_keys_for_activetab(FbTk::ResourceManager& rm,
439 439
440 440
441// NextWindow {static groups} => NextWindow {static groups} (workspace=[current]) 441// NextWindow {static groups} => NextWindow {static groups} (workspace=[current])
442void update_limit_nextwindow_to_current_workspace(FbTk::ResourceManager& rm, 442void update_limit_nextwindow_to_current_workspace(FbTk::ResourceManager_base& rm,
443 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) { 443 const FbTk::FbString& keyfilename, const FbTk::FbString& appsfilename) {
444 444
445 string whole_file = read_file(keyfilename); 445 string whole_file = read_file(keyfilename);
@@ -530,7 +530,7 @@ void update_limit_nextwindow_to_current_workspace(FbTk::ResourceManager& rm,
530 530
531struct Update { 531struct Update {
532 int version; 532 int version;
533 void (*update)(FbTk::ResourceManager& rm, const FbTk::FbString&, const FbTk::FbString&); 533 void (*update)(FbTk::ResourceManager_base& rm, const FbTk::FbString&, const FbTk::FbString&);
534}; 534};
535 535
536const Update UPDATES[] = { 536const Update UPDATES[] = {
@@ -618,16 +618,13 @@ int main(int argc, char **argv) {
618 rc_filename = getenv("HOME") + string("/.fluxbox/init"); 618 rc_filename = getenv("HOME") + string("/.fluxbox/init");
619 619
620 FbTk::ResourceManager resource_manager("session", "Session", rc_filename.c_str(),false); 620 FbTk::ResourceManager resource_manager("session", "Session", rc_filename.c_str(),false);
621 if (!resource_manager.load(rc_filename.c_str())) { 621 try {
622 // couldn't load rc file 622 resource_manager.load(rc_filename, DEFAULT_INITFILE);
623 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "Failed trying to read rc file")<<":"<<rc_filename<<endl; 623 }
624 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFileTrying, "Retrying with", "Retrying rc file loading with (the following file)")<<": "<<DEFAULT_INITFILE<<endl; 624 catch(std::runtime_error &) {
625 625 // This should only happen if system-wide init file is broken.
626 // couldn't load default rc file, either 626 // this is a fatal error for us
627 if (!resource_manager.load(DEFAULT_INITFILE)) { 627 return 1;
628 cerr<<_FB_CONSOLETEXT(Fluxbox, CantLoadRCFile, "Failed to load database", "")<<": "<<DEFAULT_INITFILE<<endl;
629 exit(1); // this is a fatal error for us
630 }
631 } 628 }
632 629
633 // run updates here 630 // run updates here