diff --git a/po/POTFILES.in b/po/POTFILES.in
index e08e37a..20f5b0b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,9 +3,7 @@ data/sm.puri.Calls-daemon.desktop.in
src/calls-application.c
src/calls-best-match.c
src/calls-call.c
-src/calls-call-data.c
src/calls-call-display.c
-src/calls-call-holder.c
src/calls-call-record.c
src/calls-call-record-row.c
src/calls-call-selector-item.c
diff --git a/po/en_GB.po b/po/en_GB.po
index aa25ace..32e6887 100644
--- a/po/en_GB.po
+++ b/po/en_GB.po
@@ -89,19 +89,7 @@ msgstr "State"
msgid "The current state of the call"
msgstr "The current state of the call"
-#: src/calls-call-data.c:136 src/calls-call-holder.c:157
-msgid "Call"
-msgstr "Call"
-
-#: src/calls-call-data.c:137
-msgid "The call"
-msgstr "The call"
-
-#: src/calls-call-data.c:143
-msgid "Party"
-msgstr "Party"
-
-#: src/calls-call-data.c:144 src/calls-encryption-indicator.c:129
+#: src/calls-encryption-indicator.c:129
msgid "The party participating in the call"
msgstr "The party participating in the call"
@@ -117,10 +105,6 @@ msgstr "Call data"
msgid "Data for the call this display will be associated with"
msgstr "Data for the call this display will be associated with"
-#: src/calls-call-holder.c:158
-msgid "The call to hold"
-msgstr "The call to hold"
-
#: src/calls-call-record.c:189
msgid "ID"
msgstr "ID"
diff --git a/po/fa.po b/po/fa.po
index f366897..82ea0a5 100644
--- a/po/fa.po
+++ b/po/fa.po
@@ -86,19 +86,7 @@ msgstr "وضعیت"
msgid "The current state of the call"
msgstr "وضعیت فعلی تماس"
-#: src/calls-call-data.c:136 src/calls-call-holder.c:157
-msgid "Call"
-msgstr "تماس"
-
-#: src/calls-call-data.c:137
-msgid "The call"
-msgstr "تماس"
-
-#: src/calls-call-data.c:143
-msgid "Party"
-msgstr ""
-
-#: src/calls-call-data.c:144 src/calls-encryption-indicator.c:129
+#: src/calls-encryption-indicator.c:129
msgid "The party participating in the call"
msgstr ""
@@ -114,10 +102,6 @@ msgstr "دادههای تماس"
msgid "Data for the call this display will be associated with"
msgstr "دادهها برای تماسی که این نمایشگر به آن مرتبط است"
-#: src/calls-call-holder.c:158
-msgid "The call to hold"
-msgstr "تماس برای انتظار"
-
#: src/calls-call-record.c:189
msgid "ID"
msgstr "شناسه"
diff --git a/po/it.po b/po/it.po
index e1f45af..6119866 100644
--- a/po/it.po
+++ b/po/it.po
@@ -90,19 +90,7 @@ msgstr "Stato"
msgid "The current state of the call"
msgstr "Lo stato corrente della chiamata"
-#: src/calls-call-data.c:136 src/calls-call-holder.c:157
-msgid "Call"
-msgstr "Chiamata"
-
-#: src/calls-call-data.c:137
-msgid "The call"
-msgstr "La chiamata"
-
-#: src/calls-call-data.c:143
-msgid "Party"
-msgstr "Party"
-
-#: src/calls-call-data.c:144 src/calls-encryption-indicator.c:129
+#: src/calls-encryption-indicator.c:129
msgid "The party participating in the call"
msgstr "La parte che partecipa alla chiamata"
@@ -118,10 +106,6 @@ msgstr "Dati di chiamata"
msgid "Data for the call this display will be associated with"
msgstr "Dati per la chiamata a cui verrà associato questo display"
-#: src/calls-call-holder.c:158
-msgid "The call to hold"
-msgstr "La chiamata da mettere in attesa"
-
#: src/calls-call-record.c:189
msgid "ID"
msgstr "ID"
diff --git a/src/calls-call-data.c b/src/calls-call-data.c
deleted file mode 100644
index 8517b10..0000000
--- a/src/calls-call-data.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2018 Purism SPC
- *
- * This file is part of Calls.
- *
- * Calls is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Calls is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Calls. If not, see .
- *
- * Author: Bob Ham
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#include "calls-call-data.h"
-#include "util.h"
-
-#include
-#include
-
-/**
- * SECTION:calls-call-data
- * @short_description: An object to hold both a #CallsCall object and
- * the #CallsParty participating in the call. These data are passed
- * to both #CallsCallDisplay and #CallsCallSelectorItem so we create a
- * convenient object to keep them together.
- * @Title: CallsCallData
- */
-
-struct _CallsCallData
-{
- GObject parent_instance;
-
- CallsCall *call;
- CallsParty *party;
-};
-
-G_DEFINE_TYPE (CallsCallData, calls_call_data, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
- PROP_CALL,
- PROP_PARTY,
- PROP_LAST_PROP,
-};
-static GParamSpec *props[PROP_LAST_PROP];
-
-
-static void
-calls_call_data_init (CallsCallData *self)
-{
-}
-
-
-static void
-set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- CallsCallData *self = CALLS_CALL_DATA (object);
-
- switch (property_id) {
- case PROP_CALL:
- g_set_object (&self->call, CALLS_CALL (g_value_get_object (value)));
- break;
-
- case PROP_PARTY:
- g_set_object (&self->party, CALLS_PARTY (g_value_get_object (value)));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-static void
-get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
-{
- CallsCallData *self = CALLS_CALL_DATA (object);
-
- switch (property_id) {
- case PROP_CALL:
- g_value_set_object (value, self->call);
- break;
-
- case PROP_PARTY:
- g_value_set_object (value, self->party);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-static void
-dispose (GObject *object)
-{
- CallsCallData *self = CALLS_CALL_DATA (object);
-
- g_clear_object (&self->call);
- g_clear_object (&self->party);
-
- G_OBJECT_CLASS (calls_call_data_parent_class)->dispose (object);
-}
-
-
-static void
-calls_call_data_class_init (CallsCallDataClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = set_property;
- object_class->get_property = get_property;
- object_class->dispose = dispose;
-
- props[PROP_CALL] =
- g_param_spec_object ("call",
- "Call",
- "The call",
- CALLS_TYPE_CALL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
- props[PROP_PARTY] =
- g_param_spec_object ("party",
- "Party",
- "The party participating in the call",
- CALLS_TYPE_PARTY,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
-
- g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
-}
-
-
-/**
- * calls_call_data_new:
- *
- * Create a new #CallsCallData object.
- *
- * Returns: the newly created #CallsCallData
- */
-CallsCallData *
-calls_call_data_new (CallsCall *call,
- CallsParty *party)
-{
- return g_object_new (CALLS_TYPE_CALL_DATA,
- "call", call,
- "party", party,
- NULL);
-}
-
-
-/**
- * calls_call_data_get_call:
- * @self: a #CallsCallData
- *
- * Get the #CallsCall stored in the object.
- *
- * Returns: the #CallsCall
- */
-CallsCall *
-calls_call_data_get_call (CallsCallData *self)
-{
- g_return_val_if_fail (CALLS_IS_CALL_DATA (self), NULL);
- return self->call;
-}
-
-
-/**
- * calls_call_data_get_party:
- * @self: a #CallsCallData
- *
- * Get the #CallsParty stored in the object.
- *
- * Returns: the #CallsParty
- */
-CallsParty *
-calls_call_data_get_party (CallsCallData *self)
-{
- g_return_val_if_fail (CALLS_IS_CALL_DATA (self), NULL);
- return self->party;
-}
diff --git a/src/calls-call-data.h b/src/calls-call-data.h
deleted file mode 100644
index 1a5fbcc..0000000
--- a/src/calls-call-data.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2018 Purism SPC
- *
- * This file is part of Calls.
- *
- * Calls is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Calls is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Calls. If not, see .
- *
- * Author: Bob Ham
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#ifndef CALLS_CALL_DATA_H__
-#define CALLS_CALL_DATA_H__
-
-#include "calls-call.h"
-#include "calls-party.h"
-
-G_BEGIN_DECLS
-
-#define CALLS_TYPE_CALL_DATA (calls_call_data_get_type ())
-
-G_DECLARE_FINAL_TYPE (CallsCallData, calls_call_data, CALLS, CALL_DATA, GObject);
-
-CallsCallData *calls_call_data_new (CallsCall *call,
- CallsParty *party);
-CallsCall *calls_call_data_get_call (CallsCallData *data);
-CallsParty *calls_call_data_get_party (CallsCallData *data);
-
-G_END_DECLS
-
-#endif /* CALLS_CALL_DATA_H__ */
diff --git a/src/calls-call-display.c b/src/calls-call-display.c
index 2bfb8fc..7ac0136 100644
--- a/src/calls-call-display.c
+++ b/src/calls-call-display.c
@@ -23,8 +23,9 @@
*/
#include "config.h"
+#include "calls-manager.h"
#include "calls-call-display.h"
-#include "calls-call-data.h"
+#include "calls-party.h"
#include "util.h"
#include
@@ -62,7 +63,7 @@ G_DEFINE_TYPE (CallsCallDisplay, calls_call_display, GTK_TYPE_OVERLAY);
enum {
PROP_0,
- PROP_CALL_DATA,
+ PROP_CALL,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
@@ -303,32 +304,22 @@ call_state_changed_cb (CallsCallDisplay *self,
CallsCallDisplay *
-calls_call_display_new (CallsCallData *data)
+calls_call_display_new (CallsCall *call)
{
return g_object_new (CALLS_TYPE_CALL_DISPLAY,
- "call-data", data,
+ "call", call,
NULL);
}
+// FIXME: this should direclty use CallsBestMatch since the matching contact could change over time
static void
-set_call (CallsCallDisplay *self, CallsCall *call)
-{
- g_signal_connect_object (call, "state-changed",
- G_CALLBACK (call_state_changed_cb),
- self,
- G_CONNECT_SWAPPED);
- self->call = call;
- g_object_ref (G_OBJECT (call));
-}
-
-
-static void
-set_party (CallsCallDisplay *self, CallsParty *party)
+set_party (CallsCallDisplay *self)
{
GtkWidget *image;
const gchar *name, *number;
-
+ g_autoptr (CallsParty) party = calls_party_new (calls_manager_get_contact_name (self->call),
+ calls_call_get_number (self->call));
image = calls_party_create_image (party);
gtk_box_pack_end (self->party_box, image, TRUE, TRUE, 0);
gtk_image_set_pixel_size (GTK_IMAGE (image), 100);
@@ -343,13 +334,37 @@ set_party (CallsCallDisplay *self, CallsParty *party)
static void
-set_call_data (CallsCallDisplay *self, CallsCallData *data)
+set_call (CallsCallDisplay *self, CallsCall *call)
{
- set_call (self, calls_call_data_get_call (data));
- set_party (self, calls_call_data_get_party (data));
+ g_signal_connect_object (call, "state-changed",
+ G_CALLBACK (call_state_changed_cb),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_set_object (&self->call, call);
+ set_party (self);
}
+static void
+get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ CallsCallDisplay *self = CALLS_CALL_DISPLAY (object);
+
+ switch (property_id) {
+ case PROP_CALL:
+ g_value_set_object (value, calls_call_display_get_call (self));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
static void
set_property (GObject *object,
guint property_id,
@@ -359,8 +374,8 @@ set_property (GObject *object,
CallsCallDisplay *self = CALLS_CALL_DISPLAY (object);
switch (property_id) {
- case PROP_CALL_DATA:
- set_call_data (self, CALLS_CALL_DATA (g_value_get_object (value)));
+ case PROP_CALL:
+ set_call (self, CALLS_CALL (g_value_get_object (value)));
break;
default:
@@ -456,16 +471,17 @@ calls_call_display_class_init (CallsCallDisplayClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->constructed = constructed;
+ object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->dispose = dispose;
object_class->finalize = finalize;
- props[PROP_CALL_DATA] =
- g_param_spec_object ("call-data",
- "Call data",
- "Data for the call this display will be associated with",
- CALLS_TYPE_CALL_DATA,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
+ props[PROP_CALL] =
+ g_param_spec_object ("call",
+ "Call",
+ "The CallsCall which this display rapresents",
+ CALLS_TYPE_CALL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
@@ -494,3 +510,11 @@ calls_call_display_class_init (CallsCallDisplayClass *klass)
gtk_widget_class_bind_template_callback (widget_class, block_delete_cb);
gtk_widget_class_bind_template_callback (widget_class, insert_text_cb);
}
+
+CallsCall *
+calls_call_display_get_call (CallsCallDisplay *self)
+{
+ g_return_val_if_fail (CALLS_IS_CALL_DISPLAY (self), NULL);
+
+ return self->call;
+}
diff --git a/src/calls-call-display.h b/src/calls-call-display.h
index 9f121aa..e27b4c3 100644
--- a/src/calls-call-display.h
+++ b/src/calls-call-display.h
@@ -25,9 +25,9 @@
#ifndef CALLS_CALL_DISPLAY_H__
#define CALLS_CALL_DISPLAY_H__
-#include
+#include "calls-call.h"
-#include "calls-call-data.h"
+#include
G_BEGIN_DECLS
@@ -35,7 +35,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsCallDisplay, calls_call_display, CALLS, CALL_DISPLAY, GtkOverlay);
-CallsCallDisplay *calls_call_display_new (CallsCallData *data);
+CallsCallDisplay *calls_call_display_new (CallsCall *call);
+CallsCall *calls_call_display_get_call (CallsCallDisplay *self);
G_END_DECLS
diff --git a/src/calls-call-holder.c b/src/calls-call-holder.c
deleted file mode 100644
index 587be6a..0000000
--- a/src/calls-call-holder.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2018 Purism SPC
- *
- * This file is part of Calls.
- *
- * Calls is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Calls is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Calls. If not, see .
- *
- * Author: Bob Ham
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#include "calls-call-holder.h"
-#include "calls-manager.h"
-#include "util.h"
-
-#include
-#include
-
-/**
- * SECTION:calls-call-holder
- * @short_description: An object to hold both a #CallsCall object and
- * data about it and widgets
- * @Title: CallsCallHolder
- */
-
-struct _CallsCallHolder
-{
- GObject parent_instance;
-
- CallsCallData *data;
- CallsCallDisplay *display;
- CallsCallSelectorItem *selector_item;
-};
-
-G_DEFINE_TYPE (CallsCallHolder, calls_call_holder, G_TYPE_OBJECT);
-
-enum {
- PROP_0,
- PROP_CALL,
- PROP_LAST_PROP,
-};
-static GParamSpec *props[PROP_LAST_PROP];
-
-
-CallsCallHolder *
-calls_call_holder_new (CallsCall *call)
-{
- return g_object_new (CALLS_TYPE_CALL_HOLDER,
- "call", call,
- NULL);
-}
-
-
-CallsCallData *
-calls_call_holder_get_data (CallsCallHolder *holder)
-{
- g_return_val_if_fail (CALLS_IS_CALL_HOLDER (holder), NULL);
- return holder->data;
-}
-
-
-CallsCallDisplay *
-calls_call_holder_get_display (CallsCallHolder *holder)
-{
- g_return_val_if_fail (CALLS_IS_CALL_HOLDER (holder), NULL);
- return holder->display;
-}
-
-
-CallsCallSelectorItem *
-calls_call_holder_get_selector_item (CallsCallHolder *holder)
-{
- g_return_val_if_fail (CALLS_IS_CALL_HOLDER (holder), NULL);
- return holder->selector_item;
-}
-
-
-static void
-set_call (CallsCallHolder *self, CallsCall *call)
-{
- CallsParty *party = calls_party_new (calls_manager_get_contact_name (call),
- calls_call_get_number (call));
-
- self->data = calls_call_data_new (call, party);
- g_object_unref (party);
-
- self->display = calls_call_display_new (self->data);
- g_object_ref_sink (self->display);
-
- self->selector_item =
- calls_call_selector_item_new (self);
- g_object_ref_sink (self->selector_item);
-}
-
-
-static void
-set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- CallsCallHolder *self = CALLS_CALL_HOLDER (object);
-
- switch (property_id) {
- case PROP_CALL:
- set_call (self, CALLS_CALL (g_value_get_object (value)));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- break;
- }
-}
-
-
-static void
-calls_call_holder_init (CallsCallHolder *self)
-{
-}
-
-
-static void
-dispose (GObject *object)
-{
- CallsCallHolder *self = CALLS_CALL_HOLDER (object);
-
- g_clear_object (&self->selector_item);
- g_clear_object (&self->display);
- g_clear_object (&self->data);
-
- G_OBJECT_CLASS (calls_call_holder_parent_class)->dispose (object);
-}
-
-
-static void
-calls_call_holder_class_init (CallsCallHolderClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->set_property = set_property;
- object_class->dispose = dispose;
-
- props[PROP_CALL] =
- g_param_spec_object ("call",
- "Call",
- "The call to hold",
- CALLS_TYPE_CALL,
- G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
-
- g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
-}
diff --git a/src/calls-call-holder.h b/src/calls-call-holder.h
deleted file mode 100644
index 544f2c9..0000000
--- a/src/calls-call-holder.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2018 Purism SPC
- *
- * This file is part of Calls.
- *
- * Calls is free software: you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Calls is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Calls. If not, see .
- *
- * Author: Bob Ham
- *
- * SPDX-License-Identifier: GPL-3.0-or-later
- *
- */
-
-#ifndef CALLS_CALL_HOLDER_H__
-#define CALLS_CALL_HOLDER_H__
-
-#include "calls-call-data.h"
-#include "calls-call-display.h"
-#include "calls-call-selector-item.h"
-
-#include
-
-G_BEGIN_DECLS
-
-#define CALLS_TYPE_CALL_HOLDER (calls_call_holder_get_type ())
-
-G_DECLARE_FINAL_TYPE (CallsCallHolder, calls_call_holder, CALLS, CALL_HOLDER, GObject);
-
-CallsCallHolder *calls_call_holder_new (CallsCall *call);
-CallsCallData *calls_call_holder_get_data (CallsCallHolder *holder);
-CallsCallDisplay *calls_call_holder_get_display (CallsCallHolder *holder);
-CallsCallSelectorItem *calls_call_holder_get_selector_item (CallsCallHolder *holder);
-
-G_END_DECLS
-
-#endif /* CALLS_CALL_HOLDER_H__ */
diff --git a/src/calls-call-selector-item.c b/src/calls-call-selector-item.c
index bdb664b..0315abd 100644
--- a/src/calls-call-selector-item.c
+++ b/src/calls-call-selector-item.c
@@ -22,8 +22,10 @@
*
*/
+#include "calls-manager.h"
#include "calls-call-selector-item.h"
-#include "calls-call-holder.h"
+#include "calls-call-display.h"
+#include "calls-party.h"
#include "util.h"
#include
@@ -46,7 +48,7 @@ G_DEFINE_TYPE (CallsCallSelectorItem, calls_call_selector_item, GTK_TYPE_EVENT_B
enum {
PROP_0,
- PROP_HOLDER,
+ PROP_DISPLAY,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
@@ -64,12 +66,12 @@ call_state_changed_cb (CallsCallSelectorItem *self,
CallsCallSelectorItem *
-calls_call_selector_item_new (CallsCallHolder *holder)
+calls_call_selector_item_new (CallsCallDisplay *display)
{
- g_return_val_if_fail (CALLS_IS_CALL_HOLDER (holder), NULL);
+ g_return_val_if_fail (CALLS_IS_CALL_DISPLAY (display), NULL);
return g_object_new (CALLS_TYPE_CALL_SELECTOR_ITEM,
- "holder", holder,
+ "display", display,
NULL);
}
@@ -81,21 +83,14 @@ calls_call_selector_item_get_display (CallsCallSelectorItem *item)
return item->display;
}
-
+// FIXME: this should direclty use CallsBestMatch since the matching contact could change over time
static void
-set_call (CallsCallSelectorItem *self, CallsCall *call)
-{
- g_signal_connect_object (call, "state-changed",
- G_CALLBACK (call_state_changed_cb),
- self,
- G_CONNECT_SWAPPED);
-}
-
-
-static void
-set_party (CallsCallSelectorItem *self, CallsParty *party)
+set_party (CallsCallSelectorItem *self)
{
GtkWidget *image;
+ CallsCall *call = calls_call_display_get_call (self->display);
+ g_autoptr (CallsParty) party = calls_party_new (calls_manager_get_contact_name (call),
+ calls_call_get_number (call));
image = calls_party_create_image (party);
gtk_box_pack_start (self->main_box, image, TRUE, TRUE, 0);
@@ -106,16 +101,23 @@ set_party (CallsCallSelectorItem *self, CallsParty *party)
static void
-set_call_holder (CallsCallSelectorItem *self, CallsCallHolder *holder)
+set_call_display (CallsCallSelectorItem *self, CallsCallDisplay *display)
{
- CallsCallData *data = calls_call_holder_get_data (holder);
- CallsCall *call = calls_call_data_get_call (data);
+ CallsCall *call = NULL;
+
+ g_return_if_fail (CALLS_IS_CALL_SELECTOR_ITEM (self));
+ g_return_if_fail (CALLS_IS_CALL_DISPLAY (display));
+
+ call = calls_call_display_get_call (display);
+ g_signal_connect_object (call, "state-changed",
+ G_CALLBACK (call_state_changed_cb),
+ self,
+ G_CONNECT_SWAPPED);
- set_call (self, call);
- set_party (self, calls_call_data_get_party (data));
call_state_changed_cb (self, calls_call_get_state (call));
- g_set_object (&self->display, calls_call_holder_get_display (holder));
+ g_set_object (&self->display, display);
+ set_party (self);
}
@@ -128,9 +130,9 @@ set_property (GObject *object,
CallsCallSelectorItem *self = CALLS_CALL_SELECTOR_ITEM (object);
switch (property_id) {
- case PROP_HOLDER:
- set_call_holder
- (self, CALLS_CALL_HOLDER (g_value_get_object (value)));
+ case PROP_DISPLAY:
+ set_call_display
+ (self, CALLS_CALL_DISPLAY (g_value_get_object (value)));
break;
default:
@@ -167,11 +169,11 @@ calls_call_selector_item_class_init (CallsCallSelectorItemClass *klass)
object_class->set_property = set_property;
object_class->dispose = dispose;
- props[PROP_HOLDER] =
- g_param_spec_object ("holder",
- "Call holder",
- "The holder for this call",
- CALLS_TYPE_CALL_HOLDER,
+ props[PROP_DISPLAY] =
+ g_param_spec_object ("display",
+ "Call display",
+ "The display for this call",
+ CALLS_TYPE_CALL_DISPLAY,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
diff --git a/src/calls-call-selector-item.h b/src/calls-call-selector-item.h
index 3ccfd65..219bbb2 100644
--- a/src/calls-call-selector-item.h
+++ b/src/calls-call-selector-item.h
@@ -38,7 +38,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsCallSelectorItem, calls_call_selector_item,
CALLS, CALL_SELECTOR_ITEM, GtkEventBox);
-CallsCallSelectorItem *calls_call_selector_item_new (CallsCallHolder *holder);
+CallsCallSelectorItem *calls_call_selector_item_new (CallsCallDisplay *display);
CallsCallDisplay * calls_call_selector_item_get_display (CallsCallSelectorItem *item);
G_END_DECLS
diff --git a/src/calls-call-window.c b/src/calls-call-window.c
index e6761d5..7de8814 100644
--- a/src/calls-call-window.c
+++ b/src/calls-call-window.c
@@ -26,7 +26,6 @@
#include "calls-call-window.h"
#include "calls-origin.h"
-#include "calls-call-holder.h"
#include "calls-call-selector-item.h"
#include "calls-new-call-box.h"
#include "calls-in-app-notification.h"
@@ -48,7 +47,7 @@ struct _CallsCallWindow
{
GtkApplicationWindow parent_instance;
- GListStore *call_holders;
+ GListStore *calls;
CallsInAppNotification *in_app_notification;
@@ -192,7 +191,7 @@ session_inhibit (CallsCallWindow *self, gboolean inhibit)
static void
update_visibility (CallsCallWindow *self)
{
- guint calls = g_list_model_get_n_items (G_LIST_MODEL (self->call_holders));
+ guint calls = g_list_model_get_n_items (G_LIST_MODEL (self->calls));
#ifdef CALLS_WAYLAND
update_layer_surface (self, calls);
@@ -215,12 +214,9 @@ update_visibility (CallsCallWindow *self)
static GtkWidget *
-call_holders_create_widget_cb (CallsCallHolder *holder,
- CallsCallWindow *self)
+calls_create_widget_cb (CallsCallSelectorItem *item,
+ gpointer user_data)
{
- CallsCallSelectorItem *item =
- calls_call_holder_get_selector_item (holder);
- g_object_ref (G_OBJECT (item));
return GTK_WIDGET (item);
}
@@ -237,63 +233,6 @@ new_call_submitted_cb (CallsCallWindow *self,
}
-typedef gboolean (*FindCallHolderFunc) (CallsCallHolder *holder,
- gpointer user_data);
-
-
-static gboolean
-find_call_holder_by_call (CallsCallHolder *holder,
- gpointer user_data)
-{
- CallsCallData *data = calls_call_holder_get_data (holder);
-
- return calls_call_data_get_call (data) == user_data;
-}
-
-
-/** Search through the list of call holders, returning the total
- number of items in the list, the position of the holder within the
- list and a pointer to the holder itself. */
-static gboolean
-find_call_holder (CallsCallWindow *self,
- guint *n_itemsp,
- guint *positionp,
- CallsCallHolder **holderp,
- FindCallHolderFunc predicate,
- gpointer user_data)
-{
- GListModel * const model = G_LIST_MODEL (self->call_holders);
- const guint n_items = g_list_model_get_n_items (model);
- guint position = 0;
- CallsCallHolder *holder;
-
- for (position = 0; position < n_items; ++position)
- {
- holder = CALLS_CALL_HOLDER (g_list_model_get_item (model, position));
- g_object_unref (G_OBJECT (holder));
-
- if (predicate (holder, user_data))
- {
-#define out(var) \
- if (var##p) \
- { \
- *var##p = var ; \
- }
-
- out (n_items);
- out (position);
- out (holder);
-
-#undef out
-
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
static void
set_focus (CallsCallWindow *self,
CallsCallDisplay *display)
@@ -331,56 +270,54 @@ void
add_call (CallsCallWindow *self,
CallsCall *call)
{
- CallsCallHolder *holder;
CallsCallDisplay *display;
+ CallsCallSelectorItem *item;
g_return_if_fail (CALLS_IS_CALL_WINDOW (self));
g_return_if_fail (CALLS_IS_CALL (call));
- holder = calls_call_holder_new (call);
-
- display = calls_call_holder_get_display (holder);
+ display = calls_call_display_new (call);
+ item = calls_call_selector_item_new (display);
gtk_stack_add_named (self->call_stack, GTK_WIDGET (display),
calls_call_get_number (call));
- g_list_store_append (self->call_holders, holder);
- g_object_unref (holder);
+ g_list_store_append (self->calls, item);
update_visibility (self);
set_focus (self, display);
}
-
-static void
-remove_call_holder (CallsCallWindow *self,
- guint n_items,
- guint position,
- CallsCallHolder *holder)
-{
- gtk_container_remove (GTK_CONTAINER (self->call_stack),
- GTK_WIDGET (calls_call_holder_get_display (holder)));
- g_list_store_remove (self->call_holders, position);
-
- update_visibility (self);
-}
-
void
remove_call (CallsCallWindow *self,
CallsCall *call,
const gchar *reason)
{
- guint n_items, position;
- CallsCallHolder *holder;
- gboolean found;
+ g_autoptr (CallsCallSelectorItem) item = NULL;
+ gint position;
g_return_if_fail (CALLS_IS_CALL_WINDOW (self));
g_return_if_fail (CALLS_IS_CALL (call));
- found = find_call_holder (self, &n_items, &position, &holder,
- find_call_holder_by_call, call);
- g_return_if_fail (found);
+ position = 0;
+ item = g_list_model_get_item (G_LIST_MODEL (self->calls), position);
+ while (item != NULL) {
+ CallsCallDisplay *display = calls_call_selector_item_get_display (item);
- remove_call_holder (self, n_items, position, holder);
+ if (calls_call_display_get_call (display) == call) {
+ g_list_store_remove (self->calls, position);
+ gtk_container_remove (GTK_CONTAINER (self->call_stack),
+ GTK_WIDGET (display));
+
+
+ break;
+ }
+
+ g_object_unref (item);
+ position++;
+ item = g_list_model_get_item (G_LIST_MODEL (self->calls), position);
+ }
+
+ update_visibility (self);
}
@@ -396,7 +333,7 @@ remove_calls (CallsCallWindow *self)
GTK_WIDGET (child->data));
g_list_free (children);
- g_list_store_remove_all (self->call_holders);
+ g_list_store_remove_all (self->calls);
update_visibility (self);
}
@@ -564,8 +501,8 @@ constructed (GObject *object)
CallsCallWindow *self = CALLS_CALL_WINDOW (object);
gtk_flow_box_bind_model (self->call_selector,
- G_LIST_MODEL (self->call_holders),
- (GtkFlowBoxCreateWidgetFunc) call_holders_create_widget_cb,
+ G_LIST_MODEL (self->calls),
+ (GtkFlowBoxCreateWidgetFunc) calls_create_widget_cb,
NULL, NULL);
update_visibility (self);
@@ -581,7 +518,7 @@ calls_call_window_init (CallsCallWindow *self)
GList *c;
gtk_widget_init_template (GTK_WIDGET (self));
- self->call_holders = g_list_store_new (CALLS_TYPE_CALL_HOLDER);
+ self->calls = g_list_store_new (CALLS_TYPE_CALL_SELECTOR_ITEM);
// Show errors in in-app-notification
g_signal_connect_swapped (calls_manager_get_default (),
@@ -611,12 +548,12 @@ dispose (GObject *object)
{
CallsCallWindow *self = CALLS_CALL_WINDOW (object);
- if (self->call_holders)
+ if (self->calls)
{
remove_calls (self);
}
- g_clear_object (&self->call_holders);
+ g_clear_object (&self->calls);
G_OBJECT_CLASS (calls_call_window_parent_class)->dispose (object);
}
diff --git a/src/calls-main-window.c b/src/calls-main-window.c
index a207be0..4a823a6 100644
--- a/src/calls-main-window.c
+++ b/src/calls-main-window.c
@@ -25,7 +25,6 @@
#include "calls-main-window.h"
#include "calls-origin.h"
#include "calls-ussd.h"
-#include "calls-call-holder.h"
#include "calls-call-selector-item.h"
#include "calls-new-call-box.h"
#include "calls-history-box.h"
diff --git a/src/meson.build b/src/meson.build
index 9be8cd8..fdefbe6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -71,8 +71,6 @@ calls_sources = files(['calls-message-source.c', 'calls-message-source.h',
'calls-origin.c', 'calls-origin.h',
'calls-provider.c', 'calls-provider.h',
'calls-party.c', 'calls-party.h',
- 'calls-call-data.c', 'calls-call-data.h',
- 'calls-call-holder.c', 'calls-call-holder.h',
'calls-call-display.c', 'calls-call-display.h',
'calls-call-selector-item.c', 'calls-call-selector-item.h',
'calls-call-window.c', 'calls-call-window.h',