Commit 329330ef authored by Giovanni Panozzo's avatar Giovanni Panozzo

Make quit cmd do not ask for confirmation

parent 6a5f5abc
......@@ -68,9 +68,10 @@ G_DEFINE_TYPE( RemminaConnectionWindow, remmina_connection_window, GTK_TYPE_WIND
#define FLOATING_TOOLBAR_WIDGET (GTK_CHECK_VERSION(3, 10, 0))
typedef struct _RemminaConnectionHolder RemminaConnectionHolder;
typedef struct _RemminaConnectionHolder RemminaConnectionHolder;
struct _RemminaConnectionWindowPriv
struct _RemminaConnectionWindowPriv
{
RemminaConnectionHolder* cnnhld;
......@@ -122,6 +123,8 @@ G_DEFINE_TYPE( RemminaConnectionWindow, remmina_connection_window, GTK_TYPE_WIND
gboolean kbcaptured;
gboolean mouse_pointer_entered;
RemminaConnectionWindowOnDeleteConfirmMode on_delete_confirm_mode;
};
typedef struct _RemminaConnectionObject
......@@ -416,16 +419,18 @@ gboolean remmina_connection_window_delete(RemminaConnectionWindow* cnnwin)
if (!REMMINA_IS_CONNECTION_WINDOW(cnnwin))
return TRUE;
n = gtk_notebook_get_n_pages(notebook);
if (n > 1)
{
dialog = gtk_message_dialog_new(GTK_WINDOW(cnnwin), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("There are %i active connections in the current window. Are you sure to close?"), n);
i = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if (i != GTK_RESPONSE_YES)
return FALSE;
if (cnnwin->priv->on_delete_confirm_mode != REMMINA_CONNECTION_WINDOW_ONDELETE_NOCONFIRM) {
n = gtk_notebook_get_n_pages(notebook);
if (n > 1)
{
dialog = gtk_message_dialog_new(GTK_WINDOW(cnnwin), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("There are %i active connections in the current window. Are you sure to close?"), n);
i = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
if (i != GTK_RESPONSE_YES)
return FALSE;
}
}
remmina_connection_window_close_all_connections(cnnwin);
......@@ -2490,6 +2495,7 @@ remmina_connection_window_new_from_holder(RemminaConnectionHolder* cnnhld)
cnnwin = REMMINA_CONNECTION_WINDOW(g_object_new(REMMINA_TYPE_CONNECTION_WINDOW, NULL));
cnnwin->priv->cnnhld = cnnhld;
cnnwin->priv->on_delete_confirm_mode = REMMINA_CONNECTION_WINDOW_ONDELETE_CONFIRM_IF_2_OR_MORE;
g_signal_connect(G_OBJECT(cnnwin), "delete-event", G_CALLBACK(remmina_connection_window_delete_event), cnnhld);
g_signal_connect(G_OBJECT(cnnwin), "destroy", G_CALLBACK(remmina_connection_window_destroy), cnnhld);
......@@ -3744,5 +3750,12 @@ remmina_connection_window_open_from_file_full(RemminaFile* remminafile, GCallbac
remmina_protocol_widget_open_connection(REMMINA_PROTOCOL_WIDGET(cnnobj->proto), remminafile);
return protocolwidget;
}
void remmina_connection_window_set_delete_confirm_mode(RemminaConnectionWindow* cnnwin, RemminaConnectionWindowOnDeleteConfirmMode mode)
{
cnnwin->priv->on_delete_confirm_mode = mode;
}
......@@ -52,7 +52,6 @@ typedef struct _RemminaConnectionWindowPriv RemminaConnectionWindowPriv;
typedef struct _RemminaConnectionWindow
{
GtkWindow window;
RemminaConnectionWindowPriv* priv;
} RemminaConnectionWindow;
......@@ -62,6 +61,12 @@ typedef struct _RemminaConnectionWindowClass
void (*toolbar_place)(RemminaConnectionWindow *gp);
} RemminaConnectionWindowClass;
typedef enum {
REMMINA_CONNECTION_WINDOW_ONDELETE_CONFIRM_IF_2_OR_MORE = 0,
REMMINA_CONNECTION_WINDOW_ONDELETE_NOCONFIRM = 1
} RemminaConnectionWindowOnDeleteConfirmMode;
GType remmina_connection_window_get_type(void)
G_GNUC_CONST;
......@@ -70,6 +75,7 @@ gboolean remmina_connection_window_open_from_filename(const gchar* filename);
/* Open a new connection window for a given RemminaFile struct. The struct will be freed after the call */
void remmina_connection_window_open_from_file(RemminaFile* remminafile);
gboolean remmina_connection_window_delete(RemminaConnectionWindow* cnnwin);
void remmina_connection_window_set_delete_confirm_mode(RemminaConnectionWindow* cnnwin, RemminaConnectionWindowOnDeleteConfirmMode mode);
GtkWidget* remmina_connection_window_open_from_file_full(RemminaFile* remminafile, GCallback disconnect_cb, gpointer data,
guint* handler);
......
......@@ -84,6 +84,18 @@ void remmina_exec_exitremmina()
g_application_quit(g_application_get_default());
}
static gboolean disable_remmina_connection_window_delete_confirm_cb(GtkWidget *widget, gpointer data)
{
TRACE_CALL("disable_remmina_connection_window_delete_confirm_cb");
RemminaConnectionWindow *rcw;
if (REMMINA_IS_CONNECTION_WINDOW(widget)) {
rcw = (RemminaConnectionWindow*)widget;
remmina_connection_window_set_delete_confirm_mode(rcw, REMMINA_CONNECTION_WINDOW_ONDELETE_NOCONFIRM);
}
return TRUE;
}
void remmina_application_condexit(RemminaCondExitType why)
{
TRACE_CALL("remmina_application_check_exitremmina");
......@@ -106,6 +118,7 @@ void remmina_application_condexit(RemminaCondExitType why)
case REMMINA_CONDEXIT_ONQUIT:
// Quit command has been sent from main window or appindicator/systray menu
// quit means QUIT.
remmina_widget_pool_foreach(disable_remmina_connection_window_delete_confirm_cb, NULL);
remmina_exec_exitremmina();
break;
}
......@@ -233,6 +246,7 @@ void remmina_exec_command(RemminaCommandType command, const gchar* data)
break;
case REMMINA_COMMAND_EXIT:
remmina_widget_pool_foreach(disable_remmina_connection_window_delete_confirm_cb, NULL);
remmina_exec_exitremmina();
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment