Commit ac0ac783 authored by Jonh Wendell's avatar Jonh Wendell Committed by Jonh Wendell S. Santana
Browse files

configure.ac, data/vinagre.glade,

2007-10-04  Jonh Wendell <jwendell@gnome.org>

	* configure.ac,
	* data/vinagre.glade,
	* src/vinagre-tab.c:
	  - Added gnome-keyring support.
	* src/vinagre-favorites.c:
	  - Don't save the password in the favorites file.
	* src/vinagre-window.c:
	  - Avoid a crash when exiting the application with more than one
	    tab opened.

svn path=/trunk/; revision=43
parent 23afd774
2007-10-04 Jonh Wendell <jwendell@gnome.org>
* configure.ac,
* data/vinagre.glade,
* src/vinagre-tab.c:
- Added gnome-keyring support.
* src/vinagre-favorites.c:
- Don't save the password in the favorites file.
* src/vinagre-window.c:
- Avoid a crash when exiting the application with more than one
tab opened.
2007-10-04 Jonh Wendell <jwendell@gnome.org>
* src/vinagre-tab.c:
......@@ -6,10 +18,10 @@
2007-10-03 Jonh Wendell <jwendell@gnome.org>
* src/vinagre-tab.c,
src/vinagre-window.c,
src/vinagre-tab.h,
src/vinagre-ui.h,
data/vinagre-ui.xml:
* src/vinagre-window.c,
* src/vinagre-tab.h,
* src/vinagre-ui.h,
* data/vinagre-ui.xml:
- Added clipboard support (copy and paste)
- Dropped edit menu, it's not being used anyway.
......
......@@ -43,6 +43,7 @@ PKG_CHECK_MODULES(VINAGRE, \
gtk+-2.0 >= $GTK_REQUIRED \
libglade-2.0 >= $LIBGLADE_REQUIRED \
gconf-2.0 >= $GCONF_REQUIRED \
gnome-keyring-1 \
gtk-vnc-1.0)
AC_SUBST(VINAGRE_CFLAGS)
AC_SUBST(VINAGRE_LIBS)
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.3.4 on Mon Sep 17 10:55:17 2007 -->
<!--Generated with glade3 3.4.0 on Thu Oct 4 14:00:19 2007 -->
<glade-interface>
<widget class="GtkDialog" id="connect_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
......@@ -45,40 +45,35 @@
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label"> </property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<widget class="GtkButton" id="find_button">
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Host:</property>
<property name="use_underline">True</property>
<property name="no_show_all">True</property>
<property name="label">gtk-find</property>
<property name="use_stock">True</property>
<property name="focus_on_click">False</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="host_entry">
<widget class="GtkSpinButton" id="port_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="activates_default">True</property>
<property name="adjustment">5900 1025 65535 1 10 10</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
......@@ -100,39 +95,44 @@
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="port_entry">
<widget class="GtkEntry" id="host_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="activates_default">True</property>
<property name="adjustment">5900 1025 65535 1 10 10</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_EXPAND | GTK_SHRINK | GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="find_button">
<property name="receives_default">True</property>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="no_show_all">True</property>
<property name="label">gtk-find</property>
<property name="use_stock">True</property>
<property name="focus_on_click">False</property>
<property name="response_id">0</property>
<property name="label" translatable="yes">_Host:</property>
<property name="use_underline">True</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label"> </property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
</widget>
<packing>
<property name="padding">6</property>
......@@ -213,22 +213,38 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">6</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="row_spacing">5</property>
<child>
<widget class="GtkLabel" id="label6">
<widget class="GtkCheckButton" id="save_password_check">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Password:</property>
<property name="label" translatable="yes">_Remember this password</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">password_entry</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="host_label">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
......@@ -241,43 +257,42 @@
<property name="activates_default">True</property>
</widget>
<packing>
<property name="position">1</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label7">
<placeholder/>
</child>
<child>
<widget class="GtkLabel" id="label21">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label"> </property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Password:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">password_entry</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="save_password_check1">
<widget class="GtkLabel" id="label19">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Save this password on keyring</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Host:</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
<property name="mnemonic_widget">password_entry</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
</widget>
......@@ -491,45 +506,38 @@
<placeholder/>
</child>
<child>
<widget class="GtkSpinButton" id="edit_favorite_port_entry">
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="activates_default">True</property>
<property name="adjustment">5000 5000 6000 1 10 10</property>
<property name="label"> </property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="edit_favorite_host_entry">
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="activates_default">True</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edit_favorite_name_entry</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="edit_favorite_name_entry">
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="is_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="activates_default">True</property>
<property name="label" translatable="yes">_Host:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edit_favorite_host_entry</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
......@@ -548,39 +556,46 @@
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<widget class="GtkEntry" id="edit_favorite_name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="is_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Host:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edit_favorite_host_entry</property>
<property name="activates_default">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label14">
<widget class="GtkEntry" id="edit_favorite_host_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">edit_favorite_name_entry</property>
<property name="activates_default">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<widget class="GtkSpinButton" id="edit_favorite_port_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label"> </property>
<property name="activates_default">True</property>
<property name="adjustment">5000 5000 6000 1 10 10</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</widget>
<packing>
......
......@@ -157,11 +157,6 @@ vinagre_favorites_add (VinagreConnection *conn,
name,
"port",
conn->port);
if (conn->password)
g_key_file_set_string (favorites,
name,
"password",
conn->password);
vinagre_connection_set_name (conn, name);
vinagre_favorites_save_file ();
......@@ -218,10 +213,6 @@ vinagre_favorites_edit (VinagreConnection *conn,
name,
"host",
conn->host);
g_key_file_set_string (favorites,
name,
"password",
conn->password);
g_key_file_set_integer (favorites,
name,
"port",
......@@ -259,10 +250,6 @@ vinagre_favorites_get_all (void)
vinagre_connection_set_host (conn, s_value);
g_free (s_value);
s_value = g_key_file_get_string (favorites, conns[i], "password", NULL);
vinagre_connection_set_password (conn, s_value);
g_free (s_value);
i_value = g_key_file_get_integer (favorites, conns[i], "port", NULL);
vinagre_connection_set_port (conn, i_value);
......@@ -345,9 +332,6 @@ vinagre_favorites_exists (const char *host, int port)
g_free (s_host);
s_host = g_key_file_get_string (favorites, conns[i], "password", NULL);
vinagre_connection_set_password (conn, s_host);
break;
}
......
......@@ -24,6 +24,7 @@
#include <glib/gi18n.h>
#include <glade/glade.h>
#include <gnome-keyring.h>
#include <vncdisplay.h>
#include "vinagre-notebook.h"
......@@ -34,12 +35,14 @@
struct _VinagreTabPrivate
{
GtkWidget *vnc;
GtkWidget *vnc;
VinagreConnection *conn;
VinagreNotebook *nb;
VinagreWindow *window;
GtkStatusbar *status;
guint status_id;
VinagreNotebook *nb;
VinagreWindow *window;
GtkStatusbar *status;
guint status_id;
gboolean save_password;
guint32 keyring_item_id;
};
G_DEFINE_TYPE(VinagreTab, vinagre_tab, GTK_TYPE_VBOX)
......@@ -218,6 +221,12 @@ vnc_auth_failed_cb (VncDisplay *vnc, const gchar *msg, VinagreTab *tab)
vinagre_utils_show_error (message->str, GTK_WINDOW (tab->priv->window));
g_string_free (message, TRUE);
if (tab->priv->keyring_item_id > 0)
{
gnome_keyring_item_delete_sync (NULL, tab->priv->keyring_item_id);
tab->priv->keyring_item_id = 0;
}
vinagre_notebook_remove_tab (tab->priv->nb, tab);
}
......@@ -255,6 +264,66 @@ vnc_server_cut_text_cb (VncDisplay *vnc, const gchar *text, VinagreTab *tab)
}
}
static void
vinagre_tab_save_password (VinagreTab *tab)
{
GnomeKeyringResult result;
if (!tab->priv->save_password)
return;
result = gnome_keyring_set_network_password_sync (
NULL, /* default keyring */
NULL, /* user */
NULL, /* domain */
tab->priv->conn->host, /* server */
NULL, /* object */
"rfb", /* protocol */
"vnc-password", /* authtype */
tab->priv->conn->port, /* port */
tab->priv->conn->password, /* password */
&tab->priv->keyring_item_id);
if (result != GNOME_KEYRING_RESULT_OK)
vinagre_utils_show_error (_("Error saving the password on the keyring."),
GTK_WINDOW (tab->priv->window));
tab->priv->save_password = FALSE;
}
static gchar *
vinagre_tab_find_password (VinagreTab *tab)
{
GnomeKeyringNetworkPasswordData *found_item;
GnomeKeyringResult result;
GList *matches;
gchar *password;
matches = NULL;
result = gnome_keyring_find_network_password_sync (
NULL, /* user */
NULL, /* domain */
tab->priv->conn->host, /* server */
NULL, /* object */
"rfb", /* protocol */
"vnc-password", /* authtype */
tab->priv->conn->port, /* port */
&matches);
if (result != GNOME_KEYRING_RESULT_OK || matches == NULL || matches->data == NULL)
return NULL;
found_item = (GnomeKeyringNetworkPasswordData *) matches->data;
password = g_strdup (found_item->password);
tab->priv->keyring_item_id = found_item->item_id;
gnome_keyring_network_password_list_free (matches);
return password;
}
static void
vnc_initialized_cb (VncDisplay *vnc, VinagreTab *tab)
{
......@@ -267,6 +336,7 @@ vnc_initialized_cb (VncDisplay *vnc, VinagreTab *tab)
gtk_label_set_label (label, vinagre_connection_best_name (tab->priv->conn));
vinagre_window_set_title (tab->priv->window);
vinagre_tab_save_password (tab);
/* Emits the signal saying that we have connected to the machine */
g_signal_emit (G_OBJECT (tab),
......@@ -279,8 +349,8 @@ ask_password(VinagreTab *tab)
{
GladeXML *xml;
const char *glade_file;
GtkWidget *password_dialog, *password_entry;
gchar *password;
GtkWidget *password_dialog, *password_entry, *host_label, *save_password_check;
gchar *password = NULL;
int result;
glade_file = vinagre_utils_get_glade_filename ();
......@@ -289,19 +359,22 @@ ask_password(VinagreTab *tab)
password_dialog = glade_xml_get_widget (xml, "password_required_dialog");
gtk_window_set_transient_for (GTK_WINDOW(password_dialog), GTK_WINDOW(tab->priv->window));
host_label = glade_xml_get_widget (xml, "host_label");
gtk_label_set_text (GTK_LABEL (host_label), vinagre_connection_best_name (tab->priv->conn));
result = gtk_dialog_run (GTK_DIALOG (password_dialog));
if (result != -5)
if (result == -5)
{
gtk_widget_destroy (GTK_WIDGET (password_dialog));
return NULL;
}
password_entry = glade_xml_get_widget (xml, "password_entry");
password = g_strdup (gtk_entry_get_text (GTK_ENTRY (password_entry)));
password_entry = glade_xml_get_widget (xml, "password_entry");
password = g_strdup (gtk_entry_get_text (GTK_ENTRY (password_entry)));
save_password_check = glade_xml_get_widget (xml, "save_password_check");
tab->priv->save_password = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (save_password_check));
}
gtk_widget_destroy (GTK_WIDGET (password_dialog));
g_object_unref (xml);
return password;
}
......@@ -309,12 +382,16 @@ static void
vnc_authentication_cb (VncDisplay *vnc, GValueArray *credList, VinagreTab *tab)
{
gchar *password;
password = ask_password (tab);
if (!password) {
vinagre_notebook_remove_tab (tab->priv->nb, tab);
return;
}
password = vinagre_tab_find_password (tab);
if (!password)
{
password = ask_password (tab);
if (!password) {
vinagre_notebook_remove_tab (tab->priv->nb, tab);
return;
}
}
vinagre_connection_set_password (tab->priv->conn, password);
vnc_display_set_credential (vnc, VNC_DISPLAY_CREDENTIAL_PASSWORD, password);
......@@ -350,6 +427,8 @@ vinagre_tab_init (VinagreTab *tab)
GtkWidget *align;
tab->priv = VINAGRE_TAB_GET_PRIVATE (tab);
tab->priv->save_password = FALSE;
tab->priv->keyring_item_id = 0;
/* Create the alignment */
align = gtk_alignment_new (0.5, 0.5, 0, 0);
......
......@@ -78,6 +78,7 @@ vinagre_window_delete_event (GtkWidget *widget,
g_signal_handler_disconnect (window->priv->notebook<