Commit 657480f4 authored by Carit Zhu's avatar Carit Zhu 🎱

Add desktop file for yocto and change ui file

parent 8acd7437
......@@ -45,10 +45,10 @@ LIBS += $(GLIB_LIBS) $(GTK3_LIBS)
objects = main.o
# Default target
all: timemanager
all: dt-manager-editor
# Build objects
timemanager: $(objects)
dt-manager-editor: $(objects)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
# Temp objects
......@@ -58,4 +58,4 @@ timemanager: $(objects)
# Clean
.PHONY: clean
clean:
rm -f *.o timemanager
rm -f *.o dt-manager-editor
[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
......@@ -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,7 +111,11 @@ static void get_time_date_status() {
buf = strchr(time_status[i], ':');
if (buf != NULL) {
get_timezone(buf + 1, timezone_cur);
strcpy(timezone_new, timezone_cur);
if (!strcmp(timezone_cur, "Universal")) {
strcpy(timezone_new, "UTC"); // Set default "Universal" timezone as UTC.
} else {
strcpy(timezone_new, timezone_cur);
}
}
}
}
......@@ -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;
}
......@@ -358,9 +383,9 @@ int main(int argc, char **argv) {
g_print("[ERROR] can not get dialog object\n");
return -1;
}
gtk_window_set_title(GTK_WINDOW(dialog), "Date & Time");
gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 200);
gtk_window_set_default_size(GTK_WINDOW(dialog), 320, 240);
gtk_builder_connect_signals(builder, NULL);
g_signal_connect(dialog, GTK_EVENT_DESTROY, G_CALLBACK(gtk_main_quit), NULL);
......
This diff is collapsed.
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