summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-04-06 10:28:41 -0400
committerMatthias Clasen <mclasen@redhat.com>2012-04-06 10:28:41 -0400
commit5e3563d25ff467c62d8cb81e045c984c31dadd85 (patch)
treecf78308a9bb5b530fc4404453caead9c0a09cd5b
parentc8493e8b8eb618647e89d436942b48e8e9fcc947 (diff)
downloadgdm-5e3563d25ff467c62d8cb81e045c984c31dadd85.tar.gz
Port gdm-initial-setup to timedated
gnome-settings-daemon does not ship its own datetime mechanism anymore, so we have to do the same thing as gnome-control-center, and use the systemd mechanism.
-rw-r--r--gui/initial-setup/Makefile.am13
-rw-r--r--gui/initial-setup/gdm-initial-setup.c89
-rw-r--r--gui/initial-setup/timedated1-interface.xml27
3 files changed, 77 insertions, 52 deletions
diff --git a/gui/initial-setup/Makefile.am b/gui/initial-setup/Makefile.am
index f90f315f..0348e223 100644
--- a/gui/initial-setup/Makefile.am
+++ b/gui/initial-setup/Makefile.am
@@ -14,6 +14,14 @@ LIBS = $(INITIAL_SETUP_LIBS) -lm
libexec_PROGRAMS = gdm-initial-setup
+dbus_built_sources = timedated.c timedated.h
+timedated.c: timedated.h
+timedated.h: Makefile.am timedated1-interface.xml
+ gdbus-codegen \
+ --interface-prefix org.freedesktop. \
+ --generate-c-code timedated \
+ $(srcdir)/timedated1-interface.xml
+
gdm_initial_setup_SOURCES = \
gdm-initial-setup.c \
panel-cell-renderer-signal.c panel-cell-renderer-signal.h \
@@ -22,14 +30,17 @@ gdm_initial_setup_SOURCES = \
cc-timezone-map.c cc-timezone-map.h \
um-utils.c um-utils.h \
tz.c tz.h \
- dtm.c dtm.h
+ $(dbus_built_sources)
ui_DATA = \
setup.ui \
welcome-image.jpg
EXTRA_DIST = \
+ timedated1-interface.xml \
$(ui_DATA) \
$(sys_DATA)
+BUILT_SOURCES = $(dbus_built_sources)
+
-include $(top_srcdir)/git.mk
diff --git a/gui/initial-setup/gdm-initial-setup.c b/gui/initial-setup/gdm-initial-setup.c
index 675f0f9e..9e6d1600 100644
--- a/gui/initial-setup/gdm-initial-setup.c
+++ b/gui/initial-setup/gdm-initial-setup.c
@@ -17,7 +17,7 @@
#include <act/act-user-manager.h>
#include "cc-timezone-map.h"
-#include "dtm.h"
+#include "timedated.h"
#include "um-utils.h"
#define GWEATHER_I_KNOW_THIS_IS_UNSTABLE
@@ -62,7 +62,7 @@ typedef struct {
/* location data */
CcTimezoneMap *map;
TzLocation *current_location;
- DateTimeMechanism *dtm;
+ Timedate1 *dtm;
/* online data */
GoaClient *goa_client;
@@ -1128,7 +1128,6 @@ prepare_account_page (SetupData *setup)
/* Location page {{{1 */
-
static void
set_timezone_cb (GObject *source,
GAsyncResult *res,
@@ -1138,25 +1137,27 @@ set_timezone_cb (GObject *source,
GError *error;
error = NULL;
- if (!date_time_mechanism_call_set_timezone_finish (setup->dtm,
- res,
- &error)) {
+ if (!timedate1_call_set_timezone_finish (setup->dtm,
+ res,
+ &error)) {
/* TODO: display any error in a user friendly way */
g_warning ("Could not set system timezone: %s", error->message);
g_error_free (error);
}
}
+
static void
queue_set_timezone (SetupData *setup)
{
/* for now just do it */
if (setup->current_location) {
- date_time_mechanism_call_set_timezone (setup->dtm,
- setup->current_location->zone,
- NULL,
- set_timezone_cb,
- setup);
+ timedate1_call_set_timezone (setup->dtm,
+ setup->current_location->zone,
+ TRUE,
+ NULL,
+ set_timezone_cb,
+ setup);
}
}
@@ -1210,37 +1211,6 @@ location_changed_cb (CcTimezoneMap *map,
}
static void
-get_timezone_cb (GObject *source,
- GAsyncResult *res,
- gpointer user_data)
-{
- SetupData *setup = user_data;
- gchar *timezone;
- GError *error;
-
- error = NULL;
- if (!date_time_mechanism_call_get_timezone_finish (setup->dtm, &timezone, res, &error)) {
- g_warning ("Could not get current timezone: %s", error->message);
- g_error_free (error);
- }
- else {
- if (!cc_timezone_map_set_timezone (setup->map, timezone)) {
- g_warning ("Timezone '%s' is unhandled, setting %s as default", timezone, DEFAULT_TZ);
- cc_timezone_map_set_timezone (setup->map, DEFAULT_TZ);
- }
- else {
- g_debug ("System timezone is '%s'", timezone);
- }
-
- setup->current_location = cc_timezone_map_get_location (setup->map);
- update_timezone (setup);
- }
-
- g_signal_connect (setup->map, "location-changed",
- G_CALLBACK (location_changed_cb), setup);
-}
-
-static void
location_changed (GObject *object, GParamSpec *param, SetupData *setup)
{
GWeatherLocationEntry *entry = GWEATHER_LOCATION_ENTRY (object);
@@ -1289,18 +1259,19 @@ prepare_location_page (SetupData *setup)
GtkWidget *frame, *map, *entry;
GWeatherLocation *world;
GError *error;
+ const gchar *timezone;
frame = WID("location-map-frame");
error = NULL;
- setup->dtm = date_time_mechanism_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
- G_DBUS_PROXY_FLAGS_NONE,
- "org.gnome.SettingsDaemon.DateTimeMechanism",
- "/",
- NULL,
- &error);
+ setup->dtm = timedate1_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.freedesktop.timedate1",
+ "/org/freedesktop/timedate1",
+ NULL,
+ &error);
if (setup->dtm == NULL) {
- g_error ("Failed to create proxy for datetime mechanism: %s", error->message);
+ g_error ("Failed to create proxy for timedated: %s", error->message);
exit (1);
}
@@ -1314,8 +1285,6 @@ prepare_location_page (SetupData *setup)
gtk_container_add (GTK_CONTAINER (frame), map);
- date_time_mechanism_call_get_timezone (setup->dtm, NULL, get_timezone_cb, setup);
-
world = gweather_location_new_world (FALSE);
entry = gweather_location_entry_new (world);
gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Search for a location"));
@@ -1325,8 +1294,24 @@ prepare_location_page (SetupData *setup)
frame = WID("location-page");
gtk_grid_attach (GTK_GRID (frame), entry, 1, 1, 1, 1);
+ timezone = timedate1_get_timezone (setup->dtm);
+
+ if (!cc_timezone_map_set_timezone (setup->map, timezone)) {
+ g_warning ("Timezone '%s' is unhandled, setting %s as default", timezone, DEFAULT_TZ);
+ cc_timezone_map_set_timezone (setup->map, DEFAULT_TZ);
+ }
+ else {
+ g_debug ("System timezone is '%s'", timezone);
+ }
+
+ setup->current_location = cc_timezone_map_get_location (setup->map);
+ update_timezone (setup);
+
g_signal_connect (G_OBJECT (entry), "notify::location",
G_CALLBACK (location_changed), setup);
+
+ g_signal_connect (setup->map, "location-changed",
+ G_CALLBACK (location_changed_cb), setup);
}
/* Online accounts {{{1 */
@@ -1822,6 +1807,8 @@ prepare_assistant (SetupData *setup)
prepare_online_page (setup);
}
+/* main {{{1 */
+
int
main (int argc, char *argv[])
{
diff --git a/gui/initial-setup/timedated1-interface.xml b/gui/initial-setup/timedated1-interface.xml
new file mode 100644
index 00000000..b035d10a
--- /dev/null
+++ b/gui/initial-setup/timedated1-interface.xml
@@ -0,0 +1,27 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.timedate1">
+ <property name="Timezone" type="s" access="read"/>
+ <property name="LocalRTC" type="b" access="read"/>
+ <property name="NTP" type="b" access="read"/>
+ <method name="SetTime">
+ <arg name="usec_utc" type="x" direction="in"/>
+ <arg name="relative" type="b" direction="in"/>
+ <arg name="user_interaction" type="b" direction="in"/>
+ </method>
+ <method name="SetTimezone">
+ <arg name="timezone" type="s" direction="in"/>
+ <arg name="user_interaction" type="b" direction="in"/>
+ </method>
+ <method name="SetLocalRTC">
+ <arg name="local_rtc" type="b" direction="in"/>
+ <arg name="fix_system" type="b" direction="in"/>
+ <arg name="user_interaction" type="b" direction="in"/>
+ </method>
+ <method name="SetNTP">
+ <arg name="use_ntp" type="b" direction="in"/>
+ <arg name="user_interaction" type="b" direction="in"/>
+ </method>
+ </interface>
+</node>