Unverified Commit ffa3e724 authored by Julian Sparber's avatar Julian Sparber
Browse files

Use CallsManager in MainWindow and NewCallBox

This removes the status message at the end of the NewCallBox, since it
will be replaced by a permanent InfoBar.

As a side effect this removes also the disconnect message when a call
ends.
Fixes: #119
parent 3e138eec
......@@ -346,7 +346,6 @@ start_proper (CallsApplication *self)
self->main_window = calls_main_window_new
(gtk_app,
provider,
G_LIST_MODEL (self->record_store),
self->contacts);
g_assert (self->main_window != NULL);
......
......@@ -29,7 +29,7 @@
#include "calls-new-call-box.h"
#include "calls-history-box.h"
#include "calls-in-app-notification.h"
#include "calls-enumerate.h"
#include "calls-manager.h"
#include "config.h"
#include "util.h"
......@@ -44,7 +44,6 @@ struct _CallsMainWindow
{
GtkApplicationWindow parent_instance;
CallsProvider *provider;
GListModel *record_store;
CallsContacts *contacts;
......@@ -64,7 +63,6 @@ G_DEFINE_TYPE (CallsMainWindow, calls_main_window, GTK_TYPE_APPLICATION_WINDOW);
enum {
PROP_0,
PROP_PROVIDER,
PROP_RECORD_STORE,
PROP_CONTACTS,
PROP_LAST_PROP,
......@@ -122,23 +120,6 @@ static const GActionEntry window_entries [] =
};
static void
call_message_cb (CallsMainWindow *self, const gchar *reason)
{
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
calls_in_app_notification_show (self->in_app_notification, reason);
}
static void
call_removed_cb (CallsMainWindow *self, CallsCall *call, const gchar *reason)
{
g_return_if_fail (CALLS_IS_MAIN_WINDOW (self));
calls_in_app_notification_show (self->in_app_notification, reason);
}
static gboolean
set_switcher_bar_reveal (GBinding *binding,
const GValue *from_value,
......@@ -160,11 +141,6 @@ set_property (GObject *object,
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
switch (property_id) {
case PROP_PROVIDER:
g_set_object (&self->provider,
CALLS_PROVIDER (g_value_get_object (value)));
break;
case PROP_RECORD_STORE:
g_set_object (&self->record_store,
G_LIST_MODEL (g_value_get_object (value)));
......@@ -182,35 +158,6 @@ set_property (GObject *object,
}
static void
set_up_provider (CallsMainWindow *self)
{
const GType msg_obj_types[3] =
{
CALLS_TYPE_PROVIDER,
CALLS_TYPE_ORIGIN,
CALLS_TYPE_CALL
};
CallsEnumerateParams *params;
unsigned i;
params = calls_enumerate_params_new (self);
for (i = 0; i < 3; ++i)
{
calls_enumerate_params_add
(params, msg_obj_types[i], "message", G_CALLBACK (call_message_cb));
}
calls_enumerate_params_add
(params, CALLS_TYPE_ORIGIN, "call-removed", G_CALLBACK (call_removed_cb));
calls_enumerate (self->provider, params);
g_object_unref (params);
}
static void
constructed (GObject *object)
{
......@@ -220,10 +167,14 @@ constructed (GObject *object)
GtkWidget *widget;
CallsHistoryBox *history;
set_up_provider (self);
// Show errors in in-app-notification
g_signal_connect_swapped (calls_manager_get_default (),
"error",
G_CALLBACK (calls_in_app_notification_show),
self->in_app_notification);
// Add new call box
self->new_call = calls_new_call_box_new (self->provider);
self->new_call = calls_new_call_box_new ();
widget = GTK_WIDGET (self->new_call);
gtk_stack_add_titled (self->main_stack, widget,
"dial-pad", _("Dial Pad"));
......@@ -279,7 +230,6 @@ dispose (GObject *object)
g_clear_object (&self->contacts);
g_clear_object (&self->record_store);
g_clear_object (&self->provider);
G_OBJECT_CLASS (calls_main_window_parent_class)->dispose (object);
}
......@@ -312,13 +262,6 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
object_class->constructed = constructed;
object_class->dispose = dispose;
props[PROP_PROVIDER] =
g_param_spec_object ("provider",
_("Provider"),
_("An object implementing low-level call-making functionality"),
CALLS_TYPE_PROVIDER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
props[PROP_RECORD_STORE] =
g_param_spec_object ("record-store",
_("Record store"),
......@@ -358,18 +301,15 @@ calls_main_window_init (CallsMainWindow *self)
CallsMainWindow *
calls_main_window_new (GtkApplication *application,
CallsProvider *provider,
GListModel *record_store,
CallsContacts *contacts)
{
g_return_val_if_fail (GTK_IS_APPLICATION (application), NULL);
g_return_val_if_fail (CALLS_IS_PROVIDER (provider), NULL);
g_return_val_if_fail (G_IS_LIST_MODEL (record_store), NULL);
g_return_val_if_fail (CALLS_IS_CONTACTS (contacts), NULL);
return g_object_new (CALLS_TYPE_MAIN_WINDOW,
"application", application,
"provider", provider,
"record-store", record_store,
"contacts", contacts,
NULL);
......
......@@ -27,7 +27,6 @@
#include <gtk/gtk.h>
#include "calls-provider.h"
#include "calls-contacts.h"
G_BEGIN_DECLS
......@@ -37,7 +36,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsMainWindow, calls_main_window, CALLS, MAIN_WINDOW, GtkApplicationWindow);
CallsMainWindow *calls_main_window_new (GtkApplication *application,
CallsProvider *provider,
GListModel *record_store,
CallsContacts *contacts);
void calls_main_window_dial (CallsMainWindow *self,
......
......@@ -23,7 +23,7 @@
*/
#include "calls-new-call-box.h"
#include "calls-enumerate.h"
#include "calls-manager.h"
#include <glib/gi18n.h>
#define HANDY_USE_UNSTABLE_API
......@@ -39,7 +39,6 @@ struct _CallsNewCallBox
GtkButton *backspace;
HdyKeypad *keypad;
GtkButton *dial;
GtkLabel *status;
GList *dial_queue;
};
......@@ -47,14 +46,6 @@ struct _CallsNewCallBox
G_DEFINE_TYPE (CallsNewCallBox, calls_new_call_box, GTK_TYPE_BOX);
enum {
PROP_0,
PROP_PROVIDER,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
enum {
ORIGIN_STORE_COLUMN_NAME,
ORIGIN_STORE_COLUMN_ORIGIN
......@@ -102,21 +93,6 @@ dial_clicked_cb (CallsNewCallBox *self)
}
void
notify_status_cb (CallsNewCallBox *self,
GParamSpec *pspec,
CallsProvider *provider)
{
gchar *status;
g_assert (CALLS_IS_PROVIDER (provider));
status = calls_provider_get_status (provider);
gtk_label_set_text (self->status, status);
g_free (status);
}
static void
dial_queued_cb (gchar *target,
CallsOrigin *origin)
......@@ -169,14 +145,12 @@ update_origin_box (CallsNewCallBox *self)
{
gtk_widget_hide (GTK_WIDGET (self->origin_box));
gtk_widget_set_sensitive (GTK_WIDGET (self->dial), FALSE);
gtk_widget_set_visible (GTK_WIDGET (self->status), TRUE);
return;
}
/* We know there is at least one origin. */
gtk_widget_set_sensitive (GTK_WIDGET (self->dial), TRUE);
gtk_widget_set_visible (GTK_WIDGET (self->status), FALSE);
if (!gtk_tree_model_iter_next (origin_store, &iter))
{
......@@ -246,53 +220,27 @@ remove_origins (CallsNewCallBox *self)
static void
set_provider (CallsNewCallBox *self, CallsProvider *provider)
{
CallsEnumerateParams *params;
params = calls_enumerate_params_new (self);
#define add(detail,cb) \
calls_enumerate_params_add \
(params, CALLS_TYPE_PROVIDER, detail, \
G_CALLBACK (cb));
add ("notify::status", notify_status_cb);
add ("origin-added", add_origin);
add ("origin-removed", remove_origin);
#undef add
calls_enumerate (provider, params);
g_object_unref (params);
}
static void
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
calls_new_call_box_init (CallsNewCallBox *self)
{
CallsNewCallBox *self = CALLS_NEW_CALL_BOX (object);
g_autoptr (GList) origins = NULL;
GList *o;
switch (property_id)
{
case PROP_PROVIDER:
set_provider (self, CALLS_PROVIDER (g_value_get_object (value)));
break;
gtk_widget_init_template (GTK_WIDGET (self));
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
g_signal_connect_swapped (calls_manager_get_default (),
"origin-add",
G_CALLBACK (add_origin),
self);
g_signal_connect_swapped (calls_manager_get_default (),
"origin-remove",
G_CALLBACK (remove_origin),
self);
static void
calls_new_call_box_init (CallsNewCallBox *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
origins = calls_manager_get_origins (calls_manager_get_default ());
for (o = origins; o != NULL; o = o->next) {
add_origin (self, o->data);
}
update_origin_box (self);
}
......@@ -320,38 +268,23 @@ calls_new_call_box_class_init (CallsNewCallBoxClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->set_property = set_property;
object_class->dispose = dispose;
props[PROP_PROVIDER] =
g_param_spec_object ("provider",
_("Provider"),
_("An object implementing low-level call-making functionality"),
CALLS_TYPE_PROVIDER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
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, backspace);
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, backspace_clicked_cb);
}
CallsNewCallBox *
calls_new_call_box_new (CallsProvider *provider)
calls_new_call_box_new (void)
{
return g_object_new (CALLS_TYPE_NEW_CALL_BOX,
"provider", provider,
NULL);
return g_object_new (CALLS_TYPE_NEW_CALL_BOX, NULL);
}
......
......@@ -25,8 +25,6 @@
#ifndef CALLS_NEW_CALL_BOX_H__
#define CALLS_NEW_CALL_BOX_H__
#include "calls-provider.h"
#include <gtk/gtk.h>
G_BEGIN_DECLS
......@@ -35,7 +33,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsNewCallBox, calls_new_call_box, CALLS, NEW_CALL_BOX, GtkBox);
CallsNewCallBox * calls_new_call_box_new (CallsProvider *provider);
CallsNewCallBox * calls_new_call_box_new (void);
void calls_new_call_box_dial (CallsNewCallBox *self,
const gchar *target);
......
......@@ -145,17 +145,5 @@
</child>
</object>
</child>
<child>
<object class="GtkLabel" id="status">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">16</property>
</packing>
</child>
</template>
</interface>
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