From 136b975b6cb1df03ff55faa50dffd5f0da75d0c0 Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 9 Mar 2018 22:42:20 +0000 Subject: [PATCH] Remove empty tabs --- src/command/cmd_ac.c | 10 +------- src/command/cmd_defs.c | 17 ++++--------- src/command/cmd_funcs.c | 52 ++-------------------------------------- src/command/cmd_funcs.h | 2 -- src/config/preferences.c | 7 ------ src/config/preferences.h | 2 -- src/config/theme.c | 1 - src/ui/console.c | 15 ------------ src/ui/statusbar.c | 47 ++++++++++-------------------------- src/ui/ui.h | 1 - src/ui/window_list.c | 4 +--- 11 files changed, 21 insertions(+), 137 deletions(-) diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c index f47b3727..31f719bd 100644 --- a/src/command/cmd_ac.c +++ b/src/command/cmd_ac.c @@ -391,8 +391,6 @@ cmd_ac_init(void) wins_ac = autocomplete_new(); autocomplete_add(wins_ac, "unread"); autocomplete_add(wins_ac, "prune"); - autocomplete_add(wins_ac, "tidy"); - autocomplete_add(wins_ac, "autotidy"); autocomplete_add(wins_ac, "swap"); roster_ac = autocomplete_new(); @@ -798,7 +796,6 @@ cmd_ac_init(void) autocomplete_add(statusbar_room_ac, "jid"); statusbar_show_ac = autocomplete_new(); - autocomplete_add(statusbar_show_ac, "empty"); autocomplete_add(statusbar_show_ac, "name"); } @@ -1335,7 +1332,7 @@ _cmd_ac_complete_params(ProfWin *window, const char *const input, gboolean previ // autocomplete boolean settings gchar *boolean_choices[] = { "/beep", "/intype", "/states", "/outtype", "/flash", "/splash", "/chlog", "/grlog", - "/history", "/vercheck", "/privileges", "/wrap", "/winstidy", "/carbons", "/encwarn", + "/history", "/vercheck", "/privileges", "/wrap", "/carbons", "/encwarn", "/lastactivity" }; for (i = 0; i < ARRAY_SIZE(boolean_choices); i++) { @@ -2667,11 +2664,6 @@ _wins_autocomplete(ProfWin *window, const char *const input, gboolean previous) { char *result = NULL; - result = autocomplete_param_with_func(input, "/wins autotidy", prefs_autocomplete_boolean_choice, previous); - if (result) { - return result; - } - result = autocomplete_param_with_ac(input, "/wins", wins_ac, TRUE, previous); if (result) { return result; diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c index 1c5a6cba..fd1c5697 100644 --- a/src/command/cmd_defs.c +++ b/src/command/cmd_defs.c @@ -962,18 +962,14 @@ static struct cmd_t command_defs[] = parse_args, 0, 3, NULL, CMD_SUBFUNCS( { "unread", cmd_wins_unread }, - { "tidy", cmd_wins_tidy }, { "prune", cmd_wins_prune }, - { "swap", cmd_wins_swap }, - { "autotidy", cmd_wins_autotidy }) + { "swap", cmd_wins_swap }) CMD_MAINFUNC(cmd_wins) CMD_TAGS( CMD_TAG_UI) CMD_SYN( "/wins", "/wins unread", - "/wins tidy", - "/wins autotidy on|off", "/wins prune", "/wins swap ") CMD_DESC( @@ -981,9 +977,7 @@ static struct cmd_t command_defs[] = "Passing no argument will list all currently active windows and information about their usage.") CMD_ARGS( { "unread", "List windows with unread messages." }, - { "tidy", "Move windows so there are no gaps." }, - { "autotidy on|off", "Automatically remove gaps when closing windows." }, - { "prune", "Close all windows with no unread messages, and then tidy so there are no gaps." }, + { "prune", "Close all windows with no unread messages." }, { "swap ", "Swap windows, target may be an empty position." }) CMD_NOEXAMPLES }, @@ -1364,8 +1358,8 @@ static struct cmd_t command_defs[] = CMD_TAGS( CMD_TAG_UI) CMD_SYN( - "/statusbar show empty|name", - "/statusbar hide empty|name", + "/statusbar show name", + "/statusbar hide name", "/statusbar maxtabs ", "/statusbar chat user|jid", "/statusbar room room|jid", @@ -1375,7 +1369,6 @@ static struct cmd_t command_defs[] = "Manage statusbar display preferences.") CMD_ARGS( { "maxtabs ", "Set the maximum number of tabs to display, must be between 0 and 10" }, - { "show|hide empty", "Show or hide empty tabs." }, { "show|hide name", "Show or hide names in tabs." }, { "chat user|jid", "Show only the users name, or the full jid if no nick is present for chat tabs." }, { "room room|jid", "Show only the rooms name, or the full jid for room tabs." }, @@ -1383,7 +1376,7 @@ static struct cmd_t command_defs[] = { "down", "Move the status bar down the screen." }) CMD_EXAMPLES( "/statusbar maxtabs 5", - "/statusbar show empty", + "/statusbar hide name", "/statusbar chat jid", "/statusbar hide name") }, diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 5e416359..3fec5e16 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -1252,17 +1252,6 @@ cmd_wins_unread(ProfWin *window, const char *const command, gchar **args) return TRUE; } -gboolean -cmd_wins_tidy(ProfWin *window, const char *const command, gchar **args) -{ - if (wins_tidy()) { - cons_show("Windows tidied."); - } else { - cons_show("No tidy needed."); - } - return TRUE; -} - gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args) { @@ -1298,23 +1287,6 @@ cmd_wins_swap(ProfWin *window, const char *const command, gchar **args) return TRUE; } -gboolean -cmd_wins_autotidy(ProfWin *window, const char *const command, gchar **args) -{ - if (g_strcmp0(args[1], "on") == 0) { - cons_show("Window autotidy enabled"); - prefs_set_boolean(PREF_WINS_AUTO_TIDY, TRUE); - wins_tidy(); - } else if (g_strcmp0(args[1], "off") == 0) { - cons_show("Window autotidy disabled"); - prefs_set_boolean(PREF_WINS_AUTO_TIDY, FALSE); - } else { - cons_bad_cmd_usage(command); - } - - return TRUE; -} - gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args) { @@ -1407,11 +1379,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) // close the window ui_close_win(index); cons_show("Closed window %d", index); - - // Tidy up the window list. - if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) { - wins_tidy(); - } + wins_tidy(); rosterwin_roster(); return TRUE; @@ -1442,11 +1410,7 @@ cmd_close(ProfWin *window, const char *const command, gchar **args) // close the window ui_close_win(index); cons_show("Closed window %s", args[0]); - - // Tidy up the window list. - if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) { - wins_tidy(); - } + wins_tidy(); rosterwin_roster(); return TRUE; @@ -5793,12 +5757,6 @@ gboolean cmd_statusbar(ProfWin *window, const char *const command, gchar **args) { if (g_strcmp0(args[0], "show") == 0) { - if (g_strcmp0(args[1], "empty") == 0) { - prefs_set_boolean(PREF_STATUSBAR_SHOW_EMPTY, TRUE); - cons_show("Enabled showing empty tabs."); - ui_resize(); - return TRUE; - } if (g_strcmp0(args[1], "name") == 0) { prefs_set_boolean(PREF_STATUSBAR_SHOW_NAME, TRUE); cons_show("Enabled showing tab names."); @@ -5810,12 +5768,6 @@ cmd_statusbar(ProfWin *window, const char *const command, gchar **args) } if (g_strcmp0(args[0], "hide") == 0) { - if (g_strcmp0(args[1], "empty") == 0) { - prefs_set_boolean(PREF_STATUSBAR_SHOW_EMPTY, FALSE); - cons_show("Disabled showing empty tabs."); - ui_resize(); - return TRUE; - } if (g_strcmp0(args[1], "name") == 0) { prefs_set_boolean(PREF_STATUSBAR_SHOW_NAME, FALSE); cons_show("Disabled showing tab names."); diff --git a/src/command/cmd_funcs.h b/src/command/cmd_funcs.h index aa703f6d..0bbf338e 100644 --- a/src/command/cmd_funcs.h +++ b/src/command/cmd_funcs.h @@ -205,10 +205,8 @@ gboolean cmd_otr_answer(ProfWin *window, const char *const command, gchar **args gboolean cmd_wins(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_unread(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wins_tidy(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_prune(ProfWin *window, const char *const command, gchar **args); gboolean cmd_wins_swap(ProfWin *window, const char *const command, gchar **args); -gboolean cmd_wins_autotidy(ProfWin *window, const char *const command, gchar **args); gboolean cmd_form_field(ProfWin *window, char *tag, gchar **args); diff --git a/src/config/preferences.c b/src/config/preferences.c index 2d2aeef8..aea2786d 100644 --- a/src/config/preferences.c +++ b/src/config/preferences.c @@ -1547,7 +1547,6 @@ _get_group(preference_t pref) case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: case PREF_WRAP: - case PREF_WINS_AUTO_TIDY: case PREF_TIME_CONSOLE: case PREF_TIME_CHAT: case PREF_TIME_MUC: @@ -1587,7 +1586,6 @@ _get_group(preference_t pref) case PREF_CONSOLE_MUC: case PREF_CONSOLE_PRIVATE: case PREF_CONSOLE_CHAT: - case PREF_STATUSBAR_SHOW_EMPTY: case PREF_STATUSBAR_SHOW_NAME: case PREF_STATUSBAR_CHAT: case PREF_STATUSBAR_ROOM: @@ -1754,8 +1752,6 @@ _get_key(preference_t pref) return "presence"; case PREF_WRAP: return "wrap"; - case PREF_WINS_AUTO_TIDY: - return "wins.autotidy"; case PREF_TIME_CONSOLE: return "time.console"; case PREF_TIME_CHAT: @@ -1846,8 +1842,6 @@ _get_key(preference_t pref) return "sourcepath"; case PREF_ROOM_LIST_CACHE: return "rooms.cache"; - case PREF_STATUSBAR_SHOW_EMPTY: - return "statusbar.show.empty"; case PREF_STATUSBAR_SHOW_NAME: return "statusbar.show.name"; case PREF_STATUSBAR_CHAT: @@ -1883,7 +1877,6 @@ _get_default_boolean(preference_t pref) case PREF_MUC_PRIVILEGES: case PREF_PRESENCE: case PREF_WRAP: - case PREF_WINS_AUTO_TIDY: case PREF_INPBLOCK_DYNAMIC: case PREF_RESOURCE_TITLE: case PREF_RESOURCE_MESSAGE: diff --git a/src/config/preferences.h b/src/config/preferences.h index f06d3845..aef019e1 100644 --- a/src/config/preferences.h +++ b/src/config/preferences.h @@ -89,7 +89,6 @@ typedef enum { PREF_MUC_PRIVILEGES, PREF_PRESENCE, PREF_WRAP, - PREF_WINS_AUTO_TIDY, PREF_TIME_CONSOLE, PREF_TIME_CHAT, PREF_TIME_MUC, @@ -144,7 +143,6 @@ typedef enum { PREF_BOOKMARK_INVITE, PREF_PLUGINS_SOURCEPATH, PREF_ROOM_LIST_CACHE, - PREF_STATUSBAR_SHOW_EMPTY, PREF_STATUSBAR_SHOW_NAME, PREF_STATUSBAR_CHAT, PREF_STATUSBAR_ROOM, diff --git a/src/config/theme.c b/src/config/theme.c index 7c5937fb..9d28f421 100644 --- a/src/config/theme.c +++ b/src/config/theme.c @@ -384,7 +384,6 @@ _load_preferences(void) _set_boolean_preference("flash", PREF_FLASH); _set_boolean_preference("splash", PREF_SPLASH); _set_boolean_preference("wrap", PREF_WRAP); - _set_boolean_preference("wins.autotidy", PREF_WINS_AUTO_TIDY); _set_boolean_preference("resource.title", PREF_RESOURCE_TITLE); _set_boolean_preference("resource.message", PREF_RESOURCE_MESSAGE); _set_boolean_preference("occupants", PREF_OCCUPANTS); diff --git a/src/ui/console.c b/src/ui/console.c index f3c7816b..dfc54df3 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -1123,15 +1123,6 @@ cons_wrap_setting(void) cons_show("Word wrap (/wrap) : OFF"); } -void -cons_winstidy_setting(void) -{ - if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) - cons_show("Window Auto Tidy (/wins) : ON"); - else - cons_show("Window Auto Tidy (/wins) : OFF"); -} - void cons_encwarn_setting(void) { @@ -1531,7 +1522,6 @@ cons_show_ui_prefs(void) cons_splash_setting(); cons_winpos_setting(); cons_wrap_setting(); - cons_winstidy_setting(); cons_time_setting(); cons_resource_setting(); cons_vercheck_setting(); @@ -1751,11 +1741,6 @@ cons_inpblock_setting(void) void cons_statusbar_setting(void) { - 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 { diff --git a/src/ui/statusbar.c b/src/ui/statusbar.c index 2b507039..991d21f2 100644 --- a/src/ui/statusbar.c +++ b/src/ui/statusbar.c @@ -292,7 +292,6 @@ _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); gint max_tabs = prefs_get_statusbartabs(); @@ -301,7 +300,7 @@ _status_bar_draw(void) 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)) { + if (tab) { wattron(statusbar_win, bracket_attrs); if (i == statusbar->current_tab) { mvwprintw(statusbar_win, 0, pos, "-"); @@ -382,46 +381,24 @@ _destroy_tab(StatusBarTab *tab) static int _tabs_width(void) { - gboolean show_empty = prefs_get_boolean(PREF_STATUSBAR_SHOW_EMPTY); gboolean show_name = prefs_get_boolean(PREF_STATUSBAR_SHOW_NAME); gint max_tabs = prefs_get_statusbartabs(); if (show_name) { - if (show_empty) { - int width = 4; - int i = 0; - for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); - if (tab) { - char *display_name = _display_name(tab); - width += strlen(display_name); - width += 4; - free(display_name); - } else { - width += 3; - } + int width = 4; + int i = 0; + for (i = 1; i <= max_tabs; i++) { + StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); + if (tab) { + char *display_name = _display_name(tab); + width += strlen(display_name); + width += 4; + free(display_name); } - return width; - } else { - int width = 4; - int i = 0; - for (i = 1; i <= max_tabs; i++) { - StatusBarTab *tab = g_hash_table_lookup(statusbar->tabs, GINT_TO_POINTER(i)); - if (tab) { - char *display_name = _display_name(tab); - width += strlen(display_name); - width += 4; - free(display_name); - } - } - return width; } + return width; } else { - if (show_empty) { - return max_tabs * 3 + 4; - } else { - return g_hash_table_size(statusbar->tabs) * 3 + 4; - } + return g_hash_table_size(statusbar->tabs) * 3 + 4; } } diff --git a/src/ui/ui.h b/src/ui/ui.h index 4630145c..d344f855 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -297,7 +297,6 @@ void cons_occupants_setting(void); void cons_roster_setting(void); void cons_presence_setting(void); void cons_wrap_setting(void); -void cons_winstidy_setting(void); void cons_time_setting(void); void cons_wintitle_setting(void); void cons_notify_setting(void); diff --git a/src/ui/window_list.c b/src/ui/window_list.c index 990a17f1..09a53ed1 100644 --- a/src/ui/window_list.c +++ b/src/ui/window_list.c @@ -238,9 +238,7 @@ wins_close_plugin(char *tag) int index = wins_get_num(toclose); ui_close_win(index); - if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) { - wins_tidy(); - } + wins_tidy(); } GList*