views: more weather service cleanups
Did I ever say how happy I'll be when people start actually following my code style when densing code to my projects?
This commit is contained in:
@@ -1765,7 +1765,7 @@ gcal_month_view_set_property (GObject *object,
|
||||
|
||||
case PROP_WEATHER_SERVICE:
|
||||
gcal_view_set_weather_service_impl_helper (&self->weather_service,
|
||||
GCAL_WEATHER_SERVICE (g_value_get_object (value)),
|
||||
g_value_get_object (value),
|
||||
(GcalWeatherUpdateFunc) update_weather,
|
||||
(GCallback) weather_changed_cb,
|
||||
GTK_WIDGET (self));
|
||||
@@ -1805,37 +1805,13 @@ gcal_month_view_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called when self is destroyed.
|
||||
*
|
||||
* WARNING: This is a workaround. This is one of the views where
|
||||
* reference counts are off. We overwrite destroy to avoid dangling
|
||||
* pointers. This issue needs to be addressed and this function removed.
|
||||
*/
|
||||
static void
|
||||
gcal_month_view_destroyed (GtkWidget *widget)
|
||||
{
|
||||
GcalMonthView *self = GCAL_MONTH_VIEW (widget);
|
||||
|
||||
if (self->weather_service)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (self->weather_service, weather_changed_cb, self);
|
||||
g_clear_object (&self->weather_service);
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (gcal_month_view_parent_class)->destroy (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_month_view_finalize (GObject *object)
|
||||
{
|
||||
GcalMonthView *self = GCAL_MONTH_VIEW (object);
|
||||
|
||||
if (self->weather_service)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (self->weather_service, weather_changed_cb, self);
|
||||
g_clear_object (&self->weather_service);
|
||||
}
|
||||
g_signal_handlers_disconnect_by_func (self->weather_service, weather_changed_cb, self);
|
||||
|
||||
g_clear_pointer (&self->date, g_free);
|
||||
g_clear_pointer (&self->children, g_hash_table_destroy);
|
||||
@@ -1844,6 +1820,7 @@ gcal_month_view_finalize (GObject *object)
|
||||
g_clear_pointer (&self->multi_cell_children, g_list_free);
|
||||
|
||||
g_clear_object (&self->manager);
|
||||
g_clear_object (&self->weather_service);
|
||||
|
||||
if (self->update_grid_id > 0)
|
||||
{
|
||||
@@ -2195,9 +2172,6 @@ gcal_month_view_class_init (GcalMonthViewClass *klass)
|
||||
widget_class->key_press_event = gcal_month_view_key_press;
|
||||
widget_class->scroll_event = gcal_month_view_scroll_event;
|
||||
|
||||
/* FIXME: Hack to deal with broken reference counts */
|
||||
widget_class->destroy = gcal_month_view_destroyed;
|
||||
|
||||
container_class = GTK_CONTAINER_CLASS (klass);
|
||||
container_class->add = gcal_month_view_add;
|
||||
container_class->remove = gcal_month_view_remove;
|
||||
|
||||
@@ -214,18 +214,13 @@ gcal_view_set_weather_service_impl_helper (GcalWeatherService **old_service,
|
||||
|
||||
if (*old_service != new_service)
|
||||
{
|
||||
if (*old_service != NULL)
|
||||
g_signal_handlers_disconnect_by_func (*old_service,
|
||||
(GCallback) weather_changed_cb,
|
||||
data);
|
||||
if (*old_service)
|
||||
g_signal_handlers_disconnect_by_func (*old_service, weather_changed_cb, data);
|
||||
|
||||
g_set_object (old_service, new_service);
|
||||
|
||||
if (*old_service != NULL)
|
||||
g_signal_connect (*old_service,
|
||||
"weather-changed",
|
||||
(GCallback) weather_changed_cb,
|
||||
data);
|
||||
if (*old_service)
|
||||
g_signal_connect (*old_service, "weather-changed", weather_changed_cb, data);
|
||||
|
||||
update_func (data);
|
||||
g_object_notify (G_OBJECT (data), "weather-service");
|
||||
|
||||
@@ -1598,41 +1598,12 @@ gcal_view_interface_init (GcalViewInterface *iface)
|
||||
iface->get_children_by_uuid = gcal_year_view_get_children_by_uuid;
|
||||
}
|
||||
|
||||
/* Called when self is destroyed.
|
||||
*
|
||||
* WARNING: This is a workaround. This is one of the views where
|
||||
* reference counts are off. We overwrite destroy to avoid dangling
|
||||
* pointers. This issue needs to be addressed and this function removed.
|
||||
*/
|
||||
static void
|
||||
gcal_year_view_destroyed (GtkWidget *widget)
|
||||
{
|
||||
GcalYearView *self = GCAL_YEAR_VIEW (widget);
|
||||
|
||||
if (self->weather_service)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (self->weather_service, weather_changed, self);
|
||||
g_clear_object (&self->weather_service);
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (gcal_year_view_parent_class)->destroy (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_year_view_finalize (GObject *object)
|
||||
{
|
||||
GcalYearView *year_view = GCAL_YEAR_VIEW (object);
|
||||
guint i;
|
||||
|
||||
if (year_view->weather_service != NULL)
|
||||
{
|
||||
g_signal_connect (year_view->weather_service,
|
||||
"weather-changed",
|
||||
(GCallback) weather_changed,
|
||||
year_view);
|
||||
g_clear_object (&year_view->weather_service);
|
||||
}
|
||||
|
||||
g_free (year_view->navigator_grid);
|
||||
g_free (year_view->selected_data);
|
||||
|
||||
@@ -1642,6 +1613,7 @@ gcal_year_view_finalize (GObject *object)
|
||||
g_clear_pointer (&year_view->date, g_free);
|
||||
|
||||
g_clear_object (&year_view->calendar_settings);
|
||||
g_clear_object (&year_view->weather_service);
|
||||
|
||||
for (i = 0; i < 12; i++)
|
||||
g_clear_pointer (&year_view->events[i], g_ptr_array_unref);
|
||||
@@ -1707,7 +1679,7 @@ gcal_year_view_set_property (GObject *object,
|
||||
|
||||
case PROP_WEATHER_SERVICE:
|
||||
gcal_view_set_weather_service_impl_helper (&self->weather_service,
|
||||
GCAL_WEATHER_SERVICE (g_value_get_object (value)),
|
||||
g_value_get_object (value),
|
||||
(GcalWeatherUpdateFunc) update_weather,
|
||||
(GCallback) weather_changed,
|
||||
GTK_WIDGET (self));
|
||||
@@ -1986,9 +1958,6 @@ gcal_year_view_class_init (GcalYearViewClass *klass)
|
||||
widget_class->size_allocate = gcal_year_view_size_allocate;
|
||||
widget_class->direction_changed = gcal_year_view_direction_changed;
|
||||
|
||||
/* Hack to deal with broken reference counts */
|
||||
widget_class->destroy = gcal_year_view_destroyed;
|
||||
|
||||
g_object_class_override_property (object_class, PROP_DATE, "active-date");
|
||||
g_object_class_override_property (object_class, PROP_MANAGER, "manager");
|
||||
g_object_class_override_property (object_class, PROP_WEATHER_SERVICE, "weather-service");
|
||||
|
||||
Reference in New Issue
Block a user