Commit 89009c8d authored by Antenore Gatta's avatar Antenore Gatta Committed by GitHub

Merge pull request #1214 from FreeRDP/issues_785_966

Issues 785 966
parents 3b76e5c3 5a5f24ae
......@@ -57,6 +57,7 @@
#include "remmina/remmina_trace_calls.h"
#define DEBUG_KB_GRABBING 0
#include "remmina_exec.h"
gchar *remmina_pref_file;
RemminaPref remmina_pref;
......@@ -3574,6 +3575,12 @@ static void remmina_connection_object_on_connect(RemminaProtocolWidget* gp, Remm
}
static void cb_autoclose_widget(GtkWidget *widget)
{
gtk_widget_destroy(widget);
remmina_application_cond_exitremmina();
}
static void remmina_connection_object_on_disconnect(RemminaProtocolWidget* gp, RemminaConnectionObject* cnnobj)
{
TRACE_CALL("remmina_connection_object_on_disconnect");
......@@ -3607,7 +3614,7 @@ static void remmina_connection_object_on_disconnect(RemminaProtocolWidget* gp, R
{
dialog = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
remmina_protocol_widget_get_error_message(gp), NULL);
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(gtk_widget_destroy), NULL);
g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(cb_autoclose_widget), NULL);
gtk_widget_show(dialog);
remmina_widget_pool_register(dialog);
}
......@@ -3622,6 +3629,8 @@ static void remmina_connection_object_on_disconnect(RemminaProtocolWidget* gp, R
cnnobj->remmina_file = NULL;
g_free(cnnobj);
remmina_application_cond_exitremmina();
}
static void remmina_connection_object_on_desktop_resize(RemminaProtocolWidget* gp, RemminaConnectionObject* cnnobj)
......
......@@ -84,6 +84,20 @@ void remmina_exec_exitremmina()
g_application_quit(g_application_get_default());
}
void remmina_application_cond_exitremmina()
{
TRACE_CALL("remmina_application_check_exitremmina");
/* Exit remmina only if there are no interesting windows left:
* no main window, no systray menu, no connection window.
* This function is usually called after a disconnection */
if (remmina_widget_pool_count() < 1 && !remmina_main_get_window() && !remmina_icon_is_available())
{
remmina_exec_exitremmina();
}
}
void remmina_exec_command(RemminaCommandType command, const gchar* data)
{
TRACE_CALL("remmina_exec_command");
......
......@@ -54,6 +54,7 @@ typedef enum
void remmina_exec_command(RemminaCommandType command, const gchar* data);
void remmina_exec_exitremmina(void);
void remmina_application_cond_exitremmina(void);
G_END_DECLS
......
......@@ -135,7 +135,7 @@ static void remmina_main_save_before_destroy()
static gboolean remmina_main_dexit(gpointer data)
{
TRACE_CALL("remmina_main_dexit");
remmina_exec_exitremmina();
remmina_application_cond_exitremmina();
return FALSE;
}
......@@ -626,7 +626,7 @@ void remmina_main_on_action_application_mpchange(GtkAction *action, gpointer use
const gchar *username;
const gchar *domain;
const gchar *group;
username = domain = group = "";
remminafile = NULL;
......@@ -645,7 +645,7 @@ void remmina_main_on_action_application_mpchange(GtkAction *action, gpointer use
if (remminafile != NULL)
remmina_file_free(remminafile);
}
void remmina_main_on_action_connections_new(GtkAction *action, gpointer user_data)
......
......@@ -150,3 +150,9 @@ gint remmina_widget_pool_foreach(RemminaWidgetPoolForEachFunc callback, gpointer
return n;
}
gint remmina_widget_pool_count()
{
TRACE_CALL("remmina_widget_pool_count");
return remmina_widget_pool->len;
}
......@@ -44,6 +44,7 @@ void remmina_widget_pool_register(GtkWidget *widget);
GtkWidget* remmina_widget_pool_find(GType type, const gchar *tag);
GtkWidget* remmina_widget_pool_find_by_window(GType type, GdkWindow *window);
gint remmina_widget_pool_foreach(RemminaWidgetPoolForEachFunc callback, gpointer data);
gint remmina_widget_pool_count(void);
G_END_DECLS
......
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