cgtk4

GTK4 draw images or icons over an image


I have an image that is drawn on the screen and I would like to place other smaller images or icons on top of it. I use GTK4 and C language and I don't know how I could do it. This is the part of the code where I insert the image into the window.

GtkWidget *win = gtk_application_window_new (app);
    gtk_window_set_title (GTK_WINDOW (win), "Window");
    gtk_window_set_default_size (GTK_WINDOW (win), 1024, 1024);
    gtk_window_set_resizable(GTK_WINDOW (win), FALSE);
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
    gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
    gtk_widget_set_valign (box, GTK_ALIGN_START);
    gtk_box_set_homogeneous (GTK_BOX (box), FALSE);
    gtk_window_set_child (GTK_WINDOW (win), box);
gtk_box_append(GTK_BOX(box), image);

I have looked for information on how to do it in GTK4 but I have not found it. I would need to know how to put one image on top of another without deleting the previous one.


Solution

  • It seems to me that what you need is a Gtk.Overlay.