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:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "calls-call-record-row.h"
|
||||
#include "calls-best-match.h"
|
||||
#include "calls-contacts.h"
|
||||
#include "contrib/hdy-avatar.h"
|
||||
#include "util.h"
|
||||
|
||||
@@ -57,7 +58,6 @@ struct _CallsCallRecordRow
|
||||
gulong end_notify_handler_id;
|
||||
guint date_change_timeout;
|
||||
|
||||
CallsContacts *contacts;
|
||||
CallsBestMatch *contact;
|
||||
};
|
||||
|
||||
@@ -67,7 +67,6 @@ G_DEFINE_TYPE (CallsCallRecordRow, calls_call_record_row, GTK_TYPE_LIST_BOX_ROW)
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_RECORD,
|
||||
PROP_CONTACTS,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
@@ -386,10 +385,9 @@ setup_contact (CallsCallRecordRow *self)
|
||||
|
||||
// Look up the best match object
|
||||
self->contact = calls_contacts_lookup_phone_number
|
||||
(self->contacts, phone_number);
|
||||
(calls_contacts_get_default (), phone_number);
|
||||
g_assert (self->contact != NULL);
|
||||
g_object_ref (self->contact);
|
||||
g_clear_object (&self->contacts);
|
||||
e_phone_number_free (phone_number);
|
||||
|
||||
g_signal_connect_swapped (self->contact,
|
||||
@@ -452,11 +450,6 @@ set_property (GObject *object,
|
||||
CALLS_CALL_RECORD (g_value_get_object (value)));
|
||||
break;
|
||||
|
||||
case PROP_CONTACTS:
|
||||
g_set_object (&self->contacts,
|
||||
CALLS_CONTACTS (g_value_get_object (value)));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -525,7 +518,6 @@ dispose (GObject *object)
|
||||
CallsCallRecordRow *self = CALLS_CALL_RECORD_ROW (object);
|
||||
|
||||
g_clear_object (&self->contact);
|
||||
g_clear_object (&self->contacts);
|
||||
g_clear_object (&self->action_map);
|
||||
g_clear_object (&self->gesture);
|
||||
|
||||
@@ -559,13 +551,6 @@ calls_call_record_row_class_init (CallsCallRecordRowClass *klass)
|
||||
CALLS_TYPE_CALL_RECORD,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
props[PROP_CONTACTS] =
|
||||
g_param_spec_object ("contacts",
|
||||
"Contacts",
|
||||
"Interface for libfolks",
|
||||
CALLS_TYPE_CONTACTS,
|
||||
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
|
||||
|
||||
|
||||
@@ -632,12 +617,10 @@ calls_call_record_row_init (CallsCallRecordRow *self)
|
||||
|
||||
|
||||
CallsCallRecordRow *
|
||||
calls_call_record_row_new (CallsCallRecord *record,
|
||||
CallsContacts *contacts)
|
||||
calls_call_record_row_new (CallsCallRecord *record)
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_CALL_RECORD_ROW,
|
||||
"record", record,
|
||||
"contacts", contacts,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user