~ubuntu-branches/ubuntu/lucid/vinagre/lucid

« back to all changes in this revision

Viewing changes to plugins/ssh/vinagre-ssh-plugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-02-09 16:25:33 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100209162533-7p06h6l947irsdyp
Tags: 2.29.90-0ubuntu1
* New upstream release:
 - Features
   + Improved SSH tunneling.
   + Show a message in the first run explaining menu accelerators and
     keyboard shortcuts behavior in Vinagre.
   + Store window size, position, panel state, etc in the XDG_CACHE_DIR
     instead of GConf.
   + Enable the username field for SSH connections.
   + Option to keep the aspect ratio when using scaling.
   + Modernize autotools.
   + SSH plugin uses the username provided from mdns (Avahi).
 - Fixes
   + Fix build on Solaris (Halton Huo).
   + Drop 1px line at toolbar in fullscreen mode.
   + Minor fixes
 - UI translations
* debian/control.in:
  - bump intltool build-dep
  - libx11-dev and libdbus-glib-1-dev build-dep

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <gmodule.h>
27
27
 
28
28
#include <vinagre/vinagre-debug.h>
 
29
#include <vinagre/vinagre-cache-prefs.h>
29
30
 
30
31
#include "vinagre-ssh-plugin.h"
31
32
#include "vinagre-ssh-connection.h"
32
33
#include "vinagre-ssh-tab.h"
33
34
 
 
35
#ifdef VINAGRE_ENABLE_AVAHI
 
36
#include <avahi-ui/avahi-ui.h>
 
37
#include <avahi-common/malloc.h>
 
38
#endif
 
39
 
34
40
#define VINAGRE_SSH_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_SSH_PLUGIN, VinagreSshPluginPrivate))
35
41
 
36
42
VINAGRE_PLUGIN_REGISTER_TYPE(VinagreSshPlugin, vinagre_ssh_plugin)
115
121
  G_OBJECT_CLASS (vinagre_ssh_plugin_parent_class)->finalize (object);
116
122
}
117
123
 
 
124
static GtkWidget *
 
125
impl_get_connect_widget (VinagrePlugin *plugin, VinagreConnection *conn)
 
126
{
 
127
  GtkWidget *box, *label, *u_box, *u_entry;
 
128
  gchar     *str;
 
129
 
 
130
  box = gtk_vbox_new (FALSE, 0);
 
131
 
 
132
  str = g_strdup_printf ("<b>%s</b>", _("SSH Options"));
 
133
  label = gtk_label_new (str);
 
134
  g_free (str);
 
135
  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
 
136
  gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
 
137
  gtk_misc_set_padding (GTK_MISC (label), 0, 6);
 
138
  gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
 
139
 
 
140
  u_box = gtk_hbox_new (FALSE, 4);
 
141
  label = gtk_label_new ("  ");
 
142
  gtk_box_pack_start (GTK_BOX (u_box), label, FALSE, FALSE, 0);
 
143
 
 
144
  label = gtk_label_new_with_mnemonic (_("_Username:"));
 
145
  gtk_box_pack_start (GTK_BOX (u_box), label, FALSE, FALSE, 0);
 
146
 
 
147
  u_entry = gtk_entry_new ();
 
148
  /* Translators: This is the tooltip for the username field in a SSH connection */
 
149
  gtk_widget_set_tooltip_text (u_entry, _("Optional. If blank, your username will be used. Also, it can be supplied in the Machine field above, in the form username@hostname."));
 
150
  g_object_set_data (G_OBJECT (box), "username_entry", u_entry);
 
151
  gtk_box_pack_start (GTK_BOX (u_box), u_entry, TRUE, TRUE, 5);
 
152
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), u_entry);
 
153
  str = g_strdup (VINAGRE_IS_CONNECTION (conn) ?
 
154
                  vinagre_connection_get_username (conn) :
 
155
                  vinagre_cache_prefs_get_string  ("ssh-connection", "username", ""));
 
156
  gtk_entry_set_text (GTK_ENTRY (u_entry), str);
 
157
  gtk_entry_set_activates_default (GTK_ENTRY (u_entry), TRUE);
 
158
  g_free (str);
 
159
 
 
160
  gtk_box_pack_start (GTK_BOX (box), u_box, TRUE, TRUE, 0);
 
161
  return box;
 
162
}
 
163
 
 
164
static void
 
165
ssh_parse_mdns_dialog (VinagrePlugin *plugin,
 
166
                       GtkWidget *connect_widget,
 
167
                       GtkWidget *dialog)
 
168
{
 
169
#ifdef VINAGRE_ENABLE_AVAHI
 
170
  const AvahiStringList *txt;
 
171
  gchar *u = NULL;
 
172
 
 
173
  for (txt = aui_service_dialog_get_txt_data (AUI_SERVICE_DIALOG (dialog)); txt; txt = txt->next)
 
174
    {
 
175
      char *key, *value;
 
176
 
 
177
      if (avahi_string_list_get_pair ((AvahiStringList*) txt, &key, &value, NULL) < 0)
 
178
        break;
 
179
 
 
180
      if (strcmp(key, "u") == 0)
 
181
        u = g_strdup(value);
 
182
 
 
183
      avahi_free (key);
 
184
      avahi_free (value);
 
185
    }
 
186
 
 
187
  if (u)
 
188
    {
 
189
      GtkEntry *u_entry = g_object_get_data (G_OBJECT (connect_widget), "username_entry");
 
190
 
 
191
      if (u_entry)
 
192
        gtk_entry_set_text (u_entry, u);
 
193
      else
 
194
        g_warning ("Wrong widget passed to ssh_parse_mdns_dialog()");
 
195
 
 
196
      g_free (u);
 
197
    }
 
198
#endif
 
199
}
 
200
 
118
201
static void
119
202
vinagre_ssh_plugin_class_init (VinagreSshPluginClass *klass)
120
203
{
132
215
  plugin_class->get_mdns_service  = impl_get_mdns_service;
133
216
  plugin_class->new_tab = impl_new_tab;
134
217
  plugin_class->get_default_port = impl_get_default_port;
 
218
  plugin_class->get_connect_widget = impl_get_connect_widget;
 
219
  plugin_class->parse_mdns_dialog = ssh_parse_mdns_dialog;
135
220
}
136
221
/* vim: set ts=8: */