Added missing files, refactored ui_switch_win to check win exists

This commit is contained in:
James Booth
2014-04-01 23:54:26 +01:00
parent 7113b97952
commit b19b881b97
7 changed files with 56 additions and 35 deletions

View File

@@ -530,12 +530,10 @@ gboolean
cmd_win(gchar **args, struct cmd_help_t help)
{
int num = atoi(args[0]);
if (ui_win_exists(num)) {
ui_switch_win(num);
} else {
gboolean switched = ui_switch_win(num);
if (switched == FALSE) {
cons_show("Window %d does not exist.", num);
}
return TRUE;
}

View File

@@ -531,12 +531,12 @@ _get_recipient_string(ProfWin *window)
return result;
}
static void
static gboolean
_ui_switch_win(const int i)
{
ui_current_page_off();
ProfWin *new_current = wins_get_by_num(i);
if (new_current != NULL) {
if (ui_win_exists(i)) {
ui_current_page_off();
ProfWin *new_current = wins_get_by_num(i);
wins_set_current_by_num(i);
ui_current_page_off();
@@ -554,6 +554,9 @@ _ui_switch_win(const int i)
status_bar_active(i);
}
wins_update_virtual_current();
return TRUE;
} else {
return FALSE;
}
}

View File

@@ -58,7 +58,7 @@ void (*ui_resize)(const int ch, const char * const input,
GSList* (*ui_get_recipients)(void);
void (*ui_handle_special_keys)(const wint_t * const ch, const char * const inp,
const int size);
void (*ui_switch_win)(const int i);
gboolean (*ui_switch_win)(const int i);
void (*ui_next_win)(void);
void (*ui_previous_win)(void);
void (*ui_gone_secure)(const char * const recipient, gboolean trusted);