1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-11 23:27:35 +00:00

new-call-box: Add entry for non-numeric inputs

This commit is contained in:
Evangelos Ribeiro Tzaras 2021-07-19 10:45:54 +02:00
parent e9661ce01c
commit db848b2c9f
3 changed files with 95 additions and 16 deletions

View file

@ -49,6 +49,8 @@ struct _CallsNewCallBox
GtkButton *backspace;
HdyKeypad *keypad;
GtkButton *dial;
GtkEntry *address_entry;
GtkButton *dial_result;
GtkGestureLongPress *long_press_back_gesture;
GList *dial_queue;
@ -59,6 +61,23 @@ struct _CallsNewCallBox
G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX);
static CallsOrigin *
get_selected_origin (CallsNewCallBox *self)
{
g_autoptr (CallsOrigin) origin = NULL;
GListModel *model = hdy_combo_row_get_model (self->origin_list);
gint index = -1;
if (model)
index = hdy_combo_row_get_selected_index (self->origin_list);
if (model && index >= 0)
origin = g_list_model_get_item (model, index);
return origin;
}
static CallsOrigin *
get_origin (CallsNewCallBox *self,
const char *target)
@ -66,7 +85,6 @@ get_origin (CallsNewCallBox *self,
CallsApplication *app = CALLS_APPLICATION (g_application_get_default ());
g_autoptr (CallsOrigin) origin = NULL;
GListModel *model;
int index = -1;
gboolean auto_use_def_origin =
calls_application_get_use_default_origins_setting (app);
@ -78,17 +96,10 @@ get_origin (CallsNewCallBox *self,
origin = g_list_model_get_item (model, 0);
return origin;
} else {
return get_selected_origin (self);
}
model = hdy_combo_row_get_model (self->origin_list);
if (model)
index = hdy_combo_row_get_selected_index (self->origin_list);
if (model && index >= 0)
origin = g_list_model_get_item (model, index);
return origin;
}
@ -148,6 +159,18 @@ dial_clicked_cb (CallsNewCallBox *self)
calls_new_call_box_dial (self, text);
}
static void
dial_result_clicked_cb (CallsNewCallBox *self)
{
CallsOrigin *origin = get_selected_origin (self);
const char *address = gtk_entry_get_text (self->address_entry);
if (origin)
calls_origin_dial (origin, address);
else
g_warning ("No suitable origin found. How was this even clicked?");
}
static void
dial_queued_cb (gchar *target,
@ -284,7 +307,9 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, long_press_back_gesture);
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, 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);
gtk_widget_class_bind_template_callback (widget_class, long_press_back_cb);

View file

@ -1,4 +1,4 @@
keypad > grid > button, .dial-button, .delete-button {
keypad > grid > button, .dial-button, .delete-button .rounded-button {
border-radius: 9999px;
-gtk-outline-radius: 9999px;
}
@ -15,6 +15,10 @@ keypad > grid > button, .dial-button, .delete-button {
font-size: 24px;
}
.address-entry {
font-size: 18px;
}
.error-state-message {
background-color: @error_color;
border-bottom: 1px solid darker(@error_color);

View file

@ -18,6 +18,7 @@
<object class="GtkListBox" id="origin_list_box">
<property name="visible">True</property>
<property name="selection-mode">none</property>
<property name="margin-bottom">6</property>
<child>
<object class="HdyComboRow" id="origin_list">
<property name="visible">True</property>
@ -26,13 +27,22 @@
</object>
</child>
<child>
<object class="GtkEntry" id="address_entry">
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create|invert-boolean"/>
<property name="xalign">0.5</property>
<style>
<class name="address-entry"/>
</style>
</object>
</child>
<child>
<object class="GtkEntry" id="keypad_entry">
<property name="visible">True</property>
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create"/>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="xalign">0.5</property>
<property name="margin_right">6</property>
<style>
<class name="phone-number-entry"/>
</style>
@ -40,7 +50,7 @@
</child>
<child>
<object class="HdyKeypad" id="keypad">
<property name="visible">True</property>
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create"/>
<property name="column_spacing">16</property>
<property name="row_spacing">10</property>
<property name="halign">center</property>
@ -55,7 +65,7 @@
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create"/>
<property name="can_focus">False</property>
<property name="orientation">horizontal</property>
<child type="center">
@ -119,6 +129,46 @@
</child>
</object>
</child>
<child>
<object class="GtkListBox" id="result_list">
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create|invert-boolean"/>
<property name="margin-top">16</property>
<property name="selection-mode">none</property>
<child>
<object class="HdyActionRow" id="result">
<property name="visible">True</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>
<child type="prefix">
<object class="HdyAvatar">
<property name="visible">True</property>
<property name="show-initials">True</property>
<property name="size">36</property>
</object>
</child>
<child>
<object class="GtkButton" id="dial_result_btn">
<property name="visible">True</property>
<property name="always_show_image">True</property>
<signal name="clicked" handler="dial_result_clicked_cb" swapped="yes"/>
<style>
<class name="rounded-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">call-start-symbolic</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
<object class="GtkGestureLongPress" id="long_press_back_gesture">
<property name="widget">backspace</property>