more eol-style
[xonotic/netradiant.git] / contrib / camera / dialogs.cpp
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 /*
23 Camera plugin for GtkRadiant
24 Copyright (C) 2002 Splash Damage Ltd.
25 */
26
27 #include "camera.h"
28
29 static GSList *g_pEditTypeRadio = NULL;
30 static GtkWidget *g_pEditModeEditRadioButton = NULL;
31 GtkWidget *g_pEditModeAddRadioButton = NULL;
32 static GtkWidget *g_pSecondsEntry = NULL;
33 static GtkWidget *g_pEventsList = NULL;
34 static GtkLabel *g_pCurrentTime = NULL;
35 static GtkLabel *g_pTotalTime = NULL;
36 static GtkAdjustment *g_pTimeLine = NULL;
37 static GtkWidget *g_pTrackCamera = NULL;
38 static GtkWidget *g_pCamName = NULL;
39 static char *g_cNull = '\0';
40
41 static gint ci_editmode_edit( GtkWidget *widget, gpointer data )
42 {
43         g_iEditMode = 0;
44
45         return TRUE;
46 }
47
48 static gint ci_editmode_add( GtkWidget *widget, gpointer data )
49 {
50         g_iEditMode = 1;
51
52         return TRUE;
53 }
54
55 /*static gint ci_delete_selected( GtkWidget *widget, gpointer data )
56 {
57   return TRUE;
58 }
59
60 static gint ci_select_all( GtkWidget *widget, gpointer data )
61 {
62   return TRUE;
63 }*/
64
65 static gint ci_new( GtkWidget *widget, gpointer data )
66 {
67         GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame; //, *name;
68         GtkWidget *fixed, *interpolated, *spline;
69         int ret, loop = 1;
70         GSList *targetTypeRadio = NULL;
71 //      char buf[128];
72
73         // create the window
74   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
75         gtk_window_set_title( GTK_WINDOW (window), "New Camera" );
76   gtk_signal_connect( GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
77   gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
78   gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
79
80         g_object_set_data (G_OBJECT (window), "loop", &loop);
81         g_object_set_data (G_OBJECT (window), "ret", &ret);
82
83         gtk_widget_realize (window);
84
85         // fill the window
86         vbox = gtk_vbox_new( FALSE, 5 );
87         gtk_container_add (GTK_CONTAINER (window), vbox);
88         gtk_widget_show( vbox );
89
90   // -------------------------- //
91
92         hbox = gtk_hbox_new( FALSE, 5 );
93   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
94         gtk_widget_show( hbox );
95
96   frame = gtk_frame_new( "Type" );
97   gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 );
98   gtk_widget_show( frame );
99
100         vbox2 = gtk_vbox_new( FALSE, 5 );
101         gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
102   gtk_container_set_border_width( GTK_CONTAINER (vbox2), 5 );
103         gtk_widget_show( vbox2 );
104
105         // -------------------------- //
106
107         fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" );
108         gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 );
109   gtk_widget_show( fixed );
110   targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) );
111
112         interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" );
113         gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 );
114   gtk_widget_show( interpolated );
115   targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) );
116
117         spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" );
118         gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 );
119   gtk_widget_show( spline );
120   targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) );
121
122   // -------------------------- //
123
124   w = gtk_hseparator_new ();
125   gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
126   gtk_widget_show (w);
127
128         // -------------------------- //
129
130         hbox = gtk_hbox_new( FALSE, 5 );
131   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
132         gtk_widget_show( hbox );
133
134         w = gtk_button_new_with_label ("Ok");
135         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
136         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
137         gtk_widget_show (w);
138
139         GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
140         gtk_widget_grab_default( w );
141
142         w = gtk_button_new_with_label ("Cancel");
143         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
144         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
145         gtk_widget_show (w);
146         ret = IDCANCEL;
147
148         // -------------------------- //
149
150         gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
151         gtk_widget_show (window);
152         gtk_grab_add (window);
153
154         bool dialogError = TRUE;
155         while (dialogError) {
156                 loop = 1;
157                 while (loop)
158                         gtk_main_iteration ();
159  
160                 dialogError = FALSE;
161
162                 if( ret == IDOK ) {
163                         if( gtk_toggle_button_get_active( (GtkToggleButton*)fixed ) )
164                                 DoNewFixedCamera();
165                         else if( gtk_toggle_button_get_active( (GtkToggleButton*)interpolated ) )
166                                 DoNewInterpolatedCamera();
167                         else if( gtk_toggle_button_get_active( (GtkToggleButton*)spline ) )
168                                 DoNewSplineCamera();
169                 }
170         }
171
172         gtk_grab_remove (window);
173         gtk_widget_destroy (window);
174
175   return TRUE;
176 }
177
178 static gint ci_load( GtkWidget *widget, gpointer data )
179 {
180   DoLoadCamera();
181
182   return TRUE;
183 }
184
185 static gint ci_save( GtkWidget *widget, gpointer data )
186 {
187   DoSaveCamera();
188
189   return TRUE;
190 }
191
192 static gint ci_unload( GtkWidget *widget, gpointer data )
193 {
194         DoUnloadCamera();
195
196         return TRUE;
197 }
198
199 static gint ci_apply( GtkWidget *widget, gpointer data )
200 {
201         if( GetCurrentCam() ) {
202                 const char *str;
203                 char buf[128];
204                 bool build = false;
205
206                 str = gtk_entry_get_text( GTK_ENTRY(g_pCamName) );
207
208                 if( str ) {
209                         GetCurrentCam()->GetCam()->setName( str );
210                         build = true;
211                 }
212
213                 str = gtk_entry_get_text( GTK_ENTRY(g_pSecondsEntry) );
214                 
215                 if( str ) {
216                         GetCurrentCam()->GetCam()->setBaseTime( atof( str ) );
217                         build = true;
218                 }
219
220                 if( build ) {
221                         GetCurrentCam()->GetCam()->buildCamera();
222                 }
223
224                 sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getBaseTime() );
225                 gtk_entry_set_text( GTK_ENTRY(g_pSecondsEntry), buf );
226
227                 sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getTotalTime() );
228                 gtk_label_set_text( g_pCurrentTime, "0.00" );
229                 gtk_label_set_text( g_pTotalTime, buf );
230
231                 gtk_adjustment_set_value( g_pTimeLine, 0.f );
232                 g_pTimeLine->upper = GetCurrentCam()->GetCam()->getTotalTime() * 1000;
233
234                 GetCurrentCam()->HasBeenModified();
235         }
236
237   return TRUE;
238 }
239
240 static gint ci_preview( GtkWidget *widget, gpointer data )
241 {
242         if( GetCurrentCam() ) {
243                 g_iPreviewRunning = 1;
244                 g_FuncTable.m_pfnSysUpdateWindows( W_XY_OVERLAY | W_CAMERA );
245         }
246
247   return TRUE;
248 }
249
250 static gint ci_expose( GtkWidget *widget, gpointer data )
251 {
252   // start edit mode
253   DoStartEdit( GetCurrentCam() );
254
255   return FALSE;
256 }
257
258 static gint ci_close( GtkWidget *widget, gpointer data )
259 {
260   gtk_widget_hide( g_pCameraInspectorWnd );
261
262   // exit edit mode
263   DoStopEdit();
264
265   return TRUE;
266 }
267
268 static GtkWidget *g_pPathListCombo = NULL;
269 static GtkLabel *g_pPathType = NULL;
270
271 static void RefreshPathListCombo( void )
272 {
273   if( !g_pPathListCombo )
274     return;
275
276   GList *combo_list = (GList*)NULL;
277
278   if( GetCurrentCam() ) {
279     combo_list = g_list_append( combo_list, (void *)GetCurrentCam()->GetCam()->getPositionObj()->getName() );
280     for( int i = 0; i < GetCurrentCam()->GetCam()->numTargets(); i++ ) {
281       combo_list = g_list_append( combo_list, (void *)GetCurrentCam()->GetCam()->getActiveTarget( i )->getName() );
282     }
283   } else {
284                 // add one empty string make gtk be quiet
285                 combo_list = g_list_append( combo_list, (gpointer)g_cNull );
286   }
287
288   gtk_combo_set_popdown_strings( GTK_COMBO( g_pPathListCombo ), combo_list );
289   g_list_free( combo_list );
290 }
291
292 static gint ci_pathlist_changed( GtkWidget *widget, gpointer data )
293 {
294   const char *str = gtk_entry_get_text( GTK_ENTRY(widget) );
295
296   if( !str || !GetCurrentCam() )
297     return TRUE;
298
299         int i;
300   for( i = 0; i < GetCurrentCam()->GetCam()->numTargets(); i++ ) {
301     if( !strcmp( str, GetCurrentCam()->GetCam()->getActiveTarget( i )->getName() ) )
302       break;
303   }
304
305   if( i >= 0 && i < GetCurrentCam()->GetCam()->numTargets() ) {
306     GetCurrentCam()->GetCam()->setActiveTarget( i );
307
308     g_iActiveTarget = i;
309                 if( g_pPathType )
310                         gtk_label_set_text( g_pPathType, GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->typeStr() );
311   } else {
312     g_iActiveTarget = -1;
313                 if( g_pPathType )
314                         gtk_label_set_text( g_pPathType, GetCurrentCam()->GetCam()->getPositionObj()->typeStr() );
315   }
316
317   // start edit mode
318   if( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) )
319     DoStartEdit( GetCurrentCam() );
320
321   return TRUE;
322 }
323
324 static void RefreshEventList( void )
325 {
326         int i;
327         char buf[128];
328
329         // Clear events list
330         gtk_clist_freeze( GTK_CLIST(g_pEventsList) );
331         gtk_clist_clear( GTK_CLIST(g_pEventsList) );
332
333         if( GetCurrentCam() ) {
334                 // Fill events list
335                 for( i = 0; i < GetCurrentCam()->GetCam()->numEvents(); i++ ) {
336                         char rowbuf[3][128], *row[3];
337                         // FIXME: sort by time?
338                         sprintf( rowbuf[0], "%li", GetCurrentCam()->GetCam()->getEvent(i)->getTime() );                 row[0] = rowbuf[0];
339                         strncpy( rowbuf[1], GetCurrentCam()->GetCam()->getEvent(i)->typeStr(), sizeof(rowbuf[0]) );     row[1] = rowbuf[1];
340                         strncpy( rowbuf[2], GetCurrentCam()->GetCam()->getEvent(i)->getParam(), sizeof(rowbuf[1]) );    row[2] = rowbuf[2];
341                         gtk_clist_append( GTK_CLIST(g_pEventsList), row );
342                 }
343
344                 // Total duration might have changed
345                 sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getTotalTime() );
346                 gtk_label_set_text( g_pCurrentTime, "0.00" );
347                 gtk_label_set_text( g_pTotalTime, buf );
348
349                 gtk_adjustment_set_value( g_pTimeLine, 0.f );
350                 g_pTimeLine->upper = ( GetCurrentCam()->GetCam()->getTotalTime() * 1000 );
351         }
352
353         gtk_clist_thaw( GTK_CLIST(g_pEventsList) );
354 }
355
356 static gint ci_rename( GtkWidget *widget, gpointer data )
357 {
358         GtkWidget *window, *w, *vbox, *hbox, *name;
359         int ret, loop = 1;
360
361         if( !GetCurrentCam() )
362                 return TRUE;
363
364         // create the window
365   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
366         gtk_window_set_title( GTK_WINDOW (window), "Rename Path" );
367   gtk_signal_connect( GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
368   gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
369   gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
370
371         g_object_set_data (G_OBJECT (window), "loop", &loop);
372         g_object_set_data (G_OBJECT (window), "ret", &ret);
373
374         gtk_widget_realize ( window );
375
376         // fill the window
377         vbox = gtk_vbox_new( FALSE, 5 );
378         gtk_container_add (GTK_CONTAINER (window), vbox);
379         gtk_widget_show( vbox );
380
381   // -------------------------- //
382
383         hbox = gtk_hbox_new( FALSE, 5 );
384   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
385         gtk_widget_show( hbox );
386
387   w = gtk_label_new( "Name:" );
388         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
389         gtk_widget_show( w );
390
391   name = gtk_entry_new();
392   gtk_box_pack_start( GTK_BOX( hbox ), name, FALSE, FALSE, 0 );
393   gtk_widget_show( name );
394
395         if( g_iActiveTarget < 0 )
396                 gtk_entry_set_text( GTK_ENTRY(name), GetCurrentCam()->GetCam()->getPositionObj()->getName() );
397         else
398                 gtk_entry_set_text( GTK_ENTRY(name), GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->getName() );
399
400   // -------------------------- //
401
402   w = gtk_hseparator_new ();
403   gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
404   gtk_widget_show (w);
405
406         // -------------------------- //
407
408         hbox = gtk_hbox_new( FALSE, 5 );
409   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
410         gtk_widget_show( hbox );
411
412         w = gtk_button_new_with_label ("Ok");
413         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
414         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
415         gtk_widget_show (w);
416
417         GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
418         gtk_widget_grab_default( w );
419
420         w = gtk_button_new_with_label ("Cancel");
421         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
422         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
423         gtk_widget_show (w);
424         ret = IDCANCEL;
425
426         // -------------------------- //
427
428         gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
429         gtk_widget_show (window);
430         gtk_grab_add (window);
431
432         bool dialogError = TRUE;
433         while (dialogError) {
434                 loop = 1;
435                 while (loop)
436                         gtk_main_iteration ();
437  
438                 dialogError = FALSE;
439
440                 if( ret == IDOK ) {
441                         const char *str = gtk_entry_get_text( GTK_ENTRY(name) );
442
443                         if( str && str[0] ) {
444                                 // Update the path
445                                 if( g_iActiveTarget < 0 )
446                                         GetCurrentCam()->GetCam()->getPositionObj()->setName( str );
447                                 else
448                                         GetCurrentCam()->GetCam()->getActiveTarget(g_iActiveTarget)->setName( str );
449
450                                 GetCurrentCam()->GetCam()->buildCamera();
451
452                                 // Rebuild the listbox
453                                 RefreshPathListCombo();
454                         } else {
455                                 dialogError = TRUE;
456                         }
457                 }
458         }
459
460         gtk_grab_remove (window);
461         gtk_widget_destroy (window);
462
463   return TRUE;
464 }
465
466 static gint ci_add_target( GtkWidget *widget, gpointer data )
467 {
468         GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *name;
469         GtkWidget *fixed, *interpolated, *spline;
470         int ret, loop = 1;
471         GSList *targetTypeRadio = NULL;
472         char buf[128];
473
474         if( !GetCurrentCam() )
475                 return TRUE;
476
477         // create the window
478   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
479         gtk_window_set_title( GTK_WINDOW (window), "Add Target" );
480   gtk_signal_connect( GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
481   gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
482   gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
483
484         g_object_set_data (G_OBJECT (window), "loop", &loop);
485         g_object_set_data (G_OBJECT (window), "ret", &ret);
486
487         gtk_widget_realize (window);
488
489         // fill the window
490         vbox = gtk_vbox_new( FALSE, 5 );
491         gtk_container_add (GTK_CONTAINER (window), vbox);
492         gtk_widget_show( vbox );
493
494   // -------------------------- //
495
496         hbox = gtk_hbox_new( FALSE, 5 );
497   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
498         gtk_widget_show( hbox );
499
500   w = gtk_label_new( "Name:" );
501         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
502         gtk_widget_show( w );
503
504   name = gtk_entry_new();
505   gtk_box_pack_start( GTK_BOX( hbox ), name, TRUE, TRUE, 0 );
506   gtk_widget_show( name );
507
508         sprintf( buf, "target%i", GetCurrentCam()->GetCam()->numTargets() + 1 );
509         gtk_entry_set_text( GTK_ENTRY(name), buf );
510
511   // -------------------------- //
512
513         hbox = gtk_hbox_new( FALSE, 5 );
514   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
515         gtk_widget_show( hbox );
516
517   frame = gtk_frame_new( "Type" );
518   gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 );
519   gtk_widget_show( frame );
520
521         vbox2 = gtk_vbox_new( FALSE, 5 );
522         gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
523   gtk_container_set_border_width( GTK_CONTAINER (vbox2), 5 );
524         gtk_widget_show( vbox2 );
525
526         // -------------------------- //
527
528         fixed = gtk_radio_button_new_with_label( targetTypeRadio, "Fixed" );
529         gtk_box_pack_start( GTK_BOX( vbox2 ), fixed, FALSE, FALSE, 3 );
530   gtk_widget_show( fixed );
531   targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( fixed ) );
532
533         interpolated = gtk_radio_button_new_with_label( targetTypeRadio, "Interpolated" );
534         gtk_box_pack_start( GTK_BOX( vbox2 ), interpolated, FALSE, FALSE, 3 );
535   gtk_widget_show( interpolated );
536   targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( interpolated ) );
537
538         spline = gtk_radio_button_new_with_label( targetTypeRadio, "Spline" );
539         gtk_box_pack_start( GTK_BOX( vbox2 ), spline, FALSE, FALSE, 3 );
540   gtk_widget_show( spline );
541   targetTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( spline ) );
542
543   // -------------------------- //
544
545   w = gtk_hseparator_new ();
546   gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
547   gtk_widget_show (w);
548
549         // -------------------------- //
550
551         hbox = gtk_hbox_new( FALSE, 5 );
552   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
553         gtk_widget_show( hbox );
554
555         w = gtk_button_new_with_label ("Ok");
556         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
557         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
558         gtk_widget_show (w);
559
560         GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
561         gtk_widget_grab_default( w );
562
563         w = gtk_button_new_with_label ("Cancel");
564         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
565         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
566         gtk_widget_show (w);
567         ret = IDCANCEL;
568
569         // -------------------------- //
570
571         gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
572         gtk_widget_show (window);
573         gtk_grab_add (window);
574
575         bool dialogError = TRUE;
576         while (dialogError) {
577                 loop = 1;
578                 while (loop)
579                         gtk_main_iteration ();
580  
581                 dialogError = FALSE;
582
583                 if( ret == IDOK ) {
584                         const char *str = gtk_entry_get_text( GTK_ENTRY(name) );
585
586                         if( str && str[0] ) {
587                                 int type;
588                                 GList *li;
589
590                                 if( gtk_toggle_button_get_active( (GtkToggleButton*)fixed ) )
591                                         type = 0;
592                                 else if( gtk_toggle_button_get_active( (GtkToggleButton*)interpolated ) )
593                                         type = 1;
594                                 else if( gtk_toggle_button_get_active( (GtkToggleButton*)spline ) )
595                                         type = 2;
596
597                                 // Add the target
598                                 GetCurrentCam()->GetCam()->addTarget( str, static_cast<idCameraPosition::positionType>(type) );
599
600                                 // Rebuild the listbox
601                                 RefreshPathListCombo();
602
603                                 // Select the last item in the listbox
604                                 li = g_list_last( GTK_LIST(GTK_COMBO(g_pPathListCombo)->list)->children );
605                                 gtk_list_select_child( GTK_LIST(GTK_COMBO(g_pPathListCombo)->list), GTK_WIDGET (li->data) );
606
607                                 // If this was the first one, refresh the event list
608                                 if( GetCurrentCam()->GetCam()->numTargets() == 1 ) {
609                                         RefreshEventList();
610                                 }
611
612                                 // Go to editmode Add
613                                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_pEditModeAddRadioButton), TRUE );
614
615                         } else {
616                                 dialogError = TRUE;
617                         }
618                 }
619         }
620
621         gtk_grab_remove (window);
622         gtk_widget_destroy (window);
623
624   return TRUE;
625 }
626
627 static GtkWidget *g_pCamListCombo = NULL;
628 static GtkLabel *g_pCamType = NULL;
629
630 void RefreshCamListCombo( void )
631 {
632   if( !g_pCamListCombo )
633     return;
634
635   GList *combo_list = (GList*)NULL;
636   CCamera *combo_cam = firstCam;
637         if( combo_cam ) {
638                 while( combo_cam ) {
639                         //combo_list = g_list_append( combo_list, (void *)combo_cam->GetCam()->getName() );
640                         //if( combo_cam->HasBeenSaved() ) {
641                                 combo_list = g_list_append( combo_list, (void *)combo_cam->GetFileName() );
642                         /*} else {
643                                 char buf[128];
644                                 sprintf( buf, "Unsaved Camera %i", combo_cam->GetCamNum() );
645                                 combo_list = g_list_append( combo_list, (void *)buf );
646
647                                 //combo_list = g_list_append( combo_list, (void *)combo_cam->GetCam()->getName() );     // FIXME: this requires camera.dll to create unique names for new cams
648                         }*/
649                         combo_cam = combo_cam->GetNext();
650                 }
651         }else {
652                 // add one empty string make gtk be quiet
653                 combo_list = g_list_append( combo_list, (gpointer)g_cNull );
654         }
655   gtk_combo_set_popdown_strings( GTK_COMBO( g_pCamListCombo ), combo_list );
656   g_list_free( combo_list );
657
658   // select our current entry in the list
659   if( GetCurrentCam() ) {
660     // stop editing on the current cam
661     //GetCurrentCam()->GetCam()->stopEdit();    // FIXME: this crashed on creating new cameras, why is it here?
662
663     GList *li = GTK_LIST( GTK_COMBO(g_pCamListCombo)->list)->children;
664     combo_cam = firstCam;
665     while( li && combo_cam ) {
666       if( combo_cam == GetCurrentCam() ) {
667         gtk_list_select_child( GTK_LIST( GTK_COMBO(g_pCamListCombo)->list ), GTK_WIDGET( li->data ) );
668         break;
669       }
670       li = li->next;
671       combo_cam = combo_cam->GetNext();
672     }
673   }
674
675   RefreshPathListCombo();
676 }
677
678 static gint ci_camlist_changed( GtkWidget *widget, gpointer data )
679 {
680   const char *str = gtk_entry_get_text( GTK_ENTRY(widget) );
681
682   CCamera *combo_cam = firstCam;
683   while( str && combo_cam ) {
684     //if( !strcmp( str, combo_cam->GetCam()->getName() ) )
685                 //if( combo_cam->HasBeenSaved() ) {
686                         if( !strcmp( str, combo_cam->GetFileName() ) )
687                                 break;
688                 /*} else {
689                         char buf[128];
690                         sprintf( buf, "Unsaved Camera %i", combo_cam->GetCamNum() );
691                         if( !strcmp( str, buf ) )
692                         //if( !strcmp( str, combo_cam->GetCam()->getName() ) )
693                                 break;
694                 }*/
695
696     combo_cam = combo_cam->GetNext();
697   }
698
699   SetCurrentCam( combo_cam );
700
701         if( g_pCamType ) {
702                 if( GetCurrentCam() ) {
703                         // Fill in our widgets fields for this camera
704                         char buf[128];
705
706                         // Set Name
707                         gtk_entry_set_text( GTK_ENTRY(g_pCamName), GetCurrentCam()->GetCam()->getName() );
708
709                         // Set type
710                         gtk_label_set_text( g_pCamType, GetCurrentCam()->GetCam()->getPositionObj()->typeStr() );
711
712                         // Set duration
713                         sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getBaseTime() );
714                         gtk_entry_set_text( GTK_ENTRY(g_pSecondsEntry), buf );
715
716                         sprintf( buf, "%.2f", GetCurrentCam()->GetCam()->getTotalTime() );
717                         gtk_label_set_text( g_pCurrentTime, "0.00" );
718                         gtk_label_set_text( g_pTotalTime, buf );
719
720                         gtk_adjustment_set_value( g_pTimeLine, 0.f );
721                         g_pTimeLine->upper = GetCurrentCam()->GetCam()->getTotalTime() * 1000;
722                 } else {
723                         // Set Name
724                         gtk_entry_set_text( GTK_ENTRY(g_pCamName), "" );
725
726                         // Set type
727                         gtk_label_set_text( g_pCamType, "" );
728
729                         // Set duration
730                         gtk_entry_set_text( GTK_ENTRY(g_pSecondsEntry), "30.00" );
731
732                         gtk_label_set_text( g_pCurrentTime, "0.00" );
733                         gtk_label_set_text( g_pTotalTime, "30.00" );
734
735                         gtk_adjustment_set_value( g_pTimeLine, 0.f );
736                         g_pTimeLine->upper = 30000;
737                 }
738
739                 // Refresh event list
740                 RefreshEventList();
741         }
742
743   RefreshPathListCombo();
744
745   // start edit mode
746   g_iActiveTarget = -1;
747   if( g_pCameraInspectorWnd && GTK_WIDGET_VISIBLE( g_pCameraInspectorWnd ) )
748     DoStartEdit( GetCurrentCam() );
749
750   return TRUE;
751 }
752
753 enum camEventType {
754         EVENT_NA = 0x00,
755         EVENT_WAIT,                             // 
756         EVENT_TARGETWAIT,       // 
757         EVENT_SPEED,                    // 
758         EVENT_TARGET,                   // char(name)
759         EVENT_SNAPTARGET,       // 
760         EVENT_FOV,                              // int(time), int(targetfov)
761         EVENT_CMD,                              // 
762         EVENT_TRIGGER,          // 
763         EVENT_STOP,                             // 
764         EVENT_CAMERA,                   // 
765         EVENT_FADEOUT,          // int(time)
766         EVENT_FADEIN,                   // int(time)
767         EVENT_FEATHER,          // 
768         EVENT_COUNT                     
769 };
770
771 // { requires parameters, enabled }
772 const bool camEventFlags[][2] = {
773   { false, false },
774   { false, true },
775   { false, false },
776   { false, false },
777   { true, true },
778   { false, false },
779   { true, true },
780   { false, false },
781   { false, false },
782   { false, true },
783   { true, true },
784   { true, true },
785   { true, true },
786   { false, true },
787 };
788
789 const char *camEventStr[] = {
790         "n/a",
791         "Wait",
792         "Target wait",
793         "Speed",
794         "Change Target <string:name>",
795         "Snap Target",
796         "FOV <int:duration> <int:targetfov>",
797         "Run Script",
798         "Trigger",
799         "Stop",
800   "Change to Camera <string:camera> (or <int:cameranum> <string:camera>",
801         "Fade Out <int:duration>",
802         "Fade In <int:duration>",
803         "Feather"
804 };
805
806 static gint ci_add( GtkWidget *widget, gpointer data )
807 {
808         GtkWidget *window, *w, *vbox, *vbox2, *hbox, *frame, *parameters;
809         GtkWidget *eventWidget[EVENT_COUNT];
810         int i, ret, loop = 1;
811         GSList *eventTypeRadio = NULL;
812 //      char buf[128];
813
814         if( !GetCurrentCam() )
815                 return TRUE;
816
817         // create the window
818   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
819         gtk_window_set_title( GTK_WINDOW (window), "Add Event" );
820   gtk_signal_connect( GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( dialog_delete_callback ), NULL );
821   gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
822   gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pCameraInspectorWnd ) );
823
824         g_object_set_data (G_OBJECT (window), "loop", &loop);
825         g_object_set_data (G_OBJECT (window), "ret", &ret);
826
827         gtk_widget_realize (window);
828
829         // fill the window
830         vbox = gtk_vbox_new( FALSE, 5 );
831         gtk_container_add (GTK_CONTAINER (window), vbox);
832         gtk_widget_show( vbox );
833
834   // -------------------------- //
835
836         hbox = gtk_hbox_new( FALSE, 5 );
837   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
838         gtk_widget_show( hbox );
839
840   frame = gtk_frame_new( "Type" );
841   gtk_box_pack_start( GTK_BOX( hbox ), frame, TRUE, TRUE, 0 );
842   gtk_widget_show( frame );
843
844         vbox2 = gtk_vbox_new( FALSE, 5 );
845         gtk_container_add( GTK_CONTAINER( frame ), vbox2 );
846   gtk_container_set_border_width( GTK_CONTAINER (vbox2), 5 );
847         gtk_widget_show( vbox2 );
848
849         // -------------------------- //
850
851         for( i = 1; i < EVENT_COUNT; i++ ) {
852                 eventWidget[i] = gtk_radio_button_new_with_label( eventTypeRadio, camEventStr[i] );
853                 gtk_box_pack_start( GTK_BOX( vbox2 ), eventWidget[i], FALSE, FALSE, 3 );
854                 gtk_widget_show( eventWidget[i] );
855                 eventTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( eventWidget[i] ) );
856     if( camEventFlags[i][1] == false )
857       gtk_widget_set_sensitive (eventWidget[i], FALSE);
858         }
859
860   // -------------------------- //
861
862         hbox = gtk_hbox_new( FALSE, 5 );
863   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
864         gtk_widget_show( hbox );
865
866   w = gtk_label_new( "Parameters:" );
867         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
868         gtk_widget_show( w );
869
870   parameters = gtk_entry_new();
871   gtk_box_pack_start( GTK_BOX( hbox ), parameters, TRUE, TRUE, 0 );
872   gtk_widget_show( parameters );
873
874   // -------------------------- //
875
876   w = gtk_hseparator_new ();
877   gtk_box_pack_start (GTK_BOX (vbox), w, FALSE, FALSE, 2);
878   gtk_widget_show (w);
879
880         // -------------------------- //
881
882         hbox = gtk_hbox_new( FALSE, 5 );
883   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
884         gtk_widget_show( hbox );
885
886         w = gtk_button_new_with_label ("Ok");
887         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
888         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDOK));
889         gtk_widget_show (w);
890
891         GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
892         gtk_widget_grab_default( w );
893
894         w = gtk_button_new_with_label ("Cancel");
895         gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0);
896         gtk_signal_connect (GTK_OBJECT (w), "clicked", GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (IDCANCEL));
897         gtk_widget_show (w);
898         ret = IDCANCEL;
899
900         // -------------------------- //
901
902         gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
903         gtk_widget_show (window);
904         gtk_grab_add (window);
905
906         bool dialogError = TRUE;
907         while (dialogError) {
908                 loop = 1;
909                 while (loop)
910                         gtk_main_iteration ();
911  
912                 dialogError = FALSE;
913
914                 if( ret == IDOK ) {
915                         const char *str = gtk_entry_get_text( GTK_ENTRY(parameters) );
916
917                         if( !camEventFlags[i][0] || ( str && str[0] ) ) {
918                                 int type = 0;
919 //                              GList *li;
920
921                                 for( type = 1; type < EVENT_COUNT; type++ ) {
922                                         if( gtk_toggle_button_get_active( (GtkToggleButton*)eventWidget[type] ) )
923                                                 break;
924                                 }
925
926                                 // Add the event
927                                 GetCurrentCam()->GetCam()->addEvent( static_cast<idCameraEvent::eventType>(type), str, (long)(g_pTimeLine->value) );
928
929                                 // Refresh event list
930                                 RefreshEventList();
931                         } else {
932                                 dialogError = TRUE;
933                         }
934                 }
935         }
936
937         gtk_grab_remove (window);
938         gtk_widget_destroy (window);
939
940   return TRUE;
941 }
942
943 static gint ci_del( GtkWidget *widget, gpointer data )
944 {
945         // TODO: add support to splines lib
946         if(     GetCurrentCam() && GTK_CLIST(g_pEventsList)->focus_row >= 0 ) {
947                 GetCurrentCam()->GetCam()->removeEvent( GTK_CLIST(g_pEventsList)->focus_row );
948                 // Refresh event list
949                 RefreshEventList();
950         }
951
952   return TRUE;
953 }
954
955 static gint ci_timeline_changed( GtkAdjustment *adjustment )
956 {
957         char buf[128];
958
959         sprintf( buf, "%.2f", adjustment->value / 1000.f );
960         gtk_label_set_text( g_pCurrentTime, buf );
961
962         // FIXME: this will never work completely perfect. Startcamera calls buildcamera, which sets all events to 'nottriggered'.
963         // So if you have a wait at the end of the path, this will go to nontriggered immediately when you go over it and the camera
964         // will have no idea where on the track it should be.
965         if( GetCurrentCam() && gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(g_pTrackCamera) ) ) {
966                 float fov;
967     vec3_t origin = { 0.0f, 0.0f, 0.0f }, dir = { 0.0f, 0.0f, 0.0f}, angles;
968
969     GetCurrentCam()->GetCam()->startCamera( 0 );
970
971                 GetCurrentCam()->GetCam()->getCameraInfo( (long)(adjustment->value), &origin[0], &dir[0], &fov );
972                 VectorSet( angles, asin (dir[2])*180/3.14159, atan2 (dir[1], dir[0])*180/3.14159, 0 );
973                 g_CameraTable.m_pfnSetCamera( origin, angles ); 
974         }       
975
976         return TRUE;
977 }
978
979 GtkWidget *CreateCameraInspectorDialog( void )
980 {
981   GtkWidget     *window, *w, *vbox, *hbox, *table, *frame;
982
983   // create the window
984   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
985         gtk_window_set_title( GTK_WINDOW (window), "Camera Inspector" );
986   gtk_signal_connect( GTK_OBJECT (window), "delete_event", GTK_SIGNAL_FUNC( ci_close ), NULL );
987   gtk_signal_connect( GTK_OBJECT (window), "expose_event", GTK_SIGNAL_FUNC( ci_expose ), NULL );
988         //  gtk_signal_connect( GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC( gtk_widget_destroy ), NULL );
989   gtk_window_set_transient_for( GTK_WINDOW( window ), GTK_WINDOW( g_pRadiantWnd ) );
990
991   // don't use show, as you don't want to have it displayed on startup ;-)
992   gtk_widget_realize( window );
993
994   // fill the window
995
996   // the table
997   // -------------------------- //
998
999   table = gtk_table_new( 3, 2, FALSE );
1000   gtk_widget_show( table );
1001   gtk_container_add( GTK_CONTAINER( window ), table );
1002   gtk_container_set_border_width( GTK_CONTAINER( table ), 5 );
1003   gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
1004   gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
1005
1006   // the properties column
1007         // -------------------------- //
1008
1009         vbox = gtk_vbox_new( FALSE, 5 );
1010         gtk_widget_show( vbox );
1011   gtk_table_attach( GTK_TABLE( table ), vbox, 0, 1, 0, 1,
1012                     (GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
1013                     (GtkAttachOptions) (GTK_FILL), 0, 0 );
1014
1015   // -------------------------- //
1016
1017         hbox = gtk_hbox_new( FALSE, 5 );
1018   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1019         gtk_widget_show( hbox );
1020
1021   w = gtk_label_new( "File:" );
1022         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1023         gtk_widget_show( w );
1024
1025   g_pCamListCombo = gtk_combo_new();
1026   gtk_box_pack_start (GTK_BOX( hbox ), g_pCamListCombo, TRUE, TRUE, 0);
1027   gtk_widget_show( g_pCamListCombo );
1028
1029   // -------------------------- //
1030
1031         hbox = gtk_hbox_new( FALSE, 5 );
1032   gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1033         gtk_widget_show( hbox );
1034
1035         w = gtk_label_new( "Name:" );
1036         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1037         gtk_widget_show( w );
1038
1039   g_pCamName = gtk_entry_new();
1040   gtk_box_pack_start( GTK_BOX( hbox ), g_pCamName, FALSE, FALSE, 0 );
1041   gtk_widget_show( g_pCamName );        
1042
1043   w = gtk_label_new( "Type: " );
1044         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1045         gtk_widget_show( w );
1046
1047   w = gtk_label_new( "" );
1048   gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1049   gtk_widget_show( w );
1050         g_pCamType = GTK_LABEL( w );
1051
1052   RefreshCamListCombo();
1053
1054   gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(g_pCamListCombo)->entry ), FALSE );
1055   gtk_signal_connect( GTK_OBJECT(GTK_COMBO(g_pCamListCombo)->entry), "changed", GTK_SIGNAL_FUNC( ci_camlist_changed ), NULL );
1056
1057   // -------------------------- //
1058
1059   frame = gtk_frame_new( "Path and Target editing" );
1060   gtk_widget_show( frame );
1061   gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 1, 2,
1062                     (GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
1063                     (GtkAttachOptions) (GTK_FILL), 0, 0 );
1064
1065         vbox = gtk_vbox_new( FALSE, 5 );
1066         gtk_container_add( GTK_CONTAINER( frame ), vbox );
1067   gtk_container_set_border_width( GTK_CONTAINER (vbox), 5 );
1068         gtk_widget_show( vbox );
1069
1070   // -------------------------- //
1071
1072         hbox = gtk_hbox_new( FALSE, 5 );
1073         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1074         gtk_widget_show( hbox );
1075
1076   w = gtk_label_new( "Edit:" );
1077         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1078         gtk_widget_show( w );
1079
1080   g_pPathListCombo = gtk_combo_new();
1081   gtk_box_pack_start (GTK_BOX( hbox ), g_pPathListCombo, TRUE, TRUE, 0);
1082   gtk_widget_show( g_pPathListCombo );
1083
1084   RefreshPathListCombo();
1085
1086         gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(g_pPathListCombo)->entry ), FALSE );
1087   gtk_signal_connect( GTK_OBJECT(GTK_COMBO(g_pPathListCombo)->entry), "changed", GTK_SIGNAL_FUNC( ci_pathlist_changed ), NULL );
1088
1089   // -------------------------- //
1090
1091   hbox = gtk_hbox_new( FALSE, 5 );
1092         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1093         gtk_widget_show( hbox );
1094
1095         g_pEditModeEditRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Edit Points" );
1096         gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeEditRadioButton, FALSE, FALSE, 3 );
1097   gtk_widget_show( g_pEditModeEditRadioButton );
1098   g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeEditRadioButton ) );
1099
1100         gtk_signal_connect( GTK_OBJECT( g_pEditModeEditRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_edit ), NULL );
1101
1102         g_pEditModeAddRadioButton = gtk_radio_button_new_with_label( g_pEditTypeRadio, "Add Points" );
1103         gtk_box_pack_start( GTK_BOX( hbox ), g_pEditModeAddRadioButton, FALSE, FALSE, 3 );
1104   gtk_widget_show( g_pEditModeAddRadioButton );
1105   g_pEditTypeRadio = gtk_radio_button_group( GTK_RADIO_BUTTON( g_pEditModeAddRadioButton ) );
1106
1107         gtk_signal_connect( GTK_OBJECT( g_pEditModeAddRadioButton ), "clicked", GTK_SIGNAL_FUNC( ci_editmode_add ), NULL );
1108
1109         // see if we should use a different default
1110         if( g_iEditMode == 1 ) {
1111                 // Go to editmode Add
1112                 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(g_pEditModeAddRadioButton), TRUE );
1113         }
1114
1115   w = gtk_label_new( "Type: " );
1116         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1117         gtk_widget_show( w );
1118
1119   w = gtk_label_new( "" );
1120   gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1121   gtk_widget_show( w );
1122         g_pPathType = GTK_LABEL( w );
1123
1124   // -------------------------- //
1125
1126         hbox = gtk_hbox_new( FALSE, 5 );
1127         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1128         gtk_widget_show( hbox );
1129
1130         w = gtk_button_new_with_label( "Rename..." );
1131         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0);
1132         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_rename ), NULL );
1133         gtk_widget_show( w );
1134
1135         w = gtk_button_new_with_label( "Add Target..." );
1136         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0);
1137         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add_target ), NULL );
1138         gtk_widget_show( w );
1139
1140         // not available in splines library
1141         /*w = gtk_button_new_with_label( "Delete Selected" );
1142         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0);
1143         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_delete_selected ), NULL );
1144         gtk_widget_show( w );
1145
1146         w = gtk_button_new_with_label( "Select All" );
1147         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, TRUE, 0);
1148         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_select_all ), NULL );
1149         gtk_widget_show( w );*/
1150
1151   // -------------------------- //
1152
1153   frame = gtk_frame_new( "Time" );
1154   gtk_widget_show( frame );
1155   gtk_table_attach( GTK_TABLE( table ), frame, 0, 1, 2, 3,
1156                     (GtkAttachOptions) (GTK_EXPAND|GTK_FILL),
1157                     (GtkAttachOptions) (GTK_FILL), 0, 0 );
1158
1159         vbox = gtk_vbox_new( FALSE, 5 );
1160         gtk_container_add( GTK_CONTAINER( frame ), vbox );
1161   gtk_container_set_border_width( GTK_CONTAINER (vbox), 5 );
1162         gtk_widget_show( vbox );
1163
1164   // -------------------------- //
1165
1166   hbox = gtk_hbox_new( FALSE, 5 );
1167         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1168         gtk_widget_show( hbox );
1169
1170   w = gtk_label_new( "Length (seconds):" );
1171         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1172         gtk_widget_show( w );
1173
1174   g_pSecondsEntry = gtk_entry_new();
1175   gtk_box_pack_start( GTK_BOX( hbox ), g_pSecondsEntry, FALSE, FALSE, 0 );
1176   gtk_widget_show( g_pSecondsEntry );
1177
1178   // -------------------------- //
1179
1180   hbox = gtk_hbox_new( FALSE, 5 );
1181         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1182         gtk_widget_show( hbox );
1183
1184   w = gtk_label_new( "Current Time: " );
1185         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1186         gtk_widget_show( w );
1187
1188   w = gtk_label_new( "0.00" );
1189   gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1190   gtk_widget_show( w );
1191         g_pCurrentTime = GTK_LABEL( w );
1192
1193   w = gtk_label_new( " of " );
1194         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1195         gtk_widget_show( w );
1196
1197   w = gtk_label_new( "0.00" );
1198   gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1199   gtk_widget_show( w );
1200         g_pTotalTime = GTK_LABEL( w );
1201
1202   // -------------------------- //
1203
1204   hbox = gtk_hbox_new( FALSE, 5 );
1205         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1206         gtk_widget_show( hbox );
1207
1208         g_pTimeLine = GTK_ADJUSTMENT( gtk_adjustment_new( 0, 0, 30000, 100, 250, 0 ) );
1209         gtk_signal_connect( GTK_OBJECT(g_pTimeLine), "value_changed", GTK_SIGNAL_FUNC( ci_timeline_changed ), NULL );
1210   w = gtk_hscale_new( g_pTimeLine );
1211   gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1212   gtk_widget_show( w );
1213   gtk_scale_set_draw_value( GTK_SCALE( w ), FALSE );
1214
1215   // -------------------------- //
1216
1217   hbox = gtk_hbox_new( FALSE, 5 );
1218         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1219         gtk_widget_show( hbox );
1220
1221   g_pTrackCamera = gtk_check_button_new_with_label( "Track Camera" );
1222   gtk_box_pack_start( GTK_BOX( hbox ), g_pTrackCamera, FALSE, FALSE, 0 );
1223   gtk_widget_show( g_pTrackCamera );
1224
1225   // -------------------------- //
1226
1227   hbox = gtk_hbox_new( FALSE, 5 );
1228         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1229         gtk_widget_show( hbox );
1230
1231   w = gtk_label_new( "Events:" );
1232         gtk_box_pack_start( GTK_BOX( hbox ), w, FALSE, FALSE, 0 );
1233         gtk_widget_show( w );
1234
1235   // -------------------------- //
1236
1237   hbox = gtk_hbox_new( FALSE, 5 );
1238         gtk_box_pack_start( GTK_BOX( vbox ), hbox, FALSE, FALSE, 0 );
1239         gtk_widget_show( hbox );
1240
1241   w = gtk_scrolled_window_new( NULL, NULL );
1242   gtk_widget_set_usize( w, 0, 150 );
1243   gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( w ), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
1244   gtk_box_pack_start( GTK_BOX( hbox ), w, TRUE, TRUE, 0 );
1245   gtk_widget_show( w );
1246
1247   g_pEventsList = gtk_clist_new( 3 );
1248   gtk_container_add( GTK_CONTAINER(w), g_pEventsList);
1249   //gtk_signal_connect( GTK_OBJECT(g_pEventsList), "select_row", GTK_SIGNAL_FUNC (proplist_select_row), NULL);
1250   gtk_clist_set_selection_mode( GTK_CLIST(g_pEventsList), GTK_SELECTION_BROWSE );
1251   gtk_clist_column_titles_hide( GTK_CLIST(g_pEventsList) );
1252   gtk_clist_set_column_auto_resize( GTK_CLIST(g_pEventsList), 0, TRUE );
1253   gtk_clist_set_column_auto_resize( GTK_CLIST(g_pEventsList), 1, TRUE );
1254         gtk_clist_set_column_auto_resize( GTK_CLIST(g_pEventsList), 2, TRUE );
1255         gtk_widget_show( g_pEventsList );
1256
1257   vbox = gtk_vbox_new( FALSE, 5 );
1258         gtk_box_pack_start( GTK_BOX( hbox ), vbox, FALSE, FALSE, 0 );
1259         gtk_widget_show( vbox );
1260
1261         w = gtk_button_new_with_label( "Add..." );
1262         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1263         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_add ), NULL );
1264         gtk_widget_show( w );
1265
1266         w = gtk_button_new_with_label( "Del" );
1267         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1268         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_del ), NULL );
1269         gtk_widget_show( w );
1270
1271   // -------------------------- //
1272
1273   /*/
1274    |
1275    |
1276    |
1277   */
1278
1279   // the buttons column
1280   // -------------------------- //
1281
1282   vbox = gtk_vbox_new( FALSE, 5 );
1283         gtk_widget_show( vbox );
1284   gtk_table_attach( GTK_TABLE( table ), vbox, 1, 2, 0, 1,
1285                     (GtkAttachOptions) (GTK_FILL),
1286                     (GtkAttachOptions) (GTK_FILL), 0, 0 );
1287
1288         w = gtk_button_new_with_label( "New..." );
1289         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1290         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_new ), NULL );
1291         gtk_widget_show( w );
1292
1293         w = gtk_button_new_with_label( "Load..." );
1294         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1295         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_load ), NULL );
1296         gtk_widget_show( w );
1297
1298   // -------------------------- //
1299
1300   vbox = gtk_vbox_new( FALSE, 5 );
1301         gtk_widget_show( vbox );
1302   gtk_table_attach( GTK_TABLE( table ), vbox, 1, 2, 1, 2,
1303                     (GtkAttachOptions) (GTK_FILL),
1304                     (GtkAttachOptions) (GTK_FILL), 0, 0 );
1305
1306         w = gtk_button_new_with_label( "Save..." );
1307         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1308         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_save ), NULL );
1309         gtk_widget_show( w );
1310
1311         w = gtk_button_new_with_label( "Unload" );
1312         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1313         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_unload ), NULL );
1314         gtk_widget_show( w );
1315   
1316   hbox = gtk_hbox_new( FALSE, 5 );
1317         gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
1318         gtk_widget_show( hbox );
1319
1320   w = gtk_button_new_with_label( "Apply" );
1321         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1322         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_apply ), NULL );
1323         gtk_widget_show( w );
1324
1325         w = gtk_button_new_with_label( "Preview" );
1326         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1327         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_preview ), NULL );
1328         gtk_widget_show( w );
1329
1330   // -------------------------- //
1331
1332         vbox = gtk_vbox_new( FALSE, 5 );
1333         gtk_widget_show( vbox );
1334   gtk_table_attach( GTK_TABLE( table ), vbox, 1, 2, 2, 3,
1335                     (GtkAttachOptions) (GTK_FILL),
1336                     (GtkAttachOptions) (GTK_FILL), 0, 0 );
1337
1338         hbox = gtk_hbox_new( FALSE, 5 );
1339         gtk_box_pack_start( GTK_BOX( vbox ), hbox, TRUE, TRUE, 0 );
1340         gtk_widget_show( hbox );
1341
1342         w = gtk_button_new_with_label( "Close" );
1343         gtk_box_pack_start( GTK_BOX( vbox ), w, FALSE, FALSE, 0);
1344         gtk_signal_connect( GTK_OBJECT( w ), "clicked", GTK_SIGNAL_FUNC( ci_close ), NULL );
1345         GTK_WIDGET_SET_FLAGS( w, GTK_CAN_DEFAULT );
1346         gtk_widget_grab_default( w );
1347         gtk_widget_show( w );
1348
1349   // -------------------------- //
1350
1351   return window;
1352 }