- // load toolbar config
- readDatabaseTexture("toolbar", "Toolbar",
- &resource.tstyle.toolbar,
- BlackPixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.label", "Toolbar.Label",
- &resource.tstyle.label,
- BlackPixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel",
- &resource.tstyle.window,
- BlackPixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.button", "Toolbar.Button",
- &resource.tstyle.button,
- WhitePixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed",
- &resource.tstyle.pressed,
- BlackPixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseTexture("toolbar.clock", "Toolbar.Clock",
- &resource.tstyle.clock,
- BlackPixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor",
- &resource.tstyle.l_text,
- WhitePixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.windowLabel.textColor",
- "Toolbar.WindowLabel.TextColor",
- &resource.tstyle.w_text,
- WhitePixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor",
- &resource.tstyle.c_text,
- WhitePixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
- readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor",
- &resource.tstyle.b_pic,
- BlackPixel(getBaseDisplay()->getXDisplay(),
- getScreenNumber()));
-
- if (XrmGetResource(resource.stylerc, "toolbar.justify",
- "Toolbar.Justify", &value_type, &value)) {
- if (strstr(value.addr, "right") || strstr(value.addr, "Right"))
- resource.tstyle.justify = BScreen::RightJustify;
- else if (strstr(value.addr, "center") || strstr(value.addr, "Center"))
- resource.tstyle.justify = BScreen::CenterJustify;
- else
+
+
+ void BScreen::LoadStyle(void) {
+ Resource &conf = resource.styleconfig;
+
+ const char *sfile = openbox.getStyleFilename();
+ bool loaded = false;
+ if (sfile != NULL) {
+ conf.setFile(sfile);
+ loaded = conf.load();
+ }
+ if (!loaded) {
+ conf.setFile(DEFAULTSTYLE);
+ if (!conf.load()) {
+ fprintf(stderr, i18n(ScreenSet, ScreenDefaultStyleLoadFail,
+ "BScreen::LoadStyle(): couldn't load "
+ "default style.\n"));
+ exit(2);
+ }
+ }
+
+ std::string s;
+ long l;
+
+ // load fonts/fontsets
+
+ if (i18n.multibyte()) {
+ readDatabaseFontSet("window.font", "Window.Font",
+ &resource.wstyle.fontset);
+ readDatabaseFontSet("toolbar.font", "Toolbar.Font",
+ &resource.tstyle.fontset);
+ readDatabaseFontSet("menu.title.font", "Menu.Title.Font",
+ &resource.mstyle.t_fontset);
+ readDatabaseFontSet("menu.frame.font", "Menu.Frame.Font",
+ &resource.mstyle.f_fontset);
+
+ resource.mstyle.t_fontset_extents =
+ XExtentsOfFontSet(resource.mstyle.t_fontset);
+ resource.mstyle.f_fontset_extents =
+ XExtentsOfFontSet(resource.mstyle.f_fontset);
+ resource.tstyle.fontset_extents =
+ XExtentsOfFontSet(resource.tstyle.fontset);
+ resource.wstyle.fontset_extents =
+ XExtentsOfFontSet(resource.wstyle.fontset);
+ } else {
+ readDatabaseFont("window.font", "Window.Font",
+ &resource.wstyle.font);
+ readDatabaseFont("menu.title.font", "Menu.Title.Font",
+ &resource.mstyle.t_font);
+ readDatabaseFont("menu.frame.font", "Menu.Frame.Font",
+ &resource.mstyle.f_font);
+ readDatabaseFont("toolbar.font", "Toolbar.Font",
+ &resource.tstyle.font);
+ }
+
+ // load window config
+ readDatabaseTexture("window.title.focus", "Window.Title.Focus",
+ &resource.wstyle.t_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.title.unfocus", "Window.Title.Unfocus",
+ &resource.wstyle.t_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.label.focus", "Window.Label.Focus",
+ &resource.wstyle.l_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.label.unfocus", "Window.Label.Unfocus",
+ &resource.wstyle.l_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.handle.focus", "Window.Handle.Focus",
+ &resource.wstyle.h_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.handle.unfocus", "Window.Handle.Unfocus",
+ &resource.wstyle.h_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.grip.focus", "Window.Grip.Focus",
+ &resource.wstyle.g_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.grip.unfocus", "Window.Grip.Unfocus",
+ &resource.wstyle.g_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.button.focus", "Window.Button.Focus",
+ &resource.wstyle.b_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.button.unfocus", "Window.Button.Unfocus",
+ &resource.wstyle.b_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("window.button.pressed", "Window.Button.Pressed",
+ &resource.wstyle.b_pressed,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.frame.focusColor",
+ "Window.Frame.FocusColor",
+ &resource.wstyle.f_focus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.frame.unfocusColor",
+ "Window.Frame.UnfocusColor",
+ &resource.wstyle.f_unfocus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.label.focus.textColor",
+ "Window.Label.Focus.TextColor",
+ &resource.wstyle.l_text_focus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.label.unfocus.textColor",
+ "Window.Label.Unfocus.TextColor",
+ &resource.wstyle.l_text_unfocus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.button.focus.picColor",
+ "Window.Button.Focus.PicColor",
+ &resource.wstyle.b_pic_focus,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("window.button.unfocus.picColor",
+ "Window.Button.Unfocus.PicColor",
+ &resource.wstyle.b_pic_unfocus,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+
+ if (conf.getValue("window.justify", "Window.Justify", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.wstyle.justify = BScreen::RightJustify;
+ else if (0 == strncasecmp(s.c_str(), "center", s.length()))
+ resource.wstyle.justify = BScreen::CenterJustify;
+ else
+ resource.wstyle.justify = BScreen::LeftJustify;
+ } else
+ resource.wstyle.justify = BScreen::LeftJustify;
+
+ // load toolbar config
+ readDatabaseTexture("toolbar", "Toolbar",
+ &resource.tstyle.toolbar,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.label", "Toolbar.Label",
+ &resource.tstyle.label,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.windowLabel", "Toolbar.WindowLabel",
+ &resource.tstyle.window,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.button", "Toolbar.Button",
+ &resource.tstyle.button,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.button.pressed", "Toolbar.Button.Pressed",
+ &resource.tstyle.pressed,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseTexture("toolbar.clock", "Toolbar.Clock",
+ &resource.tstyle.clock,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.label.textColor", "Toolbar.Label.TextColor",
+ &resource.tstyle.l_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.windowLabel.textColor",
+ "Toolbar.WindowLabel.TextColor",
+ &resource.tstyle.w_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.clock.textColor", "Toolbar.Clock.TextColor",
+ &resource.tstyle.c_text,
+ WhitePixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+ readDatabaseColor("toolbar.button.picColor", "Toolbar.Button.PicColor",
+ &resource.tstyle.b_pic,
+ BlackPixel(getBaseDisplay().getXDisplay(),
+ getScreenNumber()));
+
+ if (conf.getValue("toolbar.justify", "Toolbar.Justify", s)) {
+ if (0 == strncasecmp(s.c_str(), "right", s.length()))
+ resource.tstyle.justify = BScreen::RightJustify;
+ else if (0 == strncasecmp(s.c_str(), "center", s.length()))
+ resource.tstyle.justify = BScreen::CenterJustify;
+ else
+ resource.tstyle.justify = BScreen::LeftJustify;
+ } else