gui/calendar-management: Replace "context" property with context getter method
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/702>
This commit is contained in:
@@ -37,8 +37,6 @@ struct _GcalCalendarsPage
|
||||
AdwToastOverlay *toast_overlay;
|
||||
|
||||
AdwToast *toast;
|
||||
|
||||
GcalContext *context;
|
||||
};
|
||||
|
||||
static void gcal_calendar_management_page_iface_init (GcalCalendarManagementPageInterface *iface);
|
||||
@@ -51,13 +49,6 @@ G_DEFINE_TYPE_WITH_CODE (GcalCalendarsPage, gcal_calendars_page, ADW_TYPE_NAVIGA
|
||||
G_IMPLEMENT_INTERFACE (GCAL_TYPE_CALENDAR_MANAGEMENT_PAGE,
|
||||
gcal_calendar_management_page_iface_init))
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CONTEXT,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Auxiliary methods
|
||||
@@ -382,64 +373,10 @@ gcal_calendars_page_finalize (GObject *object)
|
||||
GcalCalendarsPage *self = (GcalCalendarsPage *)object;
|
||||
|
||||
g_clear_object (&self->toast);
|
||||
g_clear_object (&self->context);
|
||||
|
||||
G_OBJECT_CLASS (gcal_calendars_page_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_calendars_page_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalCalendarsPage *self = GCAL_CALENDARS_PAGE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
g_value_set_object (value, self->context);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_calendars_page_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalCalendarsPage *self = GCAL_CALENDARS_PAGE (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
{
|
||||
g_autoptr (GList) calendars = NULL;
|
||||
GcalManager *manager;
|
||||
GList *l;
|
||||
|
||||
self->context = g_value_dup_object (value);
|
||||
g_assert (self->context != NULL);
|
||||
|
||||
manager = gcal_context_get_manager (self->context);
|
||||
g_signal_connect_object (manager, "calendar-added", G_CALLBACK (on_manager_calendar_added_cb), self, 0);
|
||||
g_signal_connect_object (manager, "calendar-removed", G_CALLBACK (on_manager_calendar_removed_cb), self, 0);
|
||||
|
||||
calendars = gcal_manager_get_calendars (manager);
|
||||
for (l = calendars; l; l = l->next)
|
||||
add_calendar (self, l->data);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_calendars_page_class_init (GcalCalendarsPageClass *klass)
|
||||
{
|
||||
@@ -447,10 +384,6 @@ gcal_calendars_page_class_init (GcalCalendarsPageClass *klass)
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->finalize = gcal_calendars_page_finalize;
|
||||
object_class->get_property = gcal_calendars_page_get_property;
|
||||
object_class->set_property = gcal_calendars_page_set_property;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_CONTEXT, "context");
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/calendar-management/gcal-calendars-page.ui");
|
||||
|
||||
@@ -464,10 +397,22 @@ gcal_calendars_page_class_init (GcalCalendarsPageClass *klass)
|
||||
static void
|
||||
gcal_calendars_page_init (GcalCalendarsPage *self)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
GcalManager *manager = gcal_context_get_manager (context);
|
||||
g_autoptr (GList) calendars = NULL;
|
||||
GList *l;
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
gtk_list_box_set_sort_func (self->listbox,
|
||||
(GtkListBoxSortFunc) listbox_sort_func,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
g_signal_connect_object (manager, "calendar-added", G_CALLBACK (on_manager_calendar_added_cb), self, 0);
|
||||
g_signal_connect_object (manager, "calendar-removed", G_CALLBACK (on_manager_calendar_removed_cb), self, 0);
|
||||
|
||||
calendars = gcal_manager_get_calendars (manager);
|
||||
for (l = calendars; l; l = l->next)
|
||||
add_calendar (self, l->data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user