+
+void BScreen::saveSloppyFocus(bool s) {
+ resource.sloppy_focus = s;
+
+ string fmodel;
+ if (resource.sloppy_focus) {
+ fmodel = "SloppyFocus";
+ if (resource.auto_raise) fmodel += " AutoRaise";
+ if (resource.click_raise) fmodel += " ClickRaise";
+ } else {
+ fmodel = "ClickToFocus";
+ }
+ config->setValue(screenstr + "focusModel", fmodel);
+}
+
+
+void BScreen::saveAutoRaise(bool a) {
+ resource.auto_raise = a;
+ saveSloppyFocus(resource.sloppy_focus);
+}
+
+
+void BScreen::saveClickRaise(bool c) {
+ resource.click_raise = c;
+ saveSloppyFocus(resource.sloppy_focus);
+}
+
+
+void BScreen::saveImageDither(bool d) {
+ image_control->setDither(d);
+ config->setValue(screenstr + "imageDither", doImageDither());
+}
+
+
+void BScreen::saveOpaqueMove(bool o) {
+ resource.opaque_move = o;
+ config->setValue(screenstr + "opaqueMove", resource.opaque_move);
+}
+
+
+void BScreen::saveFullMax(bool f) {
+ resource.full_max = f;
+ config->setValue(screenstr + "fullMaximization", resource.full_max);
+}
+
+
+void BScreen::saveFocusNew(bool f) {
+ resource.focus_new = f;
+ config->setValue(screenstr + "focusNewWindows", resource.focus_new);
+}
+
+
+void BScreen::saveFocusLast(bool f) {
+ resource.focus_last = f;
+ config->setValue(screenstr + "focusLastWindow", resource.focus_last);
+}
+
+
+void BScreen::saveHideToolbar(bool h) {
+ resource.hide_toolbar = h;
+ if (resource.hide_toolbar)
+ toolbar->unmapToolbar();
+ else
+ toolbar->mapToolbar();
+ config->setValue(screenstr + "hideToolbar", resource.hide_toolbar);
+}
+
+
+void BScreen::saveWorkspaces(unsigned int w) {
+ resource.workspaces = w;
+ config->setValue(screenstr + "workspaces", resource.workspaces);
+}
+
+
+void BScreen::savePlacementPolicy(int p) {
+ resource.placement_policy = p;
+ const char *placement;
+ switch (resource.placement_policy) {
+ case CascadePlacement: placement = "CascadePlacement"; break;
+ case ColSmartPlacement: placement = "ColSmartPlacement"; break;
+ case RowSmartPlacement: default: placement = "RowSmartPlacement"; break;
+ }
+ config->setValue(screenstr + "windowPlacement", placement);
+}
+
+
+void BScreen::saveEdgeSnapThreshold(int t) {
+ resource.edge_snap_threshold = t;
+ config->setValue(screenstr + "edgeSnapThreshold",
+ resource.edge_snap_threshold);
+}
+
+
+void BScreen::saveRowPlacementDirection(int d) {
+ resource.row_direction = d;
+ config->setValue(screenstr + "rowPlacementDirection",
+ resource.row_direction == LeftRight ?
+ "LeftToRight" : "RightToLeft");
+}
+
+
+void BScreen::saveColPlacementDirection(int d) {
+ resource.col_direction = d;
+ config->setValue(screenstr + "colPlacementDirection",
+ resource.col_direction == TopBottom ?
+ "TopToBottom" : "BottomToTop");
+}
+
+
+#ifdef HAVE_STRFTIME
+void BScreen::saveStrftimeFormat(const std::string& format) {
+ resource.strftime_format = format;
+ config->setValue(screenstr + "strftimeFormat", resource.strftime_format);
+}
+
+#else // !HAVE_STRFTIME
+
+void BScreen::saveDateFormat(int f) {
+ resource.date_format = f;
+ config->setValue(screenstr + "dateFormat",
+ resource.date_format == B_EuropeanDate ?
+ "European" : "American");
+}
+
+
+void BScreen::saveClock24Hour(Bool c) {
+ resource.clock24hour = c;
+ config->setValue(screenstr + "clockFormat", resource.clock24hour ? 24 : 12);
+}
+#endif // HAVE_STRFTIME
+
+
+void BScreen::saveWorkspaceNames() {
+ string names;
+ WorkspaceList::iterator it;
+ WorkspaceList::iterator last = workspacesList.end() - 1;
+ for (it = workspacesList.begin(); it != workspacesList.end(); ++it) {
+ names += (*it)->getName();
+ if (it != last)
+ names += ',';
+ }
+ config->setValue(screenstr + "workspaceNames", names);
+}
+
+
+void BScreen::save_rc(void) {
+ saveSloppyFocus(resource.sloppy_focus);
+ saveAutoRaise(resource.auto_raise);
+ saveImageDither(doImageDither());
+ saveOpaqueMove(resource.opaque_move);
+ saveFullMax(resource.full_max);
+ saveFocusNew(resource.focus_new);
+ saveFocusLast(resource.focus_last);
+ saveHideToolbar(resource.hide_toolbar);
+ saveWorkspaces(resource.workspaces);
+ savePlacementPolicy(resource.placement_policy);
+ saveEdgeSnapThreshold(resource.edge_snap_threshold);
+ saveRowPlacementDirection(resource.row_direction);
+ saveColPlacementDirection(resource.col_direction);
+#ifdef HAVE_STRFTIME
+ saveStrftimeFormat(resource.strftime_format);
+#else // !HAVE_STRFTIME
+ saveDateFormat(resource.date_format);
+ savwClock24Hour(resource.clock24hour);
+#endif // HAVE_STRFTIME
+
+ toolbar->save_rc();
+ slit->save_rc();
+}
+
+
+void BScreen::load_rc(void) {
+ std::string s;
+ bool b;
+
+ if (! config->getValue(screenstr + "fullMaximization", resource.full_max))
+ resource.full_max = false;
+
+ if (! config->getValue(screenstr + "focusNewWindows", resource.focus_new))
+ resource.focus_new = false;
+
+ if (! config->getValue(screenstr + "focusLastWindow", resource.focus_last))
+ resource.focus_last = false;
+
+ if (! config->getValue(screenstr + "workspaces", resource.workspaces))
+ resource.workspaces = 1;
+
+ if (! config->getValue(screenstr + "opaqueMove", resource.opaque_move))
+ resource.opaque_move = false;
+
+ if (! config->getValue(screenstr + "hideToolbar", resource.hide_toolbar))
+ resource.hide_toolbar = false;
+
+ if (! config->getValue(screenstr + "imageDither", b))
+ b = true;
+ image_control->setDither(b);
+
+ if (! config->getValue(screenstr + "edgeSnapThreshold",
+ resource.edge_snap_threshold))
+ resource.edge_snap_threshold = 4;
+
+ if (config->getValue(screenstr + "rowPlacementDirection", s) &&
+ s == "RightToLeft")
+ resource.row_direction = RightLeft;
+ else
+ resource.row_direction = LeftRight;
+
+ if (config->getValue(screenstr + "colPlacementDirection", s) &&
+ s == "BottomToTop")
+ resource.col_direction = BottomTop;
+ else
+ resource.col_direction = TopBottom;
+
+ removeWorkspaceNames();
+ if (config->getValue(screenstr + "workspaceNames", s)) {
+ string::const_iterator it = s.begin(), end = s.end();
+ while(1) {
+ string::const_iterator tmp = it; // current string.begin()
+ it = std::find(tmp, end, ','); // look for comma between tmp and end
+ addWorkspaceName(string(tmp, it)); // s[tmp:it]
+ if (it == end)
+ break;
+ ++it;
+ }
+ }
+
+ resource.sloppy_focus = true;
+ resource.auto_raise = false;
+ resource.click_raise = false;
+ if (config->getValue(screenstr + "focusModel", s)) {
+ if (s.find("ClickToFocus") != string::npos) {
+ resource.sloppy_focus = false;
+ } else {
+ // must be sloppy
+ if (s.find("AutoRaise") != string::npos)
+ resource.auto_raise = true;
+ if (s.find("ClickRaise") != string::npos)
+ resource.click_raise = true;
+ }
+ }
+
+ if (config->getValue(screenstr + "windowPlacement", s)) {
+ if (s == "CascadePlacement")
+ resource.placement_policy = CascadePlacement;
+ else if (s == "ColSmartPlacement")
+ resource.placement_policy = ColSmartPlacement;
+ else //if (s == "RowSmartPlacement")
+ resource.placement_policy = RowSmartPlacement;
+ } else
+ resource.placement_policy = RowSmartPlacement;
+
+#ifdef HAVE_STRFTIME
+ if (config->getValue(screenstr + "strftimeFormat", s))
+ resource.strftime_format = s;
+ else
+ resource.strftime_format = "%I:%M %p";
+#else // !HAVE_STRFTIME
+ long l;
+
+ if (config->getValue(screenstr + "dateFormat", s) && s == "European")
+ resource.date_format = B_EuropeanDate;
+ else
+ resource.date_format = B_AmericanDate;
+
+ if (! config->getValue(screenstr + "clockFormat", l))
+ l = 12;
+ resource.clock24hour = l == 24;
+#endif // HAVE_STRFTIME
+}