Commit f708c36f authored by Colin Walters's avatar Colin Walters Committed by Javier Jardón

datetime: Use GnomeWallClock instead of periodic timeout

We don't actually use the ::clock property string here - this
is just making it so we don't need to wake up once a second.

https://bugzilla.gnome.org/show_bug.cgi?id=658011
parent 8b96ec6d
......@@ -77,6 +77,7 @@ POLKIT_REQUIRED_VERSION=0.97
GSD_REQUIRED_VERSION=2.91.94
NETWORK_MANAGER_REQUIRED_VERSION=0.8.992
LIBNOTIFY_REQUIRED_VERSION=0.7.3
GNOME_DESKTOP_REQUIRED_VERSION=3.1.91
COMMON_MODULES="gtk+-3.0 >= $GTK_REQUIRED_VERSION
glib-2.0 >= $GLIB_REQUIRED_VERSION
......@@ -93,6 +94,7 @@ PKG_CHECK_MODULES(SHELL, $COMMON_MODULES libgnome-menu-3.0 gio-unix-2.0)
PKG_CHECK_MODULES(BACKGROUND_PANEL, $COMMON_MODULES libxml-2.0 gnome-desktop-3.0
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
PKG_CHECK_MODULES(DATETIME_PANEL, $COMMON_MODULES dbus-glib-1
gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
PKG_CHECK_MODULES(DISPLAY_PANEL, $COMMON_MODULES dbus-glib-1 gnome-desktop-3.0 >= 3.1.0)
......
......@@ -26,11 +26,14 @@
#include "cc-timezone-map.h"
#include "dtm.h"
#include "date-endian.h"
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <gdesktop-enums.h>
#include <string.h>
#include <stdlib.h>
#include <libintl.h>
#include <libgnome-desktop/gnome-wall-clock.h>
#include <polkit/polkit.h>
/* FIXME: This should be "Etc/GMT" instead */
......@@ -77,7 +80,7 @@ struct _CcDateTimePanelPrivate
GSettings *settings;
GDesktopClockFormat clock_format;
guint update_id;
GnomeWallClock *clock_tracker;
DateTimeMechanism *dtm;
GCancellable *cancellable;
......@@ -86,7 +89,6 @@ struct _CcDateTimePanelPrivate
};
static void update_time (CcDateTimePanel *self);
static void queue_clock_update (CcDateTimePanel *self);
static void
cc_date_time_panel_get_property (GObject *object,
......@@ -119,10 +121,10 @@ cc_date_time_panel_dispose (GObject *object)
{
CcDateTimePanelPrivate *priv = CC_DATE_TIME_PANEL (object)->priv;
if (priv->update_id != 0)
if (priv->clock_tracker != NULL)
{
g_source_remove (priv->update_id);
priv->update_id = 0;
g_object_unref (priv->clock_tracker);
priv->clock_tracker = NULL;
}
if (priv->builder)
......@@ -753,6 +755,14 @@ month_year_changed (GtkWidget *widget,
change_date (panel);
}
static void
on_clock_changed (GnomeWallClock *clock,
GParamSpec *pspec,
CcDateTimePanel *panel)
{
update_time (panel);
}
static void
change_time (GtkButton *button,
CcDateTimePanel *panel)
......@@ -803,31 +813,6 @@ change_ntp (GObject *gobject,
queue_set_ntp (self);
}
static gboolean
update_time_timer (CcDateTimePanel *self)
{
g_date_time_unref (self->priv->date);
self->priv->date = g_date_time_new_now_local ();
update_time (self);
queue_clock_update (self);
return FALSE;
}
static void
queue_clock_update (CcDateTimePanel *self)
{
int timeouttime;
struct timeval tv;
gettimeofday (&tv, NULL);
timeouttime = (G_USEC_PER_SEC - tv.tv_usec) / 1000 + 1;
/* timeout of one minute if we don't care about the seconds */
timeouttime += 1000 * (59 - tv.tv_sec % 60);
self->priv->update_id = g_timeout_add (timeouttime, (GSourceFunc)update_time_timer, self);
}
static void
on_permission_changed (GPermission *permission,
GParamSpec *pspec,
......@@ -998,6 +983,9 @@ cc_date_time_panel_init (CcDateTimePanel *self)
/* setup the time itself */
priv->clock_tracker = g_object_new (GNOME_TYPE_WALL_CLOCK, NULL);
g_signal_connect (priv->clock_tracker, "notify::clock", G_CALLBACK (on_clock_changed), self);
priv->settings = g_settings_new (CLOCK_SCHEMA);
clock_settings_changed_cb (priv->settings, CLOCK_FORMAT_KEY, self);
g_signal_connect (priv->settings, "changed::" CLOCK_FORMAT_KEY,
......@@ -1035,8 +1023,6 @@ cc_date_time_panel_init (CcDateTimePanel *self)
get_timezone_cb,
self);
queue_clock_update (self);
/* add the lock button */
priv->permission = polkit_permission_new_sync ("org.gnome.settingsdaemon.datetimemechanism.configure", NULL, NULL, NULL);
if (priv->permission == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment