diff --git a/apps/file-browser.c b/apps/file-browser.c index b06dc9a9..b97a465a 100644 --- a/apps/file-browser.c +++ b/apps/file-browser.c @@ -80,6 +80,10 @@ static int last_click_offset = -1; /* So that clicking two different things quic static struct TT_Font * tt_font_thin = NULL; static struct TT_Font * tt_font_bold = NULL; +static struct MenuEntry * _menu_entry_show_icons = NULL; +static struct MenuEntry * _menu_entry_show_tiles = NULL; +static struct MenuEntry * _menu_entry_show_list = NULL; + /** * Navigation input box */ @@ -1429,7 +1433,7 @@ static void _menu_action_edit(struct MenuEntry * self) { /* View > (Show/Hide) Hidden Files */ static void _menu_action_toggle_hidden(struct MenuEntry * self) { show_hidden = !show_hidden; - menu_update_title(self, show_hidden ? "Hide Hidden Files" : "Show Hidden Files"); + menu_update_icon(self, show_hidden ? "check" : NULL); _menu_action_refresh(NULL); } @@ -1487,6 +1491,9 @@ static void _menu_action_view_mode(struct MenuEntry * entry) { mode = VIEW_MODE_LIST; } set_view_mode(mode); + menu_update_icon(_menu_entry_show_icons, view_mode == VIEW_MODE_ICONS ? "check" : NULL); + menu_update_icon(_menu_entry_show_tiles, view_mode == VIEW_MODE_TILES ? "check" : NULL); + menu_update_icon(_menu_entry_show_list, view_mode == VIEW_MODE_LIST ? "check" : NULL); reinitialize_contents(); redraw_window(); } @@ -1808,9 +1815,9 @@ int main(int argc, char * argv[]) { m = menu_create(); menu_insert(m, menu_create_normal("refresh",NULL,"Refresh", _menu_action_refresh)); menu_insert(m, menu_create_separator()); - menu_insert(m, menu_create_normal(NULL,"icons","Show Icons", _menu_action_view_mode)); - menu_insert(m, menu_create_normal(NULL,"tiles","Show Tiles", _menu_action_view_mode)); - menu_insert(m, menu_create_normal(NULL,"list","Show List", _menu_action_view_mode)); + menu_insert(m, (_menu_entry_show_icons = menu_create_normal(view_mode == VIEW_MODE_ICONS ? "check" : NULL,"icons","Show Icons", _menu_action_view_mode))); + menu_insert(m, (_menu_entry_show_tiles = menu_create_normal(view_mode == VIEW_MODE_TILES ? "check" : NULL,"tiles","Show Tiles", _menu_action_view_mode))); + menu_insert(m, (_menu_entry_show_list = menu_create_normal(view_mode == VIEW_MODE_LIST ? "check" : NULL,"list", "Show List", _menu_action_view_mode))); menu_insert(m, menu_create_separator()); menu_insert(m, menu_create_normal(NULL,NULL,"Show Hidden Files", _menu_action_toggle_hidden)); menu_set_insert(menu_bar.set, "view", m); diff --git a/apps/terminal.c b/apps/terminal.c index dd103622..c8e6158f 100644 --- a/apps/terminal.c +++ b/apps/terminal.c @@ -2148,20 +2148,20 @@ static void _menu_action_hide_borders(struct MenuEntry * self) { _no_frame = !(_no_frame); window_width = window->width - decor_width * (!_no_frame); window_height = window->height - (decor_height + menu_bar_height) * (!_no_frame); - menu_update_title(_menu_toggle_borders_context, _no_frame ? "Show borders" : "Hide borders"); - menu_update_title(_menu_toggle_borders_bar, _no_frame ? "Show borders" : "Hide borders"); + menu_update_icon(_menu_toggle_borders_context, _no_frame ? NULL : "check"); + menu_update_icon(_menu_toggle_borders_bar, _no_frame ? NULL : "check"); reinit(); } static void _menu_action_toggle_tt(struct MenuEntry * self) { _use_aa = !(_use_aa); - menu_update_title(self, _use_aa ? "Bitmap font" : "Anti-aliased font"); + menu_update_icon(self, _use_aa ? NULL : "check"); reinit(); } static void _menu_action_toggle_free_size(struct MenuEntry * self) { _free_size = !(_free_size); - menu_update_title(self, _free_size ? "Snap to Cell Size" : "Freely Resize"); + menu_update_icon(self, _free_size ? NULL : "check"); } static void _menu_action_show_about(struct MenuEntry * self) { @@ -2321,7 +2321,7 @@ int main(int argc, char ** argv) { menu_insert(menu_right_click, _menu_paste); if (!_fullscreen) { menu_insert(menu_right_click, menu_create_separator()); - _menu_toggle_borders_context = menu_create_normal(NULL, NULL, _no_frame ? "Show borders" : "Hide borders", _menu_action_hide_borders); + _menu_toggle_borders_context = menu_create_normal(_no_frame ? NULL : "check", NULL, "Show borders", _menu_action_hide_borders); menu_insert(menu_right_click, _menu_toggle_borders_context); } menu_insert(menu_right_click, menu_create_separator()); @@ -2347,11 +2347,11 @@ int main(int argc, char ** argv) { menu_set_insert(terminal_menu_bar.set, "zoom", m); m = menu_create(); - _menu_toggle_borders_bar = menu_create_normal(NULL, NULL, _no_frame ? "Show borders" : "Hide borders", _menu_action_hide_borders); + _menu_toggle_borders_bar = menu_create_normal(_no_frame ? NULL : "check", NULL, "Show borders", _menu_action_hide_borders); menu_insert(m, _menu_toggle_borders_bar); menu_insert(m, menu_create_submenu(NULL,"zoom","Set zoom...")); - menu_insert(m, menu_create_normal(NULL, NULL, _use_aa ? "Bitmap font" : "Anti-aliased font", _menu_action_toggle_tt)); - menu_insert(m, menu_create_normal(NULL, NULL, _free_size ? "Snap to Cell Size" : "Freely Resize", _menu_action_toggle_free_size)); + menu_insert(m, menu_create_normal(_use_aa ? NULL : "check", NULL, "Bitmap font", _menu_action_toggle_tt)); + menu_insert(m, menu_create_normal(_free_size ? NULL : "check", NULL, "Snap to Cell Size", _menu_action_toggle_free_size)); menu_insert(m, menu_create_separator()); menu_insert(m, menu_create_normal(NULL, NULL, "Redraw", _menu_action_redraw)); menu_set_insert(terminal_menu_bar.set, "view", m); diff --git a/base/usr/include/toaru/menu.h b/base/usr/include/toaru/menu.h index 811a939c..2dcd9d4f 100644 --- a/base/usr/include/toaru/menu.h +++ b/base/usr/include/toaru/menu.h @@ -92,6 +92,7 @@ extern struct MenuSet * menu_set_create(void); extern void menu_set_insert(struct MenuSet * set, char * action, struct MenuList * menu); extern void menu_update_title(struct MenuEntry * self, char * new_title); extern void menu_force_redraw(struct MenuList * menu); +extern void menu_update_icon(struct MenuEntry * self, char * newIcon); #define MENU_FLAG_BUBBLE_CENTER (1 << 0) #define MENU_FLAG_BUBBLE_LEFT (1 << 1) diff --git a/base/usr/share/icons/16/check.png b/base/usr/share/icons/16/check.png new file mode 100644 index 00000000..d6228394 Binary files /dev/null and b/base/usr/share/icons/16/check.png differ diff --git a/lib/menu.c b/lib/menu.c index a85c02f1..524c4333 100644 --- a/lib/menu.c +++ b/lib/menu.c @@ -266,6 +266,25 @@ void menu_update_title(struct MenuEntry * self, char * new_title) { } } +void menu_update_icon(struct MenuEntry * self, char * newIcon) { + switch (self->_type) { + case MenuEntry_Normal: { + struct MenuEntry_Normal * _self = (struct MenuEntry_Normal *)self; + if (_self->icon) free(_self->icon); + _self->icon = newIcon ? strdup(newIcon) : NULL; + break; + } + case MenuEntry_Submenu: { + struct MenuEntry_Submenu * _self = (struct MenuEntry_Submenu *)self; + if (_self->icon) free(_self->icon); + _self->icon = newIcon ? strdup(newIcon) : NULL; + break; + } + default: + break; + } +} + void menu_free_entry(struct MenuEntry * self) { switch (self->_type) { case MenuEntry_Normal: {