Menuitem option 'check'. Draw bullet '*' on the left (ugly, but simple).

This commit is contained in:
OldMan 2010-04-10 17:14:46 +06:00
parent 590acffb62
commit c5c307deea
6 changed files with 69 additions and 8 deletions

View File

@ -79,7 +79,10 @@ func_name_list_t tmp_func_list[] =
{"menu", uicb_menu }, {"menu", uicb_menu },
{"set_client_layer", uicb_set_client_layer }, {"set_client_layer", uicb_set_client_layer },
{"set_layer", uicb_set_layer }, {"set_layer", uicb_set_layer },
{"ignore_next_client_rules", uicb_ignore_next_client_rules } {"ignore_next_client_rules", uicb_ignore_next_client_rules },
{"check_max", uicb_checkmax },
{"check_free", uicb_checkfree },
{"check_layout", uicb_checklayout }
}; };
key_name_list_t key_list[] = key_name_list_t key_list[] =
@ -378,6 +381,8 @@ conf_layout_section(char *src)
conf.layout[i].symbol = get_opt(tmp, "TILE (default)", "symbol").str; conf.layout[i].symbol = get_opt(tmp, "TILE (default)", "symbol").str;
conf.layout[i].func = name_to_func(p, layout_list); conf.layout[i].func = name_to_func(p, layout_list);
conf.layout[i].type = p;
menulayout.item[i].check = name_to_func("check_layout", func_list);
} }
cfg_set_sauv(src); cfg_set_sauv(src);
@ -558,6 +563,7 @@ conf_menu_section(char *src)
conf.menu[i].item[j].name = get_opt(tmp2, "item_wname", "name").str; conf.menu[i].item[j].name = get_opt(tmp2, "item_wname", "name").str;
conf.menu[i].item[j].func = name_to_func(get_opt(tmp2, "", "func").str, func_list); conf.menu[i].item[j].func = name_to_func(get_opt(tmp2, "", "func").str, func_list);
conf.menu[i].item[j].cmd = (!get_opt(tmp2, "", "cmd").str) ? NULL : get_opt(tmp2, "", "cmd").str; conf.menu[i].item[j].cmd = (!get_opt(tmp2, "", "cmd").str) ? NULL : get_opt(tmp2, "", "cmd").str;
conf.menu[i].item[j].check = name_to_func(get_opt(tmp2, "", "check").str, func_list);
cfg_set_sauv(tmp); cfg_set_sauv(tmp);
} }

View File

@ -916,3 +916,48 @@ layout_set_client_master(Client *c)
return; return;
} }
/** Check the selected client is max
* \param cmd uicb_t type unused
*/
Bool
uicb_checkmax(uicb_t cmd)
{
if(!sel)
return False;
if(sel->flags & MaxFlag)
return True;
return False;
}
/** Check the selected client is free
* \param cmd uicb_t type unused
*/
Bool
uicb_checkfree(uicb_t cmd)
{
if(!sel)
return False;
if(sel->flags & FreeFlag)
return True;
return False;
}
/** Check layout type
* \param cmd uicb_t type layout type
*/
Bool
uicb_checklayout(uicb_t cmd)
{
screen_get_sel();
if(!strcmp(cmd, tags[selscreen][seltag[selscreen]].layout.type))
return True;
return False;
}

View File

@ -68,7 +68,7 @@ menu_draw(Menu menu, int x, int y)
BarWindow *item[menu.nitem]; BarWindow *item[menu.nitem];
BarWindow *frame; BarWindow *frame;
width = menu_get_longer_string(menu.item, menu.nitem) + PAD; width = menu_get_longer_string(menu.item, menu.nitem) + PAD * 3;
height = menu.nitem * (INFOBARH - SHADH); height = menu.nitem * (INFOBARH - SHADH);
/* Frame barwin */ /* Frame barwin */
@ -231,18 +231,22 @@ menu_draw_item_name(Menu *menu, int item, BarWindow *winitem[])
switch(menu->align) switch(menu->align)
{ {
case MA_Left: case MA_Left:
x = PAD / 2; x = PAD * 3 / 2;
break; break;
case MA_Right: case MA_Right:
x = width - textw(menu->item[item].name) + PAD / 2; x = width - textw(menu->item[item].name) + PAD * 3 / 2;
break; break;
default: default:
case MA_Center: case MA_Center:
x = width / 2 - textw(menu->item[item].name) / 2 + PAD / 2; x = width / 2 - textw(menu->item[item].name) / 2 + PAD * 3 / 2;
break; break;
} }
barwin_draw_text(winitem[item], x, FHINFOBAR, menu->item[item].name); barwin_draw_text(winitem[item], x, FHINFOBAR, menu->item[item].name);
if(menu->item[item].check)
if(menu->item[item].check(menu->item[item].cmd))
barwin_draw_text(winitem[item], PAD / 3, FHINFOBAR, "*");
return; return;
} }

View File

@ -245,6 +245,7 @@ typedef struct
typedef struct typedef struct
{ {
char *symbol; char *symbol;
char *type;
void (*func)(int screen); void (*func)(int screen);
} Layout; } Layout;
@ -274,6 +275,7 @@ typedef struct
char *name; char *name;
void (*func)(uicb_t); void (*func)(uicb_t);
uicb_t cmd; uicb_t cmd;
Bool (*check)(uicb_t);
} MenuItem; } MenuItem;
/* Menu Struct */ /* Menu Struct */

View File

@ -339,6 +339,9 @@ void uicb_toggle_abovefc(uicb_t cmd);
void uicb_set_layer(uicb_t cmd); void uicb_set_layer(uicb_t cmd);
void uicb_set_client_layer(uicb_t cmd); void uicb_set_client_layer(uicb_t cmd);
void layout_set_client_master(Client *c); void layout_set_client_master(Client *c);
Bool uicb_checkmax(uicb_t);
Bool uicb_checkfree(uicb_t);
Bool uicb_checklayout(uicb_t);
/* init.c */ /* init.c */
void init(void); void init(void);

View File

@ -163,9 +163,10 @@
fg_focus = "#D4D4D4" bg_focus = "#003366" fg_focus = "#D4D4D4" bg_focus = "#003366"
fg_normal = "#D4D4D4" bg_normal = "#191919" fg_normal = "#D4D4D4" bg_normal = "#191919"
[item] name = "Close" func = "client_kill" [/item] # Check items: possible 'check_max' or 'check_free'.
[item] name = "Maximize" func = "toggle_max" [/item] [item] name = "Close" func = "client_kill" [/item]
[item] name = "Free" func = "toggle_free" [/item] [item] name = "Maximize" func = "toggle_max" check = "check_max" [/item]
[item] name = "Free" func = "toggle_free" check = "check_free" [/item]
[/set_menu] [/set_menu]
[/menu] [/menu]