Make CallsContacts a singleton

Since passing a CallsContacts pointer down to every class it needs, started to
become laborous - especially since the intermediates classes don't need
the reference themselves - it was made a singleton

* src/calls-contacts.c: Added calls_contacts_get_default () function and
  removed calls_contacts_new ()
* src/calls-contacts.h: Added _get_default () prototype and removed the
  _new () prototype
* src/calls-application.c: Use calls_contacts_get_default () now
* src/calls-history-box.c: Removed self->contacts completely
* src/calls-history-box.h: Got rid of CallsContacts argument in _new()
* src/calls-main-window.c: Removed self->contacts completely
* src/calls-main-window.h: Got rid of CallsContacts argument in _new()
* src/calls-call-record-row.c: Use calls_contacts_get_default () now
* src/calls-call-record-row.h: Got rid of CallsContacts argument in
  _new()
* src/calls-call-holder.c: Use calls_contacts_get_default () now
* src/calls-call-holder.h: Got rid of CallsContacts argument in _new()
* src/calls-call-window.c: Removed self->contacts completely
* src/calls-call-window.h: Got rid of CallsContacts argument in _new()
* src/calls-notifier.c: Use calls_contacts_get_default () now
* src/calls-notifier.h: Got rid of CallsContacts argument in _new()
This commit is contained in:
Evangelos Ribeiro Tzaras
2020-06-17 13:44:11 +02:00
parent 17e8e4bd24
commit 0f0d10e3f2
11 changed files with 28 additions and 124 deletions

View File

@@ -339,16 +339,15 @@ start_proper (CallsApplication *self)
self->record_store = calls_record_store_new ();
g_assert (self->record_store != NULL);
self->contacts = calls_contacts_new ();
self->contacts = calls_contacts_get_default ();
g_assert (self->contacts != NULL);
self->notifier = calls_notifier_new (self->contacts);
self->notifier = calls_notifier_new ();
g_assert (CALLS_IS_NOTIFIER (self->notifier));
self->main_window = calls_main_window_new
(gtk_app,
G_LIST_MODEL (self->record_store),
self->contacts);
G_LIST_MODEL (self->record_store));
g_assert (self->main_window != NULL);
self->call_window = calls_call_window_new (gtk_app);
@@ -477,6 +476,7 @@ finalize (GObject *object)
g_clear_object (&self->call_window);
g_clear_object (&self->main_window);
g_clear_object (&self->record_store);
g_clear_object (&self->contacts);
g_clear_object (&self->ringer);
g_clear_object (&self->notifier);