[gnome-calendar] manager: Move GSettings to GcalContext
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] manager: Move GSettings to GcalContext
- Date: Thu, 25 Apr 2019 19:57:28 +0000 (UTC)
commit 802c6948e831723fdcbafbaac0adcf2992b0b9c6
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Apr 24 13:21:08 2019 -0300
manager: Move GSettings to GcalContext
src/gcal-context.c | 29 +++++++++++++++++++++++++++++
src/gcal-context.h | 2 ++
src/gcal-manager.c | 37 -------------------------------------
src/gcal-manager.h | 2 --
src/gcal-night-light-monitor.c | 4 +---
src/gcal-window.c | 10 +++-------
src/weather/gcal-weather-settings.c | 8 ++------
7 files changed, 37 insertions(+), 55 deletions(-)
---
diff --git a/src/gcal-context.c b/src/gcal-context.c
index 9d4888dc..0d3d7ba6 100644
--- a/src/gcal-context.c
+++ b/src/gcal-context.c
@@ -28,6 +28,7 @@ struct _GcalContext
GcalClock *clock;
GcalManager *manager;
+ GSettings *settings;
GcalWeatherService *weather_service;
};
@@ -38,6 +39,7 @@ enum
PROP_0,
PROP_CLOCK,
PROP_MANAGER,
+ PROP_SETTINGS,
PROP_WEATHER_SERVICE,
N_PROPS
};
@@ -79,6 +81,10 @@ gcal_context_get_property (GObject *object,
g_value_set_object (value, self->manager);
break;
+ case PROP_SETTINGS:
+ g_value_set_object (value, self->settings);
+ break;
+
case PROP_WEATHER_SERVICE:
g_value_set_object (value, self->weather_service);
break;
@@ -98,6 +104,7 @@ gcal_context_set_property (GObject *object,
{
case PROP_CLOCK:
case PROP_MANAGER:
+ case PROP_SETTINGS:
case PROP_WEATHER_SERVICE:
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -125,6 +132,12 @@ gcal_context_class_init (GcalContextClass *klass)
GCAL_TYPE_MANAGER,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
+ properties[PROP_SETTINGS] = g_param_spec_object ("settings",
+ "GNOME Calendar settings",
+ "GNOME Calendar settings",
+ G_TYPE_SETTINGS,
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY |
G_PARAM_STATIC_STRINGS);
+
properties[PROP_WEATHER_SERVICE] = g_param_spec_object ("weather-service",
"Weather service",
"Weather service",
@@ -139,6 +152,7 @@ gcal_context_init (GcalContext *self)
{
self->clock = gcal_clock_new ();
self->manager = gcal_manager_new ();
+ self->settings = g_settings_new ("org.gnome.calendar");
self->weather_service = gcal_weather_service_new ();
}
@@ -186,6 +200,21 @@ gcal_context_get_manager (GcalContext *self)
return self->manager;
}
+/**
+ * gcal_context_get_settings:
+ *
+ * Retrieves the #GSettings from @self.
+ *
+ * Returns: (transfer none): a #GSettings
+ */
+GSettings*
+gcal_context_get_settings (GcalContext *self)
+{
+ g_return_val_if_fail (GCAL_IS_CONTEXT (self), NULL);
+
+ return self->settings;
+}
+
/**
* gcal_context_get_weather_service:
*
diff --git a/src/gcal-context.h b/src/gcal-context.h
index 34f2e86c..5d1478f8 100644
--- a/src/gcal-context.h
+++ b/src/gcal-context.h
@@ -37,6 +37,8 @@ GcalClock* gcal_context_get_clock (GcalContext
GcalManager* gcal_context_get_manager (GcalContext *self);
+GSettings* gcal_context_get_settings (GcalContext *self);
+
GcalWeatherService* gcal_context_get_weather_service (GcalContext *self);
G_END_DECLS
diff --git a/src/gcal-manager.c b/src/gcal-manager.c
index 54131aa8..2d71c2c0 100644
--- a/src/gcal-manager.c
+++ b/src/gcal-manager.c
@@ -96,9 +96,6 @@ struct _GcalManager
/* timezone */
icaltimezone *system_timezone;
-
- /* property */
- GSettings *settings;
};
G_DEFINE_TYPE (GcalManager, gcal_manager, G_TYPE_OBJECT)
@@ -108,7 +105,6 @@ enum
PROP_0,
PROP_DEFAULT_CALENDAR,
PROP_LOADING,
- PROP_SETTINGS,
NUM_PROPS
};
@@ -773,7 +769,6 @@ gcal_manager_finalize (GObject *object)
GCAL_ENTRY;
- g_clear_object (&self->settings);
g_clear_object (&self->goa_client);
g_clear_object (&self->e_data_model);
g_clear_object (&self->search_data_model);
@@ -845,10 +840,6 @@ gcal_manager_get_property (GObject *object,
g_value_set_boolean (value, gcal_manager_get_loading (self));
break;
- case PROP_SETTINGS:
- g_value_set_object (value, self->settings);
- return;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}
@@ -889,17 +880,6 @@ gcal_manager_class_init (GcalManagerClass *klass)
TRUE,
G_PARAM_READABLE);
- /**
- * GcalManager:settings:
- *
- * The settings.
- */
- properties[PROP_SETTINGS] = g_param_spec_object ("settings",
- "Application settings",
- "The settings of the application passed down from
GcalApplication",
- G_TYPE_SETTINGS,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
-
g_object_class_install_properties (object_class, NUM_PROPS, properties);
/* signals */
@@ -949,7 +929,6 @@ gcal_manager_class_init (GcalManagerClass *klass)
static void
gcal_manager_init (GcalManager *self)
{
- self->settings = g_settings_new ("org.gnome.calendar");
self->system_timezone = e_cal_util_get_system_timezone ();
}
@@ -967,22 +946,6 @@ gcal_manager_new (void)
return g_object_new (GCAL_TYPE_MANAGER, NULL);
}
-/**
- * gcal_manager_get_settings:
- * @self: a #GcalManager
- *
- * Retrieves the #GSetting of @self.
- *
- * Returns: (transfer none): a #GSettings
- */
-GSettings*
-gcal_manager_get_settings (GcalManager *self)
-{
- g_return_val_if_fail (GCAL_IS_MANAGER (self), NULL);
-
- return self->settings;
-}
-
/**
* gcal_manager_get_source:
* @self: a #GcalManager
diff --git a/src/gcal-manager.h b/src/gcal-manager.h
index ce47016e..837b9c18 100644
--- a/src/gcal-manager.h
+++ b/src/gcal-manager.h
@@ -33,8 +33,6 @@ G_DECLARE_FINAL_TYPE (GcalManager, gcal_manager, GCAL, MANAGER, GObject)
GcalManager* gcal_manager_new (void);
-GSettings* gcal_manager_get_settings (GcalManager *self);
-
ESource* gcal_manager_get_source (GcalManager *self,
const gchar *uid);
diff --git a/src/gcal-night-light-monitor.c b/src/gcal-night-light-monitor.c
index 09816640..293cc687 100644
--- a/src/gcal-night-light-monitor.c
+++ b/src/gcal-night-light-monitor.c
@@ -52,14 +52,12 @@ on_night_light_proxy_properties_changed_cb (GcalNightLightMonitor *self,
const gchar * const *invalidated,
GDBusProxy *proxy)
{
- GcalManager *manager;
GSettings *settings;
g_assert (GCAL_IS_NIGHT_LIGHT_MONITOR (self));
g_assert (G_IS_DBUS_PROXY (proxy));
- manager = gcal_context_get_manager (self->context);
- settings = gcal_manager_get_settings (manager);
+ settings = gcal_context_get_settings (self->context);
if (g_settings_get_boolean (settings, "follow-night-light"))
{
diff --git a/src/gcal-window.c b/src/gcal-window.c
index cc32d0f7..36b4f3f7 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -523,13 +523,11 @@ calendar_listbox_sort_func (GtkListBoxRow *row1,
static void
load_geometry (GcalWindow *self)
{
- GcalManager *manager;
GSettings *settings;
GCAL_ENTRY;
- manager = gcal_context_get_manager (self->context);
- settings = gcal_manager_get_settings (manager);
+ settings = gcal_context_get_settings (self->context);
self->is_maximized = g_settings_get_boolean (settings, "window-maximized");
g_settings_get (settings, "window-size", "(ii)", &self->width, &self->height);
@@ -552,13 +550,11 @@ load_geometry (GcalWindow *self)
static void
save_geometry (GcalWindow *self)
{
- GcalManager *manager;
GSettings *settings;
GCAL_ENTRY;
- manager = gcal_context_get_manager (self->context);
- settings = gcal_manager_get_settings (manager);
+ settings = gcal_context_get_settings (self->context);
g_settings_set_boolean (settings, "window-maximized", self->is_maximized);
g_settings_set (settings, "window-size", "(ii)", self->width, self->height);
@@ -1310,7 +1306,7 @@ gcal_window_set_property (GObject *object,
{
GcalManager *manager = gcal_context_get_manager (self->context);
- g_settings_bind (gcal_manager_get_settings (manager),
+ g_settings_bind (gcal_context_get_settings (self->context),
"active-view",
self,
"active-view",
diff --git a/src/weather/gcal-weather-settings.c b/src/weather/gcal-weather-settings.c
index 5900eb7b..fd0a6b78 100644
--- a/src/weather/gcal-weather-settings.c
+++ b/src/weather/gcal-weather-settings.c
@@ -73,7 +73,6 @@ load_weather_settings (GcalWeatherSettings *self)
g_autoptr (GVariant) location = NULL;
g_autoptr (GVariant) value = NULL;
g_autofree gchar *location_name = NULL;
- GcalManager *manager;
GSettings *settings;
gboolean show_weather;
gboolean auto_location;
@@ -83,8 +82,7 @@ load_weather_settings (GcalWeatherSettings *self)
if (!self->context)
GCAL_RETURN ();
- manager = gcal_context_get_manager (self->context);
- settings = gcal_manager_get_settings (manager);
+ settings = gcal_context_get_settings (self->context);
value = g_settings_get_value (settings, "weather-settings");
g_variant_get (value, "(bbsmv)",
@@ -130,7 +128,6 @@ static void
save_weather_settings (GcalWeatherSettings *self)
{
g_autoptr (GWeatherLocation) location = NULL;
- GcalManager *manager;
GSettings *settings;
GVariant *value;
GVariant *vlocation;
@@ -144,8 +141,7 @@ save_weather_settings (GcalWeatherSettings *self)
location = gweather_location_entry_get_location (GWEATHER_LOCATION_ENTRY (self->weather_location_entry));
vlocation = location ? gweather_location_serialize (location) : NULL;
- manager = gcal_context_get_manager (self->context);
- settings = gcal_manager_get_settings (manager);
+ settings = gcal_context_get_settings (self->context);
value = g_variant_new ("(bbsmv)",
gtk_switch_get_active (self->show_weather_switch),
gtk_switch_get_active (self->weather_auto_location_switch),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]