[calls] sip-account-widget: Add switch to specify account can handle tel URI



commit 992a243de6c7074d33d0dcc03703e1c8963f9ac2
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Thu Oct 21 11:17:40 2021 +0200

    sip-account-widget: Add switch to specify account can handle tel URI
    
    Fixes #277

 plugins/sip/calls-sip-account-widget.c |  8 +++++++-
 plugins/sip/sip-account-widget.ui      | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
---
diff --git a/plugins/sip/calls-sip-account-widget.c b/plugins/sip/calls-sip-account-widget.c
index 51995f60..61586bfb 100644
--- a/plugins/sip/calls-sip-account-widget.c
+++ b/plugins/sip/calls-sip-account-widget.c
@@ -67,6 +67,7 @@ struct _CallsSipAccountWidget {
   char             *last_port;
   HdyComboRow      *protocol;
   GListStore       *protocols_store; /* bound model for protocol HdyComboRow */
+  GtkSwitch        *tel_switch;
 
 
   /* properties */
@@ -266,6 +267,7 @@ clear_form (CallsSipAccountWidget *self)
   gtk_entry_set_text (self->password, "");
   gtk_entry_set_text (self->port, "0");
   hdy_combo_row_set_selected_index (self->protocol, 0);
+  gtk_switch_set_state (self->tel_switch, FALSE);
 
   self->origin = NULL;
 
@@ -288,6 +290,7 @@ edit_form (CallsSipAccountWidget *self,
   g_autofree char *protocol = NULL;
   gint port;
   guint protocol_index;
+  gboolean can_tel;
 
   g_assert (CALLS_IS_SIP_ACCOUNT_WIDGET (self));
 
@@ -307,6 +310,7 @@ edit_form (CallsSipAccountWidget *self,
                 "password", &password,
                 "port", &port,
                 "transport-protocol", &protocol,
+                "can-tel", &can_tel,
                 NULL);
 
   port_str = g_strdup_printf ("%d", port);
@@ -325,6 +329,7 @@ edit_form (CallsSipAccountWidget *self,
   gtk_entry_set_text (self->password, password);
   gtk_entry_set_text (self->port, port_str);
   hdy_combo_row_set_selected_index (self->protocol, protocol_index);
+  gtk_switch_set_state (self->tel_switch, can_tel);
 
   gtk_widget_set_sensitive (self->apply_btn, FALSE);
 
@@ -397,7 +402,7 @@ on_apply_clicked (CallsSipAccountWidget *self)
                                     gtk_entry_get_text (self->display_name),
                                     get_selected_protocol (self),
                                     get_port (self),
-                                    FALSE,
+                                    gtk_switch_get_state (self->tel_switch),
                                     TRUE);
 
   update_header (self);
@@ -502,6 +507,7 @@ calls_sip_account_widget_class_init (CallsSipAccountWidgetClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CallsSipAccountWidget, password);
   gtk_widget_class_bind_template_child (widget_class, CallsSipAccountWidget, port);
   gtk_widget_class_bind_template_child (widget_class, CallsSipAccountWidget, protocol);
+  gtk_widget_class_bind_template_child (widget_class, CallsSipAccountWidget, tel_switch);
 
   gtk_widget_class_bind_template_callback (widget_class, on_login_clicked);
   gtk_widget_class_bind_template_callback (widget_class, on_delete_clicked);
diff --git a/plugins/sip/sip-account-widget.ui b/plugins/sip/sip-account-widget.ui
index 751033d4..b7cf477a 100644
--- a/plugins/sip/sip-account-widget.ui
+++ b/plugins/sip/sip-account-widget.ui
@@ -180,6 +180,24 @@
             </child>
           </object>
         </child>
+        <child>
+          <object class="HdyPreferencesGroup">
+            <property name="visible">True</property>
+            <child>
+              <object class="HdyActionRow">
+                <property name="visible">True</property>
+                <property name="title" translatable="yes">Use for Phone Calls</property>
+                <child>
+                  <object class="GtkSwitch" id="tel_switch">
+                    <property name="visible">True</property>
+                    <property name="valign">center</property>
+                    <signal name="notify::active" handler="on_user_changed" swapped="yes"/>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
   </template>


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