aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datetime-service.c')
-rw-r--r--src/datetime-service.c77
1 files changed, 12 insertions, 65 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c
index 80c0b57..8026398 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -38,6 +38,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <geoclue/geoclue-master.h>
#include <geoclue/geoclue-master-client.h>
+#define GNOME_DESKTOP_USE_UNSTABLE_API
+#include <gdesktop-enums.h>
+#include <libgnome-desktop/gnome-wall-clock.h>
+
#include <time.h>
#include <libecal/e-cal.h>
#include <libical/ical.h>
@@ -57,7 +61,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
static void geo_create_client (GeoclueMaster * master, GeoclueMasterClient * client, gchar * path, GError * error, gpointer user_data);
static gboolean update_appointment_menu_items (gpointer user_data);
static gboolean update_timezone_menu_items(gpointer user_data);
-static void setup_timer (void);
static void geo_client_invalid (GeoclueMasterClient * client, gpointer user_data);
static void geo_address_change (GeoclueMasterClient * client, gchar * a, gchar * b, gchar * c, gchar * d, gpointer user_data);
static gboolean get_greeter_mode (void);
@@ -1139,67 +1142,12 @@ 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)
+on_clock_changed (GnomeWallClock *clock,
+ GParamSpec *pspec,
+ gpointer user_data)
{
- update_current_timezone();
- datetime_interface_update(DATETIME_INTERFACE(user_data));
- update_datetime(NULL);
- setup_timer();
- 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;
-}
-
-/* Source ID for the timer */
-static guint timer = 0;
-
-/* Execute at a given time, update and setup a new
- timer to go again. */
-static gboolean
-timer_func (gpointer user_data)
-{
- timer = 0;
- /* Reset up each time to reduce error */
- setup_timer();
- update_datetime(NULL);
- return FALSE;
-}
-
-/* Sets up the time to launch the timer to update the
- date in the datetime entry */
-static void
-setup_timer (void)
-{
- if (timer != 0) {
- g_source_remove(timer);
- timer = 0;
- }
-
- time_t t;
- t = time(NULL);
- struct tm * ltime = localtime(&t);
-
- timer = g_timeout_add_seconds(((23 - ltime->tm_hour) * 60 * 60) +
- ((59 - ltime->tm_min) * 60) +
- ((60 - ltime->tm_sec)) + 60 /* one minute past */,
- timer_func, NULL);
-
- return;
+ update_datetime (NULL);
}
static void
@@ -1213,7 +1161,6 @@ session_active_change_cb (GDBusProxy * proxy, gchar * sender_name, gchar * signa
if (!idle) {
datetime_interface_update(DATETIME_INTERFACE(user_data));
update_datetime(NULL);
- setup_timer();
}
}
return;
@@ -1437,6 +1384,8 @@ service_shutdown (IndicatorService * service, gpointer user_data)
int
main (int argc, char ** argv)
{
+ GnomeWallClock *clock;
+
g_type_init();
/* Acknowledging the service init and setting up the interface */
@@ -1472,11 +1421,9 @@ main (int argc, char ** argv)
/* Setup dbus interface */
dbus = g_object_new(DATETIME_INTERFACE_TYPE, NULL);
- /* Setup timezone watch */
- build_timezone(dbus);
-
/* Setup the timer */
- setup_timer();
+ clock = g_object_new (GNOME_TYPE_WALL_CLOCK, NULL);
+ g_signal_connect (priv->clock_tracker, "notify::clock", G_CALLBACK (on_clock_changed), NULL);
/* And watch for system resumes */
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,