Commit bb27b66a authored by Marc-André Lureau's avatar Marc-André Lureau
Browse files

Fix reverse VNC plugin to work with current GNOME 3.0

parent fb7c1723
......@@ -30,7 +30,9 @@
#include <fcntl.h>
#include <errno.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <vinagre/vinagre-commands.h>
#include <vinagre/vinagre-utils.h>
#include "vinagre-reverse-vnc-listener.h"
......@@ -39,8 +41,9 @@
struct _VinagreReverseVncListenerPrivate
{
GSocketService *service;
gboolean listening;
gint port;
gboolean listening;
gint port;
VinagreWindow *window;
};
enum
......@@ -153,15 +156,9 @@ incoming (GSocketService *service,
VinagreReverseVncListener *listener)
{
VinagreConnection *conn;
GtkWindow *window;
GSocketAddress *address;
window = gtk_application_get_window (GTK_APPLICATION (g_application_get_instance ()));
if (!window)
{
g_warning (_("Incoming VNC connection arrived but there is no active window"));
return TRUE;
}
g_return_val_if_fail (listener->priv->window != NULL, FALSE);
conn = vinagre_vnc_connection_new ();
vinagre_vnc_connection_set_socket (VINAGRE_VNC_CONNECTION (conn),
......@@ -179,7 +176,7 @@ incoming (GSocketService *service,
g_free (host);
}
vinagre_cmd_direct_connect (conn, VINAGRE_WINDOW (window));
vinagre_cmd_direct_connect (conn, listener->priv->window);
return TRUE;
}
......@@ -213,7 +210,7 @@ vinagre_reverse_vnc_listener_start (VinagreReverseVncListener *listener)
{
vinagre_utils_show_error (_("Error activating reverse connections"),
_("The program could not find any available TCP ports starting at 5500. Is there any other running program consuming all your TCP ports?"),
gtk_application_get_window (GTK_APPLICATION (g_application_get_instance ())));
GTK_WINDOW (listener->priv->window));
g_object_unref (priv->service);
priv->service = NULL;
return;
......@@ -261,4 +258,17 @@ vinagre_reverse_vnc_listener_get_port (VinagreReverseVncListener *listener)
return listener->priv->listening ? listener->priv->port : 0;
}
void
vinagre_reverse_vnc_listener_set_window (VinagreReverseVncListener *listener,
VinagreWindow *window)
{
g_return_if_fail (VINAGRE_IS_REVERSE_VNC_LISTENER (listener));
if (listener->priv->window)
g_object_unref (listener->priv->window);
if (window)
listener->priv->window = g_object_ref (window);
}
/* vim: set ts=8: */
......@@ -55,6 +55,8 @@ void vinagre_reverse_vnc_listener_start (VinagreReverseVncListener *listener);
void vinagre_reverse_vnc_listener_stop (VinagreReverseVncListener *listener);
gboolean vinagre_reverse_vnc_listener_is_listening (VinagreReverseVncListener *listener);
gint vinagre_reverse_vnc_listener_get_port (VinagreReverseVncListener *listener);
void vinagre_reverse_vnc_listener_set_window (VinagreReverseVncListener *listener,
VinagreWindow *window);
G_END_DECLS
......
......@@ -82,6 +82,9 @@ impl_activate (PeasActivatable *activatable)
priv = VINAGRE_REVERSE_VNC_PLUGIN (activatable)->priv;
g_return_if_fail (priv->window != NULL);
g_return_if_fail (priv->ui_action_group == NULL);
manager = vinagre_window_get_ui_manager (priv->window);
priv->ui_action_group = gtk_action_group_new ("VinagreReverseVNCPluginActions");
......@@ -121,12 +124,18 @@ impl_deactivate (PeasActivatable *activatable)
manager = vinagre_window_get_ui_manager (priv->window);
gtk_ui_manager_remove_ui (manager, priv->ui_id);
gtk_ui_manager_remove_action_group (manager, priv->ui_action_group);
if (priv->ui_action_group)
{
gtk_ui_manager_remove_action_group (manager, priv->ui_action_group);
g_object_unref (priv->ui_action_group);
priv->ui_action_group = NULL;
}
}
static void
vinagre_reverse_vnc_plugin_set_property (GObject *object,
guint prop_id,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
......@@ -136,6 +145,8 @@ vinagre_reverse_vnc_plugin_set_property (GObject *object,
{
case PROP_OBJECT:
plugin->priv->window = VINAGRE_WINDOW (g_value_dup_object (value));
vinagre_reverse_vnc_listener_set_window (plugin->priv->listener,
VINAGRE_WINDOW (plugin->priv->window));
break;
default:
......@@ -146,8 +157,8 @@ vinagre_reverse_vnc_plugin_set_property (GObject *object,
static void
vinagre_reverse_vnc_plugin_get_property (GObject *object,
guint prop_id,
GValue *value,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
VinagreReverseVncPlugin *plugin = VINAGRE_REVERSE_VNC_PLUGIN (object);
......@@ -169,10 +180,12 @@ vinagre_reverse_vnc_plugin_dispose (GObject *object)
{
VinagreReverseVncPluginPrivate *priv = VINAGRE_REVERSE_VNC_PLUGIN (object)->priv;
if (priv->ui_action_group)
if (priv->listener)
{
g_object_unref (priv->ui_action_group);
priv->ui_action_group = NULL;
vinagre_reverse_vnc_listener_set_window (priv->listener,
NULL);
g_object_unref (priv->listener);
priv->listener = NULL;
}
if (priv->window != NULL)
......@@ -181,12 +194,6 @@ vinagre_reverse_vnc_plugin_dispose (GObject *object)
priv->window = NULL;
}
if (priv->listener)
{
g_object_unref (priv->listener);
priv->listener = NULL;
}
G_OBJECT_CLASS (vinagre_reverse_vnc_plugin_parent_class)->dispose (object);
}
......
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