[gnome-panel/wip/muktupavels/issue-33: 2/2] clock: make clock_location_get_gweather_timezone static




commit 8333d44e1afb9371d3d34af066d53db81668a88f
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sat May 29 12:50:17 2021 +0300

    clock: make clock_location_get_gweather_timezone static

 modules/clock/clock-location.c | 102 ++++++++++++++++++++---------------------
 modules/clock/clock-location.h |   1 -
 2 files changed, 51 insertions(+), 52 deletions(-)
---
diff --git a/modules/clock/clock-location.c b/modules/clock/clock-location.c
index d0f26cb83..7496f16a2 100644
--- a/modules/clock/clock-location.c
+++ b/modules/clock/clock-location.c
@@ -55,6 +55,56 @@ static void clock_location_finalize (GObject *);
 static gboolean update_weather_info (gpointer user_data);
 static void setup_weather_updates (ClockLocation *loc);
 
+static GWeatherTimezone *
+get_gweather_timezone (ClockLocation *loc)
+{
+       GWeatherTimezone *tz;
+       GWeatherLocation *gloc;
+
+       gloc = gweather_location_ref (loc->priv->loc);
+       tz = gweather_location_get_timezone (gloc);
+
+       if (tz == NULL) {
+               GWeatherLocation *tmp;
+
+               /* Some weather stations do not have timezone information.
+                * In this case, we need to find the nearest city. */
+               while (gweather_location_get_level (gloc) >= GWEATHER_LOCATION_CITY) {
+                       tmp = gloc;
+
+#ifdef HAVE_GWEATHER_40
+                       gloc = gweather_location_get_parent (gloc);
+#else
+                       gloc = gweather_location_get_parent (gloc);
+                       gloc = gweather_location_ref (gloc);
+#endif
+
+                       gweather_location_unref (tmp);
+               }
+
+               tmp = gloc;
+               gloc = gweather_location_find_nearest_city (gloc,
+                                                           loc->priv->latitude,
+                                                           loc->priv->longitude);
+               gweather_location_unref (tmp);
+
+               if (gloc == NULL) {
+                       g_warning ("Could not find the nearest city for location \"%s\"",
+                                  gweather_location_get_name (loc->priv->loc));
+                       return gweather_timezone_get_utc ();
+               }
+
+               tz = gweather_location_get_timezone (gloc);
+               tz = gweather_timezone_ref (tz);
+               gweather_location_unref (gloc);
+       } else {
+               tz = gweather_timezone_ref (tz);
+               gweather_location_unref (gloc);
+       }
+
+       return tz;
+}
+
 ClockLocation *
 clock_location_new (GnomeWallClock   *wall_clock,
                     GWeatherLocation *world,
@@ -88,7 +138,7 @@ clock_location_new (GnomeWallClock   *wall_clock,
                gweather_location_get_coords (priv->loc, &priv->latitude, &priv->longitude);
        }
 
-       priv->wtz = clock_location_get_gweather_timezone (this);
+       priv->wtz = get_gweather_timezone (this);
 
         setup_weather_updates (this);
 
@@ -212,56 +262,6 @@ clock_location_get_city (ClockLocation *loc)
         return gweather_location_get_city_name (loc->priv->loc);
 }
 
-GWeatherTimezone *
-clock_location_get_gweather_timezone (ClockLocation *loc)
-{
-       GWeatherTimezone *tz;
-       GWeatherLocation *gloc;
-
-       gloc = gweather_location_ref (loc->priv->loc);
-       tz = gweather_location_get_timezone (gloc);
-
-       if (tz == NULL) {
-               GWeatherLocation *tmp;
-
-               /* Some weather stations do not have timezone information.
-                * In this case, we need to find the nearest city. */
-               while (gweather_location_get_level (gloc) >= GWEATHER_LOCATION_CITY) {
-                       tmp = gloc;
-
-#ifdef HAVE_GWEATHER_40
-                       gloc = gweather_location_get_parent (gloc);
-#else
-                       gloc = gweather_location_get_parent (gloc);
-                       gloc = gweather_location_ref (gloc);
-#endif
-
-                       gweather_location_unref (tmp);
-               }
-
-               tmp = gloc;
-               gloc = gweather_location_find_nearest_city (gloc,
-                                                           loc->priv->latitude,
-                                                           loc->priv->longitude);
-               gweather_location_unref (tmp);
-
-               if (gloc == NULL) {
-                       g_warning ("Could not find the nearest city for location \"%s\"",
-                                  gweather_location_get_name (loc->priv->loc));
-                       return gweather_timezone_get_utc ();
-               }
-
-               tz = gweather_location_get_timezone (gloc);
-               tz = gweather_timezone_ref (tz);
-               gweather_location_unref (gloc);
-       } else {
-               tz = gweather_timezone_ref (tz);
-               gweather_location_unref (gloc);
-       }
-
-       return tz;
-}
-
 const gchar *
 clock_location_get_timezone (ClockLocation *loc)
 {
diff --git a/modules/clock/clock-location.h b/modules/clock/clock-location.h
index cb614835d..b632beda3 100644
--- a/modules/clock/clock-location.h
+++ b/modules/clock/clock-location.h
@@ -50,7 +50,6 @@ const char *clock_location_get_name (ClockLocation *loc);
 void clock_location_set_name (ClockLocation *loc, const gchar *name);
 
 gchar *clock_location_get_city (ClockLocation *loc);
-GWeatherTimezone *clock_location_get_gweather_timezone (ClockLocation *loc);
 const gchar *clock_location_get_timezone (ClockLocation *loc);
 void clock_location_get_coords (ClockLocation *loc, gdouble *latitude, gdouble *longitude);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]