rename statusbar uicb and add uicb_statusbar_set_position

This commit is contained in:
Julien Danjou 2007-12-14 15:52:52 +01:00
parent 14809f80e4
commit 84bb954004
5 changed files with 37 additions and 22 deletions

View File

@ -151,7 +151,7 @@ keys
{ {
modkey = {"Mod4"} modkey = {"Mod4"}
key = "b" key = "b"
command = "togglebar" command = "statusbar_toggle"
} }
key key
{ {

View File

@ -463,20 +463,9 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
awesomeconf->screens[screen].colors_selected[ColFG] = initxcolor(awesomeconf->display, get_phys_screen(awesomeconf->display, screen), cfg_getstr(cfg_colors, "focus_fg")); awesomeconf->screens[screen].colors_selected[ColFG] = initxcolor(awesomeconf->display, get_phys_screen(awesomeconf->display, screen), cfg_getstr(cfg_colors, "focus_fg"));
/* Statusbar */ /* Statusbar */
tmp = cfg_getstr(cfg_statusbar, "position"); awesomeconf->screens[screen].statusbar.position =
awesomeconf->screens[screen].statusbar.dposition =
if(tmp && !a_strncmp(tmp, "off", 6)) get_statusbar_position_from_str(cfg_getstr(cfg_statusbar, "position"));
awesomeconf->screens[screen].statusbar.dposition = BarOff;
else if(tmp && !a_strncmp(tmp, "bottom", 6))
awesomeconf->screens[screen].statusbar.dposition = BarBot;
else if(tmp && !a_strncmp(tmp, "right", 5))
awesomeconf->screens[screen].statusbar.dposition = BarRight;
else if(tmp && !a_strncmp(tmp, "left", 4))
awesomeconf->screens[screen].statusbar.dposition = BarLeft;
else
awesomeconf->screens[screen].statusbar.dposition = BarTop;
awesomeconf->screens[screen].statusbar.position = awesomeconf->screens[screen].statusbar.dposition;
/* Layouts */ /* Layouts */
awesomeconf->screens[screen].nlayouts = cfg_size(cfg_layouts, "layout"); awesomeconf->screens[screen].nlayouts = cfg_size(cfg_layouts, "layout");

View File

@ -276,8 +276,22 @@ updatebarpos(Display *disp, Statusbar statusbar, Padding *padding)
while(XCheckMaskEvent(disp, EnterWindowMask, &ev)); while(XCheckMaskEvent(disp, EnterWindowMask, &ev));
} }
int
get_statusbar_position_from_str(const char * pos)
{
if(!a_strncmp(pos, "off", 3))
return BarOff;
else if(!a_strncmp(pos, "bottom", 6))
return BarBot;
else if(!a_strncmp(pos, "right", 5))
return BarRight;
else if(!a_strncmp(pos, "left", 4))
return BarLeft;
return BarTop;
}
void void
uicb_togglebar(awesome_config *awesomeconf, uicb_statusbar_toggle(awesome_config *awesomeconf,
int screen, int screen,
const char *arg __attribute__ ((unused))) const char *arg __attribute__ ((unused)))
{ {
@ -289,9 +303,19 @@ uicb_togglebar(awesome_config *awesomeconf,
arrange(awesomeconf, screen); arrange(awesomeconf, screen);
} }
void
uicb_statusbar_set_position(awesome_config *awesomeconf,
int screen,
const char *arg)
{
awesomeconf->screens[screen].statusbar.dposition =
awesomeconf->screens[screen].statusbar.position =
get_statusbar_position_from_str(arg);
updatebarpos(awesomeconf->display, awesomeconf->screens[screen].statusbar, &awesomeconf->screens[screen].padding);
}
void void
uicb_setstatustext(awesome_config *awesomeconf, int screen, const char *arg) uicb_statusbar_set_text(awesome_config *awesomeconf, int screen, const char *arg)
{ {
if(!arg) if(!arg)
return; return;

View File

@ -26,10 +26,12 @@
void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *, Layout *, int, Padding *); void initstatusbar(Display *, int, Statusbar *, Cursor, XftFont *, Layout *, int, Padding *);
void drawstatusbar(awesome_config *, int); void drawstatusbar(awesome_config *, int);
int get_statusbar_position_from_str(const char *);
void updatebarpos(Display *, Statusbar, Padding *); void updatebarpos(Display *, Statusbar, Padding *);
UICB_PROTO(uicb_togglebar); UICB_PROTO(uicb_statusbar_toggle);
UICB_PROTO(uicb_setstatustext); UICB_PROTO(uicb_statusbar_set_position);
UICB_PROTO(uicb_statusbar_set_text);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99

6
uicb.c
View File

@ -67,9 +67,9 @@ const NameFuncLink UicbList[] = {
/* awesome.c */ /* awesome.c */
{"quit", uicb_quit}, {"quit", uicb_quit},
/* statusbar.c */ /* statusbar.c */
{"togglebar", uicb_togglebar}, {"statusbar_toggle", uicb_statusbar_toggle},
/* config.c */ {"statusbar_set_position", uicb_statusbar_set_position},
{"setstatustext", uicb_setstatustext}, {"statusbar_set_text", uicb_statusbar_set_text},
/* mouse.c */ /* mouse.c */
{"client_movemouse", uicb_client_movemouse}, {"client_movemouse", uicb_client_movemouse},
{"client_resizemouse", uicb_client_resizemouse}, {"client_resizemouse", uicb_client_resizemouse},