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:
@@ -45,7 +45,6 @@ struct _CallsMainWindow
|
||||
GtkApplicationWindow parent_instance;
|
||||
|
||||
GListModel *record_store;
|
||||
CallsContacts *contacts;
|
||||
|
||||
CallsInAppNotification *in_app_notification;
|
||||
|
||||
@@ -67,7 +66,6 @@ G_DEFINE_TYPE (CallsMainWindow, calls_main_window, GTK_TYPE_APPLICATION_WINDOW);
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_RECORD_STORE,
|
||||
PROP_CONTACTS,
|
||||
PROP_LAST_PROP,
|
||||
};
|
||||
static GParamSpec *props[PROP_LAST_PROP];
|
||||
@@ -153,11 +151,6 @@ set_property (GObject *object,
|
||||
G_LIST_MODEL (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;
|
||||
@@ -220,8 +213,7 @@ constructed (GObject *object)
|
||||
NULL);
|
||||
|
||||
// Add call records
|
||||
history = calls_history_box_new (self->record_store,
|
||||
self->contacts);
|
||||
history = calls_history_box_new (self->record_store);
|
||||
widget = GTK_WIDGET (history);
|
||||
gtk_stack_add_titled (self->main_stack, widget,
|
||||
"recent", _("Recent"));
|
||||
@@ -272,7 +264,6 @@ dispose (GObject *object)
|
||||
{
|
||||
CallsMainWindow *self = CALLS_MAIN_WINDOW (object);
|
||||
|
||||
g_clear_object (&self->contacts);
|
||||
g_clear_object (&self->record_store);
|
||||
|
||||
G_OBJECT_CLASS (calls_main_window_parent_class)->dispose (object);
|
||||
@@ -313,13 +304,6 @@ calls_main_window_class_init (CallsMainWindowClass *klass)
|
||||
G_TYPE_LIST_MODEL,
|
||||
G_PARAM_WRITABLE | 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);
|
||||
|
||||
|
||||
@@ -347,17 +331,14 @@ calls_main_window_init (CallsMainWindow *self)
|
||||
|
||||
CallsMainWindow *
|
||||
calls_main_window_new (GtkApplication *application,
|
||||
GListModel *record_store,
|
||||
CallsContacts *contacts)
|
||||
GListModel *record_store)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_APPLICATION (application), 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,
|
||||
"record-store", record_store,
|
||||
"contacts", contacts,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user