root/gtkimageview/tests/ex-alignment.c

Revision 142, 1.3 kB (checked in by bjourne, 6 years ago)

Improve the test test_default_state(), modify gtk_image_view_new() so
that the test passes.

Line 
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*- */
2 #include <src/gtkimagescrollwin.h>
3 #include <src/gtkimageview.h>
4
5 int
6 main (int argc, char *argv[])
7 {
8     printf ("This program demonstrates how to put a GtkImageView\n"
9             "inside an alignment widget.\n");
10
11     gtk_init (&argc, &argv);
12     GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
13
14     /* Create the GtkImageView and set it to show an image. */
15     GtkWidget *view = gtk_image_view_new ();
16     char *fname = "tests/gnome_logo.jpg";
17     GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (fname, NULL);
18     gtk_image_view_set_pixbuf (GTK_IMAGE_VIEW (view), pixbuf, TRUE);
19     /* Make the background black to easier see the views borders. */
20     gtk_image_view_set_black_bg (GTK_IMAGE_VIEW (view), TRUE);
21
22     /* Create the GtkImageScrollWin to contain the view. */
23     GtkWidget *scroll_win = gtk_image_scroll_win_new (GTK_IMAGE_VIEW (view));
24
25     /* Create an alignment that contains the scroll win. */
26     GtkWidget *alignment = gtk_alignment_new (0.5, 0.5, 0.5, 0.5);
27     gtk_container_add (GTK_CONTAINER (alignment), scroll_win);
28
29     gtk_container_add (GTK_CONTAINER (window), alignment);
30     g_signal_connect (G_OBJECT (window), "delete_event",
31                       G_CALLBACK (gtk_main_quit), NULL);
32    
33     gtk_widget_show_all (window);
34     gtk_main ();
35 }
Note: See TracBrowser for help on using the browser.