root/gtkimageview/tests/ex-alignment.c

Revision 231, 1.4 kB (checked in by bjourne, 1 year ago)

Add a program that demonstrates setting the size request of GtkImageScrollWin.

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,
7       char *argv[])
8 {
9     printf ("This program demonstrates how to put a GtkImageView\n"
10             "inside an alignment widget.\n");
11
12     gtk_init (&argc, &argv);
13     GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
14
15     /* Create the GtkImageView and set it to show an image. */
16     GtkWidget *view = gtk_image_view_new ();
17     char *fname = "tests/gnome_logo.jpg";
18     GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (fname, NULL);
19     gtk_image_view_set_pixbuf (GTK_IMAGE_VIEW (view), pixbuf, TRUE);
20     /* Make the background black to easier see the views borders. */
21     gtk_image_view_set_black_bg (GTK_IMAGE_VIEW (view), TRUE);
22
23     /* Create the GtkImageScrollWin to contain the view. */
24     GtkWidget *scroll_win = gtk_image_scroll_win_new (GTK_IMAGE_VIEW (view));
25
26     /* Create an alignment that contains the scroll win. */
27     GtkWidget *alignment = gtk_alignment_new (0.5, 0.5, 0.5, 0.5);
28     gtk_container_add (GTK_CONTAINER (alignment), scroll_win);
29
30     gtk_container_add (GTK_CONTAINER (window), alignment);
31     g_signal_connect (G_OBJECT (window), "delete_event",
32                       G_CALLBACK (gtk_main_quit), NULL);
33    
34     gtk_widget_show_all (window);
35     gtk_main ();
36 }
Note: See TracBrowser for help on using the browser.