Commit b05c6e34 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

main-window: Use a new call box

Replace the custom inplementation of a call box by a CallsNewCallBox
which is used to dial new calls and not to send DTMF tones as the call
display can now handle that.
parent 22d79bfb
......@@ -26,6 +26,7 @@
#include "calls-origin.h"
#include "calls-call-holder.h"
#include "calls-call-selector-item.h"
#include "calls-new-call-box.h"
#include "util.h"
#include <glib/gi18n.h>
......@@ -51,11 +52,6 @@ struct _CallsMainWindow
GtkStack *call_stack;
GtkScrolledWindow *call_scroll;
GtkFlowBox *call_selector;
GtkBox *dial_box;
GtkBox *dial_controls;
GtkComboBox *origin;
GtkSearchEntry *search;
HdyDialer *dial_pad;
GtkListStore *origin_store;
};
......@@ -105,60 +101,23 @@ info_response_cb (GtkInfoBar *infobar,
}
static GtkWidget *
call_holders_create_widget_cb (CallsCallHolder *holder,
CallsMainWindow *self)
{
return GTK_WIDGET (calls_call_holder_get_selector_item (holder));
}
static void
search_append_symbol (CallsMainWindow *self, gchar symbol)
new_call_submitted_cb (CallsMainWindow *self,
CallsOrigin *origin,
const gchar *number,
CallsNewCallBox *new_call_box)
{
GtkEntryBuffer *buf = gtk_entry_get_buffer (GTK_ENTRY (self->search));
guint len = gtk_entry_buffer_get_length (buf);
gtk_entry_buffer_insert_text (buf, len, &symbol, 1);
}
static void
dial_pad_symbol_clicked_cb (CallsMainWindow *self, gchar symbol, HdyDialer *dialer)
{
search_append_symbol (self, symbol);
}
static void
dial_pad_deleted_cb (CallsMainWindow *self, HdyDialer *dialer)
{
GtkEntryBuffer *buf = gtk_entry_get_buffer (GTK_ENTRY (self->search));
guint len = gtk_entry_buffer_get_length (buf);
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
gtk_entry_buffer_delete_text (buf, len - 1, 1);
calls_origin_dial (origin, number);
}
static void
dial_pad_submitted_cb (CallsMainWindow *self, const gchar *unused, HdyDialer *dialer)
static GtkWidget *
call_holders_create_widget_cb (CallsCallHolder *holder,
CallsMainWindow *self)
{
GtkTreeIter iter;
gboolean ok;
CallsOrigin *origin;
const gchar *number;
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
ok = gtk_combo_box_get_active_iter (self->origin, &iter);
g_return_if_fail (ok);
gtk_tree_model_get (GTK_TREE_MODEL (self->origin_store), &iter,
ORIGIN_STORE_COLUMN_ORIGIN, &origin,
-1);
g_return_if_fail (CALLS_IS_ORIGIN (origin));
number = gtk_entry_get_text (GTK_ENTRY (self->search));
calls_origin_dial (origin, number);
return GTK_WIDGET (calls_call_holder_get_selector_item (holder));
}
......@@ -399,28 +358,14 @@ add_origin_calls (CallsMainWindow *self, CallsOrigin *origin)
static void
add_origin (CallsMainWindow *self, CallsOrigin *origin)
{
const gint n_origins = gtk_tree_model_iter_n_children
(GTK_TREE_MODEL (self->origin_store), NULL);
GtkTreeIter iter;
if (n_origins == 1)
{
/* We have more than one origin now so show the origin combo box */
gtk_widget_show (GTK_WIDGET (self->origin));
}
gtk_list_store_append (self->origin_store, &iter);
gtk_list_store_set (self->origin_store, &iter,
ORIGIN_STORE_COLUMN_NAME, calls_origin_get_name(origin),
ORIGIN_STORE_COLUMN_ORIGIN, G_OBJECT (origin),
-1);
if (gtk_combo_box_get_active (self->origin) == -1)
{
/* We always want an item active */
gtk_combo_box_set_active (self->origin, 0);
}
g_signal_connect_swapped (origin, "message",
G_CALLBACK (show_message), self);
......@@ -459,17 +404,6 @@ dump_list_store (GtkListStore *store)
}
static void
update_origin (CallsMainWindow *self)
{
if (gtk_tree_model_iter_n_children
(GTK_TREE_MODEL (self->origin_store), NULL) < 2)
{
/* User has only one choice so hide the origin combo box */
gtk_widget_hide (GTK_WIDGET (self->origin));
}
}
static void
remove_origin (CallsMainWindow *self, CallsOrigin *origin)
{
......@@ -481,8 +415,6 @@ remove_origin (CallsMainWindow *self, CallsOrigin *origin)
g_return_if_fail (ok);
gtk_list_store_remove (self->origin_store, &iter);
update_origin (self);
}
......@@ -496,8 +428,6 @@ remove_origins (CallsMainWindow *self)
{
gtk_list_store_remove (self->origin_store, &iter);
}
update_origin (self);
}
......@@ -644,16 +574,9 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, call_stack);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, call_scroll);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, call_selector);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, dial_box);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, dial_controls);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, origin);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, search);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, dial_pad);
gtk_widget_class_bind_template_child (widget_class, CallsMainWindow, origin_store);
gtk_widget_class_bind_template_callback (widget_class, info_response_cb);
gtk_widget_class_bind_template_callback (widget_class, call_selector_child_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, back_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, dial_pad_submitted_cb);
gtk_widget_class_bind_template_callback (widget_class, dial_pad_deleted_cb);
gtk_widget_class_bind_template_callback (widget_class, dial_pad_symbol_clicked_cb);
gtk_widget_class_bind_template_callback (widget_class, new_call_submitted_cb);
}
......@@ -31,6 +31,7 @@
#include "calls-history-box.h"
#include "calls-main-window.h"
#include "calls-mm-provider.h"
#include "calls-new-call-box.h"
static void
show_window (GtkApplication *app)
......@@ -42,6 +43,7 @@ show_window (GtkApplication *app)
CALLS_TYPE_ENCRYPTION_INDICATOR;
CALLS_TYPE_HISTORY_BOX;
CALLS_TYPE_NEW_CALL_BOX;
HDY_TYPE_DIALER;
connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
......
......@@ -162,75 +162,15 @@
</packing>
</child>
<child>
<object class="GtkBox" id="dial_box">
<object class="CallsNewCallBox" id="new_call_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="dial_controls">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkComboBox" id="origin">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="model">origin_store</property>
<property name="id_column">0</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSearchEntry" id="search">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="HdyDialer" id="dial_pad">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="deleted" handler="dial_pad_deleted_cb" swapped="yes"/>
<signal name="submitted" handler="dial_pad_submitted_cb" swapped="yes"/>
<signal name="symbol-clicked" handler="dial_pad_symbol_clicked_cb" swapped="yes"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<property name="origin_store">origin_store</property>
<signal name="submitted" handler="new_call_submitted_cb" swapped="yes"/>
</object>
<packing>
<property name="name">dial-pad</property>
<property name="title" translatable="yes">Dial pad</property>
<property name="position">1</property>
<property name="name">new-call</property>
<property name="title" translatable="yes">New call</property>
</packing>
</child>
<child>
......@@ -241,7 +181,7 @@
<packing>
<property name="name">history</property>
<property name="title" translatable="yes">History</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>
......@@ -257,4 +197,4 @@
<placeholder/>
</child>
</template>
</interface>
</interface>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment