Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <gtk/gtk.h>
- #include <gdk-pixbuf/gdk-pixbuf.h>
- GtkWidget *scrollWindow;
- GtkWidget *parenWindow;
- GtkWidget *imageWidget;
- void redraw_image(GtkWidget *parenWindow, gpointer data){
- GdkPixbuf *imagePixbuf = gdk_pixbuf_new_from_file("albumart.png", NULL);
- imagePixbuf = gdk_pixbuf_scale_simple(imagePixbuf, 400, 400, GDK_INTERP_BILINEAR);
- imageWidget = gtk_image_new_from_pixbuf(imagePixbuf);
- gtk_container_add(GTK_CONTAINER(scrollWindow), imageWidget);
- }
- void activate (GtkApplication *app, gpointer user_data) {
- parenWindow = gtk_application_window_new(app);
- gtk_window_set_default_size (GTK_WINDOW (parenWindow), 400, 400);
- scrollWindow = gtk_scrolled_window_new(NULL, NULL);
- gtk_container_add (GTK_CONTAINER(parenWindow), scrollWindow);
- gtk_widget_show_all (parenWindow);
- g_signal_connect (parenWindow, "window-state-event", G_CALLBACK(redraw_image), NULL);
- }
- int main (int argc, char **argv) {
- GtkApplication *app;
- int status;
- app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
- g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
- status = g_application_run (G_APPLICATION (app), argc, argv);
- g_object_unref (app);
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement