~kroq-gar78/ubuntu/lucid/gnome-panel/fix-433631

« back to all changes in this revision

Viewing changes to debian/patches/02_sunrise_sunset_time_format.patch

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher, Martin Pitt
  • Date: 2010-01-20 19:13:17 UTC
  • Revision ID: james.westby@ubuntu.com-20100120191317-2kkuxyy2lv8ovrk0
Tags: 1:2.29.5.1-0ubuntu2
* debian/patches/05_no_session_delay.patch:
  - don't set X-GNOME-Autostart-Phase=Panel to avoid delaying other softwares
    start on login
              
[ Martin Pitt ]
* Add 02_sunrise_sunset_time_format.patch: Fix sunrise and sunset times in
  tooltip to respect 12/24 hour format setting. Thanks to Ted M Lin!
  (LP: #197657)
* Add 03_dnd_places_link.patch: When using Drag'n'Drop from Places menu,
  install a link launcher (.desktop file) instead of copying the entire
  directory. Thanks Marcel Stimberg! (LP: #62529)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 76c53350cf86cb15400c00c9ca0b84931cb5f040 Mon Sep 17 00:00:00 2001
 
2
From: Ted M Lin <tedmlin@gmail.com>
 
3
Date: Tue, 1 Sep 2009 22:00:36 -0400
 
4
Subject: [PATCH] Fix sunrise and sunset times in tooltip to respect 12/24 hour format setting.
 
5
 
 
6
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=520226
 
7
Bug-Ubuntu: https://launchpad.net/bugs/197657
 
8
 
 
9
diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c
 
10
index e1b254c..22c1e9f 100644
 
11
--- a/applets/clock/clock-location-tile.c
 
12
+++ b/applets/clock/clock-location-tile.c
 
13
@@ -501,6 +501,36 @@ format_time (struct tm   *now,
 
14
        return utf8;
 
15
 }
 
16
 
 
17
+static char *
 
18
+convert_time_to_str (time_t now, ClockFormat clock_format)
 
19
+{
 
20
+       gchar *format;
 
21
+       struct tm *tm;
 
22
+       gchar buf[128];
 
23
+
 
24
+       if (clock_format == CLOCK_FORMAT_12) {
 
25
+/* translators: This is a strftime format string that is used for formatting
 
26
+ * the time that is displayed in the sunrise/sunset popup. This string is used
 
27
+ * for 12-hour format (the %p expands to am/pm).
 
28
+ * There should be little need to translate this string.
 
29
+ */
 
30
+               format = _("%l:%M %p");
 
31
+       }
 
32
+       else {
 
33
+/* translators: This is a strftime format string that is used for formatting
 
34
+ * the time that is displayed in the sunrise/sunset popup. This string is used
 
35
+ * for a 24-hour format.
 
36
+ * There should be little need to translate this string.
 
37
+ */
 
38
+               format = _("%H:%M");
 
39
+       }
 
40
+
 
41
+       tm = localtime (&now);
 
42
+       strftime (buf, sizeof (buf) - 1, format, tm);
 
43
+
 
44
+       return g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
 
45
+}
 
46
+
 
47
 void
 
48
 clock_location_tile_refresh (ClockLocationTile *this, gboolean force_refresh)
 
49
 {
 
50
@@ -556,7 +586,8 @@ clock_location_tile_refresh (ClockLocationTile *this, gboolean force_refresh)
 
51
 }
 
52
 
 
53
 void
 
54
-weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkTooltip *tooltip)
 
55
+weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkTooltip *tooltip,
 
56
+                           ClockFormat clock_format)
 
57
 {
 
58
         GdkPixbuf *pixbuf = NULL;
 
59
         GtkIconTheme *theme = NULL;
 
60
@@ -565,6 +596,8 @@ weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkToolt
 
61
        gchar *line1, *line2, *line3, *line4, *tip;
 
62
        const gchar *icon_name;
 
63
        const gchar *sys_timezone;
 
64
+       time_t sunrise_time, sunset_time;
 
65
+       gchar *sunrise_str, *sunset_str;
 
66
 
 
67
                icon_name = weather_info_get_icon_name (info);
 
68
         theme = gtk_icon_theme_get_default ();
 
69
@@ -600,15 +633,21 @@ weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkToolt
 
70
        else
 
71
                line3 = g_strdup ("");
 
72
 
 
73
-       /* FIXME: we need libgweather to give us the time,
 
74
-        * not just a formatted string
 
75
-        */
 
76
        sys_timezone = getenv ("TZ");
 
77
        setenv ("TZ", clock_location_get_timezone (location), 1);
 
78
        tzset ();
 
79
+       if (weather_info_get_value_sunrise (info, &sunrise_time))
 
80
+               sunrise_str = convert_time_to_str (sunrise_time, clock_format);
 
81
+       else
 
82
+               sunrise_str = g_strdup ("???");
 
83
+       if (weather_info_get_value_sunset (info, &sunset_time))
 
84
+               sunset_str = convert_time_to_str (sunset_time, clock_format);
 
85
+       else
 
86
+               sunset_str = g_strdup ("???");
 
87
        line4 = g_strdup_printf (_("Sunrise: %s / Sunset: %s"),
 
88
-                                weather_info_get_sunrise (info),
 
89
-                                weather_info_get_sunset (info));
 
90
+                                sunrise_str, sunset_str);
 
91
+       g_free (sunrise_str);
 
92
+       g_free (sunset_str);
 
93
        if (sys_timezone)
 
94
                setenv ("TZ", sys_timezone, 1);
 
95
        else
 
96
@@ -635,13 +674,16 @@ weather_tooltip (GtkWidget  *widget,
 
97
         ClockLocationTile *tile = data;
 
98
         ClockLocationTilePrivate *priv = PRIVATE (tile);
 
99
        WeatherInfo *info;
 
100
+       int clock_format;
 
101
 
 
102
        info = clock_location_get_weather_info (priv->location);
 
103
 
 
104
        if (!info || !weather_info_is_valid (info))
 
105
                return FALSE;
 
106
 
 
107
-       weather_info_setup_tooltip (info, priv->location, tooltip);
 
108
+       g_signal_emit (tile, signals[NEED_CLOCK_FORMAT], 0, &clock_format);
 
109
+
 
110
+       weather_info_setup_tooltip (info, priv->location, tooltip, clock_format);
 
111
 
 
112
        return TRUE;
 
113
 }
 
114
diff --git a/applets/clock/clock-location-tile.h b/applets/clock/clock-location-tile.h
 
115
index b480e3f..628a8b5 100644
 
116
--- a/applets/clock/clock-location-tile.h
 
117
+++ b/applets/clock/clock-location-tile.h
 
118
@@ -6,6 +6,7 @@
 
119
 #include "clock.h"
 
120
 #include "clock-face.h"
 
121
 #include "clock-location.h"
 
122
+#include "clock-utils.h"
 
123
 
 
124
 G_BEGIN_DECLS
 
125
 
 
126
@@ -36,7 +37,8 @@ ClockLocationTile *clock_location_tile_new (ClockLocation *loc,
 
127
 
 
128
 ClockLocation *clock_location_tile_get_location (ClockLocationTile *this);
 
129
 
 
130
-void weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkTooltip *tip);
 
131
+void weather_info_setup_tooltip (WeatherInfo *info, ClockLocation *location, GtkTooltip *tip,
 
132
+                                ClockFormat clock_format);
 
133
 
 
134
 void clock_location_tile_refresh (ClockLocationTile *this,
 
135
                                   gboolean           force_refresh);
 
136
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
 
137
index 7ee7273..ec4100f 100644
 
138
--- a/applets/clock/clock.c
 
139
+++ b/applets/clock/clock.c
 
140
@@ -1389,7 +1389,7 @@ weather_tooltip (GtkWidget   *widget,
 
141
                         if (!info || !weather_info_is_valid (info))
 
142
                                 continue;
 
143
 
 
144
-                        weather_info_setup_tooltip (info, location, tooltip);
 
145
+                        weather_info_setup_tooltip (info, location, tooltip, cd->format);
 
146
 
 
147
                         return TRUE;
 
148
                 }
 
149
-- 
 
150
1.6.0.4
 
151