[vinagre/gnome-3-8] Revert the recognize_file() reverts
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vinagre/gnome-3-8] Revert the recognize_file() reverts
- Date: Wed, 24 Jul 2013 16:39:38 +0000 (UTC)
commit 14e878d693bfe4a81392e0c6b9a11440277e46fc
Author: David King <amigadave amigadave com>
Date: Wed Jul 24 17:33:17 2013 +0100
Revert the recognize_file() reverts
This reverts commit 45eeda2bf4e7e3428009f5016c25603bd64917fc,
e26a1fda514960967a934e1fa24b0d077d7d8d94,
a608a162867f1423279b4febd4915ab750fc95ef and
29a2af5f0aa4eb674e02b1d4072649fac474ac8f.
The commits to add recognize_file() to the VinagreProtocol interface
were in fact a series of commits, fixing a bug when opening a .vnc file
when more than one plugin was enabled.
plugins/spice/vinagre-spice-plugin.c | 16 ++++++++++++++++
plugins/vnc/vinagre-vnc-plugin.c | 16 ++++++++++++++++
vinagre/vinagre-connection.c | 18 ++++++++++--------
vinagre/vinagre-protocol.c | 26 ++++++++++++++++++++++++++
vinagre/vinagre-protocol.h | 4 ++++
5 files changed, 72 insertions(+), 8 deletions(-)
---
diff --git a/plugins/spice/vinagre-spice-plugin.c b/plugins/spice/vinagre-spice-plugin.c
index da0d885..87377ef 100644
--- a/plugins/spice/vinagre-spice-plugin.c
+++ b/plugins/spice/vinagre-spice-plugin.c
@@ -151,6 +151,21 @@ impl_new_connection_from_file (VinagreProtocol *plugin,
}
+static gboolean
+impl_recognize_file (VinagreProtocol *plugin, GFile *file)
+{
+ gboolean result = FALSE;
+ gchar *filename = g_file_get_basename (file);
+
+ if (filename)
+ {
+ result = g_str_has_suffix (filename, ".spice");
+ g_free (filename);
+ }
+
+ return result;
+}
+
static gchar **
impl_get_public_description (VinagreProtocol *plugin)
{
@@ -336,6 +351,7 @@ vinagre_spice_protocol_iface_init (VinagreProtocolInterface *iface)
iface->new_connection = impl_new_connection;
iface->new_tab = impl_new_tab;
iface->new_connection_from_file = impl_new_connection_from_file;
+ iface->recognize_file = impl_recognize_file;
}
static void
diff --git a/plugins/vnc/vinagre-vnc-plugin.c b/plugins/vnc/vinagre-vnc-plugin.c
index 5b5153c..d77140f 100644
--- a/plugins/vnc/vinagre-vnc-plugin.c
+++ b/plugins/vnc/vinagre-vnc-plugin.c
@@ -210,6 +210,21 @@ the_end:
}
+static gboolean
+impl_recognize_file (VinagreProtocol *plugin, GFile *file)
+{
+ gboolean result = FALSE;
+ gchar *filename = g_file_get_basename (file);
+
+ if (filename)
+ {
+ result = g_str_has_suffix (filename, ".vnc");
+ g_free (filename);
+ }
+
+ return result;
+}
+
static GtkWidget *
impl_new_tab (VinagreProtocol *plugin,
VinagreConnection *conn,
@@ -404,6 +419,7 @@ vinagre_vnc_protocol_iface_init (VinagreProtocolInterface *iface)
iface->get_public_description = impl_get_public_description;
iface->new_connection = impl_new_connection;
iface->new_connection_from_file = impl_new_connection_from_file;
+ iface->recognize_file = impl_recognize_file;
iface->get_mdns_service = impl_get_mdns_service;
iface->new_tab = impl_new_tab;
iface->get_connect_widget = impl_get_connect_widget;
diff --git a/vinagre/vinagre-connection.c b/vinagre/vinagre-connection.c
index 60a9c1b..ffa8e94 100644
--- a/vinagre/vinagre-connection.c
+++ b/vinagre/vinagre-connection.c
@@ -639,14 +639,16 @@ vinagre_connection_new_from_file (const gchar *uri, gchar **error_msg, gboolean
g_hash_table_iter_init (&iter, extensions);
while (g_hash_table_iter_next (&iter, NULL, &ext))
{
- conn = vinagre_protocol_new_connection_from_file ((VinagreProtocol *)ext,
- data,
- use_bookmarks,
- error_msg);
- g_free (*error_msg);
- *error_msg = NULL;
- if (conn)
- break;
+ VinagreProtocol *protocol = VINAGRE_PROTOCOL (ext);
+
+ if (vinagre_protocol_recognize_file (protocol, file_a))
+ {
+ conn = vinagre_protocol_new_connection_from_file (protocol,
+ data,
+ use_bookmarks,
+ error_msg);
+ break;
+ }
}
the_end:
diff --git a/vinagre/vinagre-protocol.c b/vinagre/vinagre-protocol.c
index 3040d8c..11ec4fd 100644
--- a/vinagre/vinagre-protocol.c
+++ b/vinagre/vinagre-protocol.c
@@ -75,6 +75,13 @@ default_new_connection_from_file (VinagreProtocol *protocol,
return NULL;
}
+static gboolean
+default_recognize_file (VinagreProtocol *protocol,
+ GFile *file)
+{
+ return FALSE;
+}
+
static GtkWidget *
default_get_connect_widget (VinagreProtocol *protocol,
VinagreConnection *initial_settings)
@@ -108,6 +115,7 @@ vinagre_protocol_default_init (VinagreProtocolInterface *iface)
iface->new_tab = default_new_tab;
iface->new_connection = default_new_connection;
iface->new_connection_from_file = default_new_connection_from_file;
+ iface->recognize_file = default_recognize_file;
iface->get_connect_widget = default_get_connect_widget;
iface->parse_mdns_dialog = default_parse_mdns_dialog;
iface->get_icon_name = dummy;
@@ -308,6 +316,24 @@ vinagre_protocol_new_connection_from_file (VinagreProtocol *protocol,
return NULL;
}
+gboolean
+vinagre_protocol_recognize_file (VinagreProtocol *protocol,
+ GFile *file)
+{
+ VinagreProtocolInterface *iface;
+
+ g_return_val_if_fail (VINAGRE_IS_PROTOCOL (protocol), FALSE);
+
+ iface = VINAGRE_PROTOCOL_GET_IFACE (protocol);
+
+ if (iface->recognize_file != NULL)
+ {
+ return iface->recognize_file (protocol, file);
+ }
+
+ return FALSE;
+}
+
/**
* vinagre_protocol_get_connect_widget:
*
diff --git a/vinagre/vinagre-protocol.h b/vinagre/vinagre-protocol.h
index cdf2eb4..933cceb 100644
--- a/vinagre/vinagre-protocol.h
+++ b/vinagre/vinagre-protocol.h
@@ -48,6 +48,8 @@ struct _VinagreProtocolInterface
const gchar *data,
gboolean use_bookmarks,
gchar **error_msg);
+ gboolean (*recognize_file) (VinagreProtocol *protocol,
+ GFile *file);
const gchar *(*get_mdns_service) (VinagreProtocol *protocol);
GtkWidget *(*new_tab) (VinagreProtocol *protocol,
VinagreConnection *conn,
@@ -80,6 +82,8 @@ VinagreConnection * vinagre_protocol_new_connection_from_file (VinagreProtocol *
const gchar *data,
gboolean use_bookmarks,
gchar **error_msg);
+gboolean vinagre_protocol_recognize_file (VinagreProtocol *protocol,
+ GFile *file);
const gchar * vinagre_protocol_get_mdns_service (VinagreProtocol *protocol);
GtkWidget * vinagre_protocol_new_tab (VinagreProtocol *protocol,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]