2
* Copyright (C) 2010 Intel, Inc
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
* Author: Thomas Wood <thomas.wood@intel.com>
22
#include "cc-datetime-panel.h"
25
#include "cc-timezone-map.h"
26
#include "set-timezone.h"
27
#include "libgnome-control-center/cc-lockbutton.h"
28
#include "date-endian.h"
30
#include <gdesktop-enums.h>
34
#include <polkit/polkit.h>
36
/* FIXME: This should be "Etc/GMT" instead */
37
#define DEFAULT_TZ "Europe/London"
38
#define GETTEXT_PACKAGE_TIMEZONES GETTEXT_PACKAGE "-timezones"
40
G_DEFINE_DYNAMIC_TYPE (CcDateTimePanel, cc_date_time_panel, CC_TYPE_PANEL)
42
#define DATE_TIME_PANEL_PRIVATE(o) \
43
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_DATE_TIME_PANEL, CcDateTimePanelPrivate))
48
CITY_COL_CITY_TRANSLATED,
49
CITY_COL_REGION_TRANSLATED,
56
REGION_COL_REGION_TRANSLATED,
60
#define W(x) (GtkWidget*) gtk_builder_get_object (priv->builder, x)
62
#define CLOCK_SCHEMA "org.gnome.desktop.interface"
63
#define CLOCK_FORMAT_KEY "clock-format"
65
struct _CcDateTimePanelPrivate
70
TzLocation *current_location;
72
GtkTreeModel *locations;
73
GtkTreeModelFilter *city_filter;
78
GDesktopClockFormat clock_format;
83
static void update_time (CcDateTimePanel *self);
84
static void queue_clock_update (CcDateTimePanel *self);
87
cc_date_time_panel_get_property (GObject *object,
95
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
100
cc_date_time_panel_set_property (GObject *object,
108
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
113
cc_date_time_panel_dispose (GObject *object)
115
CcDateTimePanelPrivate *priv = CC_DATE_TIME_PANEL (object)->priv;
117
if (priv->update_id != 0)
119
g_source_remove (priv->update_id);
125
g_object_unref (priv->builder);
126
priv->builder = NULL;
131
g_object_unref (priv->settings);
132
priv->settings = NULL;
137
g_date_time_unref (priv->date);
141
G_OBJECT_CLASS (cc_date_time_panel_parent_class)->dispose (object);
145
cc_date_time_panel_class_init (CcDateTimePanelClass *klass)
147
GObjectClass *object_class = G_OBJECT_CLASS (klass);
149
g_type_class_add_private (klass, sizeof (CcDateTimePanelPrivate));
151
object_class->get_property = cc_date_time_panel_get_property;
152
object_class->set_property = cc_date_time_panel_set_property;
153
object_class->dispose = cc_date_time_panel_dispose;
157
cc_date_time_panel_class_finalize (CcDateTimePanelClass *klass)
162
static void clock_settings_changed_cb (GSettings *settings,
164
CcDateTimePanel *panel);
167
change_clock_settings (GObject *gobject,
169
CcDateTimePanel *panel)
171
CcDateTimePanelPrivate *priv = panel->priv;
172
GDesktopClockFormat value;
174
g_signal_handlers_block_by_func (priv->settings, clock_settings_changed_cb,
177
if (gtk_switch_get_active (GTK_SWITCH (W ("24h_time_switch"))))
178
value = G_DESKTOP_CLOCK_FORMAT_24H;
180
value = G_DESKTOP_CLOCK_FORMAT_12H;
182
g_settings_set_enum (priv->settings, CLOCK_FORMAT_KEY, value);
183
priv->clock_format = value;
187
g_signal_handlers_unblock_by_func (priv->settings, clock_settings_changed_cb,
192
clock_settings_changed_cb (GSettings *settings,
194
CcDateTimePanel *panel)
196
CcDateTimePanelPrivate *priv = panel->priv;
197
GtkWidget *switch24h;
198
gboolean use_24_hour;
199
GDesktopClockFormat value;
201
value = g_settings_get_enum (settings, CLOCK_FORMAT_KEY);
202
priv->clock_format = value;
204
switch24h = W ("24h_time_switch");
206
use_24_hour = (value == G_DESKTOP_CLOCK_FORMAT_24H);
208
g_signal_handlers_block_by_func (switch24h, change_clock_settings, panel);
210
gtk_switch_set_active (GTK_SWITCH (switch24h), use_24_hour);
214
g_signal_handlers_unblock_by_func (switch24h, change_clock_settings, panel);
218
update_time (CcDateTimePanel *self)
220
CcDateTimePanelPrivate *priv = self->priv;
222
char *am_pm_widgets[] = {"ampm_up_button", "ampm_down_button", "ampm_label" };
225
if (priv->clock_format == G_DESKTOP_CLOCK_FORMAT_24H)
227
/* Update the hours label */
228
label = g_date_time_format (priv->date, "%H");
229
gtk_label_set_text (GTK_LABEL (W("hours_label")), label);
234
/* Update the hours label */
235
label = g_date_time_format (priv->date, "%I");
236
gtk_label_set_text (GTK_LABEL (W("hours_label")), label);
240
label = g_date_time_format (priv->date, "%p");
241
gtk_label_set_text (GTK_LABEL (W("ampm_label")), label);
245
for (i = 0; i < G_N_ELEMENTS (am_pm_widgets); i++)
246
gtk_widget_set_visible (W(am_pm_widgets[i]),
247
priv->clock_format == G_DESKTOP_CLOCK_FORMAT_12H);
249
/* Update the minutes label */
250
label = g_date_time_format (priv->date, "%M");
251
gtk_label_set_text (GTK_LABEL (W("minutes_label")), label);
256
set_time_cb (CcDateTimePanel *self,
259
/* TODO: display any error in a user friendly way */
262
g_warning ("Could not set system time: %s", error->message);
271
set_timezone_cb (CcDateTimePanel *self,
274
/* TODO: display any error in a user friendly way */
277
g_warning ("Could not set system timezone: %s", error->message);
282
set_using_ntp_cb (CcDateTimePanel *self,
285
/* TODO: display any error in a user friendly way */
288
g_warning ("Could not set system to use NTP: %s", error->message);
293
queue_set_datetime (CcDateTimePanel *self)
297
/* for now just do it */
298
unixtime = g_date_time_to_unix (self->priv->date);
299
set_system_time_async (unixtime, (GFunc) set_time_cb, self, NULL);
303
queue_set_ntp (CcDateTimePanel *self)
305
CcDateTimePanelPrivate *priv = self->priv;
307
/* for now just do it */
308
using_ntp = gtk_switch_get_active (GTK_SWITCH (W("network_time_switch")));
309
set_using_ntp_async (using_ntp, (GFunc) set_using_ntp_cb, self, NULL);
313
queue_set_timezone (CcDateTimePanel *self)
315
/* for now just do it */
316
if (self->priv->current_location)
318
set_system_timezone_async (self->priv->current_location->zone, (GFunc) set_timezone_cb, self, NULL);
323
change_date (CcDateTimePanel *self)
325
CcDateTimePanelPrivate *priv = self->priv;
329
old_date = priv->date;
331
mon = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (W ("month-combobox")));
332
y = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("year-spinbutton")));
333
d = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("day-spinbutton")));
335
priv->date = g_date_time_new_local (y, mon, d,
336
g_date_time_get_hour (old_date),
337
g_date_time_get_minute (old_date),
338
g_date_time_get_second (old_date));
339
g_date_time_unref (old_date);
340
queue_set_datetime (self);
344
region_changed_cb (GtkComboBox *box,
345
CcDateTimePanel *self)
347
GtkTreeModelFilter *modelfilter;
349
modelfilter = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (self->priv->builder, "city-modelfilter"));
351
gtk_tree_model_filter_refilter (modelfilter);
355
city_changed_cb (GtkComboBox *box,
356
CcDateTimePanel *self)
358
static gboolean inside = FALSE;
362
/* prevent re-entry from location changed callback */
368
if (gtk_combo_box_get_active_iter (box, &iter))
370
gtk_tree_model_get (gtk_combo_box_get_model (box), &iter,
371
CITY_COL_ZONE, &zone, -1);
373
cc_timezone_map_set_timezone (CC_TIMEZONE_MAP (self->priv->map), zone);
382
update_timezone (CcDateTimePanel *self)
384
CcDateTimePanelPrivate *priv = self->priv;
390
/* tz.c updates the local timezone, which means the spin buttons can be
391
* updated with the current time of the new location */
393
split = g_strsplit (priv->current_location->zone, "/", 2);
395
/* remove underscores */
396
g_strdelimit (split[1], "_", ' ');
398
/* update region combo */
399
widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
401
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
402
gtk_tree_model_get_iter_first (model, &iter);
408
gtk_tree_model_get (model, &iter, CITY_COL_CITY, &string, -1);
410
if (!g_strcmp0 (string, split[0]))
413
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
418
while (gtk_tree_model_iter_next (model, &iter));
421
/* update city combo */
422
widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
424
model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
425
gtk_tree_model_filter_refilter ((GtkTreeModelFilter *) gtk_builder_get_object (priv->builder, "city-modelfilter"));
426
gtk_tree_model_get_iter_first (model, &iter);
432
gtk_tree_model_get (model, &iter, CITY_COL_CITY, &string, -1);
434
if (!g_strcmp0 (string, split[1]))
437
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
442
while (gtk_tree_model_iter_next (model, &iter));
448
location_changed_cb (CcTimezoneMap *map,
449
TzLocation *location,
450
CcDateTimePanel *self)
452
CcDateTimePanelPrivate *priv = self->priv;
453
GtkWidget *region_combo, *city_combo;
455
g_debug ("location changed to %s/%s", location->country, location->zone);
457
self->priv->current_location = location;
459
/* Update the combo boxes */
460
region_combo = W("region_combobox");
461
city_combo = W("city_combobox");
463
g_signal_handlers_block_by_func (region_combo, region_changed_cb, self);
464
g_signal_handlers_block_by_func (city_combo, city_changed_cb, self);
466
update_timezone (self);
468
g_signal_handlers_unblock_by_func (region_combo, region_changed_cb, self);
469
g_signal_handlers_unblock_by_func (city_combo, city_changed_cb, self);
471
queue_set_timezone (self);
475
get_timezone_cb (CcDateTimePanel *self,
476
const gchar *timezone,
483
g_warning ("Could not get current timezone: %s", error->message);
487
if (!cc_timezone_map_set_timezone (CC_TIMEZONE_MAP (self->priv->map), timezone))
489
g_warning ("Timezone '%s' is unhandled, setting %s as default", timezone, DEFAULT_TZ);
490
cc_timezone_map_set_timezone (CC_TIMEZONE_MAP (self->priv->map), DEFAULT_TZ);
492
self->priv->current_location = cc_timezone_map_get_location (CC_TIMEZONE_MAP (self->priv->map));
493
update_timezone (self);
496
/* now that the initial state is loaded set connect the signals */
497
widget = (GtkWidget*) gtk_builder_get_object (self->priv->builder,
499
g_signal_connect (widget, "changed", G_CALLBACK (region_changed_cb), self);
501
widget = (GtkWidget*) gtk_builder_get_object (self->priv->builder,
503
g_signal_connect (widget, "changed", G_CALLBACK (city_changed_cb), self);
505
g_signal_connect (self->priv->map, "location-changed",
506
G_CALLBACK (location_changed_cb), self);
510
/* load region and city tree models */
511
struct get_region_data
513
GtkListStore *region_store;
514
GtkListStore *city_store;
518
/* Slash look-alikes that might be used in translations */
519
#define TRANSLATION_SPLIT \
520
"\342\201\204" /* FRACTION SLASH */ \
521
"\342\210\225" /* DIVISION SLASH */ \
522
"\342\247\270" /* BIG SOLIDUS */ \
523
"\357\274\217" /* FULLWIDTH SOLIDUS */ \
527
get_regions (TzLocation *loc,
528
struct get_region_data *data)
532
gchar **split_translated;
533
gchar *translated_city;
535
zone = g_strdup (loc->zone);
536
g_strdelimit (zone, "_", ' ');
537
split = g_strsplit (zone, "/", 2);
540
/* Load the translation for it */
541
zone = g_strdup (dgettext (GETTEXT_PACKAGE_TIMEZONES, loc->zone));
542
g_strdelimit (zone, "_", ' ');
543
split_translated = g_regex_split_simple ("[\\x{2044}\\x{2215}\\x{29f8}\\x{ff0f}/]", zone, 0, 0);
546
if (!g_hash_table_lookup_extended (data->table, split[0], NULL, NULL))
548
g_hash_table_insert (data->table, g_strdup (split[0]),
549
GINT_TO_POINTER (1));
550
gtk_list_store_insert_with_values (data->region_store, NULL, 0,
551
REGION_COL_REGION, split[0],
552
REGION_COL_REGION_TRANSLATED, split_translated[0], -1);
555
/* g_regex_split_simple() splits too much for us, and would break
556
* America/Argentina/Buenos_Aires into 3 strings, so rejoin the city part */
557
translated_city = g_strjoinv ("/", split_translated + 1);
559
gtk_list_store_insert_with_values (data->city_store, NULL, 0,
560
CITY_COL_CITY, split[1],
561
CITY_COL_CITY_TRANSLATED, translated_city,
562
CITY_COL_REGION, split[0],
563
CITY_COL_REGION_TRANSLATED, split_translated[0],
564
CITY_COL_ZONE, loc->zone,
567
g_free (translated_city);
569
g_strfreev (split_translated);
573
city_model_filter_func (GtkTreeModel *model,
577
GtkTreeModel *combo_model;
578
GtkTreeIter combo_iter;
579
gchar *active_region = NULL;
580
gchar *city_region = NULL;
583
if (gtk_combo_box_get_active_iter (combo, &combo_iter) == FALSE)
586
combo_model = gtk_combo_box_get_model (combo);
587
gtk_tree_model_get (combo_model, &combo_iter,
588
CITY_COL_CITY, &active_region, -1);
590
gtk_tree_model_get (model, iter,
591
CITY_COL_REGION, &city_region, -1);
593
if (g_strcmp0 (active_region, city_region) == 0)
598
g_free (city_region);
600
g_free (active_region);
607
load_regions_model (GtkListStore *regions, GtkListStore *cities)
609
struct get_region_data data;
615
table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
618
data.region_store = regions;
619
data.city_store = cities;
621
g_ptr_array_foreach (db->locations, (GFunc) get_regions, &data);
623
g_hash_table_destroy (table);
627
/* sort the models */
628
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (regions),
629
REGION_COL_REGION_TRANSLATED,
634
update_widget_state_for_ntp (CcDateTimePanel *panel,
637
CcDateTimePanelPrivate *priv = panel->priv;
639
gtk_widget_set_sensitive (W("table1"), !using_ntp);
640
gtk_widget_set_sensitive (W("table2"), !using_ntp);
644
day_changed (GtkWidget *widget,
645
CcDateTimePanel *panel)
651
month_year_changed (GtkWidget *widget,
652
CcDateTimePanel *panel)
654
CcDateTimePanelPrivate *priv = panel->priv;
658
GtkSpinButton *day_spin;
660
mon = 1 + gtk_combo_box_get_active (GTK_COMBO_BOX (W ("month-combobox")));
661
y = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (W ("year-spinbutton")));
663
/* Check the number of days in that month */
664
num_days = g_date_get_days_in_month (mon, y);
666
day_spin = GTK_SPIN_BUTTON (W("day-spinbutton"));
667
adj = GTK_ADJUSTMENT (gtk_spin_button_get_adjustment (day_spin));
668
gtk_adjustment_set_upper (adj, num_days + 1);
670
if (gtk_spin_button_get_value_as_int (day_spin) > num_days)
671
gtk_spin_button_set_value (day_spin, num_days);
677
change_time (GtkButton *button,
678
CcDateTimePanel *panel)
680
CcDateTimePanelPrivate *priv = panel->priv;
681
const gchar *widget_name;
685
old_date = priv->date;
687
widget_name = gtk_buildable_get_name (GTK_BUILDABLE (button));
689
if (strstr (widget_name, "up"))
694
if (widget_name[0] == 'h')
696
priv->date = g_date_time_add_hours (old_date, direction);
698
else if (widget_name[0] == 'm')
700
priv->date = g_date_time_add_minutes (old_date, direction);
705
hour = g_date_time_get_hour (old_date);
707
priv->date = g_date_time_add_hours (old_date, -12);
709
priv->date = g_date_time_add_hours (old_date, 12);
711
g_date_time_unref (old_date);
714
queue_set_datetime (panel);
718
change_ntp (GObject *gobject,
720
CcDateTimePanel *self)
722
update_widget_state_for_ntp (self, gtk_switch_get_active (GTK_SWITCH (gobject)));
723
queue_set_ntp (self);
727
update_time_timer (CcDateTimePanel *self)
729
g_date_time_unref (self->priv->date);
730
self->priv->date = g_date_time_new_now_local ();
732
queue_clock_update (self);
737
queue_clock_update (CcDateTimePanel *self)
742
gettimeofday (&tv, NULL);
743
timeouttime = (G_USEC_PER_SEC - tv.tv_usec) / 1000 + 1;
745
/* timeout of one minute if we don't care about the seconds */
746
timeouttime += 1000 * (59 - tv.tv_sec % 60);
748
self->priv->update_id = g_timeout_add (timeouttime, (GSourceFunc)update_time_timer, self);
752
on_permission_changed (GPermission *permission,
756
CcDateTimePanelPrivate *priv = CC_DATE_TIME_PANEL (data)->priv;
759
allowed = g_permission_get_allowed (permission);
761
/* All the widgets but the lock button and the 24h setting */
762
gtk_widget_set_sensitive (W("map-vbox"), allowed);
763
gtk_widget_set_sensitive (W("hbox2"), allowed);
764
gtk_widget_set_sensitive (W("alignment2"), allowed);
765
gtk_widget_set_sensitive (W("table1"), allowed);
769
reorder_date_widget (DateEndianess endianess,
770
CcDateTimePanelPrivate *priv)
772
GtkWidget *month, *day, *year;
775
if (endianess == DATE_ENDIANESS_MIDDLE)
778
month = W ("month-combobox");
779
day = W ("day-spinbutton");
780
year = W("year-spinbutton");
782
box = GTK_BOX (W("table1"));
785
case DATE_ENDIANESS_LITTLE:
786
gtk_box_reorder_child (box, month, 0);
787
gtk_box_reorder_child (box, day, 0);
788
gtk_box_reorder_child (box, year, -1);
790
case DATE_ENDIANESS_BIG:
791
gtk_box_reorder_child (box, month, 0);
792
gtk_box_reorder_child (box, year, 0);
793
gtk_box_reorder_child (box, day, -1);
795
case DATE_ENDIANESS_MIDDLE:
796
/* Let's please GCC */
797
g_assert_not_reached ();
803
cc_date_time_panel_init (CcDateTimePanel *self)
805
CcDateTimePanelPrivate *priv;
806
gchar *objects[] = { "datetime-panel", "region-liststore", "city-liststore",
807
"month-liststore", "city-modelfilter", "city-modelsort", NULL };
808
char *buttons[] = { "hour_up_button", "hour_down_button", "min_up_button",
809
"min_down_button", "ampm_up_button", "ampm_down_button" };
811
GtkAdjustment *adjustment;
813
GtkTreeModelFilter *city_modelfilter;
814
GtkTreeModelSort *city_modelsort;
818
GtkWidget *lockbutton;
819
GPermission *permission;
820
DateEndianess endianess;
822
priv = self->priv = DATE_TIME_PANEL_PRIVATE (self);
824
priv->builder = gtk_builder_new ();
826
ret = gtk_builder_add_objects_from_file (priv->builder, DATADIR"/datetime.ui",
831
g_warning ("Could not load ui: %s", err ? err->message : "No reason");
837
/* set up network time button */
838
using_ntp = get_using_ntp ();
839
gtk_switch_set_active (GTK_SWITCH (W("network_time_switch")), using_ntp);
840
update_widget_state_for_ntp (self, using_ntp);
841
g_signal_connect (W("network_time_switch"), "notify::active",
842
G_CALLBACK (change_ntp), self);
844
/* set up time editing widgets */
845
for (i = 0; i < G_N_ELEMENTS (buttons); i++)
847
g_signal_connect (W(buttons[i]), "clicked",
848
G_CALLBACK (change_time), self);
851
/* set up date editing widgets */
852
priv->date = g_date_time_new_now_local ();
853
endianess = date_endian_get_default (FALSE);
854
reorder_date_widget (endianess, priv);
856
/* Force the direction for the time, so that the time
857
* is presented correctly for RTL languages */
858
gtk_widget_set_direction (W("table2"), GTK_TEXT_DIR_LTR);
860
gtk_combo_box_set_active (GTK_COMBO_BOX (W ("month-combobox")),
861
g_date_time_get_month (priv->date) - 1);
862
g_signal_connect (G_OBJECT (W("month-combobox")), "changed",
863
G_CALLBACK (month_year_changed), self);
865
num_days = g_date_get_days_in_month (g_date_time_get_month (priv->date),
866
g_date_time_get_year (priv->date));
867
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_day_of_month (priv->date), 1,
868
num_days + 1, 1, 10, 1);
869
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("day-spinbutton")),
871
g_signal_connect (G_OBJECT (W("day-spinbutton")), "value-changed",
872
G_CALLBACK (day_changed), self);
874
adjustment = (GtkAdjustment*) gtk_adjustment_new (g_date_time_get_year (priv->date),
875
G_MINDOUBLE, G_MAXDOUBLE, 1,
877
gtk_spin_button_set_adjustment (GTK_SPIN_BUTTON (W ("year-spinbutton")),
879
g_signal_connect (G_OBJECT (W("year-spinbutton")), "value-changed",
880
G_CALLBACK (month_year_changed), self);
882
/* set up timezone map */
883
priv->map = widget = (GtkWidget *) cc_timezone_map_new ();
884
gtk_widget_show (widget);
886
gtk_container_add (GTK_CONTAINER (gtk_builder_get_object (priv->builder,
890
gtk_container_add (GTK_CONTAINER (self),
891
GTK_WIDGET (gtk_builder_get_object (priv->builder,
895
/* setup the time itself */
896
priv->settings = g_settings_new (CLOCK_SCHEMA);
897
clock_settings_changed_cb (priv->settings, CLOCK_FORMAT_KEY, self);
898
g_signal_connect (priv->settings, "changed::" CLOCK_FORMAT_KEY,
899
G_CALLBACK (clock_settings_changed_cb), self);
901
g_signal_connect (W("24h_time_switch"), "notify::active",
902
G_CALLBACK (change_clock_settings), self);
906
priv->locations = (GtkTreeModel*) gtk_builder_get_object (priv->builder,
909
load_regions_model (GTK_LIST_STORE (priv->locations),
910
GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
913
city_modelfilter = GTK_TREE_MODEL_FILTER (gtk_builder_get_object (priv->builder, "city-modelfilter"));
915
widget = (GtkWidget*) gtk_builder_get_object (priv->builder,
917
city_modelsort = GTK_TREE_MODEL_SORT (gtk_builder_get_object (priv->builder, "city-modelsort"));
918
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (city_modelsort), CITY_COL_CITY_TRANSLATED,
921
gtk_tree_model_filter_set_visible_func (city_modelfilter,
922
(GtkTreeModelFilterVisibleFunc) city_model_filter_func,
926
/* After the initial setup, so we can be sure that
927
* the model is filled up */
928
get_system_timezone_async ((GetTimezoneFunc) get_timezone_cb, self, NULL);
930
queue_clock_update (self);
932
/* add the lock button */
933
permission = polkit_permission_new_sync ("org.gnome.settingsdaemon.datetimemechanism.configure", NULL, NULL, NULL);
934
if (permission == NULL)
936
g_warning ("Your system does not have the '%s' PolicyKit files installed. Please check your installation",
937
"org.gnome.settingsdaemon.datetimemechanism.configure");
941
/* DtLockButton takes ownership of the permission */
942
lockbutton = cc_lock_button_new (permission);
943
gtk_widget_set_margin_top (lockbutton, 12);
944
gtk_widget_show (lockbutton);
945
gtk_box_pack_end ((GtkBox *) gtk_builder_get_object (priv->builder, "hbox"),
946
lockbutton, FALSE, FALSE, 0);
947
g_signal_connect (permission, "notify",
948
G_CALLBACK (on_permission_changed), self);
949
on_permission_changed (permission, NULL, self);
953
cc_date_time_panel_register (GIOModule *module)
955
bind_textdomain_codeset (GETTEXT_PACKAGE_TIMEZONES, "UTF-8");
957
cc_date_time_panel_register_type (G_TYPE_MODULE (module));
958
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
959
CC_TYPE_DATE_TIME_PANEL,