mate-desktop / mate-panel

MATE panel
https://mate-desktop.org
GNU General Public License v2.0
184 stars 115 forks source link

Request for clock applet Improvement: Add humidity and dew point to weather info #205

Open rickhg12hs opened 10 years ago

rickhg12hs commented 10 years ago

It would be nice to add the option of displaying the humidity and dew point for the selected location in the clock applet.

I've been using Gnome for about 2 years now. Several Gnome Shell Extensions provide detailed weather data.

Safari77 commented 6 years ago

I didn't make pull request because this is not finished, I didn't want to look at the translation hacks 😫

diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c
index a4546f7..83656aa 100644
--- a/applets/clock/clock-location-tile.c
+++ b/applets/clock/clock-location-tile.c
@@ -579,7 +579,7 @@ weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkToolt
         GtkIconTheme *theme = NULL;
         const gchar *conditions, *wind;
         gchar *temp, *apparent;
-        gchar *line1, *line2, *line3, *line4, *tip;
+        gchar *line1, *line2, *line3, *line4, *line5, *line6, *tip;
         const gchar *icon_name;
         const gchar *sys_timezone;
         time_t sunrise_time, sunset_time;
@@ -611,14 +611,17 @@ weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkToolt
                 line2 = g_strdup_printf (_("%s, feels like %s"), temp, apparent);
         else
                 line2 = g_strdup (temp);
-        g_free (temp);
-        g_free (apparent);
+
+   line3 = g_strdup_printf (_("Dew point: %s"), weather_info_get_dew (info));
+   line4 = g_strdup_printf (_("Humidity: %s"), weather_info_get_humidity (info));

         wind = weather_info_get_wind (info);
         if (strcmp (apparent, dgettext ("mate-applets-2.0", "Unknown")) != 0)
-                line3 = g_strdup_printf ("%s\n", wind);
+                line5 = g_strdup_printf ("%s\n", wind);
         else
-                line3 = g_strdup ("");
+                line5 = g_strdup ("");
+        g_free (temp);
+        g_free (apparent);

         sys_timezone = getenv ("TZ");
         setenv ("TZ", clock_location_get_timezone (location), 1);
@@ -631,7 +634,7 @@ weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkToolt
                 sunset_str = convert_time_to_str (sunset_time, clock_format);
         else
                 sunset_str = g_strdup ("???");
-        line4 = g_strdup_printf (_("Sunrise: %s / Sunset: %s"),
+        line6 = g_strdup_printf (_("Sunrise: %s / Sunset: %s"),
                                  sunrise_str, sunset_str);
         g_free (sunrise_str);
         g_free (sunset_str);
@@ -642,12 +645,15 @@ weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkToolt
                 unsetenv ("TZ");
         tzset ();

-        tip = g_strdup_printf ("<b>%s</b>\n%s\n%s%s", line1, line2, line3, line4);
+        tip = g_strdup_printf ("<b>%s</b>\n%s\n%s\n%s\n%s%s",
+                  line1, line2, line3, line4, line5, line6);
         gtk_tooltip_set_markup (tooltip, tip);
         g_free (line1);
         g_free (line2);
         g_free (line3);
         g_free (line4);
+        g_free (line5);
+        g_free (line6);
         g_free (tip);
 }
Safari77 commented 6 years ago

Against 1.20.1, fixes use-after-free

info-cppsp commented 6 years ago

looks good at first glance