SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <gtk/gtk.h>
  2. #include <gdk-pixbuf/gdk-pixbuf.h>
  3.  
  4. GtkWidget *scrollWindow;
  5. GtkWidget *parenWindow;
  6. GtkWidget *imageWidget;
  7.  
  8. void redraw_image(GtkWidget *parenWindow, gpointer data){
  9.    GdkPixbuf *imagePixbuf = gdk_pixbuf_new_from_file("albumart.png", NULL);
  10.    imagePixbuf = gdk_pixbuf_scale_simple(imagePixbuf, 400, 400, GDK_INTERP_BILINEAR);
  11.    imageWidget = gtk_image_new_from_pixbuf(imagePixbuf);
  12.    gtk_container_add(GTK_CONTAINER(scrollWindow), imageWidget);
  13. }
  14.  
  15. void activate (GtkApplication *app, gpointer user_data) {
  16.    parenWindow = gtk_application_window_new(app);
  17.    gtk_window_set_default_size (GTK_WINDOW (parenWindow), 400, 400);
  18.  
  19.    scrollWindow = gtk_scrolled_window_new(NULL, NULL);
  20.    gtk_container_add (GTK_CONTAINER(parenWindow), scrollWindow);
  21.  
  22.  
  23.    gtk_widget_show_all (parenWindow);
  24.    g_signal_connect (parenWindow, "window-state-event", G_CALLBACK(redraw_image), NULL);
  25. }
  26.  
  27. int main (int argc, char **argv) {
  28.    GtkApplication *app;
  29.    int status;
  30.  
  31.    app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  32.    g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  33.    status = g_application_run (G_APPLICATION (app), argc, argv);
  34.    g_object_unref (app);
  35.  
  36.    return status;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top