[calls] new-call-box: Hide empty results



commit 9c777b7db8754f841cd4a4ab6eb1b1ec1a8e6e45
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Thu Aug 19 01:35:14 2021 +0200

    new-call-box: Hide empty results
    
    Because the empty result looks weird.

 src/calls-new-call-box.c | 14 ++++++++++++++
 src/ui/new-call-box.ui   |  3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/src/calls-new-call-box.c b/src/calls-new-call-box.c
index 78228c4b..582358b6 100644
--- a/src/calls-new-call-box.c
+++ b/src/calls-new-call-box.c
@@ -50,6 +50,7 @@ struct _CallsNewCallBox
   HdyKeypad *keypad;
   GtkButton *dial;
   GtkEntry  *address_entry;
+  HdyActionRow *result;
   GtkButton *dial_result;
   GtkGestureLongPress *long_press_back_gesture;
 
@@ -113,6 +114,17 @@ address_activate_cb (CallsNewCallBox *self)
     calls_origin_dial (origin, address);
 }
 
+
+static void
+address_changed_cb (CallsNewCallBox *self)
+{
+  const char *address = gtk_entry_get_text (self->address_entry);
+
+  gtk_widget_set_visible (GTK_WIDGET (self->result),
+                          address && *address != '\0');
+}
+
+
 static void
 set_numeric (CallsNewCallBox *self,
              gboolean         enable)
@@ -347,6 +359,8 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, dial);
   gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, address_entry);
   gtk_widget_class_bind_template_callback (widget_class, address_activate_cb);
+  gtk_widget_class_bind_template_callback (widget_class, address_changed_cb);
+  gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, result);
   gtk_widget_class_bind_template_callback (widget_class, dial_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, dial_result_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, backspace_clicked_cb);
diff --git a/src/ui/new-call-box.ui b/src/ui/new-call-box.ui
index 4eeae97e..9a40aeed 100644
--- a/src/ui/new-call-box.ui
+++ b/src/ui/new-call-box.ui
@@ -32,6 +32,7 @@
         <property name="xalign">0.5</property>
         <property name="placeholder-text" translatable="yes">Enter a VoIP address</property>
         <signal name="activate" handler="address_activate_cb" swapped="yes"/>
+        <signal name="changed" handler="address_changed_cb" swapped="yes"/>
         <style>
           <class name="address-entry"/>
         </style>
@@ -138,7 +139,7 @@
         <property name="selection-mode">none</property>
         <child>
           <object class="HdyActionRow" id="result">
-            <property name="visible">True</property>
+            <property name="visible">False</property>
             <property name="title" bind-source="address_entry" bind-property="text"/>
             <property name="width-request">300</property>
             <property name="subtitle" translatable="yes">SIP Account</property>


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