[calls] new-call-box: Press enter to place a call



commit b1c22e4310c792896e018c032c5f737c31512ef4
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Thu Aug 19 01:08:34 2021 +0200

    new-call-box: Press enter to place a call
    
    Connect to the "activate" signal and take appropriate action
    for both numeric and non-numeric cases.

 src/calls-new-call-box.c | 14 +++++++++++++-
 src/ui/new-call-box.ui   |  2 ++
 2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/calls-new-call-box.c b/src/calls-new-call-box.c
index f7fda833..78228c4b 100644
--- a/src/calls-new-call-box.c
+++ b/src/calls-new-call-box.c
@@ -103,6 +103,16 @@ get_origin (CallsNewCallBox *self,
 }
 
 
+static void
+address_activate_cb (CallsNewCallBox *self)
+{
+  CallsOrigin *origin = get_selected_origin (self);
+  const char *address = gtk_entry_get_text (self->address_entry);
+
+  if (origin && address && *address != '\0')
+    calls_origin_dial (origin, address);
+}
+
 static void
 set_numeric (CallsNewCallBox *self,
              gboolean         enable)
@@ -130,6 +140,7 @@ notify_selected_index_cb (CallsNewCallBox *self)
 }
 
 
+
 static void
 long_press_back_cb (CallsNewCallBox *self)
 {
@@ -192,7 +203,7 @@ dial_result_clicked_cb (CallsNewCallBox *self)
   CallsOrigin *origin = get_selected_origin (self);
   const char *address = gtk_entry_get_text (self->address_entry);
 
-  if (origin)
+  if (origin && address && *address != '\0')
     calls_origin_dial (origin, address);
   else
     g_warning ("No suitable origin found. How was this even clicked?");
@@ -335,6 +346,7 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, keypad);
   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, 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 984e0828..4eeae97e 100644
--- a/src/ui/new-call-box.ui
+++ b/src/ui/new-call-box.ui
@@ -31,6 +31,7 @@
         <property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" 
bind-flags="sync-create|invert-boolean"/>
         <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"/>
         <style>
           <class name="address-entry"/>
         </style>
@@ -42,6 +43,7 @@
         <property name="hexpand">True</property>
         <property name="xalign">0.5</property>
         <property name="placeholder-text" translatable="yes">Enter a number</property>
+        <signal name="activate" handler="dial_clicked_cb" swapped="yes"/>
         <style>
           <class name="phone-number-entry"/>
         </style>


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