Merge lp:~ted/indicator-datetime/date-and-update into lp:indicator-datetime/0.3
- date-and-update
- Merge into trunk
Proposed by
Ted Gould
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 19 | ||||
Proposed branch: | lp:~ted/indicator-datetime/date-and-update | ||||
Merge into: | lp:indicator-datetime/0.3 | ||||
Diff against target: |
479 lines (+313/-6) 8 files modified
.bzrignore (+2/-0) src/Makefile.am (+29/-2) src/datetime-interface.c (+98/-0) src/datetime-interface.h (+55/-0) src/datetime-service.c (+77/-1) src/datetime-service.xml (+11/-0) src/dbus-shared.h (+3/-3) src/indicator-datetime.c (+38/-0) |
||||
To merge this branch: | bzr merge lp:~ted/indicator-datetime/date-and-update | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cody Russell (community) | Approve | ||
Aurélien Gâteau (community) | Needs Fixing | ||
Review via email: mp+34152@code.launchpad.net |
Commit message
Description of the change
Updates updates updates.
This makes the indicator update on two cases. The day changing (for a date change) and timezone changing. It fixes bugs, I need to find the numbers :)
To post a comment you must log in.
Revision history for this message
Ted Gould (ted) wrote : | # |
Merged in trunk and solved conflicts in r31
Revision history for this message
Cody Russell (bratsche) wrote : | # |
Looks fine to me.
Revision history for this message
Cody Russell (bratsche) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-07-14 16:37:01 +0000 | |||
3 | +++ .bzrignore 2010-08-31 12:59:38 +0000 | |||
4 | @@ -7,3 +7,5 @@ | |||
5 | 7 | indicator-datetime-[0-9].[0-9].[0-9].tar.gz | 7 | indicator-datetime-[0-9].[0-9].[0-9].tar.gz |
6 | 8 | data/indicator-datetime.service | 8 | data/indicator-datetime.service |
7 | 9 | data/org.ayatana.indicator.datetime.gschema.valid | 9 | data/org.ayatana.indicator.datetime.gschema.valid |
8 | 10 | src/datetime-service-client.h | ||
9 | 11 | src/datetime-service-server.h | ||
10 | 10 | 12 | ||
11 | === modified file 'src/Makefile.am' | |||
12 | --- src/Makefile.am 2010-07-22 19:13:36 +0000 | |||
13 | +++ src/Makefile.am 2010-08-31 12:59:38 +0000 | |||
14 | @@ -2,6 +2,9 @@ | |||
15 | 2 | libexec_PROGRAMS = indicator-datetime-service | 2 | libexec_PROGRAMS = indicator-datetime-service |
16 | 3 | 3 | ||
17 | 4 | indicator_datetime_service_SOURCES = \ | 4 | indicator_datetime_service_SOURCES = \ |
18 | 5 | datetime-interface.c \ | ||
19 | 6 | datetime-interface.h \ | ||
20 | 7 | datetime-server.h \ | ||
21 | 5 | calendar-menu-item.c \ | 8 | calendar-menu-item.c \ |
22 | 6 | calendar-menu-item.h \ | 9 | calendar-menu-item.h \ |
23 | 7 | datetime-service.c \ | 10 | datetime-service.c \ |
24 | @@ -9,13 +12,15 @@ | |||
25 | 9 | indicator_datetime_service_CFLAGS = \ | 12 | indicator_datetime_service_CFLAGS = \ |
26 | 10 | -Wall \ | 13 | -Wall \ |
27 | 11 | -Werror \ | 14 | -Werror \ |
29 | 12 | $(INDICATOR_CFLAGS) | 15 | $(INDICATOR_CFLAGS) \ |
30 | 16 | -DTIMEZONE_FILE="\"/etc/timezone\"" | ||
31 | 13 | indicator_datetime_service_LDADD = \ | 17 | indicator_datetime_service_LDADD = \ |
32 | 14 | $(INDICATOR_LIBS) | 18 | $(INDICATOR_LIBS) |
33 | 15 | 19 | ||
34 | 16 | datetimelibdir = $(INDICATORDIR) | 20 | datetimelibdir = $(INDICATORDIR) |
35 | 17 | datetimelib_LTLIBRARIES = libdatetime.la | 21 | datetimelib_LTLIBRARIES = libdatetime.la |
36 | 18 | libdatetime_la_SOURCES = \ | 22 | libdatetime_la_SOURCES = \ |
37 | 23 | datetime-client.h \ | ||
38 | 19 | dbus-shared.h \ | 24 | dbus-shared.h \ |
39 | 20 | indicator-datetime.c | 25 | indicator-datetime.c |
40 | 21 | libdatetime_la_CFLAGS = \ | 26 | libdatetime_la_CFLAGS = \ |
41 | @@ -27,4 +32,26 @@ | |||
42 | 27 | -module \ | 32 | -module \ |
43 | 28 | -avoid-version | 33 | -avoid-version |
44 | 29 | 34 | ||
46 | 30 | EXTRA_DIST = $(libdatetime_la_SOURCES) | 35 | datetime-service-client.h: $(srcdir)/datetime-service.xml |
47 | 36 | dbus-binding-tool \ | ||
48 | 37 | --prefix=_datetime_service_client \ | ||
49 | 38 | --mode=glib-client \ | ||
50 | 39 | --output=datetime-service-client.h \ | ||
51 | 40 | $(srcdir)/datetime-service.xml | ||
52 | 41 | |||
53 | 42 | datetime-service-server.h: $(srcdir)/datetime-service.xml | ||
54 | 43 | dbus-binding-tool \ | ||
55 | 44 | --prefix=_datetime_service_server \ | ||
56 | 45 | --mode=glib-server \ | ||
57 | 46 | --output=datetime-service-server.h \ | ||
58 | 47 | $(srcdir)/datetime-service.xml | ||
59 | 48 | |||
60 | 49 | BUILT_SOURCES = \ | ||
61 | 50 | datetime-service-client.h \ | ||
62 | 51 | datetime-service-server.h | ||
63 | 52 | |||
64 | 53 | CLEANFILES = \ | ||
65 | 54 | $(BUILT_SOURCES) | ||
66 | 55 | |||
67 | 56 | EXTRA_DIST = \ | ||
68 | 57 | datetime-service.xml | ||
69 | 31 | 58 | ||
70 | === added file 'src/datetime-interface.c' | |||
71 | --- src/datetime-interface.c 1970-01-01 00:00:00 +0000 | |||
72 | +++ src/datetime-interface.c 2010-08-31 12:59:38 +0000 | |||
73 | @@ -0,0 +1,98 @@ | |||
74 | 1 | /* | ||
75 | 2 | An indicator to time and date related information in the menubar. | ||
76 | 3 | |||
77 | 4 | Copyright 2010 Canonical Ltd. | ||
78 | 5 | |||
79 | 6 | Authors: | ||
80 | 7 | Ted Gould <ted@canonical.com> | ||
81 | 8 | |||
82 | 9 | This program is free software: you can redistribute it and/or modify it | ||
83 | 10 | under the terms of the GNU General Public License version 3, as published | ||
84 | 11 | by the Free Software Foundation. | ||
85 | 12 | |||
86 | 13 | This program is distributed in the hope that it will be useful, but | ||
87 | 14 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
88 | 15 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
89 | 16 | PURPOSE. See the GNU General Public License for more details. | ||
90 | 17 | |||
91 | 18 | You should have received a copy of the GNU General Public License along | ||
92 | 19 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
93 | 20 | */ | ||
94 | 21 | |||
95 | 22 | #ifdef HAVE_CONFIG_H | ||
96 | 23 | #include "config.h" | ||
97 | 24 | #endif | ||
98 | 25 | |||
99 | 26 | #include "datetime-interface.h" | ||
100 | 27 | #include "datetime-service-server.h" | ||
101 | 28 | #include "dbus-shared.h" | ||
102 | 29 | |||
103 | 30 | enum { | ||
104 | 31 | UPDATE_TIME, | ||
105 | 32 | LAST_SIGNAL | ||
106 | 33 | }; | ||
107 | 34 | |||
108 | 35 | static guint signals[LAST_SIGNAL] = { 0 }; | ||
109 | 36 | |||
110 | 37 | static void datetime_interface_class_init (DatetimeInterfaceClass *klass); | ||
111 | 38 | static void datetime_interface_init (DatetimeInterface *self); | ||
112 | 39 | static void datetime_interface_dispose (GObject *object); | ||
113 | 40 | static void datetime_interface_finalize (GObject *object); | ||
114 | 41 | |||
115 | 42 | G_DEFINE_TYPE (DatetimeInterface, datetime_interface, G_TYPE_OBJECT); | ||
116 | 43 | |||
117 | 44 | static void | ||
118 | 45 | datetime_interface_class_init (DatetimeInterfaceClass *klass) | ||
119 | 46 | { | ||
120 | 47 | GObjectClass *object_class = G_OBJECT_CLASS (klass); | ||
121 | 48 | |||
122 | 49 | object_class->dispose = datetime_interface_dispose; | ||
123 | 50 | object_class->finalize = datetime_interface_finalize; | ||
124 | 51 | |||
125 | 52 | signals[UPDATE_TIME] = g_signal_new("update-time", | ||
126 | 53 | G_TYPE_FROM_CLASS(klass), | ||
127 | 54 | G_SIGNAL_RUN_LAST, | ||
128 | 55 | G_STRUCT_OFFSET (DatetimeInterfaceClass, update_time), | ||
129 | 56 | NULL, NULL, | ||
130 | 57 | g_cclosure_marshal_VOID__VOID, | ||
131 | 58 | G_TYPE_NONE, 0, G_TYPE_NONE); | ||
132 | 59 | |||
133 | 60 | dbus_g_object_type_install_info(DATETIME_INTERFACE_TYPE, &dbus_glib__datetime_service_server_object_info); | ||
134 | 61 | |||
135 | 62 | return; | ||
136 | 63 | } | ||
137 | 64 | |||
138 | 65 | static void | ||
139 | 66 | datetime_interface_init (DatetimeInterface *self) | ||
140 | 67 | { | ||
141 | 68 | DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | ||
142 | 69 | dbus_g_connection_register_g_object(connection, | ||
143 | 70 | SERVICE_OBJ, | ||
144 | 71 | G_OBJECT(self)); | ||
145 | 72 | |||
146 | 73 | return; | ||
147 | 74 | } | ||
148 | 75 | |||
149 | 76 | static void | ||
150 | 77 | datetime_interface_dispose (GObject *object) | ||
151 | 78 | { | ||
152 | 79 | |||
153 | 80 | G_OBJECT_CLASS (datetime_interface_parent_class)->dispose (object); | ||
154 | 81 | return; | ||
155 | 82 | } | ||
156 | 83 | |||
157 | 84 | static void | ||
158 | 85 | datetime_interface_finalize (GObject *object) | ||
159 | 86 | { | ||
160 | 87 | |||
161 | 88 | G_OBJECT_CLASS (datetime_interface_parent_class)->finalize (object); | ||
162 | 89 | return; | ||
163 | 90 | } | ||
164 | 91 | |||
165 | 92 | void | ||
166 | 93 | datetime_interface_update (DatetimeInterface *self) | ||
167 | 94 | { | ||
168 | 95 | g_return_if_fail(IS_DATETIME_INTERFACE(self)); | ||
169 | 96 | g_signal_emit(G_OBJECT(self), signals[UPDATE_TIME], 0, TRUE); | ||
170 | 97 | return; | ||
171 | 98 | } | ||
172 | 0 | 99 | ||
173 | === added file 'src/datetime-interface.h' | |||
174 | --- src/datetime-interface.h 1970-01-01 00:00:00 +0000 | |||
175 | +++ src/datetime-interface.h 2010-08-31 12:59:38 +0000 | |||
176 | @@ -0,0 +1,55 @@ | |||
177 | 1 | /* | ||
178 | 2 | An indicator to time and date related information in the menubar. | ||
179 | 3 | |||
180 | 4 | Copyright 2010 Canonical Ltd. | ||
181 | 5 | |||
182 | 6 | Authors: | ||
183 | 7 | Ted Gould <ted@canonical.com> | ||
184 | 8 | |||
185 | 9 | This program is free software: you can redistribute it and/or modify it | ||
186 | 10 | under the terms of the GNU General Public License version 3, as published | ||
187 | 11 | by the Free Software Foundation. | ||
188 | 12 | |||
189 | 13 | This program is distributed in the hope that it will be useful, but | ||
190 | 14 | WITHOUT ANY WARRANTY; without even the implied warranties of | ||
191 | 15 | MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
192 | 16 | PURPOSE. See the GNU General Public License for more details. | ||
193 | 17 | |||
194 | 18 | You should have received a copy of the GNU General Public License along | ||
195 | 19 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||
196 | 20 | */ | ||
197 | 21 | |||
198 | 22 | #ifndef __DATETIME_INTERFACE_H__ | ||
199 | 23 | #define __DATETIME_INTERFACE_H__ | ||
200 | 24 | |||
201 | 25 | #include <glib.h> | ||
202 | 26 | #include <glib-object.h> | ||
203 | 27 | |||
204 | 28 | G_BEGIN_DECLS | ||
205 | 29 | |||
206 | 30 | #define DATETIME_INTERFACE_TYPE (datetime_interface_get_type ()) | ||
207 | 31 | #define DATETIME_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DATETIME_INTERFACE_TYPE, DatetimeInterface)) | ||
208 | 32 | #define DATETIME_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DATETIME_INTERFACE_TYPE, DatetimeInterfaceClass)) | ||
209 | 33 | #define IS_DATETIME_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DATETIME_INTERFACE_TYPE)) | ||
210 | 34 | #define IS_DATETIME_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DATETIME_INTERFACE_TYPE)) | ||
211 | 35 | #define DATETIME_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DATETIME_INTERFACE_TYPE, DatetimeInterfaceClass)) | ||
212 | 36 | |||
213 | 37 | typedef struct _DatetimeInterface DatetimeInterface; | ||
214 | 38 | typedef struct _DatetimeInterfaceClass DatetimeInterfaceClass; | ||
215 | 39 | |||
216 | 40 | struct _DatetimeInterfaceClass { | ||
217 | 41 | GObjectClass parent_class; | ||
218 | 42 | |||
219 | 43 | void (*update_time) (void); | ||
220 | 44 | }; | ||
221 | 45 | |||
222 | 46 | struct _DatetimeInterface { | ||
223 | 47 | GObject parent; | ||
224 | 48 | }; | ||
225 | 49 | |||
226 | 50 | GType datetime_interface_get_type (void); | ||
227 | 51 | void datetime_interface_update (DatetimeInterface *self); | ||
228 | 52 | |||
229 | 53 | G_END_DECLS | ||
230 | 54 | |||
231 | 55 | #endif | ||
232 | 0 | 56 | ||
233 | === modified file 'src/datetime-service.c' | |||
234 | --- src/datetime-service.c 2010-07-22 19:14:47 +0000 | |||
235 | +++ src/datetime-service.c 2010-08-31 12:59:38 +0000 | |||
236 | @@ -23,17 +23,22 @@ | |||
237 | 23 | #include <libindicator/indicator-service.h> | 23 | #include <libindicator/indicator-service.h> |
238 | 24 | 24 | ||
239 | 25 | #include <glib/gi18n.h> | 25 | #include <glib/gi18n.h> |
240 | 26 | #include <gio/gio.h> | ||
241 | 26 | 27 | ||
242 | 27 | #include <libdbusmenu-glib/server.h> | 28 | #include <libdbusmenu-glib/server.h> |
243 | 28 | #include <libdbusmenu-glib/client.h> | 29 | #include <libdbusmenu-glib/client.h> |
244 | 29 | #include <libdbusmenu-glib/menuitem.h> | 30 | #include <libdbusmenu-glib/menuitem.h> |
245 | 30 | 31 | ||
246 | 32 | #include "datetime-interface.h" | ||
247 | 31 | #include "dbus-shared.h" | 33 | #include "dbus-shared.h" |
248 | 32 | 34 | ||
249 | 35 | static void setup_timer (void); | ||
250 | 36 | |||
251 | 33 | static IndicatorService * service = NULL; | 37 | static IndicatorService * service = NULL; |
252 | 34 | static GMainLoop * mainloop = NULL; | 38 | static GMainLoop * mainloop = NULL; |
253 | 35 | static DbusmenuServer * server = NULL; | 39 | static DbusmenuServer * server = NULL; |
254 | 36 | static DbusmenuMenuitem * root = NULL; | 40 | static DbusmenuMenuitem * root = NULL; |
255 | 41 | static DatetimeInterface * dbus = NULL; | ||
256 | 37 | 42 | ||
257 | 38 | /* Global Items */ | 43 | /* Global Items */ |
258 | 39 | static DbusmenuMenuitem * date = NULL; | 44 | static DbusmenuMenuitem * date = NULL; |
259 | @@ -136,7 +141,6 @@ | |||
260 | 136 | dbusmenu_menuitem_child_append(root, date); | 141 | dbusmenu_menuitem_child_append(root, date); |
261 | 137 | 142 | ||
262 | 138 | g_idle_add(update_datetime, NULL); | 143 | g_idle_add(update_datetime, NULL); |
263 | 139 | /* TODO: Set up updating daily */ | ||
264 | 140 | } | 144 | } |
265 | 141 | 145 | ||
266 | 142 | if (calendar == NULL) { | 146 | if (calendar == NULL) { |
267 | @@ -166,6 +170,68 @@ | |||
268 | 166 | return; | 170 | return; |
269 | 167 | } | 171 | } |
270 | 168 | 172 | ||
271 | 173 | /* Run when the timezone file changes */ | ||
272 | 174 | static void | ||
273 | 175 | timezone_changed (GFileMonitor * monitor, GFile * file, GFile * otherfile, GFileMonitorEvent event, gpointer user_data) | ||
274 | 176 | { | ||
275 | 177 | datetime_interface_update(DATETIME_INTERFACE(user_data)); | ||
276 | 178 | update_datetime(NULL); | ||
277 | 179 | setup_timer(); | ||
278 | 180 | return; | ||
279 | 181 | } | ||
280 | 182 | |||
281 | 183 | /* Set up monitoring the timezone file */ | ||
282 | 184 | static void | ||
283 | 185 | build_timezone (DatetimeInterface * dbus) | ||
284 | 186 | { | ||
285 | 187 | GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE); | ||
286 | 188 | GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL); | ||
287 | 189 | if (monitor != NULL) { | ||
288 | 190 | g_signal_connect(G_OBJECT(monitor), "changed", G_CALLBACK(timezone_changed), dbus); | ||
289 | 191 | g_debug("Monitoring timezone file: '" TIMEZONE_FILE "'"); | ||
290 | 192 | } else { | ||
291 | 193 | g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'"); | ||
292 | 194 | } | ||
293 | 195 | return; | ||
294 | 196 | } | ||
295 | 197 | |||
296 | 198 | /* Source ID for the timer */ | ||
297 | 199 | static guint timer = 0; | ||
298 | 200 | |||
299 | 201 | /* Execute at a given time, update and setup a new | ||
300 | 202 | timer to go again. */ | ||
301 | 203 | static gboolean | ||
302 | 204 | timer_func (gpointer user_data) | ||
303 | 205 | { | ||
304 | 206 | timer = 0; | ||
305 | 207 | /* Reset up each time to reduce error */ | ||
306 | 208 | setup_timer(); | ||
307 | 209 | update_datetime(NULL); | ||
308 | 210 | return FALSE; | ||
309 | 211 | } | ||
310 | 212 | |||
311 | 213 | /* Sets up the time to launch the timer to update the | ||
312 | 214 | date in the datetime entry */ | ||
313 | 215 | static void | ||
314 | 216 | setup_timer (void) | ||
315 | 217 | { | ||
316 | 218 | if (timer != 0) { | ||
317 | 219 | g_source_remove(timer); | ||
318 | 220 | timer = 0; | ||
319 | 221 | } | ||
320 | 222 | |||
321 | 223 | time_t t; | ||
322 | 224 | t = time(NULL); | ||
323 | 225 | struct tm * ltime = localtime(&t); | ||
324 | 226 | |||
325 | 227 | timer = g_timeout_add_seconds(((23 - ltime->tm_hour) * 60 * 60) + | ||
326 | 228 | ((59 - ltime->tm_min) * 60) + | ||
327 | 229 | ((60 - ltime->tm_sec)) + 60 /* one minute past */, | ||
328 | 230 | timer_func, NULL); | ||
329 | 231 | |||
330 | 232 | return; | ||
331 | 233 | } | ||
332 | 234 | |||
333 | 169 | /* Repsonds to the service object saying it's time to shutdown. | 235 | /* Repsonds to the service object saying it's time to shutdown. |
334 | 170 | It stops the mainloop. */ | 236 | It stops the mainloop. */ |
335 | 171 | static void | 237 | static void |
336 | @@ -198,9 +264,19 @@ | |||
337 | 198 | dbusmenu_server_set_root(server, root); | 264 | dbusmenu_server_set_root(server, root); |
338 | 199 | build_menus(root); | 265 | build_menus(root); |
339 | 200 | 266 | ||
340 | 267 | /* Setup dbus interface */ | ||
341 | 268 | dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL); | ||
342 | 269 | |||
343 | 270 | /* Setup timezone watch */ | ||
344 | 271 | build_timezone(dbus); | ||
345 | 272 | |||
346 | 273 | /* Setup the timer */ | ||
347 | 274 | setup_timer(); | ||
348 | 275 | |||
349 | 201 | mainloop = g_main_loop_new(NULL, FALSE); | 276 | mainloop = g_main_loop_new(NULL, FALSE); |
350 | 202 | g_main_loop_run(mainloop); | 277 | g_main_loop_run(mainloop); |
351 | 203 | 278 | ||
352 | 279 | g_object_unref(G_OBJECT(dbus)); | ||
353 | 204 | g_object_unref(G_OBJECT(service)); | 280 | g_object_unref(G_OBJECT(service)); |
354 | 205 | g_object_unref(G_OBJECT(server)); | 281 | g_object_unref(G_OBJECT(server)); |
355 | 206 | g_object_unref(G_OBJECT(root)); | 282 | g_object_unref(G_OBJECT(root)); |
356 | 207 | 283 | ||
357 | === added file 'src/datetime-service.xml' | |||
358 | --- src/datetime-service.xml 1970-01-01 00:00:00 +0000 | |||
359 | +++ src/datetime-service.xml 2010-08-31 12:59:38 +0000 | |||
360 | @@ -0,0 +1,11 @@ | |||
361 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
362 | 2 | <node name="/"> | ||
363 | 3 | <interface name="org.ayatana.indicator.datetime.service"> | ||
364 | 4 | |||
365 | 5 | <!-- Methods --> | ||
366 | 6 | |||
367 | 7 | <!-- Signals --> | ||
368 | 8 | <signal name="UpdateTime" /> | ||
369 | 9 | |||
370 | 10 | </interface> | ||
371 | 11 | </node> | ||
372 | 0 | 12 | ||
373 | === modified file 'src/dbus-shared.h' | |||
374 | --- src/dbus-shared.h 2010-07-22 19:13:36 +0000 | |||
375 | +++ src/dbus-shared.h 2010-08-31 12:59:38 +0000 | |||
376 | @@ -20,9 +20,9 @@ | |||
377 | 20 | */ | 20 | */ |
378 | 21 | 21 | ||
379 | 22 | 22 | ||
383 | 23 | #define SERVICE_NAME "org.ayatana.indicator.datetime" | 23 | #define SERVICE_NAME "org.ayatana.indicator.datetime" |
384 | 24 | #define SERVICE_IFACE "org.ayatana.indicator.datetime.service" | 24 | #define SERVICE_IFACE "org.ayatana.indicator.datetime.service" |
385 | 25 | #define SERVICE_OBJ "/org/ayatana/indicator/datetime/service" | 25 | #define SERVICE_OBJ "/org/ayatana/indicator/datetime/service" |
386 | 26 | #define SERVICE_VERSION 1 | 26 | #define SERVICE_VERSION 1 |
387 | 27 | 27 | ||
388 | 28 | #define MENU_OBJ "/org/ayatana/indicator/datetime/menu" | 28 | #define MENU_OBJ "/org/ayatana/indicator/datetime/menu" |
389 | 29 | 29 | ||
390 | === modified file 'src/indicator-datetime.c' | |||
391 | --- src/indicator-datetime.c 2010-07-22 19:13:36 +0000 | |||
392 | +++ src/indicator-datetime.c 2010-08-31 12:59:38 +0000 | |||
393 | @@ -29,6 +29,9 @@ | |||
394 | 29 | #include <glib/gi18n-lib.h> | 29 | #include <glib/gi18n-lib.h> |
395 | 30 | #include <gio/gio.h> | 30 | #include <gio/gio.h> |
396 | 31 | 31 | ||
397 | 32 | /* DBus Stuff */ | ||
398 | 33 | #include <dbus/dbus-glib.h> | ||
399 | 34 | |||
400 | 32 | /* Indicator Stuff */ | 35 | /* Indicator Stuff */ |
401 | 33 | #include <libindicator/indicator.h> | 36 | #include <libindicator/indicator.h> |
402 | 34 | #include <libindicator/indicator-object.h> | 37 | #include <libindicator/indicator-object.h> |
403 | @@ -79,6 +82,7 @@ | |||
404 | 79 | IndicatorServiceManager * sm; | 82 | IndicatorServiceManager * sm; |
405 | 80 | DbusmenuGtkMenu * menu; | 83 | DbusmenuGtkMenu * menu; |
406 | 81 | 84 | ||
407 | 85 | DBusGProxy * service_proxy; | ||
408 | 82 | IdoCalendarMenuItem *ido_calendar; | 86 | IdoCalendarMenuItem *ido_calendar; |
409 | 83 | 87 | ||
410 | 84 | GSettings * settings; | 88 | GSettings * settings; |
411 | @@ -138,6 +142,7 @@ | |||
412 | 138 | static struct tm * update_label (IndicatorDatetime * io); | 142 | static struct tm * update_label (IndicatorDatetime * io); |
413 | 139 | static void guess_label_size (IndicatorDatetime * self); | 143 | static void guess_label_size (IndicatorDatetime * self); |
414 | 140 | static void setup_timer (IndicatorDatetime * self, struct tm * ltime); | 144 | static void setup_timer (IndicatorDatetime * self, struct tm * ltime); |
415 | 145 | static void update_time (DBusGProxy * proxy, gpointer user_data); | ||
416 | 141 | 146 | ||
417 | 142 | /* Indicator Module Config */ | 147 | /* Indicator Module Config */ |
418 | 143 | INDICATOR_SET_VERSION | 148 | INDICATOR_SET_VERSION |
419 | @@ -223,6 +228,8 @@ | |||
420 | 223 | self->priv->show_day = FALSE; | 228 | self->priv->show_day = FALSE; |
421 | 224 | self->priv->custom_string = g_strdup(DEFAULT_TIME_FORMAT); | 229 | self->priv->custom_string = g_strdup(DEFAULT_TIME_FORMAT); |
422 | 225 | 230 | ||
423 | 231 | self->priv->service_proxy = NULL; | ||
424 | 232 | |||
425 | 226 | self->priv->sm = NULL; | 233 | self->priv->sm = NULL; |
426 | 227 | self->priv->menu = NULL; | 234 | self->priv->menu = NULL; |
427 | 228 | 235 | ||
428 | @@ -262,6 +269,21 @@ | |||
429 | 262 | 269 | ||
430 | 263 | self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION); | 270 | self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION); |
431 | 264 | 271 | ||
432 | 272 | DBusGConnection * session = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); | ||
433 | 273 | if (session != NULL) { | ||
434 | 274 | self->priv->service_proxy = dbus_g_proxy_new_for_name(session, | ||
435 | 275 | SERVICE_NAME, | ||
436 | 276 | SERVICE_OBJ, | ||
437 | 277 | SERVICE_IFACE); | ||
438 | 278 | |||
439 | 279 | dbus_g_proxy_add_signal(self->priv->service_proxy, "UpdateTime", G_TYPE_INVALID); | ||
440 | 280 | dbus_g_proxy_connect_signal(self->priv->service_proxy, | ||
441 | 281 | "UpdateTime", | ||
442 | 282 | G_CALLBACK(update_time), | ||
443 | 283 | self, | ||
444 | 284 | NULL); | ||
445 | 285 | } | ||
446 | 286 | |||
447 | 265 | return; | 287 | return; |
448 | 266 | } | 288 | } |
449 | 267 | 289 | ||
450 | @@ -300,6 +322,11 @@ | |||
451 | 300 | self->priv->settings = NULL; | 322 | self->priv->settings = NULL; |
452 | 301 | } | 323 | } |
453 | 302 | 324 | ||
454 | 325 | if (self->priv->service_proxy != NULL) { | ||
455 | 326 | g_object_unref(self->priv->service_proxy); | ||
456 | 327 | self->priv->service_proxy = NULL; | ||
457 | 328 | } | ||
458 | 329 | |||
459 | 303 | G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object); | 330 | G_OBJECT_CLASS (indicator_datetime_parent_class)->dispose (object); |
460 | 304 | return; | 331 | return; |
461 | 305 | } | 332 | } |
462 | @@ -537,6 +564,17 @@ | |||
463 | 537 | return ltime; | 564 | return ltime; |
464 | 538 | } | 565 | } |
465 | 539 | 566 | ||
466 | 567 | /* Recieves the signal from the service that we should update | ||
467 | 568 | the time right now. Usually from a timezone switch. */ | ||
468 | 569 | static void | ||
469 | 570 | update_time (DBusGProxy * proxy, gpointer user_data) | ||
470 | 571 | { | ||
471 | 572 | IndicatorDatetime * self = INDICATOR_DATETIME(user_data); | ||
472 | 573 | struct tm * ltime = update_label(self); | ||
473 | 574 | setup_timer(self, ltime); | ||
474 | 575 | return; | ||
475 | 576 | } | ||
476 | 577 | |||
477 | 540 | /* Runs every minute and updates the time */ | 578 | /* Runs every minute and updates the time */ |
478 | 541 | gboolean | 579 | gboolean |
479 | 542 | timer_func (gpointer user_data) | 580 | timer_func (gpointer user_data) |
There are conflict marks in src/Makefile.am and src/indicator- datetime. c