[vinagre] Connect button should be inactive if no host is given. Closes #591604.



commit 19e0ddff920cd58c5020c151b11151d5df992ff5
Author: Jonh Wendell <jwendell gnome org>
Date:   Thu Aug 13 14:09:17 2009 -0300

    Connect button should be inactive if no host is given. Closes #591604.

 data/vinagre.ui           |    5 +++--
 vinagre/vinagre-connect.c |   24 ++++++++++++++++++------
 2 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/data/vinagre.ui b/data/vinagre.ui
index d0aa709..33c99ec 100644
--- a/data/vinagre.ui
+++ b/data/vinagre.ui
@@ -236,7 +236,7 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="button2">
+              <object class="GtkButton" id="connect_button">
                 <property name="label">gtk-connect</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
@@ -245,6 +245,7 @@
                 <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="use_stock">True</property>
+                <property name="sensitive">False</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -263,7 +264,7 @@
     </child>
     <action-widgets>
       <action-widget response="-6">button1</action-widget>
-      <action-widget response="-5">button2</action-widget>
+      <action-widget response="-5">connect_button</action-widget>
     </action-widgets>
   </object>
   <object class="GtkDialog" id="auth_required_dialog">
diff --git a/vinagre/vinagre-connect.c b/vinagre/vinagre-connect.c
index 3a30f26..10b76e0 100644
--- a/vinagre/vinagre-connect.c
+++ b/vinagre/vinagre-connect.c
@@ -48,6 +48,7 @@ typedef struct {
   GtkWidget *find_button;
   GtkWidget *fullscreen_check;
   GtkWidget *plugin_box;
+  GtkWidget *connect_button;
 } VinagreConnectDialog;
 
 enum {
@@ -220,14 +221,23 @@ saved_history (void)
 }
 
 static void
-setup_combo (GtkWidget *combo)
+control_connect_button (GtkEditable *entry, VinagreConnectDialog *dialog)
+{
+  gtk_widget_set_sensitive (dialog->connect_button,
+			    gtk_entry_get_text_length (GTK_ENTRY (entry)) > 0);
+}
+
+static void
+setup_combo (VinagreConnectDialog *dialog)
 {
   GtkListStore *store;
   GtkTreeIter   iter;
   GtkEntryCompletion *completion;
   GPtrArray    *history;
   gint          i, size;
+  GtkEntry     *entry;
 
+  entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dialog->host_entry)));
   store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING);
 
   history = saved_history ();
@@ -244,19 +254,20 @@ setup_combo (GtkWidget *combo)
     }
   g_ptr_array_free (history, TRUE);
 
-  gtk_combo_box_set_model (GTK_COMBO_BOX (combo),
+  gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->host_entry),
 			   GTK_TREE_MODEL (store));
-  gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (combo),
+  gtk_combo_box_entry_set_text_column (GTK_COMBO_BOX_ENTRY (dialog->host_entry),
 				       0);
 
   completion = gtk_entry_completion_new ();
   gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (store));
   gtk_entry_completion_set_text_column (completion, 0);
   gtk_entry_completion_set_inline_completion (completion, TRUE);
-  gtk_entry_set_completion (GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), completion);
+  gtk_entry_set_completion (entry, completion);
   g_object_unref (completion);
 
-  gtk_entry_set_activates_default (GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combo))), TRUE);
+  gtk_entry_set_activates_default (entry, TRUE);
+  g_signal_connect (entry, "changed", G_CALLBACK (control_connect_button), dialog);
 }
 
 static void
@@ -374,9 +385,10 @@ VinagreConnection *vinagre_connect (VinagreWindow *window)
   dialog.find_button = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "find_button"));
   dialog.fullscreen_check = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "fullscreen_check"));
   dialog.plugin_box = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "plugin_options_connect_vbox"));
+  dialog.connect_button = GTK_WIDGET (gtk_builder_get_object (dialog.xml, "connect_button"));
 
   setup_protocol (&dialog);
-  setup_combo (dialog.host_entry);
+  setup_combo (&dialog);
 
 #ifdef VINAGRE_ENABLE_AVAHI
   g_signal_connect (dialog.find_button,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]