[gtk+/wip/gbsneto/other-locations] placesview: connect to server when entry is activated



commit fc3a3814455e9f0665f4086dba90edf0ccff6857
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jul 1 00:18:58 2015 -0300

    placesview: connect to server when entry is activated
    
    Not only the connect button, but also the entry should enable
    connecting to the typed server.

 gtk/gtkplacesview.c     |   13 ++++++++++---
 gtk/ui/gtkplacesview.ui |    3 ++-
 2 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 9ed5b36..9f54e18 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -861,8 +861,7 @@ mount_volume (GtkPlacesView *view,
 }
 
 static void
-on_connect_button_clicked (GtkButton     *button,
-                           GtkPlacesView *view)
+on_connect_button_clicked (GtkPlacesView *view)
 {
   GtkPlacesViewPrivate *priv;
   const gchar *uri;
@@ -873,6 +872,14 @@ on_connect_button_clicked (GtkButton     *button,
   priv = view->priv;
   file = NULL;
 
+  /*
+   * Since the 'Connect' button is updated whenever the typed
+   * address changes, it is sufficient to check if it's sensitive
+   * or not, in order to determine if the given address is valid.
+   */
+  if (!gtk_widget_get_sensitive (priv->connect_button))
+    return;
+
        uri = gtk_entry_get_text (GTK_ENTRY (priv->address_entry));
 
   if (uri != NULL && uri[0] != '\0')
@@ -880,7 +887,7 @@ on_connect_button_clicked (GtkButton     *button,
 
   if (file)
     {
-      gtk_entry_set_text (GTK_ENTRY (priv->address_entry), NULL);
+      gtk_entry_set_text (GTK_ENTRY (priv->address_entry), "");
       mount_location (view, file);
     }
   else
diff --git a/gtk/ui/gtkplacesview.ui b/gtk/ui/gtkplacesview.ui
index 14024be..68ef7de 100644
--- a/gtk/ui/gtkplacesview.ui
+++ b/gtk/ui/gtkplacesview.ui
@@ -225,7 +225,7 @@
             <property name="can_focus">True</property>
             <property name="sensitive">False</property>
             <property name="receives_default">True</property>
-            <signal name="clicked" handler="on_connect_button_clicked" object="GtkPlacesView" swapped="no" />
+            <signal name="clicked" handler="on_connect_button_clicked" object="GtkPlacesView" swapped="yes" 
/>
           </object>
           <packing>
             <property name="pack_type">end</property>
@@ -243,6 +243,7 @@
                 <property name="width_chars">20</property>
                 <property name="placeholder_text" translatable="yes">For example: 
smb://foo.example.org</property>
                 <signal name="notify::text" handler="on_address_entry_text_changed" object="GtkPlacesView" 
swapped="yes" />
+                <signal name="activate" handler="on_connect_button_clicked" object="GtkPlacesView" 
swapped="yes" />
               </object>
               <packing>
                 <property name="expand">False</property>


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