Excuses, this is way below your level, no doubt.
I want to merge two scripts. 1 C-script and 1 for a box in GTK4.
The target is a digital clock (with seconds) in a box.
In case there is a better option with GTK4 please let me know.
Can you please tell me how I can integrate the C-script (with integer types) in the GTK4 script?
Sorry again for bothering.
Just hope to see more fun things (for me).
Thanks a lot, greetings!
The C-script with the loop (time as integers):
#include <stdio.h>
#include <time.h>
#include <unistd.h>
//example: 'https://www.geeksforgeeks.org/c-program-print-digital-clock-current-time/'
int main()
{
for (;;){
time_t s, val = 1;
struct tm* current_time;
// time in seconds
s = time(NULL);
// to get current time
current_time = localtime(&s);
// print time in minutes,
// hours and seconds
printf("\r%02d:%02d:%02d",
current_time->tm_hour,
current_time->tm_min,
current_time->tm_sec);
fflush(stdout);
usleep(10);
}
return 0;
}
GTK4 example box:
#include <gtk/gtk.h>
//Source: 'https://github.com/ToshioCP/Gtk4-tutorial/blob/main/gfm/sec4.md'
static void
app_activate (GApplication *app, gpointer user_data) {
GtkWidget *win;
GtkWidget *lab;
win = gtk_application_window_new (GTK_APPLICATION (app));
gtk_window_set_title (GTK_WINDOW (win), "lb1");
gtk_window_set_default_size (GTK_WINDOW (win), 400, 300);
(int) lab = 1;
gtk_window_set_child (GTK_WINDOW (win), lab);
gtk_widget_show (win);
}
int
main (int argc, char **argv) {
GtkApplication *app;
int stat;
app = gtk_application_new ("com.github.ToshioCP.lb1", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL);
stat =g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
return stat;
}