Browse Source

made session text customizable: font, colors, position, prefix

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@159 7c53e7cc-98ea-0310-8f1f-a0b24da60408
sip 15 years ago
parent
commit
080d166b10
5 changed files with 52 additions and 11 deletions
  1. 13 2
      THEMES
  2. 10 0
      cfg.cpp
  3. 21 9
      panel.cpp
  4. 5 0
      panel.h
  5. 3 0
      slim.conf

+ 13 - 2
THEMES

@@ -31,6 +31,12 @@ OPTIONS
     msg_x                   50%
     msg_y                   30
 
+    # Color, font, position for the session list
+    session_color           #FFFFFF
+    session_font            Verdana:size=16:bold
+    session_x               50%
+    session_y               90%
+
     # style of background: 'stretch', 'tile', 'center', 'color'
     background_style        stretch
     background_color		#FF0033
@@ -82,8 +88,8 @@ OPTIONS
 
 SHADOWS
 
-    The 'msg', 'input', 'welcome' and 'username' sections support
-    shadows; three values can be configured:
+    The 'msg', 'input', 'welcome', 'session' and 'username' sections
+    support shadows; three values can be configured:
     - color: the shadow color
     - x offset: the offset in x direction, relative to the normal text 
     - y offset: the offset in y direction, relative to the normal text
@@ -112,6 +118,11 @@ SHADOWS
     msg_shadow_xoffset 		1    
     msg_shadow_yoffset 		1    
     msg_shadow_color   		#ff00ff
+
+    # For the session:
+    session_shadow_xoffset 		1    
+    session_shadow_yoffset 		1    
+    session_shadow_color   		#ff00ff
     ----------------------------------------------------------------------
 
     

+ 10 - 0
cfg.cpp

@@ -43,6 +43,7 @@ Cfg::Cfg()
     options.insert(option("console_cmd","/usr/bin/xterm -C -fg white -bg black +sb -g %dx%d+%d+%d -fn %dx%d -T ""Console login"" -e /bin/sh -c ""/bin/cat /etc/issue; exec /bin/login"""));
     options.insert(option("screenshot_cmd","import -window root /slim.png"));
     options.insert(option("welcome_msg","Welcome to %host"));
+    options.insert(option("session_msg","Session:"));
     options.insert(option("default_user",""));
     options.insert(option("focus_password","no"));
     options.insert(option("auto_login","no"));
@@ -109,6 +110,15 @@ Cfg::Cfg()
     options.insert(option("msg_shadow_xoffset", "0"));
     options.insert(option("msg_shadow_yoffset", "0"));
     options.insert(option("msg_shadow_color","#FFFFFF"));
+    
+
+    options.insert(option("session_color","#FFFFFF"));
+    options.insert(option("session_font","Verdana:size=16:bold"));
+    options.insert(option("session_x","50%"));
+    options.insert(option("session_y","90%"));
+    options.insert(option("session_shadow_xoffset", "0"));
+    options.insert(option("session_shadow_yoffset", "0"));
+    options.insert(option("session_shadow_color","#FFFFFF"));
 
     error = "";
 

+ 21 - 9
panel.cpp

@@ -51,6 +51,10 @@ Panel::Panel(Display* dpy, int scr, Window root, Cfg* config,
     XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_color").c_str(), &msgcolor);
     XftColorAllocName(Dpy, visual, colormap, cfg->getOption("msg_shadow_color").c_str(), &msgshadowcolor);
     XftColorAllocName(Dpy, visual, colormap, cfg->getOption("intro_color").c_str(), &introcolor);
+    XftColorAllocName(Dpy, DefaultVisual(Dpy, Scr), colormap,
+                      cfg->getOption("session_color").c_str(), &sessioncolor);
+    XftColorAllocName(Dpy, DefaultVisual(Dpy, Scr), colormap,
+                      cfg->getOption("session_shadow_color").c_str(), &sessionshadowcolor);
 
     // Load properties from config / theme
     input_name_x = Cfg::string2int(cfg->getOption("input_name_x").c_str());
@@ -139,6 +143,8 @@ Panel::~Panel() {
     XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &msgcolor);
     XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &welcomecolor);
     XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &entercolor);
+    XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &sessioncolor);
+    XftColorFree (Dpy, DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr), &sessionshadowcolor);
     XFreeGC(Dpy, TextGC);
     XftFontClose(Dpy, font);
     XftFontClose(Dpy, msgfont);
@@ -566,23 +572,29 @@ void Panel::SwitchSession() {
 
 // Display session type on the screen
 void Panel::ShowSession() {
+	string msg_x, msg_y;
     XClearWindow(Dpy, Root);
-    string currsession = "Session: " + session;
+    string currsession = cfg->getOption("session_msg") + " " + session;
     XGlyphInfo extents;
-    XftDraw *draw = XftDrawCreate(Dpy, Root,
+	
+	sessionfont = XftFontOpenName(Dpy, Scr, cfg->getOption("session_font").c_str());
+    
+	XftDraw *draw = XftDrawCreate(Dpy, Root,
                                   DefaultVisual(Dpy, Scr), DefaultColormap(Dpy, Scr));
-    XftTextExtents8(Dpy, msgfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
+    XftTextExtents8(Dpy, sessionfont, reinterpret_cast<const XftChar8*>(currsession.c_str()),
                     currsession.length(), &extents);
-    int msg_x = Cfg::absolutepos("50%", XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
-    int msg_y = XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)) - extents.height -100;
+    msg_x = cfg->getOption("session_x");
+    msg_y = cfg->getOption("session_y");
+    int x = Cfg::absolutepos(msg_x, XWidthOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.width);
+    int y = Cfg::absolutepos(msg_y, XHeightOfScreen(ScreenOfDisplay(Dpy, Scr)), extents.height);
     int shadowXOffset =
-        Cfg::string2int(cfg->getOption("msg_shadow_xoffset").c_str());
+        Cfg::string2int(cfg->getOption("session_shadow_xoffset").c_str());
     int shadowYOffset =
-        Cfg::string2int(cfg->getOption("msg_shadow_yoffset").c_str());
+        Cfg::string2int(cfg->getOption("session_shadow_yoffset").c_str());
 
-    SlimDrawString8(draw, &msgcolor, msgfont, msg_x, msg_y,
+    SlimDrawString8(draw, &sessioncolor, sessionfont, x, y,
                     currsession, 
-                    &msgshadowcolor,
+                    &sessionshadowcolor,
                     shadowXOffset, shadowYOffset);
     XFlush(Dpy);
     XftDrawDestroy(draw);

+ 5 - 0
panel.h

@@ -100,6 +100,9 @@ private:
     XftFont* introfont;
     XftFont* welcomefont;
     XftColor welcomecolor;
+    XftFont* sessionfont;
+    XftColor sessioncolor;
+    XftColor sessionshadowcolor;
     XftColor welcomeshadowcolor;
     XftFont* enterfont;
     XftColor entercolor;
@@ -124,6 +127,8 @@ private:
     int welcome_y;
     int welcome_shadow_xoffset;
     int welcome_shadow_yoffset;
+    int session_shadow_xoffset;
+    int session_shadow_yoffset;
     int intro_x;
     int intro_y;
     int username_x;

+ 3 - 0
slim.conf

@@ -59,6 +59,9 @@ screenshot_cmd      import -window root /slim.png
 # welcome message. Available variables: %host, %domain
 welcome_msg         Welcome to %host
 
+# Session message. Prepended to the session name when pressing F1
+# session_msg         Session: 
+
 # shutdown / reboot messages
 shutdown_msg       The system is halting...
 reboot_msg         The system is rebooting...