]> Pileus Git - ~andy/gtk/blob - tests/testellipsise.c
exit on close.
[~andy/gtk] / tests / testellipsise.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free
16  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18
19 /*
20  * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
21  * file for a list of people on the GTK+ Team.  See the ChangeLog
22  * files for a list of changes.  These files are distributed with
23  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
24  */
25
26 #include <gtk/gtk.h>
27
28 static void
29 combo_changed_cb (GtkWidget *combo,
30                   gpointer   data)
31 {
32   GtkWidget *label = GTK_WIDGET (data);
33   gint active;
34
35   active = gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
36   
37   gtk_label_set_ellipsize (GTK_LABEL (label), (PangoEllipsizeMode)active);
38 }
39
40 int
41 main (int argc, char *argv[])
42 {
43   GtkWidget *window, *vbox, *hbox, *label, *combo;
44
45   gtk_init (&argc, &argv);
46
47   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
48   g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
49   vbox = gtk_vbox_new (0, FALSE);
50   gtk_container_add (GTK_CONTAINER (window), vbox);
51   hbox = gtk_hbox_new (0, FALSE);
52   gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
53   label = gtk_label_new ("This label may be ellipsized\nto make it fit.");
54   gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
55   combo = gtk_combo_box_new_text ();
56   gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "NONE");
57   gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "START");
58   gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "MIDDLE");
59   gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "END");
60   gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
61   gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
62   g_signal_connect (combo, "changed", G_CALLBACK (combo_changed_cb), label);
63
64   gtk_widget_show_all (window);
65
66   gtk_main ();
67
68   return 0;
69 }