weahter-settings: Receive a context
This commit is contained in:
+1
-2
@@ -1261,10 +1261,9 @@ gcal_window_constructed (GObject *object)
|
|||||||
* FIXME: this is a hack around the issue that happens when trying to bind
|
* FIXME: this is a hack around the issue that happens when trying to bind
|
||||||
* these properties using the GtkBuilder .ui file.
|
* these properties using the GtkBuilder .ui file.
|
||||||
*/
|
*/
|
||||||
g_object_bind_property (self->context, "manager", self->weather_settings, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
g_object_bind_property (self, "context", self->weather_settings, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
g_object_bind_property (self->context, "manager", self->edit_dialog, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
g_object_bind_property (self->context, "manager", self->edit_dialog, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
g_object_bind_property (self->context, "manager", self->source_dialog, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
g_object_bind_property (self->context, "manager", self->source_dialog, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
g_object_bind_property (self->context, "manager", self->weather_settings, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
|
||||||
g_object_bind_property (self->context, "manager", self->week_view, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
g_object_bind_property (self->context, "manager", self->week_view, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
g_object_bind_property (self->context, "manager", self->month_view, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
g_object_bind_property (self->context, "manager", self->month_view, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
g_object_bind_property (self->context, "manager", self->year_view, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
g_object_bind_property (self->context, "manager", self->year_view, "manager", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#define G_LOG_DOMAIN "GcalWeatherSettings"
|
#define G_LOG_DOMAIN "GcalWeatherSettings"
|
||||||
|
|
||||||
|
#include "gcal-context.h"
|
||||||
#include "gcal-debug.h"
|
#include "gcal-debug.h"
|
||||||
#include "gcal-manager.h"
|
#include "gcal-manager.h"
|
||||||
#include "gcal-utils.h"
|
#include "gcal-utils.h"
|
||||||
@@ -32,7 +33,7 @@ struct _GcalWeatherSettings
|
|||||||
GtkSwitch *weather_auto_location_switch;
|
GtkSwitch *weather_auto_location_switch;
|
||||||
GtkWidget *weather_location_entry;
|
GtkWidget *weather_location_entry;
|
||||||
|
|
||||||
GcalManager *manager;
|
GcalContext *context;
|
||||||
|
|
||||||
GcalWeatherService *weather_service;
|
GcalWeatherService *weather_service;
|
||||||
};
|
};
|
||||||
@@ -54,7 +55,7 @@ G_DEFINE_TYPE (GcalWeatherSettings, gcal_weather_settings, GTK_TYPE_BOX)
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_MANAGER,
|
PROP_CONTEXT,
|
||||||
PROP_WEATHER_SERVICE,
|
PROP_WEATHER_SERVICE,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
@@ -72,16 +73,18 @@ load_weather_settings (GcalWeatherSettings *self)
|
|||||||
g_autoptr (GVariant) location = NULL;
|
g_autoptr (GVariant) location = NULL;
|
||||||
g_autoptr (GVariant) value = NULL;
|
g_autoptr (GVariant) value = NULL;
|
||||||
g_autofree gchar *location_name = NULL;
|
g_autofree gchar *location_name = NULL;
|
||||||
|
GcalManager *manager;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
gboolean show_weather;
|
gboolean show_weather;
|
||||||
gboolean auto_location;
|
gboolean auto_location;
|
||||||
|
|
||||||
GCAL_ENTRY;
|
GCAL_ENTRY;
|
||||||
|
|
||||||
if (!self->manager)
|
if (!self->context)
|
||||||
GCAL_RETURN ();
|
GCAL_RETURN ();
|
||||||
|
|
||||||
settings = gcal_manager_get_settings (self->manager);
|
manager = gcal_context_get_manager (self->context);
|
||||||
|
settings = gcal_manager_get_settings (manager);
|
||||||
value = g_settings_get_value (settings, "weather-settings");
|
value = g_settings_get_value (settings, "weather-settings");
|
||||||
|
|
||||||
g_variant_get (value, "(bbsmv)",
|
g_variant_get (value, "(bbsmv)",
|
||||||
@@ -127,6 +130,7 @@ static void
|
|||||||
save_weather_settings (GcalWeatherSettings *self)
|
save_weather_settings (GcalWeatherSettings *self)
|
||||||
{
|
{
|
||||||
g_autoptr (GWeatherLocation) location = NULL;
|
g_autoptr (GWeatherLocation) location = NULL;
|
||||||
|
GcalManager *manager;
|
||||||
GSettings *settings;
|
GSettings *settings;
|
||||||
GVariant *value;
|
GVariant *value;
|
||||||
GVariant *vlocation;
|
GVariant *vlocation;
|
||||||
@@ -134,13 +138,14 @@ save_weather_settings (GcalWeatherSettings *self)
|
|||||||
|
|
||||||
GCAL_ENTRY;
|
GCAL_ENTRY;
|
||||||
|
|
||||||
if (!self->manager)
|
if (!self->context)
|
||||||
GCAL_RETURN ();
|
GCAL_RETURN ();
|
||||||
|
|
||||||
location = gweather_location_entry_get_location (GWEATHER_LOCATION_ENTRY (self->weather_location_entry));
|
location = gweather_location_entry_get_location (GWEATHER_LOCATION_ENTRY (self->weather_location_entry));
|
||||||
vlocation = location ? gweather_location_serialize (location) : NULL;
|
vlocation = location ? gweather_location_serialize (location) : NULL;
|
||||||
|
|
||||||
settings = gcal_manager_get_settings (self->manager);
|
manager = gcal_context_get_manager (self->context);
|
||||||
|
settings = gcal_manager_get_settings (manager);
|
||||||
value = g_variant_new ("(bbsmv)",
|
value = g_variant_new ("(bbsmv)",
|
||||||
gtk_switch_get_active (self->show_weather_switch),
|
gtk_switch_get_active (self->show_weather_switch),
|
||||||
gtk_switch_get_active (self->weather_auto_location_switch),
|
gtk_switch_get_active (self->weather_auto_location_switch),
|
||||||
@@ -292,8 +297,8 @@ gcal_weather_settings_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MANAGER:
|
case PROP_CONTEXT:
|
||||||
g_value_set_object (value, self->manager);
|
g_value_set_object (value, self->context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_WEATHER_SERVICE:
|
case PROP_WEATHER_SERVICE:
|
||||||
@@ -315,14 +320,14 @@ gcal_weather_settings_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MANAGER:
|
case PROP_CONTEXT:
|
||||||
if (g_set_object (&self->manager, g_value_get_object (value)))
|
if (g_set_object (&self->context, g_value_get_object (value)))
|
||||||
{
|
{
|
||||||
load_weather_settings (self);
|
load_weather_settings (self);
|
||||||
update_menu_weather_sensitivity (self);
|
update_menu_weather_sensitivity (self);
|
||||||
manage_weather_service (self);
|
manage_weather_service (self);
|
||||||
|
|
||||||
g_object_notify_by_pspec (object, properties[PROP_MANAGER]);
|
g_object_notify_by_pspec (object, properties[PROP_CONTEXT]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -345,10 +350,10 @@ gcal_weather_settings_class_init (GcalWeatherSettingsClass *klass)
|
|||||||
object_class->get_property = gcal_weather_settings_get_property;
|
object_class->get_property = gcal_weather_settings_get_property;
|
||||||
object_class->set_property = gcal_weather_settings_set_property;
|
object_class->set_property = gcal_weather_settings_set_property;
|
||||||
|
|
||||||
properties[PROP_MANAGER] = g_param_spec_object ("manager",
|
properties[PROP_CONTEXT] = g_param_spec_object ("context",
|
||||||
"Manager",
|
"Context",
|
||||||
"Manager",
|
"Context",
|
||||||
GCAL_TYPE_MANAGER,
|
GCAL_TYPE_CONTEXT,
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
properties[PROP_WEATHER_SERVICE] = g_param_spec_object ("weather-service",
|
properties[PROP_WEATHER_SERVICE] = g_param_spec_object ("weather-service",
|
||||||
|
|||||||
Reference in New Issue
Block a user