Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TimeManager
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Schedules
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
linux-tools
TimeManager
Commits
5e99f011
Commit
5e99f011
authored
Jun 14, 2019
by
Carit Zhu
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add updating date and time after setting timezone
parent
0b1b8777
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
main.c
main.c
+19
-10
No files found.
main.c
View file @
5e99f011
...
...
@@ -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
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment