From 719b3e752f111a93442b4668fbcfca0b385fab79 Mon Sep 17 00:00:00 2001 From: Bob Ham Date: Thu, 4 Jul 2019 15:15:16 +0100 Subject: [PATCH] calls-call-display: Add a display of dial pad digits Closes #57 --- src/calls-call-display.c | 4 ++++ src/calls-new-call-box.c | 6 +----- src/ui/call-display.ui | 10 +++++++++- src/util.c | 17 +++++++++++++++++ src/util.h | 5 +++++ 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/calls-call-display.c b/src/calls-call-display.c index 4fee4fa..8eab527 100644 --- a/src/calls-call-display.c +++ b/src/calls-call-display.c @@ -54,6 +54,7 @@ struct _CallsCallDisplay GtkButton *answer; GtkRevealer *dial_pad_revealer; + GtkEntry *dial_pad_display; }; G_DEFINE_TYPE (CallsCallDisplay, calls_call_display, GTK_TYPE_OVERLAY); @@ -121,6 +122,8 @@ dial_pad_symbol_clicked_cb (CallsCallDisplay *self, HdyDialer *dialer) { calls_call_tone_start (self->call, symbol); + + calls_entry_append (self->dial_pad_display, symbol); } static void @@ -411,6 +414,7 @@ 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); diff --git a/src/calls-new-call-box.c b/src/calls-new-call-box.c index 2f42be2..55923e1 100644 --- a/src/calls-new-call-box.c +++ b/src/calls-new-call-box.c @@ -63,11 +63,7 @@ dial_pad_symbol_clicked_cb (CallsNewCallBox *self, gchar symbol, HdyDialer *dialer) { - GtkEntryBuffer *buf = gtk_entry_get_buffer (GTK_ENTRY (self->number_entry)); - guint len = gtk_entry_buffer_get_length (buf); - const gchar str[] = {symbol, '\0'}; - - gtk_entry_buffer_insert_text (buf, len, str, 1); + calls_entry_append (GTK_ENTRY (self->number_entry), symbol); } diff --git a/src/ui/call-display.ui b/src/ui/call-display.ui index 597d274..d7f6764 100644 --- a/src/ui/call-display.ui +++ b/src/ui/call-display.ui @@ -395,12 +395,20 @@ 300 6 12 + 10 + + + True + False + 0.5 + 8 + + True True 10 - 10 True 8 False diff --git a/src/util.c b/src/util.c index ecbe315..2daabe2 100644 --- a/src/util.c +++ b/src/util.c @@ -68,3 +68,20 @@ calls_list_store_find (GtkListStore *store, return find_data.found; } + + +void +calls_entry_append (GtkEntry *entry, + gchar character) +{ + const gchar str[] = {character, '\0'}; + GtkEntryBuffer *buf; + guint len; + + g_return_if_fail (GTK_IS_ENTRY (entry)); + + buf = gtk_entry_get_buffer (entry); + len = gtk_entry_buffer_get_length (buf); + + gtk_entry_buffer_insert_text (buf, len - 1, str, 1); +} diff --git a/src/util.h b/src/util.h index 8796d63..f915c2d 100644 --- a/src/util.h +++ b/src/util.h @@ -83,6 +83,11 @@ calls_list_store_find (GtkListStore *store, gint needle_column, GtkTreeIter *iter); +/** Append a single character to a GtkEntry's contents */ +void +calls_entry_append (GtkEntry *entry, + gchar character); + G_END_DECLS #endif /* CALLS__UTIL_H__ */