1 /* XOSD
2
3 Copyright (c) 2001 Andre Renaud (andre@ignavus.net)
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gtk/gtk.h>
21
22 #include "bmp_osd.h"
23
24 GtkWidget *font_entry;
25
26 /*
27 * Apply font change and close dialog.
28 */
29 static int
font_dialog_ok(GtkButton * button,gpointer user_data)30 font_dialog_ok(GtkButton * button, gpointer user_data)
31 {
32 GtkWidget *font_dialog = user_data;
33 char *tmp_font;
34 DEBUG("font_dialog_ok");
35
36 assert(GTK_IS_FONT_SELECTION_DIALOG(font_dialog));
37
38 tmp_font = gtk_font_selection_dialog_get_font_name
39 (GTK_FONT_SELECTION_DIALOG(font_dialog));
40
41 gtk_entry_set_text(GTK_ENTRY(font_entry), tmp_font);
42
43 gtk_widget_destroy(font_dialog);
44
45 return 0;
46 }
47
48 /*
49 * Apply font change and close dialog.
50 */
51 static int
font_dialog_apply(GtkButton * button,gpointer user_data)52 font_dialog_apply(GtkButton * button, gpointer user_data)
53 {
54 GtkWidget *font_dialog = user_data;
55 char *tmp_font;
56 DEBUG("font_dialog_apply");
57
58 assert(GTK_IS_FONT_SELECTION_DIALOG(font_dialog));
59
60 tmp_font = gtk_font_selection_dialog_get_font_name
61 (GTK_FONT_SELECTION_DIALOG(font_dialog));
62
63 gtk_entry_set_text(GTK_ENTRY(font_entry), tmp_font);
64
65 return 0;
66 }
67
68 /*
69 * Create dialog window for font selection.
70 */
71 int
font_dialog_window(GtkButton * button,gpointer user_data)72 font_dialog_window(GtkButton * button, gpointer user_data)
73 {
74 GtkWidget *font_dialog;
75 GtkWidget *vbox;
76 GtkWidget *cancel_button, *apply_button, *ok_button;
77 GList *children;
78
79 DEBUG("font_dialog_window");
80 font_dialog = gtk_font_selection_dialog_new("XOSD Font");
81
82 assert(font_dialog);
83
84 if (font)
85 gtk_font_selection_dialog_set_font_name
86 (GTK_FONT_SELECTION_DIALOG(font_dialog), font);
87
88 children = gtk_container_children(GTK_CONTAINER(font_dialog));
89
90 vbox = GTK_WIDGET(children->data);
91
92 children = gtk_container_children(GTK_CONTAINER(vbox));
93
94 vbox = GTK_WIDGET(children->next->data);
95 children = gtk_container_children(GTK_CONTAINER(vbox));
96 ok_button = GTK_WIDGET(children->data);
97
98 apply_button = GTK_WIDGET(children->next->data);
99
100 cancel_button = GTK_WIDGET(children->next->next->data);
101
102 gtk_signal_connect_object(GTK_OBJECT(cancel_button), "clicked",
103 GTK_SIGNAL_FUNC(gtk_widget_destroy),
104 GTK_OBJECT(font_dialog));
105
106 gtk_signal_connect(GTK_OBJECT(ok_button), "clicked",
107 GTK_SIGNAL_FUNC(font_dialog_ok), font_dialog);
108 gtk_signal_connect(GTK_OBJECT(apply_button), "clicked",
109 GTK_SIGNAL_FUNC(font_dialog_apply), font_dialog);
110
111
112 gtk_widget_show_all(font_dialog);
113 return 0;
114 }
115
116 /* vim: tabstop=8 shiftwidth=8 noexpandtab
117 */
118