summaryrefslogtreecommitdiff
path: root/capplets/time-admin/src
diff options
context:
space:
mode:
authorrbuj <[email protected]>2019-06-19 18:58:45 +0200
committerraveit65 <[email protected]>2019-08-20 16:10:38 +0200
commit0cc88d6a62fc8eff0b93fc6c287fc1b054ced094 (patch)
tree8135d02d0b3a87fdfc0fab4956b771b1af091773 /capplets/time-admin/src
parent7a90b47c2f2daaa13834a5a58fc159b813852d8d (diff)
downloadmate-control-center-0cc88d6a62fc8eff0b93fc6c287fc1b054ced094.tar.bz2
mate-control-center-0cc88d6a62fc8eff0b93fc6c287fc1b054ced094.tar.xz
time-admin: Add time-admin.ui
Diffstat (limited to 'capplets/time-admin/src')
-rw-r--r--capplets/time-admin/src/Makefile.am10
-rw-r--r--capplets/time-admin/src/main.c296
-rw-r--r--capplets/time-admin/src/org.mate.mcc.ta.gresource.xml22
-rw-r--r--capplets/time-admin/src/time-admin.ui365
-rw-r--r--capplets/time-admin/src/time-share.c61
-rw-r--r--capplets/time-admin/src/time-share.h7
-rw-r--r--capplets/time-admin/src/time-tool.c4
-rw-r--r--capplets/time-admin/src/time-zone.c118
8 files changed, 571 insertions, 312 deletions
diff --git a/capplets/time-admin/src/Makefile.am b/capplets/time-admin/src/Makefile.am
index 59332519..95b930d8 100644
--- a/capplets/time-admin/src/Makefile.am
+++ b/capplets/time-admin/src/Makefile.am
@@ -2,21 +2,25 @@ cappletname = time-admin
bin_PROGRAMS = mate-time-admin
+BUILT_SOURCES = mate-time-admin-resources.h mate-time-admin-resources.c
+nodist_mate_time_admin_SOURCES = $(BUILT_SOURCES)
mate_time_admin_SOURCES = \
main.c time-map.c time-share.c time-tool.c time-zone.c \
time-map.h time-share.h time-tool.h time-zone.h
+mate-time-admin-resources.h mate-time-admin-resources.c: org.mate.mcc.ta.gresource.xml Makefile $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir) $(srcdir)/org.mate.mcc.ta.gresource.xml)
+ $(AM_V_GEN) XMLLINT=$(XMLLINT) $(GLIB_COMPILE_RESOURCES) --target $@ --sourcedir $(srcdir) --generate --c-name time_admin $<
+
mate_time_admin_LDADD = $(MATECC_CAPPLETS_LIBS)
mate_time_admin_LDFLAGS = -export-dynamic
AM_CPPFLAGS = \
$(MATECC_CAPPLETS_CFLAGS) \
- -DMATELOCALEDIR="\"$(datadir)/locale\""\
-DTIMPZONEDIR="\"$(datadir)/mate-time-admin/map/\""
-CLEANFILES = $(MATECC_CAPPLETS_CLEANFILES)
+CLEANFILES = $(MATECC_CAPPLETS_CLEANFILES) $(BUILT_SOURCES)
-EXTRA_DIST = time-zones.h
+EXTRA_DIST = time-admin.ui time-zones.h org.mate.mcc.ta.gresource.xml
-include $(top_srcdir)/git.mk
diff --git a/capplets/time-admin/src/main.c b/capplets/time-admin/src/main.c
index 721f0157..bbb960d9 100644
--- a/capplets/time-admin/src/main.c
+++ b/capplets/time-admin/src/main.c
@@ -25,6 +25,17 @@
#define LOCKFILE "/tmp/time-admin.pid"
#define TIME_ADMIN_PERMISSION "org.freedesktop.timedate1.set-time"
+static char *translate(const char *value)
+{
+ g_autofree gchar *zone_translated = NULL;
+ char *name;
+
+ zone_translated = g_strdup (_(value));
+ name = g_strdup_printf (C_("timezone loc", "%s"),zone_translated);
+
+ return name;
+}
+
static gboolean CheckClockHealth(gpointer data)
{
TimeAdmin *ta = (TimeAdmin *)data;
@@ -33,6 +44,7 @@ static gboolean CheckClockHealth(gpointer data)
return FALSE;
}
+
static void update_apply_timeout(TimeAdmin *ta)
{
Update_Clock_Stop(ta);
@@ -43,6 +55,7 @@ static void update_apply_timeout(TimeAdmin *ta)
}
ta->ApplyId = g_timeout_add (10000, (GSourceFunc)CheckClockHealth,ta);
}
+
static void ChangeTimeValue(GtkSpinButton *spin_button,
gpointer data)
{
@@ -62,25 +75,22 @@ static gboolean on_window_quit (GtkWidget *widget,
QuitApp(ta);
return TRUE;
}
+
static void CloseWindow (GtkButton *button,gpointer data)
{
TimeAdmin *ta = (TimeAdmin *)data;
QuitApp(ta);
}
+
static void UpdatePermission(TimeAdmin *ta)
{
gboolean is_authorized;
is_authorized = g_permission_get_allowed (G_PERMISSION (ta->Permission));
-
- gtk_widget_set_sensitive(ta->HourSpin, is_authorized);
- gtk_widget_set_sensitive(ta->MinuteSpin, is_authorized);
- gtk_widget_set_sensitive(ta->SecondSpin, is_authorized);
gtk_widget_set_sensitive(ta->TimeZoneButton, is_authorized);
- gtk_widget_set_sensitive(ta->Calendar, is_authorized);
- gtk_widget_set_sensitive(ta->SaveButton, is_authorized);
gtk_widget_set_sensitive(ta->NtpSyncSwitch, is_authorized);
+ gtk_widget_set_sensitive(ta->SaveButton, is_authorized);
}
static void on_permission_changed (GPermission *permission,
@@ -93,32 +103,58 @@ static void on_permission_changed (GPermission *permission,
static void InitMainWindow(TimeAdmin *ta)
{
- GtkWidget *Window;
- GError *error = NULL;
-
- Window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- ta->MainWindow = WindowLogin = Window;
- gtk_window_set_deletable(GTK_WINDOW(Window),FALSE);
- gtk_window_set_resizable(GTK_WINDOW(Window),FALSE);
- gtk_window_set_hide_titlebar_when_maximized(GTK_WINDOW(Window),TRUE);
- gtk_window_set_position(GTK_WINDOW(Window), GTK_WIN_POS_CENTER);
- gtk_window_set_title(GTK_WINDOW(Window),_("Time and Date Manager"));
- gtk_container_set_border_width(GTK_CONTAINER(Window),10);
- gtk_widget_set_size_request(Window, 300, 360);
- g_signal_connect(G_OBJECT(Window),
- "delete-event",
- G_CALLBACK(on_window_quit),
- ta);
- gtk_window_set_icon_name (GTK_WINDOW(Window), "preferences-system-time");
- ta->Permission = polkit_permission_new_sync (TIME_ADMIN_PERMISSION,
- NULL,
- NULL,
- &error);
+ GError *error = NULL;
+ GtkBuilder *builder;
+
+ builder = gtk_builder_new_from_resource ("/org/mate/mcc/ta/time-admin.ui");
+ gtk_builder_add_callback_symbols (builder,
+ "on_window_quit", G_CALLBACK (on_window_quit),
+ "on_button1_clicked", G_CALLBACK (RunTimeZoneDialog),
+ "on_button2_clicked", G_CALLBACK (SaveModifyTime),
+ "on_button3_clicked", G_CALLBACK (CloseWindow),
+ "on_spin1_changed", G_CALLBACK (ChangeTimeValue),
+ "on_spin2_changed", G_CALLBACK (ChangeTimeValue),
+ "on_spin3_changed", G_CALLBACK (ChangeTimeValue),
+ "on_switch1_state_set", G_CALLBACK (ChangeNtpSync),
+ NULL);
+ gtk_builder_connect_signals (builder, ta);
+ ta->MainWindow = GTK_WIDGET (gtk_builder_get_object (builder, "window1"));
+ ta->HourSpin = GTK_WIDGET (gtk_builder_get_object (builder, "spin1"));
+ ta->MinuteSpin = GTK_WIDGET (gtk_builder_get_object (builder, "spin2"));
+ ta->SecondSpin = GTK_WIDGET (gtk_builder_get_object (builder, "spin3"));
+ ta->TimeZoneButton = GTK_WIDGET (gtk_builder_get_object (builder, "button1"));
+ ta->TimeZoneEntry = GTK_WIDGET (gtk_builder_get_object (builder, "entry1"));
+ ta->NtpSyncSwitch = GTK_WIDGET (gtk_builder_get_object (builder, "switch1"));
+ ta->Calendar = GTK_WIDGET (gtk_builder_get_object (builder, "calendar1"));
+ ta->SaveButton = GTK_WIDGET (gtk_builder_get_object (builder, "button2"));
+ ta->ButtonLock = GTK_WIDGET (gtk_builder_get_object (builder, "button4"));
+ g_object_unref (builder);
+
+ /* Make sure that every window gets an icon */
+ gtk_window_set_default_icon_name ("preferences-system-time");
+
+ ta->Permission = polkit_permission_new_sync (TIME_ADMIN_PERMISSION, NULL, NULL, &error);
if (ta->Permission == NULL)
{
g_warning ("Failed to acquire %s: %s", TIME_ADMIN_PERMISSION, error->message);
g_error_free (error);
}
+ gtk_lock_button_set_permission(GTK_LOCK_BUTTON (ta->ButtonLock),ta->Permission);
+ g_signal_connect(ta->Permission, "notify", G_CALLBACK (on_permission_changed), ta);
+
+ struct tm *LocalTime = GetCurrentTime();
+ ta->UpdateTimeId = 0;
+ ta->ApplyId = 0;
+ Update_Clock_Start(ta);
+ SetupTimezoneDialog(ta);
+ const char *TimeZone = GetTimeZone(ta);
+ char *ZoneName = translate(TimeZone);
+ gtk_entry_set_text (GTK_ENTRY (ta->TimeZoneEntry), ZoneName);
+ g_free (ZoneName);
+ ta->NtpState = GetNtpState(ta);
+ gtk_switch_set_state (GTK_SWITCH(ta->NtpSyncSwitch), ta->NtpState);
+ gtk_calendar_mark_day (GTK_CALENDAR(ta->Calendar), LocalTime->tm_mday);
+ ta->OldDay = LocalTime->tm_mday;
}
static int RecordPid(void)
@@ -127,6 +163,7 @@ static int RecordPid(void)
int fd;
int Length = 0;
char WriteBuf[30] = { 0 };
+
fd = open(LOCKFILE,O_WRONLY|O_CREAT|O_TRUNC,0777);
if(fd < 0)
{
@@ -146,6 +183,7 @@ static int RecordPid(void)
return 0;
}
+
/******************************************************************************
* Function: ProcessRuning
*
@@ -194,200 +232,8 @@ static gboolean ProcessRuning(void)
ERROREXIT:
close(fd);
return TRUE;
-
}
-static char *translate(const char *value)
-{
- g_autofree gchar *zone_translated = NULL;
- char *name;
- zone_translated = g_strdup (_(value));
- name = g_strdup_printf (C_("timezone loc", "%s"),zone_translated);
-
- return name;
-}
-static GtkWidget * TimeZoneAndNtp(TimeAdmin *ta)
-{
- GtkWidget *table;
- GtkWidget *TimeZoneLabel;
- GtkWidget *NtpSyncLabel;
- const char *TimeZone;
- gboolean NtpState;
- char *ZoneName;
-
- table = gtk_grid_new();
- gtk_grid_set_column_homogeneous(GTK_GRID(table),TRUE);
-
- TimeZoneLabel = gtk_label_new (_("Time Zone:"));
- gtk_widget_set_halign(TimeZoneLabel,GTK_ALIGN_START);
- gtk_grid_attach(GTK_GRID(table) ,TimeZoneLabel, 0 , 0 , 1 , 1);
-
- SetupTimezoneDialog(ta);
- TimeZone = GetTimeZone(ta);
- ZoneName = translate(TimeZone);
- ta->TimeZoneButton = gtk_button_new_with_label(ZoneName);
- g_signal_connect (ta->TimeZoneButton,
- "clicked",
- G_CALLBACK (RunTimeZoneDialog),
- ta);
-
- gtk_grid_attach(GTK_GRID(table) ,ta->TimeZoneButton,1 , 0 , 3 , 1);
-
- NtpSyncLabel = gtk_label_new (_("Ntp Sync:"));
- gtk_widget_set_halign(NtpSyncLabel,GTK_ALIGN_START);
- gtk_grid_attach(GTK_GRID(table) ,NtpSyncLabel, 0 , 1 , 1 , 1);
-
- ta->NtpSyncSwitch = gtk_switch_new();
- NtpState = GetNtpState(ta);
- ta->NtpState = NtpState;
- gtk_switch_set_state (GTK_SWITCH(ta->NtpSyncSwitch),
- NtpState);
- gtk_grid_attach(GTK_GRID(table) ,ta->NtpSyncSwitch, 1 , 1 , 1 , 1);
- g_signal_connect (G_OBJECT(ta->NtpSyncSwitch),
- "state-set",
- G_CALLBACK (ChangeNtpSync),
- ta);
-
- gtk_grid_set_row_spacing(GTK_GRID(table), 6);
- gtk_grid_set_column_spacing(GTK_GRID(table), 12);
-
- return table;
-
-}
-
-static GtkWidget *GetSpinButton(int Initial,int Maximum,TimeAdmin *ta)
-{
- GtkWidget *SpinButton;
- GtkAdjustment *Adjustment;
-
- Adjustment = gtk_adjustment_new (Initial, 0, Maximum, 1, 0, 0);
- SpinButton = gtk_spin_button_new (Adjustment, 1, 0);
- gtk_widget_set_sensitive(SpinButton,!ta->NtpState);
- gtk_widget_set_halign(SpinButton,GTK_ALIGN_START);
- gtk_spin_button_set_wrap(GTK_SPIN_BUTTON (SpinButton), TRUE);
- gtk_spin_button_set_numeric(GTK_SPIN_BUTTON (SpinButton),TRUE);
- gtk_widget_set_hexpand (SpinButton,TRUE);
- g_signal_connect (SpinButton,
- "changed",
- G_CALLBACK (ChangeTimeValue),
- ta);
-
- SetTooltip(SpinButton,!ta->NtpState);
- return SpinButton;
-}
-static GtkWidget *SetClock(TimeAdmin *ta)
-{
- GtkWidget *table;
- GtkWidget *TimeLabel;
- struct tm *LocalTime;
-
- table = gtk_grid_new();
- gtk_grid_set_column_homogeneous(GTK_GRID(table),TRUE);
-
- TimeLabel = gtk_label_new (_("Set Time"));
- gtk_widget_set_halign(TimeLabel,GTK_ALIGN_CENTER);
- gtk_widget_set_valign(TimeLabel,GTK_ALIGN_START);
- gtk_widget_set_hexpand(TimeLabel,FALSE);
- gtk_grid_attach(GTK_GRID(table) ,TimeLabel, 1 , 0 , 1 , 1);
-
- LocalTime = GetCurrentTime();
- ta->UpdateTimeId = 0;
- ta->ApplyId = 0;
-
- ta->HourSpin = GetSpinButton(LocalTime->tm_hour,23,ta);
- gtk_grid_attach(GTK_GRID(table) ,ta->HourSpin, 0 , 1 , 1 , 1);
-
- ta->MinuteSpin = GetSpinButton(LocalTime->tm_min,59,ta);
- gtk_grid_attach(GTK_GRID(table) ,ta->MinuteSpin, 1 , 1 , 1 , 1);
-
- ta->SecondSpin = GetSpinButton (LocalTime->tm_sec,59,ta);
- gtk_grid_attach(GTK_GRID(table) ,ta->SecondSpin, 2 , 1 , 1 , 1);
-
- Update_Clock_Start(ta);
-
- gtk_grid_set_row_spacing(GTK_GRID(table), 6);
- gtk_grid_set_column_spacing(GTK_GRID(table), 12);
-
- return table;
-}
-
-static GtkWidget *SetDate(TimeAdmin *ta)
-{
- GtkWidget *table, *image, *DateLabel;
- struct tm *LocalTime;
-
- table = gtk_grid_new();
- gtk_grid_set_column_homogeneous (GTK_GRID(table), TRUE);
-
- DateLabel = gtk_label_new (_("Set Date"));
- gtk_grid_attach(GTK_GRID(table) ,DateLabel, 1 , 0 , 2 , 2);
-
- LocalTime = GetCurrentTime ();
- ta->Calendar = gtk_calendar_new ();
- gtk_widget_set_sensitive (ta->Calendar, !ta->NtpState);
- SetTooltip (ta->Calendar, !ta->NtpState);
- gtk_calendar_mark_day (GTK_CALENDAR(ta->Calendar), LocalTime->tm_mday);
- ta->OldDay = LocalTime->tm_mday;
- gtk_grid_attach (GTK_GRID(table), ta->Calendar, 0, 2, 4, 3);
-
- ta->CloseButton = gtk_button_new_with_label (_("_Close"));
- image = gtk_image_new_from_icon_name ("gtk-close", GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (ta->CloseButton), image);
- gtk_button_set_use_underline (GTK_BUTTON(ta->CloseButton), TRUE);
- gtk_style_context_add_class (gtk_widget_get_style_context (ta->CloseButton), "text-button");
- gtk_grid_attach (GTK_GRID(table), ta->CloseButton, 3, 5, 1, 1);
- g_signal_connect (ta->CloseButton,
- "clicked",
- G_CALLBACK (CloseWindow),
- ta);
-
- if (ta->Permission)
- {
- ta->ButtonLock = gtk_lock_button_new (ta->Permission);
- gtk_lock_button_set_permission (GTK_LOCK_BUTTON (ta->ButtonLock),ta->Permission);
- gtk_grid_attach (GTK_GRID(table), ta->ButtonLock, 0, 5, 1, 1);
- g_signal_connect (ta->Permission,
- "notify",
- G_CALLBACK (on_permission_changed),
- ta);
- }
-
- ta->SaveButton = gtk_button_new_with_label (_("_Save"));
- image = gtk_image_new_from_icon_name ("gtk-save", GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (ta->SaveButton), image);
- gtk_button_set_use_underline (GTK_BUTTON(ta->SaveButton), TRUE);
- gtk_style_context_add_class (gtk_widget_get_style_context (ta->SaveButton), "text-button");
- gtk_widget_set_sensitive (ta->SaveButton, !ta->NtpState);
- gtk_grid_attach (GTK_GRID(table), ta->SaveButton, 2, 5, 1, 1);
- g_signal_connect (ta->SaveButton,
- "clicked",
- G_CALLBACK (SaveModifyTime),
- ta);
-
- gtk_grid_set_row_spacing (GTK_GRID(table), 6);
- gtk_grid_set_column_spacing (GTK_GRID(table), 12);
-
- return table;
-}
-
-static void CreateClockInterface(TimeAdmin *ta)
-{
- GtkWidget *Vbox;
- GtkWidget *Vbox1;
- GtkWidget *Vbox2;
- GtkWidget *Vbox3;
-
- Vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
- gtk_container_add(GTK_CONTAINER(ta->MainWindow), Vbox);
-
- Vbox1 = TimeZoneAndNtp(ta);
- gtk_box_pack_start(GTK_BOX(Vbox),Vbox1,TRUE,TRUE,8);
-
- Vbox2 = SetClock(ta);
- gtk_box_pack_start(GTK_BOX(Vbox),Vbox2,TRUE,TRUE,8);
- Vbox3 = SetDate(ta);
- gtk_box_pack_start(GTK_BOX(Vbox),Vbox3,TRUE,TRUE,8);
-}
static gboolean InitDbusProxy(TimeAdmin *ta)
{
GError *error = NULL;
@@ -424,18 +270,16 @@ int main(int argc, char **argv)
capplet_init (NULL, &argc, &argv);
- /* Create the main window */
- InitMainWindow(&ta);
-
/* Check whether the process has been started */
if(ProcessRuning() == TRUE)
exit(0);
if(InitDbusProxy(&ta) == FALSE)
- {
exit(0);
- }
- CreateClockInterface(&ta);
- UpdatePermission(&ta);
+
+ /* Create the main window */
+ InitMainWindow(&ta);
+
+ UpdatePermission(&ta);
gtk_widget_show_all(ta.MainWindow);
gtk_main();
diff --git a/capplets/time-admin/src/org.mate.mcc.ta.gresource.xml b/capplets/time-admin/src/org.mate.mcc.ta.gresource.xml
new file mode 100644
index 00000000..44a6c03b
--- /dev/null
+++ b/capplets/time-admin/src/org.mate.mcc.ta.gresource.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This file is part of MATE Control Center.
+
+ MATE Control Center is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ MATE Control Center is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with MATE Control Center. If not, see <http://www.gnu.org/licenses/>.
+-->
+<gresources>
+ <gresource prefix="/org/mate/mcc/ta">
+ <file compressed="true">time-admin.ui</file>
+ </gresource>
+</gresources>
diff --git a/capplets/time-admin/src/time-admin.ui b/capplets/time-admin/src/time-admin.ui
new file mode 100644
index 00000000..7539d2cc
--- /dev/null
+++ b/capplets/time-admin/src/time-admin.ui
@@ -0,0 +1,365 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkAdjustment" id="adjustament1">
+ <property name="upper">23</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustament2">
+ <property name="upper">59</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustament3">
+ <property name="upper">59</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkApplicationWindow" id="window1">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Time and Date Manager</property>
+ <property name="resizable">False</property>
+ <property name="window_position">center</property>
+ <property name="icon_name">preferences-system-time</property>
+ <signal name="delete-event" handler="on_window_quit" swapped="no"/>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="row_spacing">6</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">NTP sync</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="switch1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="halign">start</property>
+ <signal name="state-set" handler="on_switch1_state_set" swapped="no"/>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">Time zone</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkEntry" id="entry1">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="editable">False</property>
+ <property name="max_width_chars">25</property>
+ <property name="caps_lock_warning">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-edit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <property name="always_show_image">True</property>
+ <signal name="clicked" handler="on_button1_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Preferences</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="spacing">12</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkSpinButton" id="spin1">
+ <property name="visible">True</property>
+ <property name="sensitive" bind-source="button2" bind-property="sensitive"/>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="caps_lock_warning">False</property>
+ <property name="input_purpose">digits</property>
+ <property name="adjustment">adjustament1</property>
+ <signal name="changed" handler="on_spin1_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="spin2">
+ <property name="visible">True</property>
+ <property name="sensitive" bind-source="button2" bind-property="sensitive"/>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="caps_lock_warning">False</property>
+ <property name="input_purpose">digits</property>
+ <property name="adjustment">adjustament2</property>
+ <signal name="changed" handler="on_spin2_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="spin3">
+ <property name="visible">True</property>
+ <property name="sensitive" bind-source="button2" bind-property="sensitive"/>
+ <property name="can_focus">True</property>
+ <property name="max_length">2</property>
+ <property name="caps_lock_warning">False</property>
+ <property name="progress_pulse_step">1</property>
+ <property name="input_purpose">digits</property>
+ <property name="adjustment">adjustament3</property>
+ <signal name="changed" handler="on_spin3_changed" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Time</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">6</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">6</property>
+ <property name="margin_right">6</property>
+ <property name="margin_top">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkCalendar" id="calendar1">
+ <property name="visible">True</property>
+ <property name="sensitive" bind-source="button2" bind-property="sensitive"/>
+ <property name="can_focus">True</property>
+ <property name="year">2019</property>
+ <property name="month">5</property>
+ <property name="day">20</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Date</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="margin_left">18</property>
+ <property name="margin_right">18</property>
+ <property name="margin_top">18</property>
+ <property name="margin_bottom">18</property>
+ <property name="spacing">12</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkLockButton" id="button4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_right">18</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label">gtk-save</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_button2_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button3">
+ <property name="label">gtk-close</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked" handler="on_button3_clicked" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/capplets/time-admin/src/time-share.c b/capplets/time-admin/src/time-share.c
index 379134e3..b5038779 100644
--- a/capplets/time-admin/src/time-share.c
+++ b/capplets/time-admin/src/time-share.c
@@ -22,18 +22,20 @@
#include <glib/gi18n.h>
/******************************************************************************
-* Function: MessageReport
-*
-* Explain: Prompt information dialog
-*
-* Input: @Title Message title
-* @Msg Message content
-* @nType Message type
-* Output:
-*
-* Author: zhuyaliang 25/05/2018
-******************************************************************************/
-int MessageReport(const char *Title,const char *Msg,int nType)
+ * Function: MessageReport
+ *
+ * Explain: Prompt information dialog
+ *
+ * Input: @Title Message title
+ * @Msg Message content
+ * @nType Message type
+ * Output:
+ *
+ * Author: zhuyaliang 25/05/2018
+ ******************************************************************************/
+int MessageReport(const char *Title,
+ const char *Msg,
+ int nType)
{
GtkWidget *dialog = NULL;
int nRet;
@@ -42,49 +44,49 @@ int MessageReport(const char *Title,const char *Msg,int nType)
{
case ERROR:
{
- dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
- "%s",Title);
+ "%s", Title);
break;
}
case WARING:
{
- dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
- "%s",Title);
+ "%s", Title);
break;
}
case INFOR:
{
- dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
- "%s",Title);
+ "%s", Title);
break;
}
case QUESTION:
{
- dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
- "%s",Title);
+ "%s", Title);
gtk_dialog_add_button (GTK_DIALOG (dialog),("_Return"),
GTK_RESPONSE_ACCEPT);
break;
}
case QUESTIONNORMAL:
{
- dialog = gtk_message_dialog_new(GTK_WINDOW(WindowLogin),
- GTK_DIALOG_DESTROY_WITH_PARENT,
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
- "%s",Title);
+ "%s", Title);
break;
}
default :
@@ -102,13 +104,10 @@ int MessageReport(const char *Title,const char *Msg,int nType)
void QuitApp(TimeAdmin *ta)
{
if(ta->UpdateTimeId > 0)
- {
g_source_remove (ta->UpdateTimeId);
- }
+
if(ta->ApplyId > 0)
- {
g_source_remove(ta->ApplyId);
- }
gtk_main_quit();
}
diff --git a/capplets/time-admin/src/time-share.h b/capplets/time-admin/src/time-share.h
index 1a842e1c..346944be 100644
--- a/capplets/time-admin/src/time-share.h
+++ b/capplets/time-admin/src/time-share.h
@@ -40,8 +40,7 @@
#define QUESTIONNORMAL 5
-GtkWidget *WindowLogin;
-int TimeoutFlag;
+int TimeoutFlag;
typedef struct
{
GtkWidget *MainWindow;
@@ -49,9 +48,9 @@ typedef struct
GtkWidget *MinuteSpin;
GtkWidget *SecondSpin;
GtkWidget *TimeZoneButton;
+ GtkWidget *TimeZoneEntry;
GtkWidget *NtpSyncSwitch;
GtkWidget *Calendar;
- GtkWidget *CloseButton;
GtkWidget *SaveButton;
int UpdateTimeId;
int ApplyId;
@@ -67,7 +66,7 @@ typedef struct
GtkWidget *map;
GtkListStore *CityListStore;
GtkTreeModelSort *CityModelSort;
- GtkWidget *ButtonLock;
+ GtkWidget *ButtonLock;
GPermission *Permission;
}TimeAdmin;
diff --git a/capplets/time-admin/src/time-tool.c b/capplets/time-admin/src/time-tool.c
index 0029f3bb..a5e13f03 100644
--- a/capplets/time-admin/src/time-tool.c
+++ b/capplets/time-admin/src/time-tool.c
@@ -191,13 +191,9 @@ static void ChangeSpinBttonState(TimeAdmin *ta,gboolean State)
{
gtk_widget_set_sensitive(ta->SaveButton,!State);
SetTooltip(ta->SaveButton,!ta->NtpState);
- gtk_widget_set_sensitive(ta->HourSpin, !State);
SetTooltip(ta->HourSpin,!ta->NtpState);
- gtk_widget_set_sensitive(ta->MinuteSpin,!State);
SetTooltip(ta->MinuteSpin,!ta->NtpState);
- gtk_widget_set_sensitive(ta->SecondSpin,!State);
SetTooltip(ta->SecondSpin,!ta->NtpState);
- gtk_widget_set_sensitive(ta->Calendar, !State);
SetTooltip(ta->Calendar,!ta->NtpState);
}
diff --git a/capplets/time-admin/src/time-zone.c b/capplets/time-admin/src/time-zone.c
index e6106f1b..713314cf 100644
--- a/capplets/time-admin/src/time-zone.c
+++ b/capplets/time-admin/src/time-zone.c
@@ -41,17 +41,21 @@
#include <libmate-desktop/mate-languages.h>
-
#define DEFAULT_TZ "Europe/London"
#define BACKFILE "/usr/share/mate-time-admin/map/backward"
+
static void LocationChanged(TimezoneMap *map,
- TzLocation *location,TimeAdmin *ta);
+ TzLocation *location,
+ TimeAdmin *ta);
+
enum {
CITY_COL_CITY_HUMAN_READABLE,
CITY_COL_ZONE,
CITY_NUM_COLS
};
-static gchar *tz_data_file_get (void)
+
+static gchar*
+tz_data_file_get (void)
{
gchar *file;
@@ -60,25 +64,31 @@ static gchar *tz_data_file_get (void)
return file;
}
-static float convert_pos (gchar *pos, int digits)
+static float
+convert_pos (gchar *pos, int digits)
{
- gchar whole[10];
- gchar *fraction;
+ gchar whole[10], *fraction;
gint i;
float t1, t2;
- if (!pos || strlen(pos) < 4 || digits > 9) return 0.0;
+ if (!pos || strlen(pos) < 4 || digits > 9)
+ return 0.0;
+
+ for (i = 0; i < digits + 1; i++)
+ whole[i] = pos[i];
- for (i = 0; i < digits + 1; i++) whole[i] = pos[i];
whole[i] = '\0';
fraction = pos + digits + 1;
t1 = g_strtod (whole, NULL);
t2 = g_strtod (fraction, NULL);
- if (t1 >= 0.0) return t1 + t2/pow (10.0, strlen(fraction));
- else return t1 - t2/pow (10.0, strlen(fraction));
+ if (t1 >= 0.0)
+ return t1 + t2/pow (10.0, strlen(fraction));
+ else
+ return t1 - t2/pow (10.0, strlen(fraction));
}
+
static int compare_country_names (const void *a, const void *b)
{
const TzLocation *tza = * (TzLocation **) a;
@@ -174,14 +184,16 @@ TzDB *tz_load_db (void)
gchar *p;
TzLocation *loc;
- if (*buf == '#') continue;
+ if (*buf == '#')
+ continue;
g_strchomp(buf);
tmpstrarr = g_strsplit(buf,"\t", 6);
latstr = g_strdup (tmpstrarr[1]);
p = latstr + 1;
- while (*p != '-' && *p != '+') p++;
+ while (*p != '-' && *p != '+')
+ p++;
lngstr = g_strdup (p);
*p = '\0';
@@ -195,7 +207,8 @@ TzDB *tz_load_db (void)
if (tmpstrarr[3] && *tmpstrarr[3] == '-' && tmpstrarr[4])
loc->comment = g_strdup (tmpstrarr[4]);
- if (tmpstrarr[3] && *tmpstrarr[3] != '-' && !islower(loc->zone)) {
+ if (tmpstrarr[3] && *tmpstrarr[3] != '-' && !islower(loc->zone))
+ {
TzLocation *locgrp;
locgrp = g_new0 (TzLocation, 1);
locgrp->country = g_strdup (tmpstrarr[0]);
@@ -224,7 +237,8 @@ TzDB *tz_load_db (void)
return tz_db;
}
-static GtkWidget *GetTimeZoneMap(TimeAdmin *ta)
+static GtkWidget*
+GetTimeZoneMap(TimeAdmin *ta)
{
GtkWidget *map;
g_autoptr(GtkEntryCompletion) completion = NULL;
@@ -240,7 +254,6 @@ static GtkWidget *GetTimeZoneMap(TimeAdmin *ta)
gtk_entry_completion_set_model (completion, GTK_TREE_MODEL (ta->CityListStore));
gtk_entry_completion_set_text_column (completion, CITY_COL_CITY_HUMAN_READABLE);
-
return map;
}
static char *
@@ -305,13 +318,14 @@ update_timezone (TimezoneMap *map)
g_date_time_unref(date);
}
-static void LocationChanged(TimezoneMap *map,
- TzLocation *location,
- TimeAdmin *ta)
+static void
+LocationChanged(TimezoneMap *map,
+ TzLocation *location,
+ TimeAdmin *ta)
{
-
update_timezone (map);
}
+
static void
get_initial_timezone (TimeAdmin *ta)
{
@@ -327,8 +341,10 @@ get_initial_timezone (TimeAdmin *ta)
}
update_timezone (TIMEZONEMAP(ta->map));
}
-static void LoadCities (TzLocation *loc,
- GtkListStore *CityStore)
+
+static void
+LoadCities (TzLocation *loc,
+ GtkListStore *CityStore)
{
g_autofree gchar *human_readable = NULL;
@@ -340,20 +356,22 @@ static void LoadCities (TzLocation *loc,
human_readable,
CITY_COL_ZONE,
loc->zone,
- -1);
+ -1);
}
-static void CreateCityList(TimeAdmin *ta)
+static void
+CreateCityList(TimeAdmin *ta)
{
TzDB *db;
ta->CityListStore = gtk_list_store_new (CITY_NUM_COLS,G_TYPE_STRING,G_TYPE_STRING);
-
db = tz_load_db ();
g_ptr_array_foreach (db->locations, (GFunc) LoadCities, ta->CityListStore);
TimeZoneDateBaseFree(db);
}
-static GtkWidget *CreateZoneFrame(TimeAdmin *ta)
+
+static GtkWidget*
+CreateZoneFrame(TimeAdmin *ta)
{
GtkWidget *TimeZoneFrame;
@@ -363,19 +381,26 @@ static GtkWidget *CreateZoneFrame(TimeAdmin *ta)
return TimeZoneFrame;
}
-static GtkWidget *CreateZoneScrolled(TimeAdmin *ta)
+
+static GtkWidget*
+CreateZoneScrolled(TimeAdmin *ta)
{
GtkWidget *Scrolled;
+
Scrolled = gtk_scrolled_window_new (NULL, NULL);
+
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (Scrolled),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
+
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (Scrolled),
GTK_SHADOW_IN);
return Scrolled;
}
-static void CreateZoneEntry(TimeAdmin *ta)
+
+static void
+CreateZoneEntry(TimeAdmin *ta)
{
GtkWidget *hbox;
@@ -390,13 +415,13 @@ static void CreateZoneEntry(TimeAdmin *ta)
gtk_search_bar_set_show_close_button (GTK_SEARCH_BAR (ta->SearchBar),FALSE);
gtk_container_add (GTK_CONTAINER (ta->SearchBar), hbox);
gtk_search_bar_set_search_mode(GTK_SEARCH_BAR(ta->SearchBar),TRUE);
-
}
-static gboolean CityChanged(GtkEntryCompletion *completion,
- GtkTreeModel *model,
- GtkTreeIter *iter,
- TimeAdmin *self)
+static gboolean
+CityChanged(GtkEntryCompletion *completion,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ TimeAdmin *self)
{
GtkWidget *entry;
g_autofree gchar *zone = NULL;
@@ -413,22 +438,22 @@ static gboolean CityChanged(GtkEntryCompletion *completion,
return TRUE;
}
-static void ChoooseTimezoneDone (GtkWidget *widget,
- TimeAdmin *ta)
+
+static void
+ChoooseTimezoneDone (GtkWidget *widget,
+ TimeAdmin *ta)
{
TimezoneMap *map;
- g_autofree gchar *ZoneCity = NULL;
map = TIMEZONEMAP(ta->map);
SetTimeZone(ta->proxy,map->location->zone);
-
- ZoneCity = translated_city_name(map->location);
- gtk_button_set_label((GTK_BUTTON(ta->TimeZoneButton)),ZoneCity);
+ gtk_entry_set_text (GTK_ENTRY (ta->TimeZoneEntry), _(map->location->zone));
gtk_widget_hide_on_delete(GTK_WIDGET(ta->dialog));
}
-static void ChoooseTimezoneClose(GtkWidget *widget,
- TimeAdmin *ta)
+static void
+ChoooseTimezoneClose(GtkWidget *widget,
+ TimeAdmin *ta)
{
gtk_widget_hide_on_delete(GTK_WIDGET(ta->dialog));
}
@@ -443,8 +468,6 @@ void SetupTimezoneDialog(TimeAdmin *ta)
NULL,
NULL);
gtk_window_set_default_size (GTK_WINDOW (ta->dialog), 730, 520);
- gtk_window_set_icon_name (GTK_WINDOW(ta->dialog), "preferences-system-time");
-
ta->TZclose = gtk_button_new_with_mnemonic (_("_Close"));
image = gtk_image_new_from_icon_name ("window-close", GTK_ICON_SIZE_BUTTON);
@@ -498,6 +521,7 @@ void SetupTimezoneDialog(TimeAdmin *ta)
TRUE,
TRUE, 8);
}
+
void tz_info_free (TzInfo *tzinfo)
{
g_return_if_fail (tzinfo != NULL);
@@ -506,6 +530,7 @@ void tz_info_free (TzInfo *tzinfo)
if (tzinfo->tzname_daylight) g_free (tzinfo->tzname_daylight);
g_free (tzinfo);
}
+
struct {
const char *orig;
const char *dest;
@@ -533,9 +558,10 @@ struct {
{ "MST", "America/Denver" }, /* Other name for the mountain tz */
{ "MST7MDT", "America/Denver" }, /* ditto */
};
+
static gboolean
compare_timezones (const char *a,
- const char *b)
+ const char *b)
{
if (g_str_equal (a, b))
return TRUE;
@@ -639,6 +665,7 @@ TzInfo *tz_info_from_location (TzLocation *loc)
return tzinfo;
}
+
glong tz_location_get_utc_offset (TzLocation *loc)
{
TzInfo *tz_info;
@@ -650,6 +677,7 @@ glong tz_location_get_utc_offset (TzLocation *loc)
return offset;
}
+
void RunTimeZoneDialog (GtkButton *button,
gpointer data)
{
@@ -657,15 +685,16 @@ void RunTimeZoneDialog (GtkButton *button,
gtk_widget_show_all(GTK_WIDGET(ta->dialog));
}
+
static void
tz_location_free (TzLocation *loc, gpointer data)
{
g_free (loc->country);
g_free (loc->zone);
g_free (loc->comment);
-
g_free (loc);
}
+
void TimeZoneDateBaseFree (TzDB *db)
{
g_ptr_array_foreach (db->locations, (GFunc) tz_location_free, NULL);
@@ -673,6 +702,7 @@ void TimeZoneDateBaseFree (TzDB *db)
g_hash_table_destroy (db->backward);
g_free (db);
}
+
GPtrArray *tz_get_locations (TzDB *db)
{
return db->locations;