Guest User

Untitled

a guest
Sep 15th, 2025
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /*
  2. on ubuntu/debian: sudo apt-get -y install libgtk-4-dev
  3.  
  4. compile: gcc $(pkg-config --cflags gtk4) -o image image.c $(pkg-config --libs gtk4)
  5.  
  6. #include <gtk/gtk.h>
  7.  
  8. static void
  9. activate (GtkApplication *app, gpointer user_data)
  10. {
  11. GtkWidget *window;
  12. GtkWidget *image;
  13.  
  14. window = gtk_application_window_new(app);
  15. gtk_window_set_title(GTK_WINDOW(window), "Image Viewer");
  16. gtk_window_set_default_size(GTK_WINDOW (window), 320, 200);
  17.  
  18. image = gtk_image_new_from_file("some-image.png");
  19. gtk_window_set_child(GTK_WINDOW(window), image);
  20.  
  21. gtk_window_present(GTK_WINDOW(window));
  22. }
  23.  
  24. int main (int argc, char **argv)
  25. {
  26. GtkApplication *app;
  27. int status;
  28.  
  29. app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
  30. g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
  31. status = g_application_run(G_APPLICATION(app), argc, argv);
  32. g_object_unref(app);
  33.  
  34. return status;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment