diff options
author | Ted Gould <ted@gould.cx> | 2010-08-30 16:18:29 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-08-30 16:18:29 -0500 |
commit | 3e00412e0950f6c4e0d27c5f046120017c38738c (patch) | |
tree | cebad16d76cb1961c7349539bc04e6356afd2db3 /src | |
parent | 48830abd993c31546bad23cc30684a537c31332c (diff) | |
download | ayatana-indicator-datetime-3e00412e0950f6c4e0d27c5f046120017c38738c.tar.gz ayatana-indicator-datetime-3e00412e0950f6c4e0d27c5f046120017c38738c.tar.bz2 ayatana-indicator-datetime-3e00412e0950f6c4e0d27c5f046120017c38738c.zip |
Watching the timezone file and updating based on it
Diffstat (limited to 'src')
-rw-r--r-- | src/datetime-service.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c index e6a5fc3..18dd073 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libindicator/indicator-service.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <libdbusmenu-glib/server.h> #include <libdbusmenu-glib/client.h> @@ -168,6 +169,30 @@ build_menus (DbusmenuMenuitem * root) return; } +/* Run when the timezone file changes */ +static void +timezone_changed (GFileMonitor * monitor, GFile * file, GFile * otherfile, GFileMonitorEvent event, gpointer user_data) +{ + datetime_interface_update(DATETIME_INTERFACE(user_data)); + update_datetime(NULL); + return; +} + +/* Set up monitoring the timezone file */ +static void +build_timezone (DatetimeInterface * dbus) +{ + GFile * timezonefile = g_file_new_for_path(TIMEZONE_FILE); + GFileMonitor * monitor = g_file_monitor_file(timezonefile, G_FILE_MONITOR_NONE, NULL, NULL); + if (monitor != NULL) { + g_signal_connect(G_OBJECT(monitor), "changed", G_CALLBACK(timezone_changed), dbus); + g_debug("Monitoring timezone file: '" TIMEZONE_FILE "'"); + } else { + g_warning("Unable to monitor timezone file: '" TIMEZONE_FILE "'"); + } + return; +} + /* Repsonds to the service object saying it's time to shutdown. It stops the mainloop. */ static void @@ -200,8 +225,12 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); build_menus(root); + /* Setup dbus interface */ dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL); + /* Setup timezone watch */ + build_timezone(dbus); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); |