removed building of a test application for target 'all'
[simple-launcher] / misc / set-hints
1 static void
2 set_hints (GtkWidget *widget)
3 {
4         ZvtTerm *term;
5   GdkGeometry hints;
6   GtkWidget *app;
7
8   g_assert (widget != NULL);
9   term = ZVT_TERM (widget);
10
11   app = gtk_widget_get_toplevel(widget);
12   g_assert (app != NULL);
13
14 #define PADDING 2
15   hints.base_width = (GTK_WIDGET (term)->style->klass->xthickness * 2) + PADDING;
16   hints.base_height =  (GTK_WIDGET (term)->style->klass->ythickness * 2);
17
18   hints.width_inc = term->charwidth;
19   hints.height_inc = term->charheight;
20
21   hints.min_width = hints.base_width + hints.width_inc;
22   hints.min_height = hints.base_height + hints.height_inc;
23
24   gtk_window_set_geometry_hints(GTK_WINDOW(app),
25               GTK_WIDGET(term),
26               &hints,
27               GDK_HINT_RESIZE_INC|GDK_HINT_MIN_SIZE|GDK_HINT_BASE_SIZE);
28 }
29   
30
31 The example above sets the window hints so that the window manager will force resizes to the nearest character, and report the character dimensions if it provides that functionality.
32
33 It should be attached to the terminal instance using gtk_signal_connect_after() so that the hints are set after the window is realized.
34
35 Example 3. Attaching the realize handler to the terminal
36
37   gtk_signal_connect_after (
38       GTK_OBJECT (term),
39       "realize",
40       GTK_SIGNAL_FUNC (set_hints),
41       term);
42