+void BScreen::setSloppyFocus(bool b) {
+ resource.sloppy_focus = b;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
+ config.setValue(s.str(),
+ (resource.sloppy_focus ?
+ (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
+ : "ClickToFocus"));
+}
+
+void BScreen::setAutoRaise(bool a) {
+ resource.auto_raise = a;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusModel" << ends;
+ config.setValue(s.str(),
+ (resource.sloppy_focus ?
+ (resource.auto_raise ? "AutoRaiseSloppyFocus" : "SloppyFocus")
+ : "ClickToFocus"));
+}
+
+void BScreen::setImageDither(bool d) {
+ resource.image_dither = d;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".imageDither" << ends;
+ config.setValue(s.str(), resource.image_dither);
+}
+
+void BScreen::setOpaqueMove(bool o) {
+ resource.opaque_move = o;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".opaqueMove" << ends;
+ config.setValue(s.str(), resource.opaque_move);
+}
+
+void BScreen::setFullMax(bool f) {
+ resource.full_max = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".fullMaximization" << ends;
+ config.setValue(s.str(), resource.full_max);
+}
+
+void BScreen::setFocusNew(bool f) {
+ resource.focus_new = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusNewWindows" << ends;
+ config.setValue(s.str(), resource.focus_new);
+}
+
+void BScreen::setFocusLast(bool f) {
+ resource.focus_last = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".focusLastWindow" << ends;
+ config.setValue(s.str(), resource.focus_last);
+}
+
+void BScreen::setWindowZones(int z) {
+ resource.zones = z;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".windowZones" << ends;
+ config.setValue(s.str(), resource.zones);
+}
+
+void BScreen::setWorkspaceCount(int w) {
+ resource.workspaces = w;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".workspaces" << ends;
+ config.setValue(s.str(), resource.workspaces);
+}
+
+void BScreen::setPlacementPolicy(int p) {
+ resource.placement_policy = p;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".windowPlacement" << ends;
+ const char *placement;
+ switch (resource.placement_policy) {
+ case CascadePlacement: placement = "CascadePlacement"; break;
+ case BestFitPlacement: placement = "BestFitPlacement"; break;
+ case ColSmartPlacement: placement = "ColSmartPlacement"; break;
+ default:
+ case RowSmartPlacement: placement = "RowSmartPlacement"; break;
+ }
+ config.setValue(s.str(), placement);
+}
+
+void BScreen::setEdgeSnapThreshold(int t) {
+ resource.edge_snap_threshold = t;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".edgeSnapThreshold" << ends;
+ config.setValue(s.str(), resource.edge_snap_threshold);
+}
+
+void BScreen::setRowPlacementDirection(int d) {
+ resource.row_direction = d;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".rowPlacementDirection" <<
+ ends;
+ config.setValue(s.str(),
+ resource.row_direction == LeftRight ?
+ "LeftToRight" : "RightToLeft");
+}
+
+void BScreen::setColPlacementDirection(int d) {
+ resource.col_direction = d;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".colPlacementDirection" <<
+ ends;
+ config.setValue(s.str(),
+ resource.col_direction == TopBottom ?
+ "TopToBottom" : "BottomToTop");
+}
+
+void BScreen::setRootCommand(const char *cmd) {
+if (resource.root_command != NULL)
+ delete [] resource.root_command;
+ if (cmd != NULL)
+ resource.root_command = bstrdup(cmd);
+ else
+ resource.root_command = NULL;
+ // this doesn't save to the Resources config because it can't be changed
+ // inside Openbox, and this way we dont add an empty command which would over-
+ // ride the styles commend when none has been specified
+}
+#ifdef HAVE_STRFTIME
+void BScreen::setStrftimeFormat(const char *f) {
+ if (resource.strftime_format != NULL)
+ delete [] resource.strftime_format;
+
+ resource.strftime_format = bstrdup(f);
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".strftimeFormat" << ends;
+ config.setValue(s.str(), resource.strftime_format);
+}
+
+#else // !HAVE_STRFTIME
+void BScreen::setDateFormat(int f) {
+ resource.date_format = f;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".dateFormat" << ends;
+ config.setValue(s.str(), resource.date_format == B_EuropeanDate ?
+ "European" : "American");
+}
+
+void BScreen::setClock24Hour(Bool c) {
+ resource.clock24hour = c;
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".clockFormat" << ends;
+ config.setValue(s.str(), resource.clock24hour ? 24 : 12);
+}
+#endif // HAVE_STRFTIME
+
+void BScreen::setHideToolbar(bool b) {
+ resource.hide_toolbar = b;
+ if (resource.hide_toolbar)
+ getToolbar()->unMapToolbar();
+ else
+ getToolbar()->mapToolbar();
+ ostrstream s;
+ s << "session.screen" << getScreenNumber() << ".hideToolbar" << ends;
+ config.setValue(s.str(), resource.hide_toolbar ? "True" : "False");
+}
+
+void BScreen::saveWorkspaceNames() {
+ ostrstream rc, names;
+
+ for (int i = 0; i < resource.workspaces; i++) {
+ Workspace *w = getWorkspace(i);
+ if (w != NULL) {
+ names << w->getName();
+ if (i < resource.workspaces-1)
+ names << ',';
+ }
+ }
+ names << ends;
+
+ rc << "session.screen" << getScreenNumber() << ".workspaceNames" << ends;
+ config.setValue(rc.str(), names.str());
+}
+
+void BScreen::save() {
+ setSloppyFocus(resource.sloppy_focus);
+ setAutoRaise(resource.auto_raise);
+ setImageDither(resource.image_dither);
+ setOpaqueMove(resource.opaque_move);
+ setFullMax(resource.full_max);
+ setFocusNew(resource.focus_new);
+ setFocusLast(resource.focus_last);
+ setWindowZones(resource.zones);
+ setWorkspaceCount(resource.workspaces);
+ setPlacementPolicy(resource.placement_policy);
+ setEdgeSnapThreshold(resource.edge_snap_threshold);
+ setRowPlacementDirection(resource.row_direction);
+ setColPlacementDirection(resource.col_direction);
+ setRootCommand(resource.root_command);
+#ifdef HAVE_STRFTIME
+ // it deletes the current value before setting the new one, so we have to
+ // duplicate the current value.
+ std::string s = resource.strftime_format;
+ setStrftimeFormat(s.c_str());
+#else // !HAVE_STRFTIME
+ setDateFormat(resource.date_format);
+ setClock24Hour(resource.clock24hour);
+#endif // HAVE_STRFTIME
+ setHideToolbar(resource.hide_toolbar);
+}
+