From 9c659246bc600b03eb28b1b970f9f0f97b5f81af Mon Sep 17 00:00:00 2001 From: Pete Maynard Date: Sun, 31 May 2015 11:43:08 +0100 Subject: Added winstidy to test stub --- tests/ui/stub_ui.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/ui') diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c index 52c38570..c2f2465b 100644 --- a/tests/ui/stub_ui.c +++ b/tests/ui/stub_ui.c @@ -458,6 +458,7 @@ 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_mouse_setting(void) {} void cons_statuses_setting(void) {} -- cgit 1.4.1-2-gfad0 From 0564976264f532b48050656b12dc2d4a3c15d8c3 Mon Sep 17 00:00:00 2001 From: Pete Date: Mon, 1 Jun 2015 11:27:01 +0100 Subject: Refactored 'ui_tidy_wins()' to return bool and not output text, Corrected underline, removed call to function 'wins_resize_all()'. --- src/command/command.c | 2 +- src/command/commands.c | 9 ++++++--- src/ui/core.c | 10 ++-------- src/ui/ui.h | 2 +- tests/ui/stub_ui.c | 5 ++++- 5 files changed, 14 insertions(+), 14 deletions(-) (limited to 'tests/ui') diff --git a/src/command/command.c b/src/command/command.c index 25571e81..ea6df2ba 100644 --- a/src/command/command.c +++ b/src/command/command.c @@ -688,7 +688,7 @@ static struct cmd_t command_defs[] = cmd_winstidy, parse_args, 1, 1, &cons_winstidy_setting, { "/winstidy on|off", "Auto tidy windows.", { "/winstidy on|off", - "------------", + "---------------", "Enable or disable auto window tidy.", NULL } } }, diff --git a/src/command/commands.c b/src/command/commands.c index 89ded432..86781330 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -689,7 +689,11 @@ cmd_wins(gchar **args, struct cmd_help_t help) if (args[0] == NULL) { cons_show_wins(); } else if (strcmp(args[0], "tidy") == 0) { - ui_tidy_wins(); + if ( ui_tidy_wins() ) { + cons_show("Windows tidied."); + } else { + cons_show("No tidy needed."); + } } else if (strcmp(args[0], "prune") == 0) { ui_prune_wins(); } else if (strcmp(args[0], "swap") == 0) { @@ -723,8 +727,6 @@ cmd_winstidy(gchar **args, struct cmd_help_t help) { gboolean result = _cmd_set_boolean_preference(args[0], help, "Wins Auto Tidy", PREF_WINS_AUTO_TIDY); - wins_resize_all(); - return result; } @@ -3254,6 +3256,7 @@ cmd_close(gchar **args, struct cmd_help_t help) // Tidy up the window list. if (prefs_get_boolean(PREF_WINS_AUTO_TIDY)) { + // TODO: Any benefit of checking the return value? ui_tidy_wins(); } diff --git a/src/ui/core.c b/src/ui/core.c index e7059ef0..c028e818 100644 --- a/src/ui/core.c +++ b/src/ui/core.c @@ -1105,16 +1105,10 @@ ui_close_win(int index) status_bar_active(1); } -void +gboolean ui_tidy_wins(void) { - gboolean tidied = wins_tidy(); - - if (tidied) { - cons_show("Windows tidied."); - } else { - cons_show("No tidy needed."); - } + return wins_tidy(); } void diff --git a/src/ui/ui.h b/src/ui/ui.h index 8f6a364e..29ee6bef 100644 --- a/src/ui/ui.h +++ b/src/ui/ui.h @@ -216,7 +216,7 @@ void ui_show_all_room_rosters(void); void ui_hide_all_room_rosters(void); gboolean ui_chat_win_exists(const char * const barejid); -void ui_tidy_wins(void); +gboolean ui_tidy_wins(void); void ui_prune_wins(void); gboolean ui_swap_wins(int source_win, int target_win); diff --git a/tests/ui/stub_ui.c b/tests/ui/stub_ui.c index c2f2465b..4c53eae5 100644 --- a/tests/ui/stub_ui.c +++ b/tests/ui/stub_ui.c @@ -315,7 +315,10 @@ void ui_redraw_all_room_rosters(void) {} void ui_show_all_room_rosters(void) {} void ui_hide_all_room_rosters(void) {} -void ui_tidy_wins(void) {} +gboolean ui_tidy_wins(void) { + // TODO: I'm assuming it should return true, but lack knowledge about the tests. + return TRUE; +} void ui_prune_wins(void) {} gboolean ui_swap_wins(int source_win, int target_win) { -- cgit 1.4.1-2-gfad0