gui/window: Remove "context" property
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/702>
This commit is contained in:
@@ -325,7 +325,6 @@ gcal_application_activate (GApplication *application)
|
||||
|
||||
self->window = g_object_new (GCAL_TYPE_WINDOW,
|
||||
"application", self,
|
||||
"context", self->context,
|
||||
"active-date", self->initial_date,
|
||||
NULL);
|
||||
|
||||
|
||||
+30
-39
@@ -29,7 +29,6 @@
|
||||
#include "gcal-drop-overlay.h"
|
||||
#include "gcal-event-editor-dialog.h"
|
||||
#include "gcal-event-widget.h"
|
||||
#include "gcal-context.h"
|
||||
#include "gcal-manager.h"
|
||||
#include "gcal-month-view.h"
|
||||
#include "gcal-quick-add-popover.h"
|
||||
@@ -129,7 +128,6 @@ struct _GcalWindow
|
||||
GtkWidget *views[N_WEEKDAYS - 1];
|
||||
gboolean subscribed;
|
||||
|
||||
GcalContext *context;
|
||||
GcalWindowView active_view;
|
||||
|
||||
GDateTime *active_date;
|
||||
@@ -171,7 +169,6 @@ enum
|
||||
PROP_0,
|
||||
PROP_ACTIVE_DATE,
|
||||
PROP_ACTIVE_VIEW,
|
||||
PROP_CONTEXT,
|
||||
PROP_NEW_EVENT_MODE,
|
||||
N_PROPS
|
||||
};
|
||||
@@ -292,13 +289,14 @@ get_next_date_tooltip (GcalWindow *window,
|
||||
static void
|
||||
maybe_add_subscribers_to_timeline (GcalWindow *self)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
GcalTimeline *timeline;
|
||||
|
||||
if (self->subscribed)
|
||||
return;
|
||||
|
||||
|
||||
timeline = gcal_manager_get_timeline (gcal_context_get_manager (self->context));
|
||||
timeline = gcal_manager_get_timeline (gcal_context_get_manager (context));
|
||||
gcal_timeline_add_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->week_view));
|
||||
gcal_timeline_add_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->month_view));
|
||||
gcal_timeline_add_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->agenda_view));
|
||||
@@ -342,12 +340,13 @@ update_active_date (GcalWindow *window,
|
||||
static void
|
||||
recalculate_calendar_colors_css (GcalWindow *self)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
g_autoptr (GString) css_colors = NULL;
|
||||
g_autoptr (GList) calendars = NULL;
|
||||
GcalManager *manager;
|
||||
|
||||
css_colors = g_string_new (NULL);
|
||||
manager = gcal_context_get_manager (self->context);
|
||||
manager = gcal_context_get_manager (context);
|
||||
calendars = gcal_manager_get_calendars (manager);
|
||||
for (GList *l = calendars; l; l = l->next)
|
||||
{
|
||||
@@ -608,6 +607,7 @@ on_window_new_event_cb (GSimpleAction *action,
|
||||
GVariant *param,
|
||||
gpointer user_data)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
g_autoptr (ECalComponent) comp = NULL;
|
||||
g_autoptr (GDateTime) start = NULL;
|
||||
g_autoptr (GDateTime) end = NULL;
|
||||
@@ -623,7 +623,7 @@ on_window_new_event_cb (GSimpleAction *action,
|
||||
0, 0, 0);
|
||||
end = g_date_time_add_days (start, 1);
|
||||
|
||||
manager = gcal_context_get_manager (self->context);
|
||||
manager = gcal_context_get_manager (context);
|
||||
comp = build_component_from_details ("", start, end);
|
||||
default_calendar = gcal_manager_get_default_calendar (manager);
|
||||
event = gcal_event_new (default_calendar, comp, NULL);
|
||||
@@ -876,6 +876,7 @@ create_event_detailed_cb (GcalView *view,
|
||||
GcalRange *range,
|
||||
GcalWindow *self)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
g_autoptr (GDateTime) range_start = NULL;
|
||||
g_autoptr (GDateTime) range_end = NULL;
|
||||
GcalCalendar *default_calendar;
|
||||
@@ -883,7 +884,7 @@ create_event_detailed_cb (GcalView *view,
|
||||
ECalComponent *comp;
|
||||
GcalEvent *event;
|
||||
|
||||
manager = gcal_context_get_manager (self->context);
|
||||
manager = gcal_context_get_manager (context);
|
||||
range_start = gcal_range_get_start (range);
|
||||
range_end = gcal_range_get_end (range);
|
||||
comp = build_component_from_details ("", range_start, range_end);
|
||||
@@ -953,6 +954,7 @@ static void
|
||||
on_toast_dismissed_cb (AdwToast *toast,
|
||||
GcalWindow *self)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
GcalRecurrenceModType modifier;
|
||||
GcalManager *manager;
|
||||
GcalEvent *event;
|
||||
@@ -963,7 +965,7 @@ on_toast_dismissed_cb (AdwToast *toast,
|
||||
if (!self->delete_event_toast)
|
||||
GCAL_RETURN();
|
||||
|
||||
manager = gcal_context_get_manager (self->context);
|
||||
manager = gcal_context_get_manager (context);
|
||||
event = g_object_get_data (G_OBJECT (toast), "event");
|
||||
modifier = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toast), "modifier"));
|
||||
|
||||
@@ -1041,6 +1043,7 @@ on_ics_files_filtered_cb (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autofree gchar* toast_title = NULL;
|
||||
AdwToast *error_toast = NULL;
|
||||
@@ -1072,9 +1075,11 @@ on_ics_files_filtered_cb (GObject *source_object,
|
||||
|
||||
if (filter_result->ics_files)
|
||||
{
|
||||
context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
|
||||
g_clear_pointer (&self->import_dialog, gtk_widget_unparent);
|
||||
|
||||
self->import_dialog = gcal_import_dialog_new_for_file_list (self->context, filter_result->ics_files);
|
||||
self->import_dialog = gcal_import_dialog_new_for_file_list (context, filter_result->ics_files);
|
||||
adw_dialog_present (ADW_DIALOG (self->import_dialog), GTK_WIDGET (self));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (self->import_dialog), (gpointer *)&self->import_dialog);
|
||||
@@ -1159,8 +1164,6 @@ gcal_window_finalize (GObject *object)
|
||||
g_clear_pointer (&window->event_creation_data, g_free);
|
||||
}
|
||||
|
||||
g_clear_object (&window->context);
|
||||
|
||||
gcal_clear_date_time (&window->active_date);
|
||||
|
||||
g_clear_object (&window->colors_provider);
|
||||
@@ -1173,12 +1176,13 @@ gcal_window_finalize (GObject *object)
|
||||
static void
|
||||
gcal_window_dispose (GObject *object)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
GcalTimeline *timeline;
|
||||
GcalWindow *self;
|
||||
|
||||
self = GCAL_WINDOW (object);
|
||||
|
||||
timeline = gcal_manager_get_timeline (gcal_context_get_manager (self->context));
|
||||
timeline = gcal_manager_get_timeline (gcal_context_get_manager (context));
|
||||
gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->week_view));
|
||||
gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->month_view));
|
||||
gcal_timeline_remove_subscriber (timeline, GCAL_TIMELINE_SUBSCRIBER (self->agenda_view));
|
||||
@@ -1198,6 +1202,7 @@ gcal_window_dispose (GObject *object)
|
||||
static void
|
||||
gcal_window_constructed (GObject *object)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
GcalWindow *self;
|
||||
GSettings *settings;
|
||||
gboolean maximized;
|
||||
@@ -1211,7 +1216,7 @@ gcal_window_constructed (GObject *object)
|
||||
G_OBJECT_CLASS (gcal_window_parent_class)->constructed (object);
|
||||
|
||||
/* Load saved geometry *after* the construct-time properties are set */
|
||||
settings = gcal_context_get_settings (self->context);
|
||||
settings = gcal_context_get_settings (context);
|
||||
|
||||
maximized = g_settings_get_boolean (settings, "window-maximized");
|
||||
g_settings_get (settings, "window-size", "(ii)", &width, &height);
|
||||
@@ -1224,7 +1229,7 @@ gcal_window_constructed (GObject *object)
|
||||
/* CSS */
|
||||
load_css_providers (self);
|
||||
|
||||
g_object_connect (gcal_context_get_manager (self->context),
|
||||
g_object_connect (gcal_context_get_manager (context),
|
||||
"swapped-object-signal::calendar-added", recalculate_calendar_colors_css, self,
|
||||
"swapped-object-signal::calendar-changed", recalculate_calendar_colors_css, self,
|
||||
"swapped-object-signal::calendar-removed", recalculate_calendar_colors_css, self,
|
||||
@@ -1259,18 +1264,6 @@ gcal_window_set_property (GObject *object,
|
||||
set_new_event_mode (GCAL_WINDOW (object), g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_CONTEXT:
|
||||
g_assert (self->context == NULL);
|
||||
self->context = g_value_dup_object (value);
|
||||
|
||||
g_settings_bind (gcal_context_get_settings (self->context),
|
||||
"active-view",
|
||||
self,
|
||||
"active-view",
|
||||
G_SETTINGS_BIND_SET | G_SETTINGS_BIND_GET);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
@@ -1300,10 +1293,6 @@ gcal_window_get_property (GObject *object,
|
||||
g_value_set_boolean (value, self->new_event_mode);
|
||||
break;
|
||||
|
||||
case PROP_CONTEXT:
|
||||
g_value_set_object (value, self->context);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
}
|
||||
@@ -1317,6 +1306,7 @@ gcal_window_get_property (GObject *object,
|
||||
static void
|
||||
gcal_window_unmap (GtkWidget *widget)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
GcalWindow *self;
|
||||
GSettings *settings;
|
||||
gint height;
|
||||
@@ -1325,7 +1315,7 @@ gcal_window_unmap (GtkWidget *widget)
|
||||
GCAL_ENTRY;
|
||||
|
||||
self = GCAL_WINDOW (widget);
|
||||
settings = gcal_context_get_settings (self->context);
|
||||
settings = gcal_context_get_settings (context);
|
||||
|
||||
gtk_window_get_default_size (GTK_WINDOW (self), &width, &height);
|
||||
|
||||
@@ -1381,12 +1371,6 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
GCAL_WINDOW_VIEW_MONTH,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_CONTEXT] = g_param_spec_object ("context",
|
||||
"Context",
|
||||
"Context",
|
||||
GCAL_TYPE_CONTEXT,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
properties[PROP_NEW_EVENT_MODE] = g_param_spec_boolean ("new-event-mode",
|
||||
"New Event mode",
|
||||
"Whether the window is in new-event-mode or not",
|
||||
@@ -1447,6 +1431,7 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
static void
|
||||
gcal_window_init (GcalWindow *self)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
static const GActionEntry actions[] = {
|
||||
{"change-view", on_view_action_activated, "i" },
|
||||
{"next-date", on_window_next_date_activated_cb },
|
||||
@@ -1486,6 +1471,12 @@ gcal_window_init (GcalWindow *self)
|
||||
|
||||
gcal_drop_overlay_set_drop_target(self->drop_overlay, self->drop_target);
|
||||
g_signal_connect_object (self->event_editor, "closed", G_CALLBACK (event_editor_closed_cb), self, 0);
|
||||
|
||||
g_settings_bind (gcal_context_get_settings (context),
|
||||
"active-view",
|
||||
self,
|
||||
"active-view",
|
||||
G_SETTINGS_BIND_SET | G_SETTINGS_BIND_GET);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1503,7 +1494,6 @@ gcal_window_new_with_date (GcalApplication *app,
|
||||
{
|
||||
return g_object_new (GCAL_TYPE_WINDOW,
|
||||
"application", GTK_APPLICATION (app),
|
||||
"context", gcal_application_get_context (app),
|
||||
"active-date", date,
|
||||
NULL);
|
||||
}
|
||||
@@ -1568,11 +1558,12 @@ gcal_window_import_files (GcalWindow *self,
|
||||
GFile **files,
|
||||
gint n_files)
|
||||
{
|
||||
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||
g_return_if_fail (GCAL_IS_WINDOW (self));
|
||||
|
||||
g_clear_pointer (&self->import_dialog, gtk_widget_unparent);
|
||||
|
||||
self->import_dialog = gcal_import_dialog_new_for_files (self->context, files, n_files);
|
||||
self->import_dialog = gcal_import_dialog_new_for_files (context, files, n_files);
|
||||
adw_dialog_present (ADW_DIALOG (self->import_dialog), GTK_WIDGET (self));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (self->import_dialog), (gpointer *)&self->import_dialog);
|
||||
|
||||
Reference in New Issue
Block a user