vinagre r268 - in branches/unstable: . src
- From: jwendell svn gnome org
- To: svn-commits-list gnome org
- Subject: vinagre r268 - in branches/unstable: . src
- Date: Wed, 19 Mar 2008 19:05:08 +0000 (GMT)
Author: jwendell
Date: Wed Mar 19 19:05:08 2008
New Revision: 268
URL: http://svn.gnome.org/viewvc/vinagre?rev=268&view=rev
Log:
2008-03-19 Jonh Wendell <jwendell gnome org>
Make VinagreConnection a GObject.
Modified:
branches/unstable/ (props changed)
branches/unstable/ChangeLog
branches/unstable/configure.ac
branches/unstable/src/ (props changed)
branches/unstable/src/Makefile.am
branches/unstable/src/vinagre-bookmarks.c
branches/unstable/src/vinagre-bookmarks.h
branches/unstable/src/vinagre-commands.c
branches/unstable/src/vinagre-connection.c
branches/unstable/src/vinagre-connection.h
branches/unstable/src/vinagre-fav.c
branches/unstable/src/vinagre-notebook.c
branches/unstable/src/vinagre-tab.c
branches/unstable/src/vinagre-window.c
Modified: branches/unstable/configure.ac
==============================================================================
--- branches/unstable/configure.ac (original)
+++ branches/unstable/configure.ac Wed Mar 19 19:05:08 2008
@@ -86,6 +86,18 @@
AC_SUBST(AVAHI_LIBS)
AM_CONDITIONAL(VINAGRE_AVAHI, [test "x$VINAGRE_ENABLE_AVAHI" = "xyes"])
+dnl define a MAINT-like variable REBUILD which is set
+dnl if Perl, so autogenerated sources can be rebuilt
+AC_PATH_PROGS(PERL, perl5 perl)
+AC_ARG_ENABLE(rebuilds, [ --disable-rebuilds disable all source autogeneration rules],,enable_rebuilds=yes)
+REBUILD=\#
+if test "x$enable_rebuilds" = "xyes" && \
+ test -n "$PERL" && \
+ $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 ; then
+ REBUILD=
+fi
+AC_SUBST(REBUILD)
+
#*******************************************************************************
AC_OUTPUT([
Modified: branches/unstable/src/Makefile.am
==============================================================================
--- branches/unstable/src/Makefile.am (original)
+++ branches/unstable/src/Makefile.am Wed Mar 19 19:05:08 2008
@@ -1,3 +1,5 @@
+NULL =
+
INCLUDES = \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
@@ -7,7 +9,8 @@
-DVINAGRE_DATADIR=\""$(datadir)/vinagre"\" \
-DPACKAGE_LOCALE_DIR=\""$(datadir)/locale"\" \
$(VINAGRE_CFLAGS) \
- $(AVAHI_CFLAGS)
+ $(AVAHI_CFLAGS) \
+ $(NULL)
bin_PROGRAMS = vinagre
@@ -23,10 +26,53 @@
vinagre-tab.c vinagre-tab.h \
vinagre-utils.c vinagre-utils.h \
vinagre-window.c vinagre-window.h \
- vinagre-ui.h vinagre-window-private.h
+ vinagre-ui.h vinagre-window-private.h \
+ vinagre-enums.h vinagre-enums.c \
+ $(NULL)
vinagre_LDADD = \
$(VINAGRE_LIBS) \
$(GTKVNC_LIBS) \
- $(AVAHI_LIBS)
+ $(AVAHI_LIBS) \
+ $(NULL)
+
+vinagre_enum_headers = \
+ $(top_srcdir)/src/vinagre-connection.h \
+ $(NULL)
+
+vinagre-enums.c: @REBUILD@ $(vinagre_enum_headers)
+ glib-mkenums --fhead "#include <glib-object.h>\n" \
+ --fhead "#include \"vinagre-enums.h\"\n\n" \
+ --fprod "\n/* enumerations from \"@filename \" */" \
+ --fprod "\n#include \"@filename \"\n" \
+ --vhead "static const G Type@Value _ enum_name@_values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+ --vtail " { 0, NULL, NULL }\n};\n\n" \
+ --vtail "GType\n enum_name@_get_type (void)\n{\n" \
+ --vtail " static GType type = 0;\n\n" \
+ --vtail " if (!type)\n" \
+ --vtail " type = g_ type@_register_static (\"@EnumName \", _ enum_name@_values);\n\n" \
+ --vtail " return type;\n}\n\n" \
+ $(vinagre_enum_headers) > $@
+
+vinagre-enums.h: @REBUILD@ $(vinagre_enum_headers)
+ glib-mkenums --fhead "#ifndef __VINAGRE_ENUMS_H__\n" \
+ --fhead "#define __VINAGRE_ENUMS_H__ 1\n\n" \
+ --fhead "G_BEGIN_DECLS\n\n" \
+ --ftail "G_END_DECLS\n\n" \
+ --ftail "#endif /* __VINAGRE_ENUMS_H__ */\n" \
+ --fprod "\n/* --- @filename@ --- */" \
+ --eprod "#define VINAGRE_TYPE_ ENUMSHORT@ @enum_name _get_type()\n" \
+ --eprod "GType @enum_name _get_type (void);\n" \
+ $(vinagre_enum_headers) > $@
+
+BUILT_SOURCES = \
+ vinagre-enums.c \
+ vinagre-enums.h \
+ $(NULL)
+
+DISTCLEANFILES = \
+ $(BUILT_SOURCES) \
+ $(NULL)
+$(vinagre_OBJECTS): $(BUILT_SOURCES)
Modified: branches/unstable/src/vinagre-bookmarks.c
==============================================================================
--- branches/unstable/src/vinagre-bookmarks.c (original)
+++ branches/unstable/src/vinagre-bookmarks.c Wed Mar 19 19:05:08 2008
@@ -132,7 +132,8 @@
GtkWidget *dialog;
const gchar *name;
- g_return_val_if_fail (conn != NULL, FALSE);
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), FALSE);
+ g_return_val_if_fail (VINAGRE_IS_WINDOW (window), FALSE);
glade_file = vinagre_utils_get_glade_filename ();
xml = glade_xml_new (glade_file, "add_to_bookmarks_dialog", NULL);
@@ -147,16 +148,16 @@
{
name = gtk_entry_get_text (GTK_ENTRY (glade_xml_get_widget (xml, "bookmark_name_entry")));
if (strlen(name) < 1)
- name = conn->host;
+ name = vinagre_connection_get_host (conn);
g_key_file_set_string (bookmarks,
name,
"host",
- conn->host);
+ vinagre_connection_get_host (conn));
g_key_file_set_integer (bookmarks,
name,
"port",
- conn->port);
+ vinagre_connection_get_port (conn));
vinagre_connection_set_name (conn, name);
vinagre_bookmarks_save_file ();
@@ -178,7 +179,8 @@
GtkWidget *dialog, *host_entry, *name_entry, *port_entry;
const gchar *name;
- g_return_val_if_fail (conn != NULL, FALSE);
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), FALSE);
+ g_return_val_if_fail (VINAGRE_IS_WINDOW (window), FALSE);
glade_file = vinagre_utils_get_glade_filename ();
xml = glade_xml_new (glade_file, "edit_bookmark_dialog", NULL);
@@ -189,9 +191,9 @@
host_entry = glade_xml_get_widget (xml, "edit_bookmark_host_entry");
port_entry = glade_xml_get_widget (xml, "edit_bookmark_port_entry");
- gtk_entry_set_text (GTK_ENTRY(name_entry), conn->name);
- gtk_entry_set_text (GTK_ENTRY(host_entry), conn->host);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (port_entry), conn->port);
+ gtk_entry_set_text (GTK_ENTRY(name_entry), vinagre_connection_get_name (conn));
+ gtk_entry_set_text (GTK_ENTRY(host_entry), vinagre_connection_get_host (conn));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (port_entry), vinagre_connection_get_port (conn));
gtk_widget_show_all (dialog);
@@ -200,23 +202,23 @@
if (result == GTK_RESPONSE_OK)
{
- g_key_file_remove_group (bookmarks, conn->name, NULL);
+ g_key_file_remove_group (bookmarks, vinagre_connection_get_name (conn), NULL);
name = gtk_entry_get_text (GTK_ENTRY (name_entry));
vinagre_connection_set_host (conn, gtk_entry_get_text (GTK_ENTRY (host_entry)));
vinagre_connection_set_port (conn, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (port_entry)));
- if (strlen(conn->name) < 1)
- name = conn->host;
+ if (strlen(vinagre_connection_get_name (conn)) < 1)
+ name = vinagre_connection_get_host (conn);
g_key_file_set_string (bookmarks,
name,
"host",
- conn->host);
+ vinagre_connection_get_host (conn));
g_key_file_set_integer (bookmarks,
name,
"port",
- conn->port);
+ vinagre_connection_get_port (conn));
vinagre_connection_set_name (conn, name);
vinagre_bookmarks_save_file ();
@@ -270,10 +272,15 @@
GError *error = NULL;
g_return_val_if_fail (bookmarks != NULL, FALSE);
- g_return_val_if_fail (conn != NULL, FALSE);
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), FALSE);
+ g_return_val_if_fail (VINAGRE_IS_WINDOW (window), FALSE);
- name = vinagre_connection_best_name (conn);
- g_return_val_if_fail (g_key_file_has_group (bookmarks, name), FALSE);
+ name = vinagre_connection_get_best_name (conn);
+ if (!g_key_file_has_group (bookmarks, name))
+ {
+ g_free (name);
+ return FALSE;
+ }
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -300,10 +307,10 @@
g_free (name);
return FALSE;
}
- g_free (name);
vinagre_bookmarks_save_file ();
}
+ g_free (name);
return (result == GTK_RESPONSE_OK);
}
Modified: branches/unstable/src/vinagre-bookmarks.h
==============================================================================
--- branches/unstable/src/vinagre-bookmarks.h (original)
+++ branches/unstable/src/vinagre-bookmarks.h Wed Mar 19 19:05:08 2008
@@ -22,7 +22,6 @@
#define __VINAGRE_FAVORITES_H__
#include <glib.h>
-#include <gtk/gtk.h>
#include "vinagre-connection.h"
#include "vinagre-window.h"
Modified: branches/unstable/src/vinagre-commands.c
==============================================================================
--- branches/unstable/src/vinagre-commands.c (original)
+++ branches/unstable/src/vinagre-commands.c Wed Mar 19 19:05:08 2008
@@ -249,7 +249,7 @@
conn = vinagre_tab_get_conn (VINAGRE_TAB (window->priv->active_tab));
g_return_if_fail (conn != NULL);
- name = vinagre_connection_best_name (conn);
+ name = vinagre_connection_get_best_name (conn);
vinagre_bookmarks_add (conn, window);
vinagre_tab_set_title (VINAGRE_TAB (window->priv->active_tab),
Modified: branches/unstable/src/vinagre-connection.c
==============================================================================
--- branches/unstable/src/vinagre-connection.c (original)
+++ branches/unstable/src/vinagre-connection.c Wed Mar 19 19:05:08 2008
@@ -21,108 +21,401 @@
#include <stdlib.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
+#include <gtk/gtkicontheme.h>
#include "vinagre-connection.h"
+#include "vinagre-enums.h"
#include "vinagre-bookmarks.h"
+struct _VinagreConnectionPrivate
+{
+ VinagreConnectionProtocol protocol;
+ gchar *host;
+ gint port;
+ gchar *name;
+ gchar *password;
+ gchar *desktop_name;
+};
+
+enum
+{
+ PROP_0,
+ PROP_PROTOCOL,
+ PROP_HOST,
+ PROP_PORT,
+ PROP_NAME,
+ PROP_PASSWORD,
+ PROP_DESKTOP_NAME,
+ PROP_BEST_NAME,
+ PROP_ICON
+};
+
+#define VINAGRE_CONNECTION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VINAGRE_TYPE_CONNECTION, VinagreConnectionPrivate))
+G_DEFINE_TYPE (VinagreConnection, vinagre_connection, G_TYPE_OBJECT);
+
+static void
+vinagre_connection_init (VinagreConnection *conn)
+{
+ conn->priv = G_TYPE_INSTANCE_GET_PRIVATE (conn, VINAGRE_TYPE_CONNECTION, VinagreConnectionPrivate);
+
+ conn->priv->protocol = VINAGRE_CONNECTION_PROTOCOL_VNC;
+ conn->priv->host = NULL;
+ conn->priv->port = 0;
+ conn->priv->password = NULL;
+ conn->priv->name = NULL;
+ conn->priv->desktop_name = NULL;
+}
+
+static void
+vinagre_connection_finalize (GObject *object)
+{
+ VinagreConnection *conn = VINAGRE_CONNECTION (object);
+
+ if (conn->priv->host)
+ g_free (conn->priv->host);
+ conn->priv->host = NULL;
+
+ if (conn->priv->password)
+ g_free (conn->priv->password);
+ conn->priv->password = NULL;
+
+ if (conn->priv->name)
+ g_free (conn->priv->name);
+ conn->priv->name = NULL;
+
+ if (conn->priv->desktop_name)
+ g_free (conn->priv->desktop_name);
+ conn->priv->desktop_name = NULL;
+
+ G_OBJECT_CLASS (vinagre_connection_parent_class)->finalize (object);
+}
+
+static void
+vinagre_connection_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ VinagreConnection *conn;
+
+ g_return_if_fail (VINAGRE_IS_CONNECTION (object));
+
+ conn = VINAGRE_CONNECTION (object);
+
+ switch (prop_id)
+ {
+ case PROP_PROTOCOL:
+ vinagre_connection_set_protocol (conn, g_value_get_enum (value));
+ break;
+
+ case PROP_HOST:
+ vinagre_connection_set_host (conn, g_value_get_string (value));
+ break;
+
+ case PROP_PORT:
+ vinagre_connection_set_port (conn, g_value_get_int (value));
+ break;
+
+ case PROP_PASSWORD:
+ vinagre_connection_set_password (conn, g_value_get_string (value));
+ break;
+
+ case PROP_NAME:
+ vinagre_connection_set_name (conn, g_value_get_string (value));
+ break;
+
+ case PROP_DESKTOP_NAME:
+ vinagre_connection_set_desktop_name (conn, g_value_get_string (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+vinagre_connection_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ VinagreConnection *conn;
+
+ g_return_if_fail (VINAGRE_IS_CONNECTION (object));
+
+ conn = VINAGRE_CONNECTION (object);
+
+
+ switch (prop_id)
+ {
+ case PROP_PROTOCOL:
+ g_value_set_enum (value, conn->priv->protocol);
+ break;
+
+ case PROP_HOST:
+ g_value_set_string (value, conn->priv->host);
+ break;
+
+ case PROP_PORT:
+ g_value_set_int (value, conn->priv->port);
+ break;
+
+ case PROP_PASSWORD:
+ g_value_set_string (value, conn->priv->password);
+ break;
+
+ case PROP_NAME:
+ g_value_set_string (value, conn->priv->name);
+ break;
+
+ case PROP_DESKTOP_NAME:
+ g_value_set_string (value, conn->priv->desktop_name);
+ break;
+
+ case PROP_BEST_NAME:
+ g_value_set_string (value, vinagre_connection_get_best_name (conn));
+ break;
+
+ case PROP_ICON:
+ g_value_set_object (value, vinagre_connection_get_icon (conn));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+vinagre_connection_class_init (VinagreConnectionClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GObjectClass* parent_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (VinagreConnectionPrivate));
+
+ object_class->finalize = vinagre_connection_finalize;
+ object_class->set_property = vinagre_connection_set_property;
+ object_class->get_property = vinagre_connection_get_property;
+
+ g_object_class_install_property (object_class,
+ PROP_PROTOCOL,
+ g_param_spec_enum ("protocol",
+ "protocol",
+ "connection protocol",
+ VINAGRE_TYPE_CONNECTION_PROTOCOL,
+ VINAGRE_CONNECTION_PROTOCOL_VNC,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_HOST,
+ g_param_spec_string ("host",
+ "hostname",
+ "hostname or ip address of this connection",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_PORT,
+ g_param_spec_int ("port",
+ "port",
+ "tcp/ip port of this connection",
+ 0,
+ G_MAXINT,
+ 5900,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_PASSWORD,
+ g_param_spec_string ("password",
+ "password",
+ "password (if any) necessary for complete this connection",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_NAME,
+ g_param_spec_string ("name",
+ "connection name",
+ "friendly name for this connection",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_DESKTOP_NAME,
+ g_param_spec_string ("desktop-name",
+ "desktop-name",
+ "name of this connection as reported by the server",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_BEST_NAME,
+ g_param_spec_string ("best-name",
+ "best-name",
+ "preferred name for this connection",
+ NULL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+ g_object_class_install_property (object_class,
+ PROP_ICON,
+ g_param_spec_object ("icon",
+ "icon",
+ "icon of this connection",
+ GDK_TYPE_PIXBUF,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_BLURB));
+
+}
+
VinagreConnection *
vinagre_connection_new ()
{
- VinagreConnection *conn;
+ return g_object_new (VINAGRE_TYPE_CONNECTION, NULL);
+}
- conn = g_new (VinagreConnection, 1);
- conn->host = NULL;
- conn->port = 0;
- conn->name = NULL;
- conn->password = NULL;
- conn->desktop_name = NULL;
- conn->type = VINAGRE_CONNECTION_TYPE_VNC;
+void
+vinagre_connection_set_protocol (VinagreConnection *conn,
+ VinagreConnectionProtocol protocol)
+{
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
- return conn;
+ conn->priv->protocol = protocol;
}
+VinagreConnectionProtocol
+vinagre_connection_get_protocol (VinagreConnection *conn)
+{
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn),
+ VINAGRE_CONNECTION_PROTOCOL_INVALID);
-void
+ return conn->priv->protocol;
+}
+
+void
vinagre_connection_set_host (VinagreConnection *conn,
- const char *host)
+ const gchar *host)
{
- if (conn->host)
- g_free (conn->host);
- conn->host = g_strdup (host);
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
+
+ if (conn->priv->host)
+ g_free (conn->priv->host);
+ conn->priv->host = g_strdup (host);
+}
+const gchar *
+vinagre_connection_get_host (VinagreConnection *conn)
+{
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
+
+ return conn->priv->host;
}
void
vinagre_connection_set_port (VinagreConnection *conn,
- int port)
+ gint port)
{
- conn->port = port;
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
+
+ conn->priv->port = port;
+}
+gint
+vinagre_connection_get_port (VinagreConnection *conn)
+{
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), 0);
+
+ return conn->priv->port;
}
void
vinagre_connection_set_password (VinagreConnection *conn,
- const char *password)
+ const gchar *password)
{
- if (conn->password)
- g_free (conn->password);
- conn->password = g_strdup (password);
-}
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
-void
-vinagre_connection_set_name (VinagreConnection *conn,
- const char *name)
-{
- if (conn->name)
- g_free (conn->name);
- conn->name = g_strdup (name);
+ if (conn->priv->password)
+ g_free (conn->priv->password);
+ conn->priv->password = g_strdup (password);
}
-
-void
-vinagre_connection_set_desktop_name (VinagreConnection *conn,
- const char *desktop_name)
+const gchar *
+vinagre_connection_get_password (VinagreConnection *conn)
{
- if (conn->desktop_name)
- g_free (conn->desktop_name);
- conn->desktop_name = g_strdup (desktop_name);
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
+
+ return conn->priv->password;
}
void
-vinagre_connection_free (VinagreConnection *conn)
+vinagre_connection_set_name (VinagreConnection *conn,
+ const gchar *name)
{
- if (conn) {
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
- if (conn->host)
- g_free (conn->host);
- conn->host = NULL;
+ if (conn->priv->name)
+ g_free (conn->priv->name);
+ conn->priv->name = g_strdup (name);
+}
+const gchar *
+vinagre_connection_get_name (VinagreConnection *conn)
+{
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
- if (conn->password)
- g_free (conn->password);
- conn->password = NULL;
+ return conn->priv->name;
+}
- if (conn->name)
- g_free (conn->name);
- conn->name = NULL;
+void
+vinagre_connection_set_desktop_name (VinagreConnection *conn,
+ const gchar *desktop_name)
+{
+ g_return_if_fail (VINAGRE_IS_CONNECTION (conn));
- if (conn->desktop_name)
- g_free (conn->desktop_name);
- conn->desktop_name = NULL;
+ if (conn->priv->desktop_name)
+ g_free (conn->priv->desktop_name);
+ conn->priv->desktop_name = g_strdup (desktop_name);
+}
+const gchar *
+vinagre_connection_get_desktop_name (VinagreConnection *conn)
+{
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
- g_free (conn);
- conn = NULL;
- }
+ return conn->priv->desktop_name;
}
gchar *
-vinagre_connection_best_name (VinagreConnection *conn)
+vinagre_connection_get_best_name (VinagreConnection *conn)
{
- g_return_val_if_fail (conn != NULL, NULL);
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
- if (conn->name)
- return g_strdup (conn->name);
+ if (conn->priv->name)
+ return g_strdup (conn->priv->name);
- if (conn->desktop_name)
- return g_strdup (conn->desktop_name);
+ if (conn->priv->desktop_name)
+ return g_strdup (conn->priv->desktop_name);
- if (conn->host)
- return g_strdup_printf ("%s:%d", conn->host, conn->port);
+ if (conn->priv->host)
+ return g_strdup_printf ("%s:%d", conn->priv->host, conn->priv->port);
return NULL;
}
@@ -134,11 +427,11 @@
new_conn = vinagre_connection_new ();
- vinagre_connection_set_host (new_conn, conn->host);
- vinagre_connection_set_port (new_conn, conn->port);
- vinagre_connection_set_password (new_conn, conn->password);
- vinagre_connection_set_name (new_conn, conn->name);
- vinagre_connection_set_desktop_name (new_conn, conn->desktop_name);
+ vinagre_connection_set_host (new_conn, vinagre_connection_get_host (conn));
+ vinagre_connection_set_port (new_conn, vinagre_connection_get_port (conn));
+ vinagre_connection_set_password (new_conn, vinagre_connection_get_password (conn));
+ vinagre_connection_set_name (new_conn, vinagre_connection_get_name (conn));
+ vinagre_connection_set_desktop_name (new_conn, vinagre_connection_get_desktop_name (conn));
return new_conn;
}
@@ -269,6 +562,8 @@
GdkPixbuf *pixbuf;
GtkIconTheme *icon_theme;
+ g_return_val_if_fail (VINAGRE_IS_CONNECTION (conn), NULL);
+
icon_theme = gtk_icon_theme_get_default ();
pixbuf = gtk_icon_theme_load_icon (icon_theme,
"application-x-vnc",
Modified: branches/unstable/src/vinagre-connection.h
==============================================================================
--- branches/unstable/src/vinagre-connection.h (original)
+++ branches/unstable/src/vinagre-connection.h Wed Mar 19 19:05:08 2008
@@ -24,44 +24,75 @@
#include <glib.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+G_BEGIN_DECLS
+
+#define VINAGRE_TYPE_CONNECTION (vinagre_connection_get_type ())
+#define VINAGRE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VINAGRE_TYPE_CONNECTION, VinagreConnection))
+#define VINAGRE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VINAGRE_TYPE_CONNECTION, VinagreConnectionClass))
+#define VINAGRE_IS_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VINAGRE_TYPE_CONNECTION))
+#define VINAGRE_IS_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VINAGRE_TYPE_CONNECTION))
+#define VINAGRE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VINAGRE_TYPE_CONNECTION, VinagreConnectionClass))
+
+typedef struct _VinagreConnectionClass VinagreConnectionClass;
+typedef struct _VinagreConnection VinagreConnection;
+typedef struct _VinagreConnectionPrivate VinagreConnectionPrivate;
+
typedef enum
{
- VINAGRE_CONNECTION_TYPE_VNC = 0
-} VinagreConnectionType;
+ VINAGRE_CONNECTION_PROTOCOL_VNC = 1,
+ VINAGRE_CONNECTION_PROTOCOL_RDP,
+ VINAGRE_CONNECTION_PROTOCOL_INVALID
+} VinagreConnectionProtocol;
+
+struct _VinagreConnectionClass
+{
+ GObjectClass parent_class;
+};
-typedef struct
+struct _VinagreConnection
{
- char *host;
- int port;
- char *name;
- char *password;
- char *desktop_name;
- VinagreConnectionType type;
-} VinagreConnection;
+ GObject parent_instance;
+ VinagreConnectionPrivate *priv;
+};
+
+GType vinagre_connection_get_type (void) G_GNUC_CONST;
VinagreConnection *vinagre_connection_new (void);
-void vinagre_connection_set_host (VinagreConnection *conn,
- const char *host);
-void vinagre_connection_set_port (VinagreConnection *conn,
- int port);
-void vinagre_connection_set_password (VinagreConnection *conn,
- const char *password);
-void vinagre_connection_set_name (VinagreConnection *conn,
- const char *name);
-void vinagre_connection_set_desktop_name (VinagreConnection *conn,
- const char *desktop_name);
-
-void vinagre_connection_free (VinagreConnection *conn);
+VinagreConnectionProtocol vinagre_connection_get_protocol (VinagreConnection *conn);
+void vinagre_connection_set_protocol (VinagreConnection *conn,
+ VinagreConnectionProtocol protocol);
+
+const gchar* vinagre_connection_get_host (VinagreConnection *conn);
+void vinagre_connection_set_host (VinagreConnection *conn,
+ const gchar *host);
+
+gint vinagre_connection_get_port (VinagreConnection *conn);
+void vinagre_connection_set_port (VinagreConnection *conn,
+ gint port);
+
+const gchar* vinagre_connection_get_password (VinagreConnection *conn);
+void vinagre_connection_set_password (VinagreConnection *conn,
+ const gchar *password);
+
+const gchar* vinagre_connection_get_name (VinagreConnection *conn);
+void vinagre_connection_set_name (VinagreConnection *conn,
+ const gchar *name);
+
+const gchar* vinagre_connection_get_desktop_name (VinagreConnection *conn);
+void vinagre_connection_set_desktop_name (VinagreConnection *conn,
+ const gchar *desktop_name);
+
+gchar* vinagre_connection_get_best_name (VinagreConnection *conn);
-gchar *vinagre_connection_best_name (VinagreConnection *conn);
+VinagreConnection* vinagre_connection_clone (VinagreConnection *conn);
-VinagreConnection *vinagre_connection_clone (VinagreConnection *conn);
+VinagreConnection* vinagre_connection_new_from_string (const gchar *url, gchar **error_msg);
+VinagreConnection* vinagre_connection_new_from_file (const gchar *uri, gchar **error_msg);
-VinagreConnection *vinagre_connection_new_from_string (const gchar *url, gchar **error_msg);
-VinagreConnection *vinagre_connection_new_from_file (const gchar *uri, gchar **error_msg);
+GdkPixbuf* vinagre_connection_get_icon (VinagreConnection *conn);
-GdkPixbuf *vinagre_connection_get_icon (VinagreConnection *conn);
+G_END_DECLS
#endif /* __VINAGRE_CONNECTION_H__ */
/* vim: ts=8 */
Modified: branches/unstable/src/vinagre-fav.c
==============================================================================
--- branches/unstable/src/vinagre-fav.c (original)
+++ branches/unstable/src/vinagre-fav.c Wed Mar 19 19:05:08 2008
@@ -368,7 +368,7 @@
fav->priv->model = GTK_TREE_MODEL (gtk_list_store_new (NUM_COLS,
GDK_TYPE_PIXBUF,
G_TYPE_STRING,
- G_TYPE_POINTER));
+ VINAGRE_TYPE_CONNECTION));
fav->priv->tree = gtk_tree_view_new_with_model (fav->priv->model);
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (fav->priv->tree), FALSE);
@@ -482,7 +482,7 @@
while (list)
{
conn = (VinagreConnection *) list->data;
- name = vinagre_connection_best_name (conn);
+ name = vinagre_connection_get_best_name (conn);
pixbuf = vinagre_connection_get_icon (conn);
Modified: branches/unstable/src/vinagre-notebook.c
==============================================================================
--- branches/unstable/src/vinagre-notebook.c (original)
+++ branches/unstable/src/vinagre-notebook.c Wed Mar 19 19:05:08 2008
@@ -94,7 +94,7 @@
{
gchar *message, *name;
- name = vinagre_connection_best_name (vinagre_tab_get_conn (tab));
+ name = vinagre_connection_get_best_name (vinagre_tab_get_conn (tab));
message = g_strdup_printf (_("Connection to host \"%s\" was closed."),
name);
vinagre_utils_show_error (message, GTK_WINDOW (nb->priv->window));
@@ -157,7 +157,7 @@
gtk_box_pack_start (GTK_BOX (label_hbox), icon, FALSE, FALSE, 0);
/* setup label */
- name = vinagre_connection_best_name (vinagre_tab_get_conn (tab));
+ name = vinagre_connection_get_best_name (vinagre_tab_get_conn (tab));
label = gtk_label_new (name);
g_free (name);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
Modified: branches/unstable/src/vinagre-tab.c
==============================================================================
--- branches/unstable/src/vinagre-tab.c (original)
+++ branches/unstable/src/vinagre-tab.c Wed Mar 19 19:05:08 2008
@@ -173,7 +173,8 @@
g_signal_handlers_disconnect_by_func (tab->priv->window,
vinagre_tab_window_state_cb,
tab);
- vinagre_connection_free (tab->priv->conn);
+ g_object_unref (tab->priv->conn);
+ tab->priv->conn = NULL;
G_OBJECT_CLASS (vinagre_tab_parent_class)->finalize (object);
}
@@ -249,9 +250,9 @@
tab->priv->status = GTK_STATUSBAR (vinagre_window_get_statusbar (tab->priv->window));
tab->priv->status_id = gtk_statusbar_get_context_id (tab->priv->status, "VNC Widget Messages");
- port = g_strdup_printf ("%d", tab->priv->conn->port);
+ port = g_strdup_printf ("%d", vinagre_connection_get_port (tab->priv->conn));
- if (!vnc_display_open_host (VNC_DISPLAY(tab->priv->vnc), tab->priv->conn->host, port))
+ if (!vnc_display_open_host (VNC_DISPLAY(tab->priv->vnc), vinagre_connection_get_host (tab->priv->conn), port))
vinagre_utils_show_error (_("Error connecting to host."), NULL);
vnc_display_set_pointer_local (VNC_DISPLAY(tab->priv->vnc), TRUE);
@@ -285,7 +286,7 @@
gchar *name;
message = g_string_new (NULL);
- name = vinagre_connection_best_name (vinagre_tab_get_conn (tab));
+ name = vinagre_connection_get_best_name (vinagre_tab_get_conn (tab));
g_string_printf (message, _("Authentication to host \"%s\" has failed"),
name);
@@ -313,7 +314,7 @@
gchar *name;
message = g_string_new (NULL);
- name = vinagre_connection_best_name (vinagre_tab_get_conn (tab));
+ name = vinagre_connection_get_best_name (vinagre_tab_get_conn (tab));
g_string_printf (message, _("Authentication method to host \"%s\" is unsupported. (%u)"),
name,
@@ -360,9 +361,11 @@
data = g_slice_new (GtkRecentData);
uri = g_string_new (NULL);
- g_string_printf (uri, "vnc://%s:%d", tab->priv->conn->host, tab->priv->conn->port);
+ g_string_printf (uri, "vnc://%s:%d",
+ vinagre_connection_get_host (tab->priv->conn),
+ vinagre_connection_get_port (tab->priv->conn));
- data->display_name = vinagre_connection_best_name (tab->priv->conn);
+ data->display_name = vinagre_connection_get_best_name (tab->priv->conn);
data->description = NULL;
data->mime_type = g_strdup ("application/x-remote-connection");
data->app_name = (gchar *) g_get_application_name ();
@@ -393,12 +396,12 @@
NULL, /* default keyring */
NULL, /* user */
NULL, /* domain */
- tab->priv->conn->host, /* server */
+ vinagre_connection_get_host (tab->priv->conn), /* server */
NULL, /* object */
"rfb", /* protocol */
"vnc-password", /* authtype */
- tab->priv->conn->port, /* port */
- tab->priv->conn->password, /* password */
+ vinagre_connection_get_port (tab->priv->conn), /* port */
+ vinagre_connection_get_password (tab->priv->conn), /* password */
&tab->priv->keyring_item_id);
if (result != GNOME_KEYRING_RESULT_OK)
@@ -421,11 +424,11 @@
result = gnome_keyring_find_network_password_sync (
NULL, /* user */
NULL, /* domain */
- tab->priv->conn->host, /* server */
+ vinagre_connection_get_host (tab->priv->conn), /* server */
NULL, /* object */
"rfb", /* protocol */
"vnc-password", /* authtype */
- tab->priv->conn->port, /* port */
+ vinagre_connection_get_port (tab->priv->conn), /* port */
&matches);
if (result != GNOME_KEYRING_RESULT_OK || matches == NULL || matches->data == NULL)
@@ -450,7 +453,7 @@
vinagre_connection_set_desktop_name (tab->priv->conn,
vnc_display_get_name (VNC_DISPLAY (tab->priv->vnc)));
- name = vinagre_connection_best_name (tab->priv->conn);
+ name = vinagre_connection_get_best_name (tab->priv->conn);
label = g_object_get_data (G_OBJECT (tab), "label");
g_return_if_fail (label != NULL);
gtk_label_set_label (label, name);
@@ -488,7 +491,7 @@
gtk_window_set_transient_for (GTK_WINDOW(password_dialog), GTK_WINDOW(tab->priv->window));
host_label = glade_xml_get_widget (xml, "host_label");
- name = vinagre_connection_best_name (tab->priv->conn);
+ name = vinagre_connection_get_best_name (tab->priv->conn);
gtk_label_set_text (GTK_LABEL (host_label), name);
g_free (name);
@@ -674,8 +677,8 @@
"<b>%s</b> %d\n"
"<b>%s</b> %dx%d",
_("Desktop Name:"), vnc_display_get_name (VNC_DISPLAY (tab->priv->vnc)),
- _("Host:"), tab->priv->conn->host,
- _("Port:"), tab->priv->conn->port,
+ _("Host:"), vinagre_connection_get_host (tab->priv->conn),
+ _("Port:"), vinagre_connection_get_port (tab->priv->conn),
_("Dimensions:"), vnc_display_get_width (VNC_DISPLAY (tab->priv->vnc)), vnc_display_get_height (VNC_DISPLAY (tab->priv->vnc)));
return tip;
@@ -741,7 +744,7 @@
pix = vnc_display_get_pixbuf (VNC_DISPLAY (tab->priv->vnc));
filename = NULL;
- name = vinagre_connection_best_name (tab->priv->conn);
+ name = vinagre_connection_get_best_name (tab->priv->conn);
suggested_filename = g_string_new (NULL);
g_string_printf (suggested_filename, _("Screenshot of %s"), name);
g_string_append (suggested_filename, ".png");
Modified: branches/unstable/src/vinagre-window.c
==============================================================================
--- branches/unstable/src/vinagre-window.c (original)
+++ branches/unstable/src/vinagre-window.c Wed Mar 19 19:05:08 2008
@@ -52,7 +52,7 @@
if (window->priv->fav_conn_selected)
{
- vinagre_connection_free (window->priv->fav_conn_selected);
+ g_object_unref (window->priv->fav_conn_selected);
window->priv->fav_conn_selected = NULL;
}
@@ -275,7 +275,7 @@
if (conn)
{
vinagre_cmd_open_bookmark (window, conn);
- vinagre_connection_free (conn);
+ g_object_unref (conn);
}
else
{
@@ -519,7 +519,7 @@
if (window->priv->fav_conn_selected)
{
- vinagre_connection_free (window->priv->fav_conn_selected);
+ g_object_unref (window->priv->fav_conn_selected);
window->priv->fav_conn_selected = NULL;
}
@@ -576,11 +576,13 @@
while (favs)
{
conn = (VinagreConnection *) favs->data;
- name = vinagre_connection_best_name (conn);
+ name = vinagre_connection_get_best_name (conn);
action_name = g_strdup_printf ("Fav_%d", i);
/* Translators: This is server:port, a statusbar tooltip when mouse is over a bookmark item on menu */
- tooltip = g_strdup_printf (_("Open %s:%d"), conn->host, conn->port);
+ tooltip = g_strdup_printf (_("Open %s:%d"),
+ vinagre_connection_get_host (conn),
+ vinagre_connection_get_port (conn));
action_label = vinagre_utils_escape_underscores (
name,
-1);
@@ -592,7 +594,7 @@
g_object_set_data_full (G_OBJECT (action),
"conn",
conn,
- (GDestroyNotify) vinagre_connection_free);
+ (GDestroyNotify) g_object_unref);
gtk_action_group_add_action (p->bookmarks_list_action_group,
GTK_ACTION (action));
@@ -763,7 +765,7 @@
return;
}
- name = vinagre_connection_best_name (vinagre_tab_get_conn (VINAGRE_TAB (window->priv->active_tab)));
+ name = vinagre_connection_get_best_name (vinagre_tab_get_conn (VINAGRE_TAB (window->priv->active_tab)));
title = g_strdup_printf ("%s - %s",
name,
g_get_application_name ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]