36
|
1 #include <sys/types.h>
|
|
2 #include <sys/stat.h>
|
|
3 #include <unistd.h>
|
|
4 #include <string.h>
|
|
5
|
|
6 #include <gdk/gdkkeysyms.h>
|
|
7 #include <gtk/gtk.h>
|
|
8
|
|
9 #include "config.h"
|
|
10
|
|
11 #include "config_gui.h"
|
|
12
|
|
13 #if 0
|
|
14 static gchar *check_file_exists (const gchar *directory, const gchar *filename);
|
|
15 static GtkWidget *create_pixmap (GtkWidget *widget, const gchar *filename);
|
|
16 static GtkWidget *create_dummy_pixmap (GtkWidget *widget);
|
|
17 /*static GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name);*/
|
|
18 static void add_pixmap_directory (const gchar *directory);
|
|
19
|
|
20 ConfigWin *lv_xmms_config_gui_new (void)
|
|
21 {
|
|
22 ConfigWin *config_gui;
|
|
23
|
|
24 GtkWidget *window_main;
|
|
25 GtkWidget *vbox_main;
|
|
26 GtkWidget *frame_vis_plugin;
|
|
27 GtkWidget *vbox3;
|
|
28 GtkWidget *scrolledwindow_vis_plugins;
|
|
29 GtkWidget *viewport1;
|
|
30 GtkWidget *list_vis_plugins;
|
|
31 GtkWidget *hbox_vis_plugin_controls;
|
|
32 GtkWidget *hbox_vis_plugin_buttons;
|
|
33 GtkWidget *button_vis_plugin_conf;
|
|
34 GtkWidget *button_vis_plugin_about;
|
|
35 GtkWidget *checkbutton_vis_plugin;
|
|
36 GtkWidget *checkbutton_fullscreen;
|
|
37 GSList *buttongroup_plugins_group = NULL;
|
|
38 GtkWidget *radiobutton_all_plugins;
|
|
39 GtkWidget *radiobutton_onlynongl;
|
|
40 GtkWidget *radiobutton_onlygl;
|
|
41 GtkWidget *hbox_fps;
|
|
42 GtkWidget *label_fps;
|
|
43 GtkObject *spinbutton_fps_adj;
|
|
44 GtkWidget *spinbutton_fps;
|
|
45 GtkWidget *frame_morph_plugin;
|
|
46 GtkWidget *vbox_morph_plugin;
|
|
47 GtkWidget *optionmenu_morph_plugin;
|
|
48 GtkWidget *optionmenu_morph_plugin_menu;
|
|
49 GtkWidget *hbox_morph_plugin_controls;
|
|
50 GtkWidget *hbox_morph_plugin_buttons;
|
|
51 GtkWidget *button_morph_plugin_conf;
|
|
52 GtkWidget *button_morph_plugin_about;
|
|
53 GtkWidget *checkbutton_morph_random;
|
|
54 GtkWidget *hbox_main_buttons;
|
|
55 GtkWidget *button_ok;
|
|
56 GtkWidget *button_apply;
|
|
57 GtkWidget *button_cancel;
|
|
58 GtkTooltips *tooltips;
|
|
59
|
|
60 tooltips = gtk_tooltips_new ();
|
|
61
|
|
62 add_pixmap_directory (PACKAGE_DATADIR);
|
|
63
|
|
64 window_main = gtk_window_new (GTK_WINDOW_DIALOG);
|
|
65 gtk_object_set_data (GTK_OBJECT (window_main), "window_main", window_main);
|
|
66 gtk_window_set_title (GTK_WINDOW (window_main), _("LibVisual XMMS Plugin"));
|
|
67 gtk_window_set_position (GTK_WINDOW (window_main), GTK_WIN_POS_CENTER);
|
|
68 gtk_window_set_default_size (GTK_WINDOW (window_main), -1, 450);
|
|
69
|
|
70 vbox_main = gtk_vbox_new (FALSE, 0);
|
|
71 gtk_widget_ref (vbox_main);
|
|
72 gtk_object_set_data_full (GTK_OBJECT (window_main), "vbox_main", vbox_main,
|
|
73 (GtkDestroyNotify) gtk_widget_unref);
|
|
74 gtk_widget_show (vbox_main);
|
|
75 gtk_container_add (GTK_CONTAINER (window_main), vbox_main);
|
|
76 gtk_container_set_border_width (GTK_CONTAINER (vbox_main), 6);
|
|
77
|
|
78 frame_vis_plugin = gtk_frame_new (_("Visualization Plugins"));
|
|
79 gtk_widget_ref (frame_vis_plugin);
|
|
80 gtk_object_set_data_full (GTK_OBJECT (window_main), "frame_vis_plugin", frame_vis_plugin,
|
|
81 (GtkDestroyNotify) gtk_widget_unref);
|
|
82 gtk_widget_show (frame_vis_plugin);
|
|
83 gtk_box_pack_start (GTK_BOX (vbox_main), frame_vis_plugin, TRUE, TRUE, 0);
|
|
84 gtk_container_set_border_width (GTK_CONTAINER (frame_vis_plugin), 2);
|
|
85
|
|
86 vbox3 = gtk_vbox_new (FALSE, 0);
|
|
87 gtk_widget_ref (vbox3);
|
|
88 gtk_object_set_data_full (GTK_OBJECT (window_main), "vbox3", vbox3,
|
|
89 (GtkDestroyNotify) gtk_widget_unref);
|
|
90 gtk_widget_show (vbox3);
|
|
91 gtk_container_add (GTK_CONTAINER (frame_vis_plugin), vbox3);
|
|
92
|
|
93 scrolledwindow_vis_plugins = gtk_scrolled_window_new (NULL, NULL);
|
|
94 gtk_widget_ref (scrolledwindow_vis_plugins);
|
|
95 gtk_object_set_data_full (GTK_OBJECT (window_main), "scrolledwindow_vis_plugins", scrolledwindow_vis_plugins,
|
|
96 (GtkDestroyNotify) gtk_widget_unref);
|
|
97 gtk_widget_show (scrolledwindow_vis_plugins);
|
|
98 gtk_box_pack_start (GTK_BOX (vbox3), scrolledwindow_vis_plugins, TRUE, TRUE, 0);
|
|
99 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow_vis_plugins), 2);
|
|
100 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_vis_plugins), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
|
|
101
|
|
102 viewport1 = gtk_viewport_new (NULL, NULL);
|
|
103 gtk_widget_ref (viewport1);
|
|
104 gtk_object_set_data_full (GTK_OBJECT (window_main), "viewport1", viewport1,
|
|
105 (GtkDestroyNotify) gtk_widget_unref);
|
|
106 gtk_widget_show (viewport1);
|
|
107 gtk_container_add (GTK_CONTAINER (scrolledwindow_vis_plugins), viewport1);
|
|
108
|
|
109 list_vis_plugins = gtk_list_new ();
|
|
110 gtk_widget_ref (list_vis_plugins);
|
|
111 gtk_object_set_data_full (GTK_OBJECT (window_main), "list_vis_plugins", list_vis_plugins,
|
|
112 (GtkDestroyNotify) gtk_widget_unref);
|
|
113 gtk_widget_show (list_vis_plugins);
|
|
114 gtk_container_add (GTK_CONTAINER (viewport1), list_vis_plugins);
|
|
115 gtk_list_set_selection_mode (GTK_LIST (list_vis_plugins), GTK_SELECTION_SINGLE);
|
|
116
|
|
117 hbox_vis_plugin_controls = gtk_hbox_new (FALSE, 0);
|
|
118 gtk_widget_ref (hbox_vis_plugin_controls);
|
|
119 gtk_object_set_data_full (GTK_OBJECT (window_main), "hbox_vis_plugin_controls", hbox_vis_plugin_controls,
|
|
120 (GtkDestroyNotify) gtk_widget_unref);
|
|
121 gtk_widget_show (hbox_vis_plugin_controls);
|
|
122 gtk_box_pack_start (GTK_BOX (vbox3), hbox_vis_plugin_controls, FALSE, FALSE, 0);
|
|
123 gtk_container_set_border_width (GTK_CONTAINER (hbox_vis_plugin_controls), 2);
|
|
124
|
|
125 hbox_vis_plugin_buttons = gtk_hbox_new (TRUE, 0);
|
|
126 gtk_widget_ref (hbox_vis_plugin_buttons);
|
|
127 gtk_object_set_data_full (GTK_OBJECT (window_main), "hbox_vis_plugin_buttons", hbox_vis_plugin_buttons,
|
|
128 (GtkDestroyNotify) gtk_widget_unref);
|
|
129 gtk_widget_show (hbox_vis_plugin_buttons);
|
|
130 gtk_box_pack_start (GTK_BOX (hbox_vis_plugin_controls), hbox_vis_plugin_buttons, FALSE, TRUE, 0);
|
|
131
|
|
132 button_vis_plugin_conf = gtk_button_new_with_label (_("Configure"));
|
|
133 gtk_widget_ref (button_vis_plugin_conf);
|
|
134 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_vis_plugin_conf", button_vis_plugin_conf,
|
|
135 (GtkDestroyNotify) gtk_widget_unref);
|
|
136 gtk_widget_show (button_vis_plugin_conf);
|
|
137 gtk_box_pack_start (GTK_BOX (hbox_vis_plugin_buttons), button_vis_plugin_conf, FALSE, TRUE, 0);
|
|
138 gtk_container_set_border_width (GTK_CONTAINER (button_vis_plugin_conf), 2);
|
|
139
|
|
140 button_vis_plugin_about = gtk_button_new_with_label (_("About"));
|
|
141 gtk_widget_ref (button_vis_plugin_about);
|
|
142 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_vis_plugin_about", button_vis_plugin_about,
|
|
143 (GtkDestroyNotify) gtk_widget_unref);
|
|
144 gtk_widget_show (button_vis_plugin_about);
|
|
145 gtk_box_pack_start (GTK_BOX (hbox_vis_plugin_buttons), button_vis_plugin_about, FALSE, TRUE, 0);
|
|
146 gtk_container_set_border_width (GTK_CONTAINER (button_vis_plugin_about), 2);
|
|
147
|
|
148 checkbutton_vis_plugin = gtk_check_button_new_with_label (_("Enable/Disable"));
|
|
149 gtk_widget_ref (checkbutton_vis_plugin);
|
|
150 gtk_object_set_data_full (GTK_OBJECT (window_main), "checkbutton_vis_plugin", checkbutton_vis_plugin,
|
|
151 (GtkDestroyNotify) gtk_widget_unref);
|
|
152 gtk_widget_show (checkbutton_vis_plugin);
|
|
153 gtk_box_pack_end (GTK_BOX (hbox_vis_plugin_controls), checkbutton_vis_plugin, FALSE, TRUE, 0);
|
|
154 gtk_container_set_border_width (GTK_CONTAINER (checkbutton_vis_plugin), 2);
|
|
155
|
|
156 checkbutton_fullscreen = gtk_check_button_new_with_label (_("Fullscreen"));
|
|
157 gtk_widget_ref (checkbutton_fullscreen);
|
|
158 gtk_object_set_data_full (GTK_OBJECT (window_main), "checkbutton_fullscreen", checkbutton_fullscreen,
|
|
159 (GtkDestroyNotify) gtk_widget_unref);
|
|
160 gtk_widget_show (checkbutton_fullscreen);
|
|
161 gtk_box_pack_start (GTK_BOX (vbox3), checkbutton_fullscreen, FALSE, FALSE, 0);
|
|
162 gtk_tooltips_set_tip (tooltips, checkbutton_fullscreen, _("You can toggle between normal and fullscreen mode pressing key TAB or F11"), NULL);
|
|
163
|
|
164 radiobutton_all_plugins = gtk_radio_button_new_with_label (buttongroup_plugins_group, _("All plugins"));
|
|
165 buttongroup_plugins_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton_all_plugins));
|
|
166 gtk_widget_ref (radiobutton_all_plugins);
|
|
167 gtk_object_set_data_full (GTK_OBJECT (window_main), "radiobutton_all_plugins", radiobutton_all_plugins,
|
|
168 (GtkDestroyNotify) gtk_widget_unref);
|
|
169 gtk_widget_show (radiobutton_all_plugins);
|
|
170 gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_all_plugins, FALSE, FALSE, 0);
|
|
171
|
|
172 radiobutton_onlynongl = gtk_radio_button_new_with_label (buttongroup_plugins_group, _("Only non GL plugins"));
|
|
173 buttongroup_plugins_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton_onlynongl));
|
|
174 gtk_widget_ref (radiobutton_onlynongl);
|
|
175 gtk_object_set_data_full (GTK_OBJECT (window_main), "radiobutton_onlynongl", radiobutton_onlynongl,
|
|
176 (GtkDestroyNotify) gtk_widget_unref);
|
|
177 gtk_widget_show (radiobutton_onlynongl);
|
|
178 gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_onlynongl, FALSE, FALSE, 0);
|
|
179
|
|
180 radiobutton_onlygl = gtk_radio_button_new_with_label (buttongroup_plugins_group, _("Only GL plugins"));
|
|
181 buttongroup_plugins_group = gtk_radio_button_group (GTK_RADIO_BUTTON (radiobutton_onlygl));
|
|
182 gtk_widget_ref (radiobutton_onlygl);
|
|
183 gtk_object_set_data_full (GTK_OBJECT (window_main), "radiobutton_onlygl", radiobutton_onlygl,
|
|
184 (GtkDestroyNotify) gtk_widget_unref);
|
|
185 gtk_widget_show (radiobutton_onlygl);
|
|
186 gtk_box_pack_start (GTK_BOX (vbox3), radiobutton_onlygl, FALSE, FALSE, 0);
|
|
187
|
|
188 hbox_fps = gtk_hbox_new (FALSE, 0);
|
|
189 gtk_widget_ref (hbox_fps);
|
|
190 gtk_object_set_data_full (GTK_OBJECT (window_main), "hbox_fps", hbox_fps,
|
|
191 (GtkDestroyNotify) gtk_widget_unref);
|
|
192 gtk_widget_show (hbox_fps);
|
|
193 gtk_box_pack_start (GTK_BOX (vbox3), hbox_fps, FALSE, FALSE, 0);
|
|
194 gtk_container_set_border_width (GTK_CONTAINER (hbox_fps), 2);
|
|
195
|
|
196 label_fps = gtk_label_new (_("Maximum Frames Per Second:"));
|
|
197 gtk_widget_ref (label_fps);
|
|
198 gtk_object_set_data_full (GTK_OBJECT (window_main), "label_fps", label_fps,
|
|
199 (GtkDestroyNotify) gtk_widget_unref);
|
|
200 gtk_widget_show (label_fps);
|
|
201 gtk_box_pack_start (GTK_BOX (hbox_fps), label_fps, FALSE, FALSE, 6);
|
|
202 gtk_label_set_justify (GTK_LABEL (label_fps), GTK_JUSTIFY_LEFT);
|
|
203
|
|
204 spinbutton_fps_adj = gtk_adjustment_new (30, 10, 100, 1, 10, 10);
|
|
205 spinbutton_fps = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_fps_adj), 1, 0);
|
|
206 gtk_widget_ref (spinbutton_fps);
|
|
207 gtk_object_set_data_full (GTK_OBJECT (window_main), "spinbutton_fps", spinbutton_fps,
|
|
208 (GtkDestroyNotify) gtk_widget_unref);
|
|
209 gtk_widget_show (spinbutton_fps);
|
|
210 gtk_box_pack_start (GTK_BOX (hbox_fps), spinbutton_fps, FALSE, FALSE, 0);
|
|
211
|
|
212 frame_morph_plugin = gtk_frame_new (_("Morph Plugin"));
|
|
213 gtk_widget_ref (frame_morph_plugin);
|
|
214 gtk_object_set_data_full (GTK_OBJECT (window_main), "frame_morph_plugin", frame_morph_plugin,
|
|
215 (GtkDestroyNotify) gtk_widget_unref);
|
|
216 gtk_widget_show (frame_morph_plugin);
|
|
217 gtk_box_pack_start (GTK_BOX (vbox_main), frame_morph_plugin, FALSE, TRUE, 0);
|
|
218 gtk_container_set_border_width (GTK_CONTAINER (frame_morph_plugin), 2);
|
|
219
|
|
220 vbox_morph_plugin = gtk_vbox_new (FALSE, 0);
|
|
221 gtk_widget_ref (vbox_morph_plugin);
|
|
222 gtk_object_set_data_full (GTK_OBJECT (window_main), "vbox_morph_plugin", vbox_morph_plugin,
|
|
223 (GtkDestroyNotify) gtk_widget_unref);
|
|
224 gtk_widget_show (vbox_morph_plugin);
|
|
225 gtk_container_add (GTK_CONTAINER (frame_morph_plugin), vbox_morph_plugin);
|
|
226
|
|
227 optionmenu_morph_plugin = gtk_option_menu_new ();
|
|
228 gtk_widget_ref (optionmenu_morph_plugin);
|
|
229 gtk_object_set_data_full (GTK_OBJECT (window_main), "optionmenu_morph_plugin", optionmenu_morph_plugin,
|
|
230 (GtkDestroyNotify) gtk_widget_unref);
|
|
231 gtk_widget_show (optionmenu_morph_plugin);
|
|
232 gtk_box_pack_start (GTK_BOX (vbox_morph_plugin), optionmenu_morph_plugin, FALSE, FALSE, 0);
|
|
233 gtk_tooltips_set_tip (tooltips, optionmenu_morph_plugin, _("Select the kind of morph that will be applied when switching from one visualization plugin to another "), NULL);
|
|
234 optionmenu_morph_plugin_menu = gtk_menu_new ();
|
|
235 gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu_morph_plugin), optionmenu_morph_plugin_menu);
|
|
236
|
|
237 hbox_morph_plugin_controls = gtk_hbox_new (FALSE, 0);
|
|
238 gtk_widget_ref (hbox_morph_plugin_controls);
|
|
239 gtk_object_set_data_full (GTK_OBJECT (window_main), "hbox_morph_plugin_controls", hbox_morph_plugin_controls,
|
|
240 (GtkDestroyNotify) gtk_widget_unref);
|
|
241 gtk_widget_show (hbox_morph_plugin_controls);
|
|
242 gtk_box_pack_start (GTK_BOX (vbox_morph_plugin), hbox_morph_plugin_controls, TRUE, TRUE, 0);
|
|
243 gtk_container_set_border_width (GTK_CONTAINER (hbox_morph_plugin_controls), 2);
|
|
244
|
|
245 hbox_morph_plugin_buttons = gtk_hbox_new (TRUE, 0);
|
|
246 gtk_widget_ref (hbox_morph_plugin_buttons);
|
|
247 gtk_object_set_data_full (GTK_OBJECT (window_main), "hbox_morph_plugin_buttons", hbox_morph_plugin_buttons,
|
|
248 (GtkDestroyNotify) gtk_widget_unref);
|
|
249 gtk_widget_show (hbox_morph_plugin_buttons);
|
|
250 gtk_box_pack_start (GTK_BOX (hbox_morph_plugin_controls), hbox_morph_plugin_buttons, FALSE, FALSE, 0);
|
|
251
|
|
252 button_morph_plugin_conf = gtk_button_new_with_label (_("Configure"));
|
|
253 gtk_widget_ref (button_morph_plugin_conf);
|
|
254 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_morph_plugin_conf", button_morph_plugin_conf,
|
|
255 (GtkDestroyNotify) gtk_widget_unref);
|
|
256 gtk_widget_show (button_morph_plugin_conf);
|
|
257 gtk_box_pack_start (GTK_BOX (hbox_morph_plugin_buttons), button_morph_plugin_conf, FALSE, TRUE, 0);
|
|
258 gtk_container_set_border_width (GTK_CONTAINER (button_morph_plugin_conf), 2);
|
|
259
|
|
260 button_morph_plugin_about = gtk_button_new_with_label (_("About"));
|
|
261 gtk_widget_ref (button_morph_plugin_about);
|
|
262 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_morph_plugin_about", button_morph_plugin_about,
|
|
263 (GtkDestroyNotify) gtk_widget_unref);
|
|
264 gtk_widget_show (button_morph_plugin_about);
|
|
265 gtk_box_pack_start (GTK_BOX (hbox_morph_plugin_buttons), button_morph_plugin_about, FALSE, TRUE, 0);
|
|
266 gtk_container_set_border_width (GTK_CONTAINER (button_morph_plugin_about), 2);
|
|
267
|
|
268 checkbutton_morph_random = gtk_check_button_new_with_label (_("Select one morph plugin randomly"));
|
|
269 gtk_widget_ref (checkbutton_morph_random);
|
|
270 gtk_object_set_data_full (GTK_OBJECT (window_main), "checkbutton_morph_random", checkbutton_morph_random,
|
|
271 (GtkDestroyNotify) gtk_widget_unref);
|
|
272 gtk_widget_show (checkbutton_morph_random);
|
|
273 gtk_box_pack_start (GTK_BOX (vbox_morph_plugin), checkbutton_morph_random, FALSE, FALSE, 0);
|
|
274
|
|
275 hbox_main_buttons = gtk_hbox_new (TRUE, 0);
|
|
276 gtk_widget_ref (hbox_main_buttons);
|
|
277 gtk_object_set_data_full (GTK_OBJECT (window_main), "hbox_main_buttons", hbox_main_buttons,
|
|
278 (GtkDestroyNotify) gtk_widget_unref);
|
|
279 gtk_widget_show (hbox_main_buttons);
|
|
280 gtk_box_pack_start (GTK_BOX (vbox_main), hbox_main_buttons, FALSE, FALSE, 6);
|
|
281
|
|
282 button_ok = gtk_button_new_with_label (_("Accept"));
|
|
283 gtk_widget_ref (button_ok);
|
|
284 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_ok", button_ok,
|
|
285 (GtkDestroyNotify) gtk_widget_unref);
|
|
286 gtk_widget_show (button_ok);
|
|
287 gtk_box_pack_start (GTK_BOX (hbox_main_buttons), button_ok, FALSE, TRUE, 0);
|
|
288 GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT);
|
|
289
|
|
290 button_apply = gtk_button_new_with_label (_("Apply"));
|
|
291 gtk_widget_ref (button_apply);
|
|
292 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_apply", button_apply,
|
|
293 (GtkDestroyNotify) gtk_widget_unref);
|
|
294 gtk_widget_show (button_apply);
|
|
295 gtk_box_pack_start (GTK_BOX (hbox_main_buttons), button_apply, FALSE, TRUE, 6);
|
|
296 GTK_WIDGET_SET_FLAGS (button_apply, GTK_CAN_DEFAULT);
|
|
297
|
|
298 button_cancel = gtk_button_new_with_label (_("Cancel"));
|
|
299 gtk_widget_ref (button_cancel);
|
|
300 gtk_object_set_data_full (GTK_OBJECT (window_main), "button_cancel", button_cancel,
|
|
301 (GtkDestroyNotify) gtk_widget_unref);
|
|
302 gtk_widget_show (button_cancel);
|
|
303 gtk_box_pack_start (GTK_BOX (hbox_main_buttons), button_cancel, FALSE, TRUE, 6);
|
|
304 GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT);
|
|
305
|
|
306 gtk_object_set_data (GTK_OBJECT (window_main), "tooltips", tooltips);
|
|
307
|
|
308 config_gui = g_new0 (ConfigWin, 1);
|
|
309
|
|
310 config_gui->window_main = window_main;
|
|
311
|
|
312 config_gui->list_vis_plugins = list_vis_plugins;
|
|
313 config_gui->button_vis_plugin_conf = button_vis_plugin_conf;
|
|
314 config_gui->button_vis_plugin_about = button_vis_plugin_about;
|
|
315 config_gui->checkbutton_vis_plugin = checkbutton_vis_plugin;
|
|
316
|
|
317 config_gui->checkbutton_fullscreen = checkbutton_fullscreen;
|
|
318 config_gui->radiobutton_onlygl = radiobutton_onlygl;
|
|
319 config_gui->radiobutton_onlynongl = radiobutton_onlynongl;
|
|
320 config_gui->radiobutton_all_plugins = radiobutton_all_plugins;
|
|
321 config_gui->spinbutton_fps = spinbutton_fps;
|
|
322
|
|
323 config_gui->optionmenu_morph_plugin = optionmenu_morph_plugin;
|
|
324 config_gui->optionmenu_morph_plugin_group = NULL;
|
|
325 config_gui->button_morph_plugin_conf = button_morph_plugin_conf;
|
|
326 config_gui->button_morph_plugin_about = button_morph_plugin_about;
|
|
327 config_gui->checkbutton_morph_random = checkbutton_morph_random;
|
|
328
|
|
329 config_gui->button_ok = button_ok;
|
|
330 config_gui->button_apply = button_apply;
|
|
331 config_gui->button_cancel = button_cancel;
|
|
332
|
|
333 return config_gui;
|
|
334 }
|
|
335
|
|
336 /* This is a dummy pixmap we use when a pixmap can't be found. */
|
|
337 static char *dummy_pixmap_xpm[] = {
|
|
338 /* columns rows colors chars-per-pixel */
|
|
339 "1 1 1 1",
|
|
340 " c None",
|
|
341 /* pixels */
|
|
342 " "
|
|
343 };
|
|
344
|
|
345 static GtkWidget *create_dummy_pixmap (GtkWidget *widget)
|
|
346 {
|
|
347 GdkColormap *colormap;
|
|
348 GdkPixmap *gdkpixmap;
|
|
349 GdkBitmap *mask;
|
|
350 GtkWidget *pixmap;
|
|
351
|
|
352 colormap = gtk_widget_get_colormap (widget);
|
|
353 gdkpixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
|
|
354 NULL, dummy_pixmap_xpm);
|
|
355 if (gdkpixmap == NULL)
|
|
356 g_error (_("Couldn't create replacement pixmap."));
|
|
357 pixmap = gtk_pixmap_new (gdkpixmap, mask);
|
|
358 gdk_pixmap_unref (gdkpixmap);
|
|
359 gdk_bitmap_unref (mask);
|
|
360 return pixmap;
|
|
361 }
|
|
362
|
|
363 static GList *pixmaps_directories = NULL;
|
|
364
|
|
365 static void add_pixmap_directory (const gchar *directory)
|
|
366 {
|
|
367 pixmaps_directories = g_list_prepend (pixmaps_directories,
|
|
368 g_strdup (directory));
|
|
369 }
|
|
370
|
|
371 static GtkWidget *create_pixmap (GtkWidget *widget, const gchar *filename)
|
|
372 {
|
|
373 gchar *found_filename = NULL;
|
|
374 GdkColormap *colormap;
|
|
375 GdkPixmap *gdkpixmap;
|
|
376 GdkBitmap *mask;
|
|
377 GtkWidget *pixmap;
|
|
378 GList *elem;
|
|
379
|
|
380 if (!filename || !filename[0])
|
|
381 return create_dummy_pixmap (widget);
|
|
382
|
|
383 /* We first try any pixmaps directories set by the application. */
|
|
384 elem = pixmaps_directories;
|
|
385 while (elem)
|
|
386 {
|
|
387 found_filename = check_file_exists ((gchar*)elem->data, filename);
|
|
388 if (found_filename)
|
|
389 break;
|
|
390 elem = elem->next;
|
|
391 }
|
|
392
|
|
393 /* If we haven't found the pixmap, try the source directory. */
|
|
394 if (!found_filename)
|
|
395 {
|
|
396 found_filename = check_file_exists ("../pixmaps", filename);
|
|
397 }
|
|
398
|
|
399 if (!found_filename)
|
|
400 {
|
|
401 g_warning (_("Couldn't find pixmap file: %s"), filename);
|
|
402 return create_dummy_pixmap (widget);
|
|
403 }
|
|
404
|
|
405 colormap = gtk_widget_get_colormap (widget);
|
|
406 gdkpixmap = gdk_pixmap_colormap_create_from_xpm (NULL, colormap, &mask,
|
|
407 NULL, found_filename);
|
|
408 if (gdkpixmap == NULL)
|
|
409 {
|
|
410 g_warning (_("Error loading pixmap file: %s"), found_filename);
|
|
411 g_free (found_filename);
|
|
412 return create_dummy_pixmap (widget);
|
|
413 }
|
|
414 g_free (found_filename);
|
|
415 pixmap = gtk_pixmap_new (gdkpixmap, mask);
|
|
416 gdk_pixmap_unref (gdkpixmap);
|
|
417 gdk_bitmap_unref (mask);
|
|
418 return pixmap;
|
|
419 }
|
|
420
|
|
421 static gchar *check_file_exists (const gchar *directory, const gchar *filename)
|
|
422 {
|
|
423 gchar *full_filename;
|
|
424 struct stat s;
|
|
425 gint status;
|
|
426
|
|
427 full_filename = (gchar*) g_malloc (strlen (directory) + 1
|
|
428 + strlen (filename) + 1);
|
|
429 strcpy (full_filename, directory);
|
|
430 strcat (full_filename, G_DIR_SEPARATOR_S);
|
|
431 strcat (full_filename, filename);
|
|
432
|
|
433 status = stat (full_filename, &s);
|
|
434 if (status == 0 && S_ISREG (s.st_mode))
|
|
435 return full_filename;
|
|
436 g_free (full_filename);
|
|
437 return NULL;
|
|
438 }
|
|
439
|
|
440 /*static GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name)
|
|
441 {
|
|
442 GtkWidget *parent, *found_widget;
|
|
443
|
|
444 for (;;)
|
|
445 {
|
|
446 if (GTK_IS_MENU (widget))
|
|
447 parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
|
448 else
|
|
449 parent = widget->parent;
|
|
450 if (parent == NULL)
|
|
451 break;
|
|
452 widget = parent;
|
|
453 }
|
|
454
|
|
455 found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget),
|
|
456 widget_name);
|
|
457 if (!found_widget)
|
|
458 g_warning ("Widget not found: %s", widget_name);
|
|
459 return found_widget;
|
|
460 }*/
|
|
461
|
|
462 #endif
|