Mercurial > audlegacy
annotate Plugins/Visualization/paranormal/client.c @ 1532:f74a6ba233c2 trunk
[svn] - allow configdb::pnxmms::preset to set what pn preset to load on start
author | nenolod |
---|---|
date | Tue, 08 Aug 2006 02:19:55 -0700 |
parents | bdb22d1e6302 |
children | 984c99a1fb2e |
rev | line source |
---|---|
1521 | 1 /* pnxmms - An xmms visualization plugin using the Paranormal |
2 * audio visualization library | |
3 * | |
4 * Copyright (C) 2001 Jamie Gennis <jgennis@mindspring.com> | |
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 Free | |
18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 */ | |
20 | |
21 #ifdef HAVE_CONFIG_H | |
22 #include <config.h> | |
23 #endif | |
24 | |
25 #include <sys/types.h> | |
26 #include <sys/stat.h> | |
27 #include <unistd.h> | |
28 #include <stdio.h> | |
29 #include <errno.h> | |
30 | |
31 #include <gtk/gtk.h> | |
32 #include <audacious/plugin.h> | |
33 #include <audacious/configdb.h> | |
34 #include <SDL/SDL.h> | |
35 #include <SDL/SDL_thread.h> | |
36 | |
37 #include "pn.h" | |
38 | |
39 /* Paranormal visualization object */ | |
40 static PnVis *vis; | |
41 | |
42 /* Paranormal audio data object */ | |
43 static PnAudioData *audio_data; | |
44 | |
45 /* SDL window's surface */ | |
46 static SDL_Surface *screen; | |
47 | |
48 /* Synchronization stuffs */ | |
49 static SDL_Thread *render_thread; | |
50 static int render_func (void *data); | |
51 static gboolean kill_render_thread; | |
52 static gboolean quit_timeout_func (gpointer data); | |
53 static guint quit_timeout; | |
54 static gboolean render_thread_finished; | |
55 | |
56 static SDL_mutex *vis_mutex; | |
57 static SDL_mutex *audio_data_mutex; | |
58 static gfloat intermediate_pcm_data[3][512]; | |
59 static gfloat intermediate_freq_data[3][256]; | |
60 | |
61 /* PNXMMS Options */ | |
62 static gboolean options_read = FALSE; | |
63 static gboolean preset_changed = FALSE; | |
64 static gchar *preset; | |
65 static guint image_width = 320; | |
66 static guint image_height = 240; | |
67 | |
68 /* Config dialog */ | |
69 GtkWidget *config_dialog; | |
70 GtkWidget *load_button; | |
71 | |
72 /* Config functions */ | |
73 static void read_options (void); | |
74 static void write_options (void); | |
75 static void load_default_vis (void); | |
76 static void create_config_dialog (void); | |
77 | |
78 /* Rendering functions */ | |
79 static void draw_image (PnImage *image); | |
80 | |
81 /* XMMS interface */ | |
82 static void pn_xmms_init (void); | |
83 static void pn_xmms_cleanup (void); | |
84 static void pn_xmms_about (void); | |
85 static void pn_xmms_configure (void); | |
86 static void pn_xmms_render_pcm (gint16 data[2][512]); | |
87 static void pn_xmms_render_freq (gint16 data[2][256]); | |
88 | |
89 static VisPlugin pn_xmms_vp = | |
90 { | |
91 NULL, /* handle */ | |
92 NULL, /* filename */ | |
93 0, /* xmms_session */ | |
1524 | 94 "Paranormal Visualization Studio " VERSION, |
1521 | 95 2, |
96 2, | |
97 pn_xmms_init, | |
98 pn_xmms_cleanup, | |
99 NULL, /* pn_xmms_about, */ | |
100 pn_xmms_configure, | |
101 NULL, /* disable_plugin */ | |
102 NULL, /* playback_start */ | |
103 NULL, /* pkayback_stop */ | |
104 pn_xmms_render_pcm, | |
105 pn_xmms_render_freq | |
106 }; | |
107 | |
108 VisPlugin* | |
109 get_vplugin_info (void) | |
110 { | |
111 return &pn_xmms_vp; | |
112 } | |
113 | |
114 static void | |
115 pn_xmms_init (void) | |
116 { | |
117 /* Load the saved options */ | |
118 read_options (); | |
119 | |
120 /* Initialize SDL */ | |
121 if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) | |
122 { | |
123 g_warning ("Unable to initialize SDL: %s\n", SDL_GetError ()); | |
124 pn_xmms_vp.disable_plugin (&pn_xmms_vp); | |
125 } | |
126 | |
127 screen = SDL_SetVideoMode (image_width, image_height, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE); | |
128 if (! screen) | |
129 { | |
130 g_warning ("Unable to create a new SDL window: %s\n", SDL_GetError ()); | |
131 pn_xmms_vp.disable_plugin (&pn_xmms_vp); | |
132 } | |
133 | |
1524 | 134 SDL_WM_SetCaption ("Paranormal Visualization Studio " VERSION, PACKAGE); |
1521 | 135 |
136 /* Initialize Paranormal */ | |
137 pn_init (); | |
138 | |
139 /* Set up the visualization objects */ | |
140 vis = pn_vis_new (image_width, image_height); | |
141 pn_object_ref (PN_OBJECT (vis)); | |
142 pn_object_sink (PN_OBJECT (vis)); | |
143 | |
144 if (! preset || ! pn_vis_load_from_file (vis, preset)) | |
145 load_default_vis (); | |
146 | |
147 audio_data = pn_audio_data_new (); | |
148 pn_object_ref (PN_OBJECT (audio_data)); | |
149 pn_object_sink (PN_OBJECT (audio_data)); | |
150 pn_audio_data_set_stereo (audio_data, FALSE); | |
151 pn_audio_data_set_pcm_samples (audio_data, 512); | |
152 pn_audio_data_set_freq_bands (audio_data, 256); | |
153 | |
154 /* Set up the render thread */ | |
155 audio_data_mutex = SDL_CreateMutex (); | |
156 vis_mutex = SDL_CreateMutex (); | |
157 if (! audio_data_mutex || ! vis_mutex) | |
158 { | |
159 g_warning ("Unable to create mutex: %s\n", SDL_GetError ()); | |
160 pn_xmms_vp.disable_plugin (&pn_xmms_vp); | |
161 } | |
162 | |
163 kill_render_thread = FALSE; | |
164 render_thread_finished = FALSE; | |
165 render_thread = SDL_CreateThread (render_func, NULL); | |
166 if (! render_thread) | |
167 { | |
168 g_warning ("Unable to create render thread: %s\n", SDL_GetError ()); | |
169 pn_xmms_vp.disable_plugin (&pn_xmms_vp); | |
170 } | |
171 | |
172 /* Create the quit-checker timeout */ | |
173 quit_timeout = gtk_timeout_add (500, quit_timeout_func, NULL); | |
174 } | |
175 | |
176 static void | |
177 pn_xmms_cleanup (void) | |
178 { | |
179 if (quit_timeout != 0) | |
180 { | |
181 gtk_timeout_remove (quit_timeout); | |
182 quit_timeout = 0; | |
183 } | |
184 | |
185 if (render_thread) | |
186 { | |
187 kill_render_thread = TRUE; | |
188 SDL_WaitThread (render_thread, NULL); | |
189 render_thread = NULL; | |
190 } | |
191 | |
192 if (audio_data_mutex) | |
193 { | |
194 SDL_DestroyMutex (audio_data_mutex); | |
195 audio_data_mutex = NULL; | |
196 } | |
197 | |
198 if (screen) | |
199 { | |
200 SDL_FreeSurface (screen); | |
201 screen = NULL; | |
202 } | |
203 SDL_Quit (); | |
204 | |
205 if (vis) | |
206 { | |
207 pn_object_unref (PN_OBJECT (vis)); | |
208 vis = NULL; | |
209 } | |
210 | |
211 write_options (); | |
212 } | |
213 | |
214 static void | |
215 pn_xmms_about (void) | |
216 { | |
217 /* FIXME: This needs to wait until XMMS supports GTK+ 2.0 */ | |
218 } | |
219 | |
220 static void | |
221 pn_xmms_configure (void) | |
222 { | |
223 read_options (); | |
224 create_config_dialog (); | |
225 } | |
226 | |
227 static void | |
228 pn_xmms_render_pcm (gint16 data[2][512]) | |
229 { | |
230 guint i; | |
231 | |
232 /* Set up the audio data */ | |
233 for (i=0; i<512; i++) | |
234 { | |
235 intermediate_pcm_data[PN_CHANNEL_LEFT][i] = (gfloat)(data[0][i]) / 32768.0; | |
236 intermediate_pcm_data[PN_CHANNEL_RIGHT][i] = (gfloat)(data[0][i]) / 32768.0; | |
237 intermediate_pcm_data[PN_CHANNEL_CENTER][i] = .5 * (intermediate_pcm_data[PN_CHANNEL_LEFT][i] | |
238 + intermediate_pcm_data[PN_CHANNEL_RIGHT][i]); | |
239 } | |
240 } | |
241 | |
242 static void | |
243 pn_xmms_render_freq (gint16 data[2][256]) | |
244 { | |
245 guint i; | |
246 | |
247 /* Set up the audio data */ | |
248 for (i=0; i<256; i++) | |
249 { | |
250 intermediate_freq_data[PN_CHANNEL_LEFT][i] = (gfloat)(data[0][i]) / 32768.0; | |
251 intermediate_freq_data[PN_CHANNEL_RIGHT][i] = (gfloat)(data[0][i]) / 32768.0; | |
252 intermediate_freq_data[PN_CHANNEL_CENTER][i] = .5 * (intermediate_freq_data[PN_CHANNEL_LEFT][i] | |
253 + intermediate_freq_data[PN_CHANNEL_RIGHT][i]); | |
254 } | |
255 } | |
256 | |
257 static gboolean | |
258 quit_timeout_func (gpointer data) | |
259 { | |
260 if (render_thread_finished) | |
261 { | |
262 pn_xmms_vp.disable_plugin (&pn_xmms_vp); | |
263 quit_timeout = 0; | |
264 return FALSE; | |
265 } | |
266 return TRUE; | |
267 } | |
268 | |
269 static int | |
270 render_func (void *data) | |
271 { | |
272 guint i; | |
273 PnImage *image; | |
274 guint last_time = 0, last_second = 0; | |
275 gfloat fps = 0.0; | |
276 guint this_time; | |
277 SDL_Event event; | |
278 | |
279 while (! kill_render_thread) | |
280 { | |
281 /* Lock & copy the audio data */ | |
282 SDL_mutexP (audio_data_mutex); | |
283 | |
284 for (i=0; i<3; i++) | |
285 { | |
286 memcpy (PN_AUDIO_DATA_PCM_DATA (audio_data, i), intermediate_pcm_data[i], 512 * sizeof (gfloat)); | |
287 memcpy (PN_AUDIO_DATA_FREQ_DATA (audio_data, i), intermediate_freq_data[i], 256 * sizeof (gfloat)); | |
288 } | |
289 | |
290 SDL_mutexV (audio_data_mutex); | |
291 | |
292 pn_audio_data_update (audio_data); | |
293 | |
294 /* Render the image */ | |
295 SDL_mutexP (vis_mutex); | |
296 image = pn_vis_render (vis, audio_data); | |
297 SDL_mutexV (vis_mutex); | |
298 | |
299 /* Draw the image */ | |
300 draw_image (image); | |
301 | |
302 /* Compute the FPS */ | |
303 this_time = SDL_GetTicks (); | |
304 | |
305 fps = fps * .95 + (1000.0 / (gfloat) (this_time - last_time)) * .05; | |
306 if (this_time > 2000 + last_second) | |
307 { | |
308 last_second = this_time; | |
309 printf ("paranormal fps: %f\n", fps); | |
310 } | |
311 last_time = this_time; | |
312 | |
313 /* Handle window events */ | |
314 while (SDL_PollEvent (&event)) | |
315 { | |
316 switch (event.type) | |
317 { | |
318 case SDL_QUIT: | |
319 render_thread_finished = TRUE; | |
320 return 0; | |
321 | |
322 case SDL_VIDEORESIZE: | |
323 image_width = event.resize.w; | |
324 image_height = event.resize.h; | |
325 screen = SDL_SetVideoMode (image_width, image_height, 32, | |
326 SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE); | |
327 printf ("changed to: w: %u, h: %u\n", image_width, image_height); | |
328 pn_vis_set_image_size (vis, image_width, image_height); | |
329 break; | |
330 | |
331 case SDL_KEYDOWN: | |
332 switch (event.key.keysym.sym) | |
333 { | |
334 case SDLK_ESCAPE: | |
335 render_thread_finished = TRUE; | |
336 return 0; | |
337 | |
338 case SDLK_RETURN: | |
339 if (event.key.keysym.mod & (KMOD_ALT | KMOD_META)) | |
340 { | |
341 /* Toggle fullscreen */ | |
342 SDL_WM_ToggleFullScreen (screen); | |
343 if (SDL_ShowCursor (SDL_QUERY) == SDL_ENABLE) | |
344 SDL_ShowCursor (SDL_DISABLE); | |
345 else | |
346 SDL_ShowCursor (SDL_ENABLE); | |
347 } | |
348 break; | |
349 case SDLK_BACKQUOTE: | |
350 { | |
351 char fname[20]; | |
352 int i = 0; | |
353 struct stat buf; | |
354 | |
355 do | |
356 { | |
357 sprintf (fname, "pnxmms_ss_%05u.bmp", i++); | |
358 } while(!(stat(fname, &buf) != 0 && errno == ENOENT )); | |
359 SDL_SaveBMP(screen, fname); | |
360 } | |
361 break; | |
362 | |
363 default: | |
364 break; | |
365 } | |
366 break; | |
367 } | |
368 } | |
1530 | 369 |
370 /* don't lock the CPU :P */ | |
371 g_usleep(10000); | |
1521 | 372 } |
373 | |
374 return 0; | |
375 } | |
376 | |
377 static void | |
378 draw_image (PnImage *image) | |
379 { | |
380 guint width, height, src_stride, dest_stride; | |
381 guint i; | |
382 register PnColor *src; | |
383 register Uint32 *dest; | |
384 | |
385 /* Lock the SDL surface */ | |
386 SDL_LockSurface (screen); | |
387 | |
388 /* Get the dimentions */ | |
389 width = pn_image_get_width (image); | |
390 height = pn_image_get_height (image); | |
391 | |
392 src_stride = pn_image_get_pitch (image) >> 2; | |
393 dest_stride = screen->pitch >> 2; | |
394 | |
395 src = pn_image_get_image_buffer (image); | |
396 dest = (Uint32 *) screen->pixels; | |
397 | |
398 /* Copy the pixel data */ | |
399 while (--height > 0) | |
400 { | |
401 for (i=0; i<width; i++) | |
402 dest[i] = SDL_MapRGB (screen->format, src[i].red, src[i].green, src[i].blue); | |
403 dest += dest_stride; | |
404 src += src_stride; | |
405 } | |
406 | |
407 /* Unlock the SDL surface */ | |
408 SDL_UnlockSurface (screen); | |
409 | |
410 /* Draw it to the screen */ | |
411 SDL_Flip (screen); | |
412 } | |
413 | |
414 static void | |
415 read_options (void) | |
416 { | |
417 ConfigDb *cfg; | |
418 gint i; | |
419 | |
420 if (options_read == TRUE) | |
421 return; | |
422 | |
423 cfg = bmp_cfg_db_open (); | |
424 if (!cfg) | |
425 return; | |
426 | |
427 if (bmp_cfg_db_get_int (cfg, "pnxmms", "image_width", &i)) | |
428 image_width = i; | |
429 | |
430 if (bmp_cfg_db_get_int (cfg, "pnxmms", "image_height", &i)) | |
431 image_height = i; | |
432 | |
1532
f74a6ba233c2
[svn] - allow configdb::pnxmms::preset to set what pn preset to load on start
nenolod
parents:
1530
diff
changeset
|
433 bmp_cfg_db_get_string (cfg, "pnxmms", "preset", &preset); |
f74a6ba233c2
[svn] - allow configdb::pnxmms::preset to set what pn preset to load on start
nenolod
parents:
1530
diff
changeset
|
434 |
1521 | 435 bmp_cfg_db_close (cfg); |
436 | |
437 return; | |
438 } | |
439 | |
440 static void | |
441 write_options (void) | |
442 { | |
443 ConfigDb *cfg; | |
444 | |
445 cfg = bmp_cfg_db_open (); | |
446 if (!cfg) | |
447 fprintf (stderr, "PNXMMS: Unable to open XMMS config file!\n"); | |
448 | |
449 bmp_cfg_db_set_int (cfg, "pnxmms", "image_width", image_width); | |
450 bmp_cfg_db_set_int (cfg, "pnxmms", "image_height", image_height); | |
451 | |
1532
f74a6ba233c2
[svn] - allow configdb::pnxmms::preset to set what pn preset to load on start
nenolod
parents:
1530
diff
changeset
|
452 if (preset) |
f74a6ba233c2
[svn] - allow configdb::pnxmms::preset to set what pn preset to load on start
nenolod
parents:
1530
diff
changeset
|
453 bmp_cfg_db_set_string (cfg, "pnxmms", "preset", preset); |
f74a6ba233c2
[svn] - allow configdb::pnxmms::preset to set what pn preset to load on start
nenolod
parents:
1530
diff
changeset
|
454 |
1521 | 455 bmp_cfg_db_close (cfg); |
456 } | |
457 | |
458 static void | |
459 load_default_vis (void) | |
460 { | |
461 PnContainer *container; | |
462 PnActuator *actuator; | |
463 PnOption *option; | |
464 | |
465 /* Actuator List */ | |
466 container = (PnContainer *) pn_actuator_list_new (); | |
467 | |
468 /* Scope */ | |
469 actuator = (PnActuator *) pn_scope_new (); | |
470 option = pn_actuator_get_option_by_name (actuator, "init_script"); | |
471 pn_string_option_set_value (PN_STRING_OPTION (option), "samples = width/2;"); | |
472 option = pn_actuator_get_option_by_name (actuator, "frame_script"); | |
473 pn_string_option_set_value (PN_STRING_OPTION (option), | |
474 "base = base + .04;\n" | |
475 "red = abs (sin (.5 * pi + .1 * base));\n" | |
476 "green = .5 * abs (sin (.5 * pi - .2 * base));\n" | |
477 "blue = abs (sin (.5 * pi + .3 * base));"); | |
478 option = pn_actuator_get_option_by_name (actuator, "sample_script"); | |
479 pn_string_option_set_value (PN_STRING_OPTION (option), | |
480 "x = 2 * iteration - 1;\n" | |
481 "y = value;"); | |
482 option = pn_actuator_get_option_by_name (actuator, "draw_method"); | |
1522 | 483 pn_list_option_set_index (PN_LIST_OPTION (option), 1); |
1521 | 484 pn_container_add_actuator (container, actuator, PN_POSITION_TAIL); |
485 | |
486 /* Distortion */ | |
487 actuator = (PnActuator *) pn_distortion_new (); | |
488 option = pn_actuator_get_option_by_name (actuator, "distortion_script"); | |
489 pn_string_option_set_value (PN_STRING_OPTION (option), | |
490 "intensity = .99 + .08 * r;\n" | |
491 "r = .98 * atan (r);\n" | |
492 "theta = theta + .01;"); | |
493 option = pn_actuator_get_option_by_name (actuator, "polar_coords"); | |
494 pn_boolean_option_set_value (PN_BOOLEAN_OPTION (option), TRUE); | |
495 pn_container_add_actuator (container, actuator, PN_POSITION_TAIL); | |
496 | |
497 /* Add the actuator list to the vis */ | |
498 pn_vis_set_root_actuator (vis, PN_ACTUATOR (container)); | |
499 } | |
500 | |
501 static void | |
502 apply_settings (void) | |
503 { | |
504 if (preset_changed) | |
505 { | |
506 preset_changed = FALSE; | |
507 SDL_mutexP (vis_mutex); | |
508 pn_vis_load_from_file (vis, preset); | |
509 SDL_mutexV (vis_mutex); | |
510 } | |
511 | |
512 write_options (); | |
513 } | |
514 | |
515 static void | |
516 destroy_config_dialog (GtkObject *user_data, gpointer data) | |
517 { | |
518 gtk_widget_destroy (GTK_WIDGET(config_dialog)); | |
519 config_dialog = NULL; | |
520 } | |
521 | |
522 static void | |
523 apply_button_cb (GtkButton *button, gpointer data) | |
524 { | |
525 apply_settings (); | |
526 } | |
527 | |
528 static void | |
529 ok_button_cb (GtkButton *button, gpointer data) | |
530 { | |
531 apply_settings (); | |
532 destroy_config_dialog (NULL, NULL); | |
533 } | |
534 | |
535 static void | |
536 cancel_button_cb (GtkButton *button, gpointer data) | |
537 { | |
538 destroy_config_dialog (NULL, NULL); | |
539 } | |
540 | |
541 /* If selector != NULL, then it's 'OK', otherwise it's 'Cancel' */ | |
542 static void | |
543 load_preset_cb (GtkButton *button, GtkFileSelection *selector) | |
544 { | |
545 if (selector) | |
546 { | |
547 if (preset) | |
548 g_free (preset); | |
549 preset = g_strdup (gtk_file_selection_get_filename (selector)); | |
550 gtk_label_set_text (GTK_LABEL (GTK_BIN (load_button)->child), preset); | |
551 preset_changed = TRUE; | |
552 } | |
553 | |
554 gtk_widget_set_sensitive (config_dialog, TRUE); | |
555 } | |
556 | |
557 static void | |
558 load_preset_button_cb (GtkButton *button, gpointer data) | |
559 { | |
560 GtkWidget *selector; | |
561 | |
562 selector = gtk_file_selection_new ("Load Preset"); | |
563 | |
564 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (selector)->ok_button), | |
565 "clicked", GTK_SIGNAL_FUNC (load_preset_cb), selector); | |
566 gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (selector)->cancel_button), | |
567 "clicked", GTK_SIGNAL_FUNC (load_preset_cb), NULL); | |
568 | |
569 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (selector)->ok_button), | |
570 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
571 (gpointer) selector); | |
572 gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (selector)->cancel_button), | |
573 "clicked", GTK_SIGNAL_FUNC (gtk_widget_destroy), | |
574 (gpointer) selector); | |
575 | |
576 gtk_widget_set_sensitive (config_dialog, FALSE); | |
577 gtk_widget_show (selector); | |
578 } | |
579 | |
580 static void | |
581 create_config_dialog (void) | |
582 { | |
583 GtkWidget *bbox, *button, *vbox, *frame, *table, *label; | |
584 | |
585 if (config_dialog != NULL) | |
586 return; | |
587 | |
588 /* Create the dialog */ | |
589 config_dialog = gtk_dialog_new (); | |
590 gtk_window_set_title (GTK_WINDOW (config_dialog), PACKAGE " " VERSION | |
591 " - Configuration"); | |
592 gtk_widget_set_usize (config_dialog, 500, 300); | |
593 gtk_container_border_width (GTK_CONTAINER (config_dialog), 8); | |
594 gtk_signal_connect_object (GTK_OBJECT (config_dialog), "delete-event", | |
595 destroy_config_dialog, NULL); | |
596 | |
597 /* OK / Cancel / Apply */ | |
598 bbox = gtk_hbutton_box_new (); | |
599 gtk_widget_show (bbox); | |
600 gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_END); | |
601 gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), 8); | |
602 gtk_button_box_set_child_size (GTK_BUTTON_BOX (bbox), 64, 0); | |
603 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (config_dialog)->action_area), | |
604 bbox, FALSE, FALSE, 0); | |
605 button = gtk_button_new_with_label ("OK"); | |
606 gtk_widget_show (button); | |
607 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL); | |
608 gtk_signal_connect (GTK_OBJECT (button), "clicked", | |
609 GTK_SIGNAL_FUNC (ok_button_cb), NULL); | |
610 gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); | |
611 button = gtk_button_new_with_label ("Cancel"); | |
612 gtk_widget_show (button); | |
613 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL); | |
614 gtk_signal_connect (GTK_OBJECT (button), "clicked", | |
615 GTK_SIGNAL_FUNC (cancel_button_cb), NULL); | |
616 gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); | |
617 button = gtk_button_new_with_label ("Apply"); | |
618 gtk_widget_show (button); | |
619 gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NORMAL); | |
620 gtk_signal_connect (GTK_OBJECT (button), "clicked", | |
621 GTK_SIGNAL_FUNC (apply_button_cb), NULL); | |
622 gtk_box_pack_start (GTK_BOX (bbox), button, FALSE, FALSE, 0); | |
623 | |
624 | |
625 /* The vertical box */ | |
626 vbox = gtk_vbox_new (FALSE, 1); | |
627 gtk_widget_show (vbox); | |
628 gtk_box_pack_start (GTK_BOX (GTK_DIALOG (config_dialog)->vbox), vbox, | |
629 TRUE, TRUE, 0); | |
630 | |
631 /* General options */ | |
632 frame = gtk_frame_new (NULL); | |
633 gtk_widget_show (frame); | |
634 gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); | |
635 gtk_frame_set_label (GTK_FRAME (frame), "General"); | |
636 table = gtk_table_new (2, 1, TRUE); | |
637 gtk_widget_show (table); | |
638 gtk_container_add (GTK_CONTAINER (frame), table); | |
639 label = gtk_label_new ("Preset File: "); | |
640 gtk_widget_show (label); | |
641 gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, | |
642 GTK_FILL, 0, 3, 3); | |
643 load_button = gtk_button_new_with_label (preset ? preset : "<default>"); | |
644 gtk_widget_show (load_button); | |
645 gtk_table_attach (GTK_TABLE (table), load_button, 1, 2, 0, 1, | |
646 GTK_EXPAND | GTK_FILL, 0, 3, 3); | |
647 gtk_signal_connect (GTK_OBJECT (load_button), "clicked", | |
648 GTK_SIGNAL_FUNC (load_preset_button_cb), NULL); | |
649 | |
650 /* Show it all */ | |
651 gtk_widget_show (config_dialog); | |
652 gtk_widget_grab_focus (config_dialog); | |
653 } |