manager: Move GcalClock to GcalApplication

GcalManager is basically an object that is shared
among classes that need to modify calendars, while
GcalClock is just a wall clock implementation.

Move it to GcalApplication, so that objects without
access to GcalManager can still access the clock.
This commit is contained in:
Georges Basile Stavracas Neto
2018-05-04 21:37:53 -03:00
parent d00a4bc7b7
commit cfa8794313
9 changed files with 103 additions and 66 deletions
+16 -5
View File
@@ -21,6 +21,8 @@
#include "config.h"
#include "e-cal-data-model-subscriber.h"
#include "gcal-application.h"
#include "gcal-clock.h"
#include "gcal-debug.h"
#include "gcal-month-cell.h"
#include "gcal-month-popover.h"
@@ -2087,11 +2089,6 @@ gcal_month_view_set_property (GObject *object,
case PROP_MANAGER:
self->manager = g_value_dup_object (value);
g_signal_connect_swapped (gcal_manager_get_clock (self->manager),
"day-changed",
G_CALLBACK (update_month_cells),
self);
for (i = 0; i < 42; i++)
gcal_month_cell_set_manager (GCAL_MONTH_CELL (self->month_cell[i / 7][i % 7]), self->manager);
@@ -2220,6 +2217,8 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
static void
gcal_month_view_init (GcalMonthView *self)
{
GcalApplication *application;
gtk_widget_init_template (GTK_WIDGET (self));
gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);
@@ -2254,5 +2253,17 @@ gcal_month_view_init (GcalMonthView *self)
G_BINDING_DEFAULT);
g_signal_connect (self->overflow_popover, "event-activated", G_CALLBACK (on_month_popover_event_activated_cb), self);
/* Connect to the wall clock */
application = GCAL_APPLICATION (g_application_get_default ());
g_assert (application != NULL);
g_signal_connect_object (gcal_application_get_clock (application),
"day-changed",
G_CALLBACK (update_month_cells),
self,
G_CONNECT_SWAPPED);
}