mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-06 11:35:32 +00:00
Replace HdyDialer with HdyKeypad and bump libhandy to 0.0.12
HdyDialer was deprecated and therefore is replaced with HdyKeypad. HdyDialer used a `gchr *` to store the entered phone number. On every button press the entire text of the display entry was replaced with the new string, which messed up selection and cursor position. HdyKeypad connects directly to a GtkEntry and inserts each button press the same way as a keyboard stroke would do. In the case of the `call display` entry every new digit is appended to the end of the input and therefore it also moves the cursor to the end of the entry. Instead of making the Entry not editable, only the events which would remove text form the entry are blocked, via the `delete-text` signal. And the signal `insert-text` is used to block unwanted chars from beeing inserted. Same as for the `call display` entry also the `new call box` entry is made editable and the signal `insert-text` is used to block unwanted chars. All other user action possible on a entry arn't blocked e.g. repositioning the cursor. The advantage of making the Entry editable is that we can show the cursor position. It also allows the user to select the position where new digits are inserted in the `new call box`. On a button press the focus is set to the Entry to give the correct feedback to the user. This centers the text on the entry, as required by the design. This also makes the delete button remove only one char at the time, to move closer to the desired UX. Related: https://source.puri.sm/Librem5/calls/issues/58 Fixes: https://source.puri.sm/Librem5/calls/issues/82
This commit is contained in:
parent
dc9b7102de
commit
497fe072fc
6 changed files with 69 additions and 93 deletions
2
debian/control
vendored
2
debian/control
vendored
|
@ -4,7 +4,7 @@ Priority: optional
|
|||
Maintainer: Bob Ham <rah@settrans.net>
|
||||
Build-Depends:
|
||||
debhelper (>= 11),
|
||||
libhandy-0.0-dev (>= 0.0.10),
|
||||
libhandy-0.0-dev (>= 0.0.12),
|
||||
libgtk-3-dev,
|
||||
modemmanager-dev,
|
||||
libmm-glib-dev (>= 1.12.0),
|
||||
|
|
|
@ -56,7 +56,6 @@ struct _CallsCallDisplay
|
|||
GtkButton *answer;
|
||||
|
||||
GtkRevealer *dial_pad_revealer;
|
||||
GtkEntry *dial_pad_display;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CallsCallDisplay, calls_call_display, GTK_TYPE_OVERLAY);
|
||||
|
@ -118,16 +117,6 @@ add_call_clicked_cb (GtkButton *button,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
dial_pad_symbol_clicked_cb (CallsCallDisplay *self,
|
||||
gchar symbol,
|
||||
HdyDialer *dialer)
|
||||
{
|
||||
calls_call_tone_start (self->call, symbol);
|
||||
|
||||
calls_entry_append (self->dial_pad_display, symbol);
|
||||
}
|
||||
|
||||
static void
|
||||
hide_dial_pad_clicked_cb (CallsCallDisplay *self)
|
||||
{
|
||||
|
@ -536,6 +525,37 @@ constructed (GObject *object)
|
|||
parent_class->constructed (object);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
block_delete_cb (GtkWidget *widget)
|
||||
{
|
||||
g_signal_stop_emission_by_name (widget, "delete-text");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
insert_text_cb (GtkEditable *editable,
|
||||
gchar *text,
|
||||
gint length,
|
||||
gint *position,
|
||||
CallsCallDisplay *self)
|
||||
{
|
||||
gint end_pos = -1;
|
||||
|
||||
calls_call_tone_start (self->call, *text);
|
||||
|
||||
// Make sure that new chars are inserted at the end of the input
|
||||
*position = end_pos;
|
||||
g_signal_handlers_block_by_func (editable,
|
||||
(gpointer) insert_text_cb, self);
|
||||
gtk_editable_insert_text (editable, text, length, &end_pos);
|
||||
g_signal_handlers_unblock_by_func (editable,
|
||||
(gpointer) insert_text_cb, self);
|
||||
|
||||
g_signal_stop_emission_by_name (editable, "insert-text");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_call_display_init (CallsCallDisplay *self)
|
||||
{
|
||||
|
@ -600,13 +620,13 @@ calls_call_display_class_init (CallsCallDisplayClass *klass)
|
|||
gtk_widget_class_bind_template_child (widget_class, CallsCallDisplay, hang_up);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallDisplay, answer);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallDisplay, dial_pad_revealer);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsCallDisplay, dial_pad_display);
|
||||
gtk_widget_class_bind_template_callback (widget_class, answer_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, hang_up_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, hold_toggled_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, mute_toggled_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, speaker_toggled_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, add_call_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dial_pad_symbol_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, hide_dial_pad_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, block_delete_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, insert_text_cb);
|
||||
}
|
||||
|
|
|
@ -36,9 +36,8 @@ struct _CallsNewCallBox
|
|||
|
||||
GtkListStore *origin_store;
|
||||
GtkComboBox *origin_box;
|
||||
GtkEntry *number_entry;
|
||||
GtkButton *backspace;
|
||||
HdyDialer *dial_pad;
|
||||
HdyKeypad *keypad;
|
||||
GtkButton *dial;
|
||||
GtkLabel *status;
|
||||
|
||||
|
@ -88,47 +87,18 @@ get_origin (CallsNewCallBox *self)
|
|||
static void
|
||||
backspace_clicked_cb (CallsNewCallBox *self)
|
||||
{
|
||||
const gchar *old;
|
||||
size_t len;
|
||||
gchar *new;
|
||||
|
||||
old = hdy_dialer_get_number (self->dial_pad);
|
||||
g_assert (old != NULL);
|
||||
|
||||
len = strlen (old);
|
||||
if (len == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new = g_strndup (old, strlen (old) - 1);
|
||||
hdy_dialer_set_number (self->dial_pad, new);
|
||||
g_free (new);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dial_pad_notify_number_cb (CallsNewCallBox *self,
|
||||
GParamSpec *pspec,
|
||||
GObject *gobject)
|
||||
{
|
||||
const gchar *number;
|
||||
|
||||
g_assert (strcmp(g_param_spec_get_name (pspec), "number") == 0);
|
||||
|
||||
number = hdy_dialer_get_number (self->dial_pad);
|
||||
gtk_entry_set_text (self->number_entry, number);
|
||||
gtk_widget_set_visible (GTK_WIDGET (self->backspace),
|
||||
strlen (number) > 0);
|
||||
GtkWidget *entry = hdy_keypad_get_entry (self->keypad);
|
||||
g_signal_emit_by_name (entry, "backspace", NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
dial_clicked_cb (CallsNewCallBox *self)
|
||||
{
|
||||
GtkWidget *entry = hdy_keypad_get_entry (self->keypad);
|
||||
calls_new_call_box_dial
|
||||
(self,
|
||||
gtk_entry_get_text (GTK_ENTRY (self->number_entry)));
|
||||
gtk_entry_get_text (GTK_ENTRY (entry)));
|
||||
}
|
||||
|
||||
|
||||
|
@ -333,12 +303,13 @@ constructed (GObject *object)
|
|||
{
|
||||
GObjectClass *parent_class = g_type_class_peek (G_TYPE_OBJECT);
|
||||
CallsNewCallBox *self = CALLS_NEW_CALL_BOX (object);
|
||||
GtkWidget *entry = hdy_keypad_get_entry (self->keypad);
|
||||
PangoAttrList *attrs;
|
||||
|
||||
// Increase the size of the number entry text
|
||||
attrs = pango_attr_list_new ();
|
||||
pango_attr_list_insert (attrs, pango_attr_scale_new (1.2));
|
||||
gtk_entry_set_attributes (self->number_entry, attrs);
|
||||
gtk_entry_set_attributes (GTK_ENTRY (entry), attrs);
|
||||
pango_attr_list_unref (attrs);
|
||||
|
||||
parent_class->constructed (object);
|
||||
|
@ -386,13 +357,11 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
|
|||
gtk_widget_class_set_template_from_resource (widget_class, "/sm/puri/calls/ui/new-call-box.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, origin_store);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, origin_box);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, number_entry);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, backspace);
|
||||
gtk_widget_class_bind_template_child (widget_class, CallsNewCallBox, dial_pad);
|
||||
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, status);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dial_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, dial_pad_notify_number_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, backspace_clicked_cb);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ calls_includes = [ top_include, src_include ]
|
|||
|
||||
calls_deps = [ dependency('gobject-2.0'),
|
||||
dependency('gtk+-3.0'),
|
||||
dependency('libhandy-0.0', version: '>= 0.0.10'),
|
||||
dependency('libhandy-0.0', version: '>= 0.0.12'),
|
||||
dependency('gsound'),
|
||||
dependency('libpeas-1.0'),
|
||||
dependency('gom-1.0'),
|
||||
|
|
|
@ -388,7 +388,7 @@
|
|||
<class name="background"/>
|
||||
</style>
|
||||
<child type="center">
|
||||
<object class="GtkBox">
|
||||
<object class="GtkBox" id="box_keypad">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
@ -397,24 +397,23 @@
|
|||
<property name="margin_top">12</property>
|
||||
<property name="spacing">10</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="dial_pad_display">
|
||||
<object class="GtkEntry" id="keypad_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="margin_bottom">8</property>
|
||||
<property name="im-module">simple</property>
|
||||
<signal name="delete-text" handler="block_delete_cb"/>
|
||||
<signal name="insert-text" handler="insert_text_cb"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="HdyDialer">
|
||||
<object class="HdyKeypad" id="keypad">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="column_spacing">10</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="row_spacing">8</property>
|
||||
<property name="show_action_buttons">False</property>
|
||||
<property name="hexpand">False</property>
|
||||
<signal name="symbol-clicked" handler="dial_pad_symbol_clicked_cb" swapped="yes"/>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="column_spacing">16</property>
|
||||
<property name="row_spacing">10</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="entry">keypad_entry</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
|
|
@ -47,28 +47,21 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="orientation">horizontal</property>
|
||||
<child>
|
||||
<object class="GtkEntry" id="number_entry">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="input-purpose">phone</property>
|
||||
<property name="input-hints">no-emoji|inhibit-osk</property>
|
||||
<object class="GtkEntry" id="keypad_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="margin_right">6</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="backspace">
|
||||
<property name="always_show_image">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="relief">none</property>
|
||||
<property name="visible">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="focus-on-click">False</property>
|
||||
<signal name="clicked" handler="backspace_clicked_cb" swapped="yes"/>
|
||||
<style>
|
||||
<class name="image-button"/>
|
||||
</style>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="a11y-backspace">
|
||||
<property name="accessible-name" translatable="yes">Backspace through number</property>
|
||||
|
@ -78,7 +71,6 @@
|
|||
<object class="GtkImage">
|
||||
<property name="visible">True</property>
|
||||
<property name="icon-name">edit-clear-symbolic</property>
|
||||
<property name="icon-size">2</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -90,18 +82,14 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="HdyDialer" id="dial_pad">
|
||||
<object class="HdyKeypad" id="keypad">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="column_spacing">10</property>
|
||||
<property name="margin_bottom">20</property>
|
||||
<property name="margin_top">20</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="row_spacing">8</property>
|
||||
<property name="show_action_buttons">False</property>
|
||||
<property name="width_request">300</property>
|
||||
<property name="hexpand">False</property>
|
||||
<signal name="notify::number" handler="dial_pad_notify_number_cb" swapped="yes"/>
|
||||
<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>
|
||||
|
|
Loading…
Reference in a new issue