Commit 5e99f011 authored by Carit Zhu's avatar Carit Zhu 🎱

add updating date and time after setting timezone

parent 0b1b8777
......@@ -32,6 +32,13 @@ static char timezone_new[32] = {0};
static char timezone_buffer[512][32];
static int timezone_num = 0;
static void date_init(GtkEntry *entry_date, GtkEntry *entry_hour, GtkEntry *entry_minute, GtkEntry *entry_second);
static void update_date_time() {
date_init(GTK_ENTRY(entry_date), GTK_ENTRY(entry_hour),
GTK_ENTRY(entry_minute), GTK_ENTRY(entry_second));
}
static int get_timezone(const char *src, char *timezone) {
const char *buf = src;
int index = 0;
......@@ -68,6 +75,10 @@ static void set_timedatectl(char *command, char *data) {
static void set_timezone(char *timezone) {
if (strcmp(timezone_cur, timezone)) {
set_timedatectl("set-timezone", timezone);
/* Update current timezone to be set */
strcpy(timezone_cur, timezone);
/* Update current date time after setting timezone */
update_date_time();
}
}
......@@ -112,10 +123,9 @@ static void get_time_date_status() {
if (buf != NULL) {
get_timezone(buf + 1, timezone_cur);
if (!strcmp(timezone_cur, "Universal")) {
strcpy(timezone_new, "UTC"); // Set default "Universal" timezone as UTC.
} else {
strcpy(timezone_new, timezone_cur);
strcpy(timezone_cur, "UTC"); // Set default "Universal" timezone as UTC.
}
strcpy(timezone_new, timezone_cur);
}
}
}
......@@ -140,18 +150,17 @@ static void combo_handler(GObject *combo, gpointer user_data) {
/* Obtain string from model. */
gtk_tree_model_get(model, &iter, 0, &string, -1);
}
#ifdef DEBUG
/* Print string to the console - if string is NULL, print NULL. */
g_print("[DEBUG] Selected (complex): >> %s <<\n", ( string ? string : "NULL" ));
#endif
/* Update current timezone */
strcpy(timezone_new, string);
strcpy(timezone_new, ( string ? string : "NULL" ));
/* Free string (if not NULL). */
if (string)
g_free(string);
#ifdef DEBUG
/* Print string to the console - if string is NULL, print NULL. */
g_print("[DEBUG] Selected (complex): >> %s <<\n", timezone_new);
#endif
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment