diff options
Diffstat (limited to 'src/Theme.cc')
-rw-r--r-- | src/Theme.cc | 86 |
1 files changed, 48 insertions, 38 deletions
diff --git a/src/Theme.cc b/src/Theme.cc index c57c850..4caa734 100644 --- a/src/Theme.cc +++ b/src/Theme.cc | |||
@@ -41,6 +41,8 @@ | |||
41 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 41 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
42 | // DEALINGS IN THE SOFTWARE. | 42 | // DEALINGS IN THE SOFTWARE. |
43 | 43 | ||
44 | // $Id: Theme.cc,v 1.8 2002/01/08 00:12:51 fluxgen Exp $ | ||
45 | |||
44 | #ifndef _GNU_SOURCE | 46 | #ifndef _GNU_SOURCE |
45 | #define _GNU_SOURCE | 47 | #define _GNU_SOURCE |
46 | #endif // _GNU_SOURCE | 48 | #endif // _GNU_SOURCE |
@@ -49,31 +51,35 @@ | |||
49 | # include "config.h" | 51 | # include "config.h" |
50 | #endif //HAVE_CONFIG_H_ | 52 | #endif //HAVE_CONFIG_H_ |
51 | 53 | ||
52 | #ifdef HAVE_CTYPE_H | ||
53 | # include <ctype.h> | ||
54 | #endif // HAVE_CTYPE_H | ||
55 | |||
56 | #include "Theme.hh" | 54 | #include "Theme.hh" |
55 | |||
57 | #include "i18n.hh" | 56 | #include "i18n.hh" |
58 | #include "Basemenu.hh" | 57 | #include "Basemenu.hh" |
59 | #include "fluxbox.hh" | ||
60 | #include "StringUtil.hh" | 58 | #include "StringUtil.hh" |
61 | 59 | ||
62 | #include <X11/Xresource.h> | 60 | #include <X11/Xresource.h> |
63 | #include <stdio.h> | ||
64 | #include <stdarg.h> | ||
65 | #include <string.h> | ||
66 | 61 | ||
67 | #ifndef FONT_ELEMENT_SIZE | 62 | #ifdef HAVE_CTYPE_H |
68 | # define FONT_ELEMENT_SIZE 50 | 63 | # include <ctype.h> |
69 | #endif // FONT_ELEMENT_SIZE | 64 | #endif // HAVE_CTYPE_H |
70 | 65 | ||
71 | Theme::Theme(Display *display, Window rootwindow, Colormap colormap, int screennum, BImageControl *ic, const char *filename) { | 66 | #include <cstdio> |
67 | #include <cstdarg> | ||
68 | #include <string> | ||
69 | #include <strstream> | ||
70 | #include <iostream> | ||
71 | using namespace std; | ||
72 | |||
73 | |||
74 | Theme::Theme(Display *display, Window rootwindow, Colormap colormap, | ||
75 | int screennum, BImageControl *ic, const char *filename, const char *rootcommand): | ||
76 | m_imagecontrol(ic), | ||
77 | m_display(display), | ||
78 | m_colormap(colormap), | ||
79 | m_screennum(screennum), | ||
80 | m_rootcommand(rootcommand) | ||
81 | { | ||
72 | 82 | ||
73 | m_screennum = screennum; | ||
74 | m_display = display; | ||
75 | m_imagecontrol = ic; | ||
76 | m_colormap = colormap; | ||
77 | //default settings | 83 | //default settings |
78 | m_menustyle.titlefont.set = m_menustyle.framefont.set = m_toolbarstyle.font.set = | 84 | m_menustyle.titlefont.set = m_menustyle.framefont.set = m_toolbarstyle.font.set = |
79 | m_windowstyle.font.set = m_windowstyle.tab.font.set = 0; | 85 | m_windowstyle.font.set = m_windowstyle.tab.font.set = 0; |
@@ -285,7 +291,7 @@ void Theme::freeToolbarStyle() { | |||
285 | //---------- load ------------ | 291 | //---------- load ------------ |
286 | // Loads a theme from a file | 292 | // Loads a theme from a file |
287 | //---------------------------- | 293 | //---------------------------- |
288 | void Theme::load(const char *filename) { | 294 | void Theme::load(const char *filename){ |
289 | m_database = XrmGetFileDatabase(filename); | 295 | m_database = XrmGetFileDatabase(filename); |
290 | if (!m_database) | 296 | if (!m_database) |
291 | m_database = XrmGetFileDatabase(DEFAULTSTYLE); | 297 | m_database = XrmGetFileDatabase(DEFAULTSTYLE); |
@@ -648,39 +654,42 @@ void Theme::loadToolbarStyle() { | |||
648 | void Theme::loadRootCommand() { | 654 | void Theme::loadRootCommand() { |
649 | XrmValue value; | 655 | XrmValue value; |
650 | char *value_type; | 656 | char *value_type; |
651 | Fluxbox *fb=Fluxbox::instance(); | ||
652 | 657 | ||
653 | const char *root_cmd=fb->getRootCommand(); | 658 | if (m_rootcommand.size()) { |
654 | |||
655 | if (root_cmd) { | ||
656 | #ifndef __EMX__ | 659 | #ifndef __EMX__ |
657 | const int display_strlen = 1024; | 660 | //const int display_strlen = 1024; |
658 | char displaystring[display_strlen]; | 661 | //char displaystring[display_strlen]; |
659 | snprintf(displaystring, display_strlen, "DISPLAY=%s%d", | 662 | strstream displaystring; |
660 | DisplayString(m_display), m_screennum); | 663 | displaystring<<"DISPLAY="<<DisplayString(m_display)<<m_screennum; |
664 | cerr<<__FILE__<<"("<<__LINE__<<"): displaystring="<<displaystring.str()<<endl; | ||
665 | //snprintf(displaystring, display_strlen, "DISPLAY=%s%d", | ||
666 | //DisplayString(m_display), m_screennum); | ||
661 | 667 | ||
662 | bexec(root_cmd, displaystring); | 668 | bexec(m_rootcommand.c_str(), displaystring.str()); |
663 | #else // __EMX__ | 669 | #else // __EMX__ |
664 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", root_cmd, NULL); | 670 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", m_rootcommand.c_str(), NULL); |
665 | #endif // !__EMX__ | 671 | #endif // !__EMX__ |
666 | 672 | ||
667 | #ifdef DEBUG | 673 | #ifdef DEBUG |
668 | fprintf(stderr, "rootcommand:%s\n", root_cmd); | 674 | cerr<<__FILE__<<"("<<__LINE__<<"): Rootcommand: "<<m_rootcommand<<endl; |
669 | #endif //!DEBUG | 675 | #endif //!DEBUG |
670 | 676 | ||
671 | } else if (XrmGetResource(m_database, "rootCommand", | 677 | } else if (XrmGetResource(m_database, "rootCommand", |
672 | "RootCommand", &value_type, &value)) { | 678 | "RootCommand", &value_type, &value)) { |
673 | #ifndef __EMX__ | 679 | #ifndef __EMX__ |
674 | const int display_strlen = 1024; | 680 | //const int display_strlen = 1024; |
675 | char displaystring[display_strlen]; | 681 | //char displaystring[display_strlen]; |
676 | 682 | strstream displaystring; | |
677 | snprintf(displaystring, display_strlen, "DISPLAY=%s%d", | 683 | displaystring<<"DISPLAY="<<DisplayString(m_display)<<m_screennum; |
678 | DisplayString(m_display), m_screennum); | 684 | cerr<<__FILE__<<"("<<__LINE__<<"): displaystring="<<displaystring.str()<<endl; |
685 | //snprintf(displaystring, display_strlen, "DISPLAY=%s%d", | ||
686 | // DisplayString(m_display), m_screennum); | ||
679 | 687 | ||
680 | bexec(value.addr, displaystring); | 688 | bexec(value.addr, displaystring.str()); |
681 | #else // __EMX__ | 689 | #else // __EMX__ |
682 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", value.addr, NULL); | 690 | spawnlp(P_NOWAIT, "cmd.exe", "cmd.exe", "/c", value.addr, NULL); |
683 | #endif // !__EMX__ | 691 | #endif // !__EMX__ |
692 | |||
684 | #ifdef DEBUG | 693 | #ifdef DEBUG |
685 | fprintf(stderr, "rootcommand:%s\n", value.addr); | 694 | fprintf(stderr, "rootcommand:%s\n", value.addr); |
686 | #endif | 695 | #endif |
@@ -1049,6 +1058,7 @@ void Theme::reconfigure() { | |||
1049 | 1058 | ||
1050 | XFontSet Theme::createFontSet(char *fontname) { | 1059 | XFontSet Theme::createFontSet(char *fontname) { |
1051 | XFontSet fs; | 1060 | XFontSet fs; |
1061 | const int FONT_ELEMENT_SIZE=50; | ||
1052 | char **missing, *def = "-"; | 1062 | char **missing, *def = "-"; |
1053 | int nmissing, pixel_size = 0, buf_size = 0; | 1063 | int nmissing, pixel_size = 0, buf_size = 0; |
1054 | char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; | 1064 | char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; |