1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-14 04:15:37 +00:00

new-call-box: Switch to using CuiDialpad

It has been in libcall-ui for some time, so let's use it.

This will also easy the transition to Gtk4 as it's one less widget we
have to worry about.
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-12-16 15:19:19 +01:00
parent 527f3a72ca
commit d8446e680b
2 changed files with 17 additions and 138 deletions

View file

@ -31,6 +31,7 @@
#include "calls-settings.h"
#include "calls-ussd.h"
#include <call-ui.h>
#include <glib/gi18n.h>
#include <handy.h>
@ -46,13 +47,10 @@ struct _CallsNewCallBox {
GtkListBox *origin_list_box;
HdyComboRow *origin_list;
GtkButton *backspace;
HdyKeypad *keypad;
GtkButton *dial;
CuiDialpad *dialpad;
GtkEntry *address_entry;
HdyActionRow *result;
GtkButton *dial_result;
GtkGestureLongPress *long_press_back_gesture;
GList *dial_queue;
@ -170,23 +168,6 @@ notify_selected_index_cb (CallsNewCallBox *self)
}
static void
long_press_back_cb (CallsNewCallBox *self)
{
GtkEntry *entry = hdy_keypad_get_entry (self->keypad);
gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1);
}
static void
backspace_clicked_cb (CallsNewCallBox *self)
{
GtkEntry *entry = hdy_keypad_get_entry (self->keypad);
g_signal_emit_by_name (entry, "backspace", NULL);
}
static void
ussd_send_cb (GObject *object,
GAsyncResult *result,
@ -215,21 +196,23 @@ ussd_send_cb (GObject *object,
}
static void
dial_clicked_cb (CallsNewCallBox *self)
dialpad_dialed_cb (CuiDialpad *dialpad,
const char *number,
CallsNewCallBox *self)
{
GtkEntry *entry = hdy_keypad_get_entry (self->keypad);
GtkWidget *window;
const char *text;
g_assert (CALLS_IS_NEW_CALL_BOX (self));
window = gtk_widget_get_toplevel (GTK_WIDGET (self));
text = gtk_entry_get_text (entry);
if (CALLS_IS_MAIN_WINDOW (window))
calls_main_window_dial (CALLS_MAIN_WINDOW (window), text);
calls_main_window_dial (CALLS_MAIN_WINDOW (window), number);
else
calls_new_call_box_dial (self, text);
calls_new_call_box_dial (self, number);
}
static void
dial_result_clicked_cb (CallsNewCallBox *self)
{
@ -306,7 +289,7 @@ origin_count_changed_cb (CallsNewCallBox *self)
n_items = g_list_model_get_n_items (origins);
gtk_widget_set_visible (GTK_WIDGET (self->origin_list_box), n_items > 1);
gtk_widget_set_sensitive (GTK_WIDGET (self->dial), n_items > 0);
gtk_widget_set_sensitive (GTK_WIDGET (self->dialpad), n_items > 0);
if (n_items)
dial_queued (self);
@ -358,9 +341,6 @@ calls_new_call_box_dispose (GObject *object)
clear_dial_queue (self);
if (self->long_press_back_gesture != NULL)
g_object_unref (self->long_press_back_gesture);
G_OBJECT_CLASS (calls_new_call_box_parent_class)->dispose (object);
}
@ -377,18 +357,13 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Calls/ui/new-call-box.ui");
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, origin_list_box);
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, origin_list);
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, backspace);
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, dialpad);
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, dialpad_dialed_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);
gtk_widget_class_bind_template_callback (widget_class, notify_selected_index_cb);
props[PROP_NUMERIC_INPUT_ONLY] =
@ -409,6 +384,7 @@ calls_new_call_box_new (void)
}
void
calls_new_call_box_dial (CallsNewCallBox *self,
const gchar *target)
@ -439,7 +415,6 @@ calls_new_call_box_send_ussd_async (CallsNewCallBox *self,
{
g_autoptr (CallsOrigin) origin = NULL;
g_autoptr (GTask) task = NULL;
GtkEntry *entry;
g_return_if_fail (CALLS_IS_NEW_CALL_BOX (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
@ -463,9 +438,6 @@ calls_new_call_box_send_ussd_async (CallsNewCallBox *self,
calls_ussd_initiate_async (CALLS_USSD (origin), target, cancellable,
ussd_send_cb, g_steal_pointer (&task));
entry = hdy_keypad_get_entry (self->keypad);
gtk_editable_delete_text (GTK_EDITABLE (entry), 0, -1);
}
char *

View file

@ -4,18 +4,12 @@
<requires lib="gtk+" version="3.22"/>
<requires lib="libhandy" version="1.0"/>
<template class="CallsNewCallBox" parent="GtkBox">
<property name="margin_bottom">16</property>
<property name="margin_left">24</property>
<property name="margin_right">24</property>
<property name="margin_top">16</property>
<property name="margin_top">6</property>
<property name="orientation">vertical</property>
<property name="visible">True</property>
<child>
<object class="HdyClamp">
<property name="visible">True</property>
<property name="vexpand">True</property>
<property name="maximum-size">300</property>
<child>
<object class="HdyClamp">
<property name="visible">True</property>
@ -28,7 +22,6 @@
<object class="GtkListBox" id="origin_list_box">
<property name="visible">True</property>
<property name="selection-mode">none</property>
<property name="margin-bottom">6</property>
<property name="halign">center</property>
<child>
<object class="HdyComboRow" id="origin_list">
@ -51,89 +44,9 @@
</object>
</child>
<child>
<object class="GtkEntry" id="keypad_entry">
<object class="CuiDialpad" id="dialpad">
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create"/>
<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>
</object>
</child>
<child>
<object class="HdyKeypad" id="keypad">
<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>
<property name="margin_top">18</property>
<property name="margin_bottom">18</property>
<property name="entry">keypad_entry</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible" bind-source="CallsNewCallBox" bind-property="numeric-input-only" bind-flags="sync-create"/>
<property name="orientation">horizontal</property>
<child type="center">
<object class="GtkButton" id="dial">
<property name="always_show_image">True</property>
<property name="receives_default">True</property>
<property name="visible">True</property>
<signal name="clicked" handler="dial_clicked_cb" swapped="yes"/>
<style>
<class name="suggested-action"/>
<class name="image-button"/>
<class name="dial-button"/>
</style>
<child internal-child="accessible">
<object class="AtkObject" id="a11y-dial">
<property name="accessible-name" translatable="yes">Dial</property>
</object>
</child>
<child>
<object class="GtkImage" id="back_image">
<property name="visible">True</property>
<property name="icon-name">call-start-symbolic</property>
<property name="icon-size">5</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkButton" id="backspace">
<property name="always_show_image">True</property>
<property name="visible">True</property>
<property name="focus-on-click">False</property>
<property name="margin_right">15</property>
<property name="valign">center</property>
<property name="halign">center</property>
<signal name="clicked" handler="backspace_clicked_cb" swapped="yes"/>
<child internal-child="accessible">
<object class="AtkObject" id="a11y-backspace">
<property name="accessible-name" translatable="yes">Delete character in front of cursor</property>
</object>
</child>
<style>
<class name="delete-button"/>
</style>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon-name">edit-clear-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
<signal name="dialed" handler="dialpad_dialed_cb"/>
</object>
</child>
<child>
@ -178,11 +91,5 @@
</child>
</object>
</child>
</object>
</child>
</template>
<object class="GtkGestureLongPress" id="long_press_back_gesture">
<property name="widget">backspace</property>
<signal name="pressed" handler="long_press_back_cb" object="CallsNewCallBox" swapped="true"/>
</object>
</interface>