[libgweather/wip/tintou/modern-code: 1/5] location: define GWeatherLocation with G_DEFINE_BOXED_TYPE
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather/wip/tintou/modern-code: 1/5] location: define GWeatherLocation with G_DEFINE_BOXED_TYPE
- Date: Wed, 7 Oct 2020 14:36:52 +0000 (UTC)
commit 7a7e6eaed6be380805a0c4f337ae9dcc21be520a
Author: Corentin Noël <corentin noel collabora com>
Date: Wed Oct 7 15:50:44 2020 +0200
location: define GWeatherLocation with G_DEFINE_BOXED_TYPE
This allows to remove some boilerplate code.
libgweather/gweather-location.c | 17 ++---------------
libgweather/gweather-location.h | 2 ++
2 files changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/libgweather/gweather-location.c b/libgweather/gweather-location.c
index c472f274..27d75605 100644
--- a/libgweather/gweather-location.c
+++ b/libgweather/gweather-location.c
@@ -52,6 +52,8 @@
* hierarchy of locations works.
*/
+G_DEFINE_BOXED_TYPE(GWeatherLocation, gweather_location, gweather_location_ref, gweather_location_unref)
+
/**
* GWeatherLocationLevel:
* @GWEATHER_LOCATION_WORLD: A location representing the entire world.
@@ -550,21 +552,6 @@ gweather_location_unref (GWeatherLocation *loc)
_gweather_location_unref_no_check (loc);
}
-GType
-gweather_location_get_type (void)
-{
- static volatile gsize type_volatile = 0;
-
- if (g_once_init_enter (&type_volatile)) {
- GType type = g_boxed_type_register_static (
- g_intern_static_string ("GWeatherLocation"),
- (GBoxedCopyFunc) gweather_location_ref,
- (GBoxedFreeFunc) gweather_location_unref);
- g_once_init_leave (&type_volatile, type);
- }
- return type_volatile;
-}
-
/**
* gweather_location_get_name:
* @loc: a #GWeatherLocation
diff --git a/libgweather/gweather-location.h b/libgweather/gweather-location.h
index 701862d8..baebb6a2 100644
--- a/libgweather/gweather-location.h
+++ b/libgweather/gweather-location.h
@@ -152,6 +152,8 @@ GWeatherLocation *gweather_location_new_detached (const char *name
GWEATHER_EXTERN
const char *gweather_location_level_to_string (GWeatherLocationLevel level);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GWeatherLocation, gweather_location_unref)
+
G_END_DECLS
#endif /* __GWEATHER_LOCATIONS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]