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
657480f4
Commit
657480f4
authored
Jun 14, 2019
by
Carit Zhu
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add desktop file for yocto and change ui file
parent
8acd7437
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
198 additions
and
87 deletions
+198
-87
Makefile
Makefile
+3
-3
dt-manager-editor.desktop
dt-manager-editor.desktop
+13
-0
main.c
main.c
+30
-5
timemanager.ui
timemanager.ui
+152
-79
No files found.
Makefile
View file @
657480f4
...
...
@@ -45,10 +45,10 @@ LIBS += $(GLIB_LIBS) $(GTK3_LIBS)
objects
=
main.o
# Default target
all
:
timemanage
r
all
:
dt-manager-edito
r
# Build objects
timemanage
r
:
$(objects)
dt-manager-edito
r
:
$(objects)
$(CC)
$(CFLAGS)
$(LDFLAGS)
-o
$@
$<
$(LIBS)
# Temp objects
...
...
@@ -58,4 +58,4 @@ timemanager: $(objects)
# Clean
.PHONY
:
clean
clean
:
rm
-f
*
.o
timemanage
r
rm
-f
*
.o
dt-manager-edito
r
dt-manager-editor.desktop
0 → 100644
View file @
657480f4
[Desktop Entry]
Name=Date & Time
Exec=dt-manager-editor
Terminal=false
Type=Application
Comment=Set date and time
StartupNotify=false
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=TimeManager
X-GNOME-Bugzilla-Component=dt-manager-editor
Categories=GNOME;GTK;Settings;
NotShowIn=KDE;GNOME;
Name[en_US]=dt-manager-editor
main.c
View file @
657480f4
...
...
@@ -71,11 +71,16 @@ static void set_timezone(char *timezone) {
}
}
static
void
set_ntp
(
char
*
enable
)
{
set_timedatectl
(
"set-ntp"
,
enable
);
}
static
void
set_date_time
(
const
char
*
date
,
const
char
*
hour
,
const
char
*
min
,
const
char
*
sec
)
{
char
data
[
32
]
=
{
0
};
if
(
strcmp
(
active_date
,
date
))
{
sprintf
(
data
,
"'%s %s:%s:%s'"
,
date
,
hour
,
min
,
sec
);
set_ntp
(
"no"
);
// set ntp as no before seting time/date
set_timedatectl
(
"set-time"
,
data
);
strcpy
(
active_date
,
date
);
strcpy
(
active_hour
,
hour
);
...
...
@@ -83,6 +88,7 @@ static void set_date_time(const char *date, const char *hour, const char *min, c
strcpy
(
active_sec
,
sec
);
}
else
if
(
strcmp
(
active_hour
,
hour
)
||
strcmp
(
active_min
,
min
)
||
strcmp
(
active_sec
,
sec
))
{
sprintf
(
data
,
"'%s:%s:%s'"
,
hour
,
min
,
sec
);
set_ntp
(
"no"
);
// set ntp as no before seting time/date
set_timedatectl
(
"set-time"
,
data
);
strcpy
(
active_hour
,
hour
);
strcpy
(
active_min
,
min
);
...
...
@@ -105,10 +111,14 @@ static void get_time_date_status() {
buf
=
strchr
(
time_status
[
i
],
':'
);
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
);
}
}
}
}
#ifdef DEBUG
g_print
(
"[DEBUG] Current timezone: %s
\n
"
,
timezone_cur
);
#endif
...
...
@@ -345,10 +355,25 @@ static int gobjects_init(GtkBuilder *builder, GtkWidget *dialog) {
int
main
(
int
argc
,
char
**
argv
)
{
GtkBuilder
*
builder
=
gtk_builder_new
();
GtkWidget
*
dialog
;
char
ui_path
[
64
]
=
"timemanager.ui"
;
if
(
argc
>=
3
&&
(
argc
%
2
!=
0
))
{
for
(
int
i
=
1
;
i
<
argc
;
i
+=
2
)
{
if
(
!
strcmp
(
argv
[
i
],
"--ui"
))
{
strncpy
(
ui_path
,
argv
[
i
+
1
],
63
);
}
}
}
#ifdef DEBUG
g_print
(
"[DEBUG] ui path is %s
\n
"
,
ui_path
);
#endif
gtk_init
(
&
argc
,
&
argv
);
if
(
!
gtk_builder_add_from_file
(
builder
,
"timemanager.ui"
,
NULL
))
{
if
(
!
gtk_builder_add_from_file
(
builder
,
ui_path
,
NULL
))
{
g_print
(
"[ERROR] can not load glade file
\n
"
);
return
-
1
;
}
...
...
@@ -360,7 +385,7 @@ int main(int argc, char **argv) {
}
gtk_window_set_title
(
GTK_WINDOW
(
dialog
),
"Date & Time"
);
gtk_window_set_default_size
(
GTK_WINDOW
(
dialog
),
400
,
20
0
);
gtk_window_set_default_size
(
GTK_WINDOW
(
dialog
),
320
,
24
0
);
gtk_builder_connect_signals
(
builder
,
NULL
);
g_signal_connect
(
dialog
,
GTK_EVENT_DESTROY
,
G_CALLBACK
(
gtk_main_quit
),
NULL
);
...
...
timemanager.ui
View file @
657480f4
This diff is collapsed.
Click to expand it.
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