"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "gtkfind-1.1/gtk_print1.c" of archive gtkfind-1.1.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /* gtk_print1.c */
2 /* the gtk_print function from gtkmain.c, from the GTK library
3
4 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22
23 #include"gtk_print1.h"
24
25 void
26 gtk_print1 (gchar *str)
27 {
28 static GtkWidget *window = NULL;
29 static GtkWidget *text;
30 static int level = 0;
31 GtkWidget *box1;
32 GtkWidget *box2;
33 GtkWidget *table;
34 GtkWidget *hscrollbar;
35 GtkWidget *vscrollbar;
36 GtkWidget *separator;
37 GtkWidget *button;
38
39 if (level > 0)
40 {
41 fputs (str, stdout);
42 fflush (stdout);
43 return;
44 }
45
46 if (!window)
47 {
48 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
49
50 gtk_signal_connect (GTK_OBJECT (window), "destroy",
51 (GtkSignalFunc) gtk_widget_destroyed,
52 &window);
53
54 gtk_window_set_title (GTK_WINDOW (window), "gtkfind messages");
55
56 box1 = gtk_vbox_new (FALSE, 0);
57 gtk_container_add (GTK_CONTAINER (window), box1);
58 gtk_widget_show (box1);
59
60
61 box2 = gtk_vbox_new (FALSE, 10);
62 gtk_container_border_width (GTK_CONTAINER (box2), 10);
63 gtk_box_pack_start (GTK_BOX (box1), box2, TRUE, TRUE, 0);
64 gtk_widget_show (box2);
65
66
67 table = gtk_table_new (2, 2, FALSE);
68 gtk_table_set_row_spacing (GTK_TABLE (table), 0, 2);
69 gtk_table_set_col_spacing (GTK_TABLE (table), 0, 2);
70 gtk_box_pack_start (GTK_BOX (box2), table, TRUE, TRUE, 0);
71 gtk_widget_show (table);
72
73 text = gtk_text_new (NULL, NULL);
74 gtk_text_set_editable (GTK_TEXT (text), FALSE);
75 gtk_table_attach_defaults (GTK_TABLE (table), text, 0, 1, 0, 1);
76 gtk_widget_show (text);
77 gtk_widget_realize (text);
78
79 hscrollbar = gtk_hscrollbar_new (GTK_TEXT (text)->hadj);
80 gtk_table_attach (GTK_TABLE (table), hscrollbar, 0, 1, 1, 2,
81 GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0);
82 gtk_widget_show (hscrollbar);
83
84 vscrollbar = gtk_vscrollbar_new (GTK_TEXT (text)->vadj);
85 gtk_table_attach (GTK_TABLE (table), vscrollbar, 1, 2, 0, 1,
86 GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
87 gtk_widget_show (vscrollbar);
88
89 separator = gtk_hseparator_new ();
90 gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
91 gtk_widget_show (separator);
92
93
94 box2 = gtk_vbox_new (FALSE, 10);
95 gtk_container_border_width (GTK_CONTAINER (box2), 10);
96 gtk_box_pack_start (GTK_BOX (box1), box2, FALSE, TRUE, 0);
97 gtk_widget_show (box2);
98
99
100 button = gtk_button_new_with_label ("close");
101 gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
102 (GtkSignalFunc) gtk_widget_hide,
103 GTK_OBJECT (window));
104 gtk_box_pack_start (GTK_BOX (box2), button, TRUE, TRUE, 0);
105 GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
106 gtk_widget_grab_default (button);
107 gtk_widget_show (button);
108 }
109
110 level += 1;
111 gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, str, -1);
112 level -= 1;
113
114 if (!GTK_WIDGET_VISIBLE (window))
115 gtk_widget_show (window);
116 }