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