1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Make option to allow hiding windows with no messages in statusbar

`statusbar.show.read` can be set to false in the config.
`/statusbar show|hide read`.

Implement https://github.com/profanity-im/profanity/issues/1285
This commit is contained in:
Michael Vetter 2020-05-21 16:04:26 +02:00
parent e41ae21bea
commit cb78ee4665
7 changed files with 55 additions and 13 deletions

View File

@ -955,6 +955,7 @@ cmd_ac_init(void)
statusbar_show_ac = autocomplete_new();
autocomplete_add(statusbar_show_ac, "name");
autocomplete_add(statusbar_show_ac, "number");
autocomplete_add(statusbar_show_ac, "read");
status_ac = autocomplete_new();
autocomplete_add(status_ac, "set");

View File

@ -1343,8 +1343,8 @@ static struct cmd_t command_defs[] =
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/statusbar show name|number",
"/statusbar hide name|number",
"/statusbar show name|number|read",
"/statusbar hide name|number|read",
"/statusbar maxtabs <value>",
"/statusbar tablen <value>",
"/statusbar self user|barejid|fulljid|off",
@ -1359,6 +1359,7 @@ static struct cmd_t command_defs[] =
{ "tablen <value>", "Set the maximum number of characters to show as the tab name, 0 sets to unlimited." },
{ "show|hide name", "Show or hide names in tabs." },
{ "show|hide number", "Show or hide numbers in tabs." },
{ "show|hide read", "Show or hide inactive tabs." },
{ "self user|barejid|fulljid", "Show account user name, barejid, fulljid as status bar title." },
{ "self off", "Disable showing self as status bar title." },
{ "chat user|jid", "Show users name, or the fulljid if no nick is present for chat tabs." },
@ -1370,6 +1371,7 @@ static struct cmd_t command_defs[] =
"/statusbar tablen 5",
"/statusbar self user",
"/statusbar chat jid",
"/statusbar hide read",
"/statusbar hide name")
},

View File

@ -6070,6 +6070,12 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "read") == 0) {
prefs_set_boolean(PREF_STATUSBAR_SHOW_READ, TRUE);
cons_show("Enabled showing inactive tabs.");
ui_resize();
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
}
@ -6097,6 +6103,12 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args)
ui_resize();
return TRUE;
}
if (g_strcmp0(args[1], "read") == 0) {
prefs_set_boolean(PREF_STATUSBAR_SHOW_READ, FALSE);
cons_show("Disabled showing inactive tabs.");
ui_resize();
return TRUE;
}
cons_bad_cmd_usage(command);
return TRUE;
}

View File

@ -1750,6 +1750,7 @@ _get_group(preference_t pref)
case PREF_OCCUPANTS_COLOR_NICK:
case PREF_STATUSBAR_SHOW_NAME:
case PREF_STATUSBAR_SHOW_NUMBER:
case PREF_STATUSBAR_SHOW_READ:
case PREF_STATUSBAR_SELF:
case PREF_STATUSBAR_CHAT:
case PREF_STATUSBAR_ROOM:
@ -2051,6 +2052,8 @@ _get_key(preference_t pref)
return "statusbar.show.name";
case PREF_STATUSBAR_SHOW_NUMBER:
return "statusbar.show.number";
case PREF_STATUSBAR_SHOW_READ:
return "statusbar.show.read";
case PREF_STATUSBAR_SELF:
return "statusbar.self";
case PREF_STATUSBAR_CHAT:
@ -2122,6 +2125,7 @@ _get_default_boolean(preference_t pref)
case PREF_BOOKMARK_INVITE:
case PREF_ROOM_LIST_CACHE:
case PREF_STATUSBAR_SHOW_NUMBER:
case PREF_STATUSBAR_SHOW_READ:
case PREF_REVEAL_OS:
case PREF_CORRECTION_ALLOW:
case PREF_RECEIPTS_SEND:

View File

@ -159,6 +159,7 @@ typedef enum {
PREF_ROOM_LIST_CACHE,
PREF_STATUSBAR_SHOW_NAME,
PREF_STATUSBAR_SHOW_NUMBER,
PREF_STATUSBAR_SHOW_READ,
PREF_STATUSBAR_SELF,
PREF_STATUSBAR_CHAT,
PREF_STATUSBAR_ROOM,

View File

@ -1795,39 +1795,45 @@ void
cons_statusbar_setting(void)
{
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME)) {
cons_show("Show tab names (/statusbar) : ON");
cons_show("Show tab names (/statusbar) : ON");
} else {
cons_show("Show tab names (/statusbar) : OFF");
cons_show("Show tab names (/statusbar) : OFF");
}
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER)) {
cons_show("Show tab numbers (/statusbar) : ON");
cons_show("Show tab numbers (/statusbar) : ON");
} else {
cons_show("Show tab numbers (/statusbar) : OFF");
cons_show("Show tab numbers (/statusbar) : OFF");
}
cons_show("Max tabs (/statusbar) : %d", prefs_get_statusbartabs());
if (prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER)) {
cons_show("Show tab with no actions (/statusbar) : ON");
} else {
cons_show("Show tab with no actions (/statusbar) : OFF");
}
cons_show("Max tabs (/statusbar) : %d", prefs_get_statusbartabs());
gint pref_len = prefs_get_statusbartablen();
if (pref_len == 0) {
cons_show("Max tab length (/statusbar) : OFF");
cons_show("Max tab length (/statusbar) : OFF");
} else {
cons_show("Max tab length (/statusbar) : %d", pref_len);
cons_show("Max tab length (/statusbar) : %d", pref_len);
}
char *pref_self = prefs_get_string(PREF_STATUSBAR_SELF);
if (g_strcmp0(pref_self, "off") == 0) {
cons_show("Self statusbar display (/statusbar) : OFF");
cons_show("Self statusbar display (/statusbar) : OFF");
} else {
cons_show("Self statusbar display (/statusbar) : %s", pref_self);
cons_show("Self statusbar display (/statusbar) : %s", pref_self);
}
prefs_free_string(pref_self);
char *pref_chat = prefs_get_string(PREF_STATUSBAR_CHAT);
cons_show("Chat tab display (/statusbar) : %s", pref_chat);
cons_show("Chat tab display (/statusbar) : %s", pref_chat);
prefs_free_string(pref_chat);
char *pref_room = prefs_get_string(PREF_STATUSBAR_ROOM);
cons_show("Room tab display (/statusbar) : %s", pref_room);
cons_show("Room tab display (/statusbar) : %s", pref_room);
prefs_free_string(pref_room);
}

View File

@ -371,6 +371,11 @@ _status_bar_draw_tab(StatusBarTab *tab, int pos, int num)
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
// dont show this
if (!show_read && !is_current && !tab->highlight)
return pos;
pos = _status_bar_draw_bracket(is_current, pos, "[");
@ -515,6 +520,7 @@ _tabs_width(void)
{
gboolean show_number = prefs_get_boolean(PREF_STATUSBAR_SHOW_NUMBER);
gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME);
gboolean show_read = prefs_get_boolean(PREF_STATUSBAR_SHOW_READ);
gint max_tabs = prefs_get_statusbartabs();
if (show_name && show_number) {
@ -523,6 +529,11 @@ _tabs_width(void)
for (i = 1; i <= max_tabs; i++) {
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab) {
gboolean is_current = i == statusbar->current_tab;
// dont calculate this in because not shown
if (!show_read && !is_current && !tab->highlight)
continue;
char *display_name = _display_name(tab);
width += utf8_display_len(display_name);
width += 4;
@ -538,6 +549,11 @@ _tabs_width(void)
for (i = 1; i <= max_tabs; i++) {
StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i));
if (tab) {
gboolean is_current = i == statusbar->current_tab;
// dont calculate this in because not shown
if (!show_read && !is_current && !tab->highlight)
continue;
char *display_name = _display_name(tab);
width += utf8_display_len(display_name);
width += 2;