Commit 1d737066 authored by Giovanni Panozzo's avatar Giovanni Panozzo

Fixes for issue #744

parent 5f71ab70
......@@ -330,31 +330,41 @@ static void remmina_connection_window_close_all_connections(RemminaConnectionWin
}
static gboolean remmina_connection_window_delete_event(GtkWidget* widget, GdkEvent* event, gpointer data)
void remmina_connection_window_delete(RemminaConnectionWindow* cnnwin)
{
TRACE_CALL("remmina_connection_window_delete_event");
RemminaConnectionHolder* cnnhld = (RemminaConnectionHolder*) data;
RemminaConnectionWindowPriv* priv = cnnhld->cnnwin->priv;
TRACE_CALL("remmina_connection_window_delete");
RemminaConnectionWindowPriv* priv = cnnwin->priv;
RemminaConnectionHolder *cnnhld = cnnwin->priv->cnnhld;
GtkNotebook* notebook = GTK_NOTEBOOK(priv->notebook);
GtkWidget* dialog;
gint i, n;
if (!REMMINA_IS_CONNECTION_WINDOW(cnnwin))
return;
n = gtk_notebook_get_n_pages(notebook);
if (n > 1)
{
dialog = gtk_message_dialog_new(GTK_WINDOW(cnnhld->cnnwin), GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
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 TRUE;
return;
}
remmina_connection_window_close_all_connections(cnnhld->cnnwin);
remmina_connection_window_close_all_connections(cnnwin);
gtk_widget_destroy(GTK_WIDGET(cnnhld->cnnwin));
if (GTK_IS_WIDGET(cnnwin))
gtk_widget_destroy(GTK_WIDGET(cnnwin));
cnnhld->cnnwin = NULL;
}
static gboolean remmina_connection_window_delete_event(GtkWidget* widget, GdkEvent* event, gpointer data)
{
TRACE_CALL("remmina_connection_window_delete_event");
remmina_connection_window_delete(REMMINA_CONNECTION_WINDOW(widget));
return TRUE;
}
......
......@@ -69,6 +69,7 @@ G_GNUC_CONST;
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);
void remmina_connection_window_delete(RemminaConnectionWindow* cnnwin);
GtkWidget* remmina_connection_window_open_from_file_full(RemminaFile* remminafile, GCallback disconnect_cb, gpointer data,
guint* handler);
......
......@@ -57,7 +57,8 @@ static gboolean cb_closewidget(GtkWidget *widget, gpointer data)
/* The correct way to close a remmina_connection_window is to send
* it a "delete-event" signal. Simply destroying it will not close
* all network connections */
g_signal_emit_by_name(G_OBJECT(widget), "delete-event", NULL);
if (REMMINA_IS_CONNECTION_WINDOW(widget))
remmina_connection_window_delete(REMMINA_CONNECTION_WINDOW(widget));
return TRUE;
}
......
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