forked from Mirrors/sngrep
Added an exit confirmation dialog
This commit is contained in:
parent
fbbe93b885
commit
5020fef2b6
|
@ -11,26 +11,30 @@
|
|||
##-----------------------------------------------------------------------------
|
||||
## Change default scrolling in call list
|
||||
# set cl.scrollstep 20
|
||||
## Disable exit prompt
|
||||
# set cl.noexitprompt 1
|
||||
## Or set its default button
|
||||
# set cl.defexitbutton 0/1
|
||||
|
||||
##-----------------------------------------------------------------------------
|
||||
## You can change the default number of columns in call list
|
||||
## set cl.columns {count}
|
||||
## set cl.columns {count}
|
||||
##
|
||||
## Set displayed columns in call list screen
|
||||
## set cl.column{num} {field}
|
||||
## set cl.column{num} {field}
|
||||
##
|
||||
## You can also configure the column width using
|
||||
## set cl.column{num}.width {cols}
|
||||
## set cl.column{num}.width {cols}
|
||||
##
|
||||
## Available columns fields are:
|
||||
## - sipfrom
|
||||
## - sipto
|
||||
## - src
|
||||
## - dst
|
||||
## - callid
|
||||
## - xcallid
|
||||
## - msgcnt
|
||||
## - starting
|
||||
## - sipfrom
|
||||
## - sipto
|
||||
## - src
|
||||
## - dst
|
||||
## - callid
|
||||
## - xcallid
|
||||
## - msgcnt
|
||||
## - starting
|
||||
|
||||
# set cl.columns 6
|
||||
# set cl.column0 sipfrom
|
||||
|
|
|
@ -323,6 +323,13 @@ call_list_handle_key(PANEL *panel, int key)
|
|||
call_group_add(info->group, info->cur_call);
|
||||
}
|
||||
break;
|
||||
case 'q':
|
||||
case 27: /* KEY_ESC */
|
||||
// Handle quit from this screen unless requested
|
||||
if (get_option_int_value("cl.noexitprompt") != 1) {
|
||||
return call_list_exit_confirm(panel);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -385,6 +392,74 @@ call_list_help(PANEL *panel)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
call_list_exit_confirm(PANEL *panel)
|
||||
{
|
||||
WINDOW *exit_win;
|
||||
PANEL *exit_panel;
|
||||
int c;
|
||||
// Initial exit status
|
||||
int exit = get_option_int_value("cl.defexitbutton") ;
|
||||
// If not a valid, set yes by default
|
||||
if (exit != 0 && exit != 1 ) exit = 1;
|
||||
|
||||
// Create a new panel and show centered
|
||||
exit_win = newwin(8, 40, (LINES - 20) / 2, (COLS - 65) / 2);
|
||||
exit_panel = new_panel(exit_win);
|
||||
keypad(exit_win, TRUE);
|
||||
|
||||
// Set the window title
|
||||
mvwprintw(exit_win, 1, 13, "Confirm exit");
|
||||
|
||||
// Write border and boxes around the window
|
||||
wattron(exit_win, COLOR_PAIR(DETAIL_BORDER_COLOR));
|
||||
box(exit_win, 0, 0);
|
||||
mvwhline(exit_win, 2, 1, ACS_HLINE, 40);
|
||||
mvwhline(exit_win, 5, 1, ACS_HLINE, 40);
|
||||
mvwaddch(exit_win, 2, 0, ACS_LTEE);
|
||||
mvwaddch(exit_win, 5, 0, ACS_LTEE);
|
||||
mvwaddch(exit_win, 2, 39, ACS_RTEE);
|
||||
mvwaddch(exit_win, 5, 39, ACS_RTEE);
|
||||
|
||||
// Exit confirmation message message
|
||||
wattron(exit_win, COLOR_PAIR(HELP_COLOR));
|
||||
mvwprintw(exit_win, 3, 2, "Are you sure you want to quit?");
|
||||
wattroff(exit_win, COLOR_PAIR(HELP_COLOR));
|
||||
|
||||
for(;;) {
|
||||
// A list of available keys in this window
|
||||
if (exit) wattron(exit_win, A_REVERSE);
|
||||
mvwprintw(exit_win, 6, 10, " Yes ");
|
||||
wattroff(exit_win, A_REVERSE);
|
||||
if (!exit) wattron(exit_win, A_REVERSE);
|
||||
mvwprintw(exit_win, 6, 20, " No ");
|
||||
wattroff(exit_win, A_REVERSE);
|
||||
|
||||
update_panels();
|
||||
doupdate();
|
||||
|
||||
c = wgetch(exit_win);
|
||||
switch (c) {
|
||||
case KEY_RIGHT:
|
||||
exit = 0;
|
||||
break;
|
||||
case KEY_LEFT:
|
||||
exit = 1;
|
||||
break;
|
||||
case 9:
|
||||
exit = (exit)?0:1;
|
||||
break;
|
||||
case 10:
|
||||
// If we return 1, we let ui_manager to handle this
|
||||
// key and exit sngrep gracefully
|
||||
return exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
call_list_add_column(PANEL *panel, enum sip_attr_id id, const char* attr, const char *title,
|
||||
int width)
|
||||
|
|
Loading…
Reference in New Issue