summaryrefslogtreecommitdiff
path: root/capplets/time-admin/src
diff options
context:
space:
mode:
Diffstat (limited to 'capplets/time-admin/src')
-rw-r--r--capplets/time-admin/src/main.c142
-rw-r--r--capplets/time-admin/src/time-map.c36
-rw-r--r--capplets/time-admin/src/time-map.h6
-rw-r--r--capplets/time-admin/src/time-share.c20
-rw-r--r--capplets/time-admin/src/time-share.h6
-rw-r--r--capplets/time-admin/src/time-tool.c68
-rw-r--r--capplets/time-admin/src/time-tool.h2
-rw-r--r--capplets/time-admin/src/time-zone.c88
-rw-r--r--capplets/time-admin/src/time-zone.h8
9 files changed, 188 insertions, 188 deletions
diff --git a/capplets/time-admin/src/main.c b/capplets/time-admin/src/main.c
index 96d0df6d..f33864f7 100644
--- a/capplets/time-admin/src/main.c
+++ b/capplets/time-admin/src/main.c
@@ -1,4 +1,4 @@
-/* mate-user-admin
+/* mate-user-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -30,25 +30,25 @@ static gboolean CheckClockHealth(gpointer data)
TimeAdmin *ta = (TimeAdmin *)data;
Update_Clock_Start(ta);
ta->ApplyId = 0;
-
+
return FALSE;
-}
+}
static void update_apply_timeout(TimeAdmin *ta)
{
Update_Clock_Stop(ta);
- if (ta->ApplyId > 0)
+ if (ta->ApplyId > 0)
{
g_source_remove (ta->ApplyId);
ta->ApplyId = 0;
}
ta->ApplyId = g_timeout_add (10000, (GSourceFunc)CheckClockHealth,ta);
-}
+}
static void ChangeTimeValue(GtkSpinButton *spin_button,
gpointer *data)
{
TimeAdmin *ta = (TimeAdmin *)data;
if(TimeoutFlag == 0)
- {
+ {
update_apply_timeout(ta);
}
}
@@ -62,16 +62,16 @@ static GdkPixbuf * GetAppIcon(void)
{
MessageReport(("Get Icon Fail"),Error->message,ERROR);
g_error_free(Error);
- }
-
+ }
+
return Pixbuf;
-}
+}
static gboolean on_window_quit (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
TimeAdmin *ta = (TimeAdmin *)user_data;
-
+
QuitApp(ta);
return TRUE;
}
@@ -80,7 +80,7 @@ static void CloseWindow (GtkButton *button,gpointer data)
TimeAdmin *ta = (TimeAdmin *)data;
QuitApp(ta);
-}
+}
static void UpdatePermission(TimeAdmin *ta)
{
gboolean is_authorized;
@@ -116,7 +116,7 @@ static void InitMainWindow(TimeAdmin *ta)
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_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),
@@ -152,39 +152,39 @@ static int RecordPid(void)
{
int pid = 0;
int fd;
- int Length = 0;
+ int Length = 0;
char WriteBuf[30] = { 0 };
fd = open(LOCKFILE,O_WRONLY|O_CREAT|O_TRUNC,0777);
if(fd < 0)
{
MessageReport(_("open file"),_("Create pid file failed"),ERROR);
- return -1;
- }
- chmod(LOCKFILE,0777);
+ return -1;
+ }
+ chmod(LOCKFILE,0777);
pid = getpid();
sprintf(WriteBuf,"%d",pid);
Length = write(fd,WriteBuf,strlen(WriteBuf));
if(Length <= 0 )
{
MessageReport(_("write file"),_("write pid file failed"),ERROR);
- return -1;
- }
+ return -1;
+ }
close(fd);
return 0;
-}
+}
/******************************************************************************
-* Function: ProcessRuning
-*
-* Explain: Check whether the process has been started,If the process is not started,
+* Function: ProcessRuning
+*
+* Explain: Check whether the process has been started,If the process is not started,
* record the current process ID =====>"/tmp/user-admin.pid"
-*
-* Input:
-*
-*
+*
+* Input:
+*
+*
* Output: start :TRUE
* not start :FALSE
-*
+*
* Author: zhuyaliang 31/07/2018
******************************************************************************/
static gboolean ProcessRuning(void)
@@ -201,38 +201,38 @@ static gboolean ProcessRuning(void)
{
MessageReport(_("open file"),_("open pid file failed"),ERROR);
return TRUE;
- }
+ }
if(read(fd,ReadBuf,sizeof(ReadBuf)) <= 0)
{
MessageReport(_("read file"),_("read pid file failed"),ERROR);
goto ERROREXIT;
- }
+ }
pid = atoi(ReadBuf);
if(kill(pid,0) == 0)
- {
+ {
goto ERROREXIT;
}
}
-
+
if(RecordPid() < 0)
Run = TRUE;
-
+
return Run;
ERROREXIT:
close(fd);
return TRUE;
-}
+}
static char *translate(const char *value)
{
g_autofree gchar *zone_translated = NULL;
char *name;
-
+
zone_translated = g_strdup (dgettext (GETTEXT_PACKAGE_TIMEZONES,value));
name = g_strdup_printf (C_("timezone loc", "%s"),zone_translated);
-
+
return name;
-}
+}
static GtkWidget * TimeZoneAndNtp(TimeAdmin *ta)
{
GtkWidget *table;
@@ -249,8 +249,8 @@ static GtkWidget * TimeZoneAndNtp(TimeAdmin *ta)
gtk_widget_set_halign(TimeZoneLabel,GTK_ALIGN_START);
SetLableFontType(TimeZoneLabel,11,_("Time Zone:"));
gtk_grid_attach(GTK_GRID(table) ,TimeZoneLabel, 0 , 0 , 1 , 1);
-
- SetupTimezoneDialog(ta);
+
+ SetupTimezoneDialog(ta);
TimeZone = GetTimeZone(ta);
ZoneName = translate(TimeZone);
ta->TimeZoneButton = gtk_button_new_with_label(ZoneName);
@@ -260,12 +260,12 @@ static GtkWidget * TimeZoneAndNtp(TimeAdmin *ta)
ta);
gtk_grid_attach(GTK_GRID(table) ,ta->TimeZoneButton,1 , 0 , 3 , 1);
-
+
NtpSyncLabel = gtk_label_new(NULL);
gtk_widget_set_halign(NtpSyncLabel,GTK_ALIGN_START);
SetLableFontType(NtpSyncLabel,11,_("Ntp Sync:"));
gtk_grid_attach(GTK_GRID(table) ,NtpSyncLabel, 0 , 1 , 1 , 1);
-
+
ta->NtpSyncSwitch = gtk_switch_new();
NtpState = GetNtpState(ta);
ta->NtpState = NtpState;
@@ -276,13 +276,13 @@ static GtkWidget * TimeZoneAndNtp(TimeAdmin *ta)
"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)
{
@@ -301,45 +301,45 @@ static GtkWidget *GetSpinButton(int Initial,int Maximum,TimeAdmin *ta)
G_CALLBACK (ChangeTimeValue),
ta);
- SetTooltip(SpinButton,!ta->NtpState);
+ 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(NULL);
SetLableFontType(TimeLabel,13,_("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)
{
@@ -349,15 +349,15 @@ static GtkWidget *SetDate(TimeAdmin *ta)
table = gtk_grid_new();
gtk_grid_set_column_homogeneous(GTK_GRID(table),TRUE);
-
+
DateLabel = gtk_label_new(NULL);
SetLableFontType(DateLabel,13,_("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);
+ 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);
@@ -368,9 +368,9 @@ static GtkWidget *SetDate(TimeAdmin *ta)
"clicked",
G_CALLBACK (CloseWindow),
ta);
-
+
gtk_grid_attach(GTK_GRID(table) ,ta->ButtonLock, 0 , 5 , 1 , 1);
-
+
ta->SaveButton = gtk_button_new_with_label (_("Save"));
gtk_widget_set_sensitive(ta->SaveButton,!ta->NtpState);
gtk_grid_attach(GTK_GRID(table) ,ta->SaveButton, 2 , 5 , 1 , 1);
@@ -381,7 +381,7 @@ static GtkWidget *SetDate(TimeAdmin *ta)
gtk_grid_set_row_spacing(GTK_GRID(table), 6);
gtk_grid_set_column_spacing(GTK_GRID(table), 12);
-
+
return table;
}
@@ -394,7 +394,7 @@ static void CreateClockInterface(TimeAdmin *ta)
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);
@@ -402,7 +402,7 @@ static void CreateClockInterface(TimeAdmin *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;
@@ -412,7 +412,7 @@ static gboolean InitDbusProxy(TimeAdmin *ta)
{
MessageReport(_("g_bus_get_sync"),error->message,ERROR);
goto EXIT;
- }
+ }
ta->proxy = g_dbus_proxy_new_sync (ta->Connection,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
@@ -425,29 +425,29 @@ static gboolean InitDbusProxy(TimeAdmin *ta)
{
MessageReport(_("g_bus_proxy_new"),error->message,ERROR);
goto EXIT;
- }
+ }
return TRUE;
EXIT:
g_error_free(error);
return FALSE;
-}
+}
int main(int argc, char **argv)
{
TimeAdmin ta;
- bindtextdomain (PACKAGE,MATELOCALEDIR);
- textdomain (PACKAGE);
- bind_textdomain_codeset (GETTEXT_PACKAGE_TIMEZONES, "UTF-8");
-
+ bindtextdomain (PACKAGE,MATELOCALEDIR);
+ textdomain (PACKAGE);
+ bind_textdomain_codeset (GETTEXT_PACKAGE_TIMEZONES, "UTF-8");
+
gtk_init(&argc, &argv);
-
+
/* Create the main window */
InitMainWindow(&ta);
/* Check whether the process has been started */
if(ProcessRuning() == TRUE)
- exit(0);
+ exit(0);
if(InitDbusProxy(&ta) == FALSE)
{
exit(0);
@@ -456,6 +456,6 @@ int main(int argc, char **argv)
UpdatePermission(&ta);
gtk_widget_show_all(ta.MainWindow);
gtk_main();
-
+
return TRUE;
}
diff --git a/capplets/time-admin/src/time-map.c b/capplets/time-admin/src/time-map.c
index 10a3666e..ad38ef52 100644
--- a/capplets/time-admin/src/time-map.c
+++ b/capplets/time-admin/src/time-map.c
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -31,13 +31,13 @@ typedef struct
guchar green;
guchar blue;
guchar alpha;
-}TimezoneMapOffset;
+}TimezoneMapOffset;
enum
{
LOCATION_CHANGED,
LAST_SIGNAL
};
-
+
G_DEFINE_TYPE (TimezoneMap, timezone_map, GTK_TYPE_WIDGET)
static guint signals[LAST_SIGNAL];
static TimezoneMapOffset color_codes[] =
@@ -428,13 +428,13 @@ set_location (TimezoneMap *map,
TzLocation *location)
{
g_autoptr(TzInfo) info = NULL;
-
+
map->location = location;
info = tz_info_from_location (map->location);
map->selected_offset = tz_location_get_utc_offset (map->location)
- / (60.0*60.0) +
+ / (60.0*60.0) +
((info->daylight) ? -1.0 : 0.0);
-
+
g_signal_emit (map, signals[LOCATION_CHANGED], 0, map->location,NULL);
}
@@ -524,8 +524,8 @@ timezone_map_class_init (TimezoneMapClass *klass)
widget_class->realize = cc_timezone_map_realize;
widget_class->draw = cc_timezone_map_draw;
widget_class->state_flags_changed = cc_timezone_map_state_flags_changed;
-
-
+
+
signals[LOCATION_CHANGED] = g_signal_new ("location-changed",
TYPE_TIMEZONE_MAP,
G_SIGNAL_RUN_FIRST,
@@ -541,10 +541,10 @@ static void
timezone_map_init (TimezoneMap *map)
{
GError *err = NULL;
-
+
map->orig_background = gdk_pixbuf_new_from_file (TIMPZONEDIR"bg.png",&err);
if (!map->orig_background)
- {
+ {
g_warning ("Could not load background image: %s",
(err) ? err->message : "Unknown error");
g_clear_error (&err);
@@ -575,10 +575,10 @@ timezone_map_init (TimezoneMap *map)
map->tzdb = tz_load_db ();
- g_signal_connect_object (map,
- "button-press-event",
- G_CALLBACK (button_press_event),
- map,
+ g_signal_connect_object (map,
+ "button-press-event",
+ G_CALLBACK (button_press_event),
+ map,
G_CONNECT_SWAPPED);
}
gboolean timezone_map_set_timezone (TimezoneMap *map,
@@ -588,7 +588,7 @@ gboolean timezone_map_set_timezone (TimezoneMap *map,
guint i;
g_autofree gchar *real_tz = NULL;
gboolean ret;
-
+
real_tz = tz_info_get_clean_name (map->tzdb, timezone);
locations = tz_get_locations (map->tzdb);
@@ -612,7 +612,7 @@ gboolean timezone_map_set_timezone (TimezoneMap *map,
return ret;
}
TzLocation *timezone_map_get_location (TimezoneMap *map)
-{
+{
return map->location;
}
void timezone_map_set_bubble_text (TimezoneMap *map,
@@ -624,6 +624,6 @@ void timezone_map_set_bubble_text (TimezoneMap *map,
}
TimezoneMap * timezone_map_new (void)
-{
+{
return g_object_new (TYPE_TIMEZONE_MAP, NULL);
-}
+}
diff --git a/capplets/time-admin/src/time-map.h b/capplets/time-admin/src/time-map.h
index e7e574dc..979dceaf 100644
--- a/capplets/time-admin/src/time-map.h
+++ b/capplets/time-admin/src/time-map.h
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -49,7 +49,7 @@ typedef struct TimezoneMap
typedef struct TimezoneMapClass
{
GtkWidgetClass parent_class;
-
+
} TimezoneMapClass;
GType timezone_map_get_type (void) G_GNUC_CONST;
@@ -62,7 +62,7 @@ gboolean timezone_map_set_timezone (TimezoneMap *map,
TzLocation *timezone_map_get_location (TimezoneMap *map);
-TimezoneMap * timezone_map_new (void);
+TimezoneMap * timezone_map_new (void);
G_END_DECLS
#endif
diff --git a/capplets/time-admin/src/time-share.c b/capplets/time-admin/src/time-share.c
index b4c34e80..797f506f 100644
--- a/capplets/time-admin/src/time-share.c
+++ b/capplets/time-admin/src/time-share.c
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -22,14 +22,14 @@
/******************************************************************************
* Function: MessageReport
-*
+*
* Explain: Prompt information dialog
-*
+*
* Input: @Title Message title
-* @Msg Message content
+* @Msg Message content
* @nType Message type
-* Output:
-*
+* Output:
+*
* Author: zhuyaliang 25/05/2018
******************************************************************************/
int MessageReport(const char *Title,const char *Msg,int nType)
@@ -85,7 +85,7 @@ int MessageReport(const char *Title,const char *Msg,int nType)
GTK_BUTTONS_YES_NO,
"%s",Title);
break;
- }
+ }
default :
break;
@@ -114,12 +114,12 @@ 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();
}
GtkWidget* DialogAddButtonWithIconName (GtkDialog *dialog,
diff --git a/capplets/time-admin/src/time-share.h b/capplets/time-admin/src/time-share.h
index a0088a87..e5e8a476 100644
--- a/capplets/time-admin/src/time-share.h
+++ b/capplets/time-admin/src/time-share.h
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -46,7 +46,7 @@
GtkWidget *WindowLogin;
int TimeoutFlag;
-typedef struct
+typedef struct
{
GtkWidget *MainWindow;
GtkWidget *HourSpin;
@@ -57,7 +57,7 @@ typedef struct
GtkWidget *Calendar;
GtkWidget *CloseButton;
GtkWidget *SaveButton;
- int UpdateTimeId;
+ int UpdateTimeId;
int ApplyId;
int OldDay;
gboolean NtpState;
diff --git a/capplets/time-admin/src/time-tool.c b/capplets/time-admin/src/time-tool.c
index f2375808..0e12bd65 100644
--- a/capplets/time-admin/src/time-tool.c
+++ b/capplets/time-admin/src/time-tool.c
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -25,20 +25,20 @@ struct tm *GetCurrentTime(void)
time_t tt;
tzset();
tt=time(NULL);
-
+
return localtime(&tt);
}
static void UpdateDate(TimeAdmin *ta,gboolean state)
{
struct tm *LocalTime;
-
+
if(state == TRUE)
- {
+ {
LocalTime = GetCurrentTime();
- gtk_calendar_select_month (GTK_CALENDAR (ta->Calendar),
+ gtk_calendar_select_month (GTK_CALENDAR (ta->Calendar),
LocalTime->tm_mon,
LocalTime->tm_year+1900);
- gtk_calendar_select_day (GTK_CALENDAR (ta->Calendar),
+ gtk_calendar_select_day (GTK_CALENDAR (ta->Calendar),
LocalTime->tm_mday);
}
}
@@ -47,18 +47,18 @@ static gboolean UpdateClock(gpointer data)
TimeAdmin *ta = (TimeAdmin *)data;
struct tm *LocalTime;
gchar *str;
-
+
LocalTime = GetCurrentTime();
TimeoutFlag = 1;
gtk_spin_button_set_value(GTK_SPIN_BUTTON(ta->HourSpin),LocalTime->tm_hour);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(ta->MinuteSpin),LocalTime->tm_min);
str = g_strdup_printf ("%02d", LocalTime->tm_sec);
gtk_entry_set_text(GTK_ENTRY(ta->SecondSpin),str);
-
- UpdateDate(ta,ta->NtpState);
+
+ UpdateDate(ta,ta->NtpState);
gtk_calendar_mark_day(GTK_CALENDAR(ta->Calendar),LocalTime->tm_mday);
if(LocalTime->tm_mday != ta->OldDay)
- {
+ {
gtk_calendar_unmark_day(GTK_CALENDAR(ta->Calendar),ta->OldDay);
ta->OldDay = LocalTime->tm_mday;
}
@@ -72,16 +72,16 @@ void Update_Clock_Start(TimeAdmin *ta)
if(ta->UpdateTimeId <= 0)
{
ta->UpdateTimeId = g_timeout_add(1000,(GSourceFunc)UpdateClock,ta);
- }
+ }
-}
+}
void Update_Clock_Stop(TimeAdmin *ta)
{
if(ta->UpdateTimeId > 0)
{
g_source_remove(ta->UpdateTimeId);
ta->UpdateTimeId = 0;
- }
+ }
}
gboolean GetNtpState(TimeAdmin *ta)
{
@@ -102,7 +102,7 @@ gboolean GetNtpState(TimeAdmin *ta)
{
goto EXIT;
}
-
+
ret = g_dbus_proxy_call_sync (proxy,
"Get",
g_variant_new ("(ss)",
@@ -124,7 +124,7 @@ EXIT:
g_error_free(error);
return FALSE;
-}
+}
const gchar *GetTimeZone(TimeAdmin *ta)
{
@@ -145,7 +145,7 @@ const gchar *GetTimeZone(TimeAdmin *ta)
{
goto EXIT;
}
-
+
ret = g_dbus_proxy_call_sync (proxy,
"Get",
g_variant_new ("(ss)",
@@ -172,7 +172,7 @@ void SetTimeZone(GDBusProxy *proxy,const char *zone)
{
GError *error = NULL;
GVariant *ret;
-
+
ret = g_dbus_proxy_call_sync (proxy,
"SetTimezone",
g_variant_new ("(sb)",zone,1),
@@ -184,20 +184,20 @@ void SetTimeZone(GDBusProxy *proxy,const char *zone)
if(ret == NULL)
{
MessageReport(_("Set time zone"),error->message,ERROR);
- }
-}
+ }
+}
static void ChangeSpinBttonState(TimeAdmin *ta,gboolean State)
{
gtk_widget_set_sensitive(ta->SaveButton,!State);
- SetTooltip(ta->SaveButton,!ta->NtpState);
+ SetTooltip(ta->SaveButton,!ta->NtpState);
gtk_widget_set_sensitive(ta->HourSpin, !State);
- SetTooltip(ta->HourSpin,!ta->NtpState);
+ SetTooltip(ta->HourSpin,!ta->NtpState);
gtk_widget_set_sensitive(ta->MinuteSpin,!State);
- SetTooltip(ta->MinuteSpin,!ta->NtpState);
+ SetTooltip(ta->MinuteSpin,!ta->NtpState);
gtk_widget_set_sensitive(ta->SecondSpin,!State);
- SetTooltip(ta->SecondSpin,!ta->NtpState);
+ SetTooltip(ta->SecondSpin,!ta->NtpState);
gtk_widget_set_sensitive(ta->Calendar, !State);
- SetTooltip(ta->Calendar,!ta->NtpState);
+ SetTooltip(ta->Calendar,!ta->NtpState);
}
gboolean ChangeNtpSync(GtkSwitch *widget,gboolean state,gpointer data)
@@ -205,7 +205,7 @@ gboolean ChangeNtpSync(GtkSwitch *widget,gboolean state,gpointer data)
TimeAdmin *ta = (TimeAdmin *)data;
GError *error = NULL;
GVariant *ret;
-
+
ret = g_dbus_proxy_call_sync (ta->proxy,
"SetNTP",
g_variant_new ("(bb)",state,state),
@@ -219,22 +219,22 @@ gboolean ChangeNtpSync(GtkSwitch *widget,gboolean state,gpointer data)
MessageReport(_("Set Ntp sync"),error->message,ERROR);
g_error_free(error);
return TRUE;
- }
+ }
else
{
ta->NtpState = state;
ChangeSpinBttonState(ta,state);
Update_Clock_Start(ta);
UpdateDate(ta,state);
- }
+ }
return FALSE;
-}
+}
static guint GetTimeStamp(TimeAdmin *ta)
{
guint year,month,day,hour,min,sec;
GDateTime *dt;
char *st;
-
+
gtk_calendar_get_date(GTK_CALENDAR(ta->Calendar),&year,&month,&day);
hour = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ta->HourSpin));
min = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ta->MinuteSpin));
@@ -249,7 +249,7 @@ static void SetTime(GDBusProxy *proxy,gint64 TimeSec)
{
GError *error = NULL;
GVariant *ret;
-
+
ret = g_dbus_proxy_call_sync (proxy,
"SetTime",
g_variant_new ("(xbb)",TimeSec * 1000 * 1000,0,0),
@@ -262,8 +262,8 @@ static void SetTime(GDBusProxy *proxy,gint64 TimeSec)
{
MessageReport(_("Set Ntp sync"),error->message,ERROR);
g_error_free(error);
- }
-}
+ }
+}
void SaveModifyTime (GtkButton *button,gpointer data)
{
TimeAdmin *ta = (TimeAdmin *)data;
@@ -277,5 +277,5 @@ void SaveModifyTime (GtkButton *button,gpointer data)
else
{
MessageReport(_("Set Time"),_("NTP synchronization has been started, the modification is invalid"),INFOR);
- }
-}
+ }
+}
diff --git a/capplets/time-admin/src/time-tool.h b/capplets/time-admin/src/time-tool.h
index ad098bce..f5461b0d 100644
--- a/capplets/time-admin/src/time-tool.h
+++ b/capplets/time-admin/src/time-tool.h
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
diff --git a/capplets/time-admin/src/time-zone.c b/capplets/time-admin/src/time-zone.c
index b2c6265c..a0852bf2 100644
--- a/capplets/time-admin/src/time-zone.c
+++ b/capplets/time-admin/src/time-zone.c
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -94,8 +94,8 @@ static void load_backward_tz (TzDB *tz_db)
{
g_error("%s does not exist\r\n",BACKFILE);
- }
- while(fgets(buf,128,fp))
+ }
+ while(fgets(buf,128,fp))
{
g_auto(GStrv) items = NULL;
guint j;
@@ -128,26 +128,26 @@ static void load_backward_tz (TzDB *tz_db)
real = "Etc/GMT";
g_hash_table_insert (tz_db->backward, g_strdup (alias), g_strdup (real));
-
- }
+
+ }
fclose(fp);
}
TzDB *tz_load_db (void)
-{
+{
g_autofree gchar *tz_data_file = NULL;
TzDB *tz_db;
FILE *tzfile;
char buf[4096];
tz_data_file = tz_data_file_get ();
- if (!tz_data_file)
+ if (!tz_data_file)
{
g_warning ("Could not get the TimeZone data file name");
return NULL;
}
tzfile = fopen (tz_data_file, "r");
- if (!tzfile)
+ if (!tzfile)
{
g_warning ("Could not open *%s*\n", tz_data_file);
return NULL;
@@ -224,15 +224,15 @@ static GtkWidget *GetTimeZoneMap(TimeAdmin *ta)
"location-changed",
G_CALLBACK (LocationChanged),
ta);
-
+
completion = gtk_entry_completion_new ();
gtk_entry_set_completion (GTK_ENTRY (ta->TimezoneEntry), completion);
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 *
translated_city_name (TzLocation *loc)
{
@@ -273,7 +273,7 @@ update_timezone (TimezoneMap *map)
current_location = timezone_map_get_location (TIMEZONEMAP (map));
city_country = translated_city_name (current_location);
-
+
timezone = g_time_zone_new (current_location->zone);
current_date = g_date_time_new_now_local ();
date = g_date_time_to_timezone (current_date, timezone);
@@ -323,12 +323,12 @@ static void LoadCities (TzLocation *loc,
g_autofree gchar *human_readable = NULL;
human_readable = translated_city_name (loc);
- gtk_list_store_insert_with_values (CityStore,
- NULL,
+ gtk_list_store_insert_with_values (CityStore,
+ NULL,
0,
- CITY_COL_CITY_HUMAN_READABLE,
+ CITY_COL_CITY_HUMAN_READABLE,
human_readable,
- CITY_COL_ZONE,
+ CITY_COL_ZONE,
loc->zone,
-1);
}
@@ -336,13 +336,13 @@ static void LoadCities (TzLocation *loc,
static void CreateCityList(TimeAdmin *ta)
{
g_autoptr(TzDB) db = NULL;
-
+
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);
-}
+}
static GtkWidget *CreateZoneFrame(TimeAdmin *ta)
{
GtkWidget *TimeZoneFrame;
@@ -350,9 +350,9 @@ static GtkWidget *CreateZoneFrame(TimeAdmin *ta)
TimeZoneFrame = gtk_frame_new (_("Time Zone"));
gtk_widget_set_size_request(TimeZoneFrame,300,200);
gtk_frame_set_shadow_type(GTK_FRAME(TimeZoneFrame),GTK_SHADOW_NONE);
-
+
return TimeZoneFrame;
-}
+}
static GtkWidget *CreateZoneScrolled(TimeAdmin *ta)
{
GtkWidget *Scrolled;
@@ -364,11 +364,11 @@ static GtkWidget *CreateZoneScrolled(TimeAdmin *ta)
GTK_SHADOW_IN);
return Scrolled;
-}
+}
static void CreateZoneEntry(TimeAdmin *ta)
{
GtkWidget *hbox;
-
+
ta->TimezoneEntry = gtk_search_entry_new ();
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_widget_set_halign (hbox, GTK_ALIGN_CENTER);
@@ -381,7 +381,7 @@ static void CreateZoneEntry(TimeAdmin *ta)
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,
@@ -391,9 +391,9 @@ static gboolean CityChanged(GtkEntryCompletion *completion,
GtkWidget *entry;
g_autofree gchar *zone = NULL;
- gtk_tree_model_get (model,
+ gtk_tree_model_get (model,
iter,
- CITY_COL_ZONE,
+ CITY_COL_ZONE,
&zone,
-1);
timezone_map_set_timezone (TIMEZONEMAP (self->map), zone);
@@ -408,12 +408,12 @@ static void ChoooseTimezoneDone (GtkWidget *widget,
{
TimezoneMap *map;
g_autofree gchar *ZoneCity = NULL;
-
- map = TIMEZONEMAP(ta->map);
+
+ 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_button_set_label((GTK_BUTTON(ta->TimeZoneButton)),ZoneCity);
gtk_widget_hide_on_delete(GTK_WIDGET(ta->dialog));
}
@@ -439,12 +439,12 @@ void SetupTimezoneDialog(TimeAdmin *ta)
ta->TZclose = DialogAddButtonWithIconName(GTK_DIALOG(ta->dialog),
_("Close"),
"window-close",
- GTK_RESPONSE_CANCEL);
-
+ GTK_RESPONSE_CANCEL);
+
ta->TZconfire = DialogAddButtonWithIconName(GTK_DIALOG(ta->dialog),
_("Confirm"),
"emblem-default",
- GTK_RESPONSE_OK);
+ GTK_RESPONSE_OK);
g_signal_connect (ta->TZconfire,
"clicked",
G_CALLBACK (ChoooseTimezoneDone),
@@ -455,9 +455,9 @@ void SetupTimezoneDialog(TimeAdmin *ta)
G_CALLBACK (ChoooseTimezoneClose),
ta);
- Vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ Vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (Vbox), "linked");
-
+
TimeZoneFrame = CreateZoneFrame(ta);
Scrolled = CreateZoneScrolled(ta);
@@ -470,11 +470,11 @@ void SetupTimezoneDialog(TimeAdmin *ta)
gtk_container_add (GTK_CONTAINER (Scrolled),ta->map);
gtk_box_pack_start(GTK_BOX(Vbox),TimeZoneFrame,TRUE,TRUE,10);
get_initial_timezone(ta);
-
+
g_signal_connect(gtk_entry_get_completion (GTK_ENTRY (ta->TimezoneEntry)),
- "match-selected",
- G_CALLBACK (CityChanged),
- ta);
+ "match-selected",
+ G_CALLBACK (CityChanged),
+ ta);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (ta->dialog))),
Vbox,
@@ -484,7 +484,7 @@ void SetupTimezoneDialog(TimeAdmin *ta)
void tz_info_free (TzInfo *tzinfo)
{
g_return_if_fail (tzinfo != NULL);
-
+
if (tzinfo->tzname_normal) g_free (tzinfo->tzname_normal);
if (tzinfo->tzname_daylight) g_free (tzinfo->tzname_daylight);
g_free (tzinfo);
@@ -535,18 +535,18 @@ compare_timezones (const char *a,
char *tz_info_get_clean_name (TzDB *tz_db,
const char *tz)
-{
+{
char *ret;
const char *timezone;
guint i;
gboolean replaced;
-
+
/* Remove useless prefixes */
if (g_str_has_prefix (tz, "right/"))
tz = tz + strlen ("right/");
else if (g_str_has_prefix (tz, "posix/"))
tz = tz + strlen ("posix/");
-
+
/* Here start the crazies */
replaced = FALSE;
@@ -625,7 +625,7 @@ TzInfo *tz_info_from_location (TzLocation *loc)
glong tz_location_get_utc_offset (TzLocation *loc)
{
g_autoptr(TzInfo) tz_info = NULL;
- glong offset;
+ glong offset;
tz_info = tz_info_from_location (loc);
offset = tz_info->utc_offset;
diff --git a/capplets/time-admin/src/time-zone.h b/capplets/time-admin/src/time-zone.h
index a0c993d5..70473b24 100644
--- a/capplets/time-admin/src/time-zone.h
+++ b/capplets/time-admin/src/time-zone.h
@@ -1,4 +1,4 @@
-/* time-admin
+/* time-admin
* Copyright (C) 2018 zhuyaliang https://github.com/zhuyaliang/
*
* This program is free software: you can redistribute it and/or modify
@@ -27,13 +27,13 @@
#endif
typedef struct TzDB
-{
+{
GPtrArray *locations;
GHashTable *backward;
}TzDB;
-
+
typedef struct TzLocation
-{
+{
gchar *country;
gdouble latitude;
gdouble longitude;