diff options
author | James Booth <boothj5@gmail.com> | 2018-03-08 22:27:49 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2018-03-08 22:27:49 +0000 |
commit | 720dce866eb759a7b5ecdaff7c7d9ceeb6e2487c (patch) | |
tree | 8f9e072c17a0d8ecb8acefd97f304015442fd694 /src/ui | |
parent | 119c5650cf1b40d3074faae1a280e8d3dfbedc03 (diff) | |
download | profani-tty-720dce866eb759a7b5ecdaff7c7d9ceeb6e2487c.tar.gz |
Add prefs for empty tabs and tab names
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/console.c | 16 | ||||
-rw-r--r-- | src/ui/statusbar.c | 25 | ||||
-rw-r--r-- | src/ui/ui.h | 1 | ||||
-rw-r--r-- | src/ui/window.c | 7 |
4 files changed, 36 insertions, 13 deletions
diff --git a/src/ui/console.c b/src/ui/console.c index 55bba1c5..84e7b59b 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1748,6 +1748,22 @@ cons_inpblock_setting(void) } void +cons_statusbar_setting(void) +{ + cons_winpos_setting(); + if (prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY)) { + cons_show("Show empty tabs (/statusbar) : ON"); + } else { + cons_show("Show empty tabs (/statusbar) : OFF"); + } + if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME)) { + cons_show("Show tab names (/statusbar) : ON"); + } else { + cons_show("Show tab names (/statusbar) : OFF"); + } +} + +void cons_winpos_setting(void) { ProfWinPlacement *placement = prefs_get_win_placement(); diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index ff264202..ca8e8a47 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -63,9 +63,7 @@ typedef struct _status_bar_t { int current_tab; } StatusBar; -#define MAX_TABS 5 -#define SHOW_EMPTY_TABS FALSE -#define SHOW_NAME TRUE +#define MAX_TABS 10 static GTimeZone *tz; static StatusBar *statusbar; @@ -229,8 +227,6 @@ status_bar_clear(void) statusbar->message = NULL; } - werase(statusbar_win); - _status_bar_draw(); } @@ -248,8 +244,11 @@ status_bar_clear_message(void) static int _tabs_width(void) { - if (SHOW_NAME) { - if (SHOW_EMPTY_TABS) { + gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY); + gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME); + + if (show_name) { + if (show_empty) { int width = 4; int i = 0; for (i = 1; i <= MAX_TABS; i++) { @@ -275,7 +274,7 @@ _tabs_width(void) return width; } } else { - if (SHOW_EMPTY_TABS) { + if (show_empty) { return MAX_TABS * 3 + 4; } else { return g_hash_table_size(statusbar->tabs) * 3 + 4; @@ -286,6 +285,7 @@ _tabs_width(void) static void _status_bar_draw(void) { + werase(statusbar_win); wbkgd(statusbar_win, theme_attrs(THEME_STATUS_TEXT)); int pos = 1; @@ -337,12 +337,15 @@ _status_bar_draw(void) pos = cols - _tabs_width(); int bracket_attrs = theme_attrs(THEME_STATUS_BRACKET); + gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY); + gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME); + int i = 1; for (i = 1; i <= MAX_TABS; i++) { int display_num = i == 10 ? 0 : i; StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); - if (tab || (tab == NULL && SHOW_EMPTY_TABS)) { + if (tab || (tab == NULL && show_empty)) { wattron(statusbar_win, bracket_attrs); if (i == statusbar->current_tab) { mvwprintw(statusbar_win, 0, pos, "-"); @@ -356,7 +359,7 @@ _status_bar_draw(void) int status_attrs = theme_attrs(THEME_STATUS_NEW); wattron(statusbar_win, status_attrs); mvwprintw(statusbar_win, 0, pos, "%d", display_num); - if (SHOW_NAME) { + if (show_name) { pos++; mvwprintw(statusbar_win, 0, pos, ":"); pos++; @@ -368,7 +371,7 @@ _status_bar_draw(void) int status_attrs = theme_attrs(THEME_STATUS_ACTIVE); wattron(statusbar_win, status_attrs); mvwprintw(statusbar_win, 0, pos, "%d", display_num); - if (SHOW_NAME) { + if (show_name) { pos++; mvwprintw(statusbar_win, 0, pos, ":"); pos++; diff --git a/src/ui/ui.h b/src/ui/ui.h index 5d779df6..81af4b30 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -318,6 +318,7 @@ void cons_autoping_setting(void); void cons_autoconnect_setting(void); void cons_room_cache_setting(void); void cons_inpblock_setting(void); +void cons_statusbar_setting(void); void cons_winpos_setting(void); void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity); void cons_show_contact_offline(PContact contact, char *resource, char *status); diff --git a/src/ui/window.c b/src/ui/window.c index 83da1219..39d178ee 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -210,7 +210,10 @@ win_create_muc_config(const char *const roomjid, DataForm *form) { ProfMucConfWin *new_win = malloc(sizeof(ProfMucConfWin)); new_win->window.type = WIN_MUC_CONFIG; - new_win->window.tab_name = strdup(roomjid); + GString *tab_str = g_string_new(roomjid); + g_string_append(tab_str, " config"); + new_win->window.tab_name = strdup(tab_str->str); + g_string_free(tab_str, TRUE); new_win->window.layout = _win_create_simple_layout(); new_win->roomjid = strdup(roomjid); @@ -257,7 +260,7 @@ win_create_plugin(const char *const plugin_name, const char *const tag) { ProfPluginWin *new_win = malloc(sizeof(ProfPluginWin)); new_win->window.type = WIN_PLUGIN; - new_win->window.tab_name = strdup(plugin_name); + new_win->window.tab_name = strdup(tag); new_win->window.layout = _win_create_simple_layout(); new_win->tag = strdup(tag); |