2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
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.
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.
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
23 // Base dialog class, provides a way to run modal dialogs and
24 // set/get the widget values in member variables.
26 // Leonardo Zide (leo@lokigames.com)
31 #include "debugging/debugging.h"
34 #include "mainframe.h"
38 #include <gtk/gtkmain.h>
39 #include <gtk/gtkvbox.h>
40 #include <gtk/gtkhbox.h>
41 #include <gtk/gtktogglebutton.h>
42 #include <gtk/gtkspinbutton.h>
43 #include <gtk/gtkradiobutton.h>
44 #include <gtk/gtkentry.h>
45 #include <gtk/gtkcombobox.h>
46 #include <gtk/gtklabel.h>
47 #include <gtk/gtktable.h>
48 #include <gtk/gtkhscale.h>
49 #include <gtk/gtkalignment.h>
51 #include "stream/stringstream.h"
53 #include "gtkutil/dialog.h"
54 #include "gtkutil/button.h"
55 #include "gtkutil/entry.h"
56 #include "gtkutil/image.h"
61 GtkEntry* DialogEntry_new(){
62 GtkEntry* entry = GTK_ENTRY( gtk_entry_new() );
63 gtk_widget_show( GTK_WIDGET( entry ) );
64 gtk_widget_set_size_request( GTK_WIDGET( entry ), 64, -1 );
71 DialogEntryRow( GtkWidget* row, GtkEntry* entry ) : m_row( row ), m_entry( entry ){
77 DialogEntryRow DialogEntryRow_new( const char* name ){
78 GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
79 gtk_widget_show( alignment );
81 GtkEntry* entry = DialogEntry_new();
82 gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( entry ) );
84 return DialogEntryRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), entry );
88 GtkSpinButton* DialogSpinner_new( double value, double lower, double upper, int fraction ){
89 double step = 1.0 / double(fraction);
90 unsigned int digits = 0;
91 for (; fraction > 1; fraction /= 10 )
95 GtkSpinButton* spin = GTK_SPIN_BUTTON( gtk_spin_button_new( GTK_ADJUSTMENT( gtk_adjustment_new( value, lower, upper, step, 10, 0 ) ), step, digits ) );
96 gtk_widget_show( GTK_WIDGET( spin ) );
97 gtk_widget_set_size_request( GTK_WIDGET( spin ), 64, -1 );
101 class DialogSpinnerRow
104 DialogSpinnerRow( GtkWidget* row, GtkSpinButton* spin ) : m_row( row ), m_spin( spin ){
107 GtkSpinButton* m_spin;
110 DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){
111 GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
112 gtk_widget_show( alignment );
114 GtkSpinButton* spin = DialogSpinner_new( value, lower, upper, fraction );
115 gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( spin ) );
117 return DialogSpinnerRow( GTK_WIDGET( DialogRow_new( name, alignment ) ), spin );
125 void( *Import ) ( Type_&, Other_ ),
126 void( *Export ) ( Type_&, const Callback1<Other_>& )
132 typedef Other_ Other;
134 typedef ReferenceCaller1<Type, Other, Import> ImportCaller;
135 typedef ReferenceCaller1<Type, const Callback1<Other>&, Export> ExportCaller;
138 typedef ImportExport<bool, bool, BoolImport, BoolExport> BoolImportExport;
139 typedef ImportExport<int, int, IntImport, IntExport> IntImportExport;
140 typedef ImportExport<std::size_t, std::size_t, SizeImport, SizeExport> SizeImportExport;
141 typedef ImportExport<float, float, FloatImport, FloatExport> FloatImportExport;
142 typedef ImportExport<CopiedString, const char*, StringImport, StringExport> StringImportExport;
146 void BoolToggleImport( GtkToggleButton& widget, bool value ){
147 gtk_toggle_button_set_active( &widget, value );
149 void BoolToggleExport( GtkToggleButton& widget, const BoolImportCallback& importCallback ){
150 importCallback( gtk_toggle_button_get_active( &widget ) != FALSE );
152 typedef ImportExport<GtkToggleButton, bool, BoolToggleImport, BoolToggleExport> BoolToggleImportExport;
155 void IntRadioImport( GtkRadioButton& widget, int index ){
156 radio_button_set_active( &widget, index );
158 void IntRadioExport( GtkRadioButton& widget, const IntImportCallback& importCallback ){
159 importCallback( radio_button_get_active( &widget ) );
161 typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
163 void TextEntryImport( GtkEntry& widget, const char* text ){
164 gtk_entry_set_text( &widget, text );
166 void TextEntryExport( GtkEntry& widget, const StringImportCallback& importCallback ){
167 importCallback( gtk_entry_get_text( &widget ) );
169 typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;
172 void IntEntryImport( GtkEntry& widget, int value ){
173 entry_set_int( &widget, value );
175 void IntEntryExport( GtkEntry& widget, const IntImportCallback& importCallback ){
176 importCallback( atoi( gtk_entry_get_text( &widget ) ) );
178 typedef ImportExport<GtkEntry, int, IntEntryImport, IntEntryExport> IntEntryImportExport;
181 void SizeEntryImport( GtkEntry& widget, std::size_t value ){
182 entry_set_int( &widget, int(value) );
184 void SizeEntryExport( GtkEntry& widget, const SizeImportCallback& importCallback ){
185 int value = atoi( gtk_entry_get_text( &widget ) );
189 importCallback( value );
191 typedef ImportExport<GtkEntry, std::size_t, SizeEntryImport, SizeEntryExport> SizeEntryImportExport;
194 void FloatEntryImport( GtkEntry& widget, float value ){
195 entry_set_float( &widget, value );
197 void FloatEntryExport( GtkEntry& widget, const FloatImportCallback& importCallback ){
198 importCallback( (float)atof( gtk_entry_get_text( &widget ) ) );
200 typedef ImportExport<GtkEntry, float, FloatEntryImport, FloatEntryExport> FloatEntryImportExport;
203 void FloatSpinnerImport( GtkSpinButton& widget, float value ){
204 gtk_spin_button_set_value( &widget, value );
206 void FloatSpinnerExport( GtkSpinButton& widget, const FloatImportCallback& importCallback ){
207 importCallback( float(gtk_spin_button_get_value_as_float( &widget ) ) );
209 typedef ImportExport<GtkSpinButton, float, FloatSpinnerImport, FloatSpinnerExport> FloatSpinnerImportExport;
212 void IntSpinnerImport( GtkSpinButton& widget, int value ){
213 gtk_spin_button_set_value( &widget, value );
215 void IntSpinnerExport( GtkSpinButton& widget, const IntImportCallback& importCallback ){
216 importCallback( gtk_spin_button_get_value_as_int( &widget ) );
218 typedef ImportExport<GtkSpinButton, int, IntSpinnerImport, IntSpinnerExport> IntSpinnerImportExport;
221 void IntAdjustmentImport( GtkAdjustment& widget, int value ){
222 gtk_adjustment_set_value( &widget, value );
224 void IntAdjustmentExport( GtkAdjustment& widget, const IntImportCallback& importCallback ){
225 importCallback( (int)gtk_adjustment_get_value( &widget ) );
227 typedef ImportExport<GtkAdjustment, int, IntAdjustmentImport, IntAdjustmentExport> IntAdjustmentImportExport;
230 void IntComboImport( GtkComboBox& widget, int value ){
231 gtk_combo_box_set_active( &widget, value );
233 void IntComboExport( GtkComboBox& widget, const IntImportCallback& importCallback ){
234 importCallback( gtk_combo_box_get_active( &widget ) );
236 typedef ImportExport<GtkComboBox, int, IntComboImport, IntComboExport> IntComboImportExport;
239 template<typename FirstArgument>
240 class CallbackDialogData : public DLG_DATA
243 typedef Callback1<FirstArgument> ImportCallback;
244 typedef Callback1<const ImportCallback&> ExportCallback;
247 ImportCallback m_importWidget;
248 ExportCallback m_exportWidget;
249 ImportCallback m_importViewer;
250 ExportCallback m_exportViewer;
253 CallbackDialogData( const ImportCallback& importWidget, const ExportCallback& exportWidget, const ImportCallback& importViewer, const ExportCallback& exportViewer )
254 : m_importWidget( importWidget ), m_exportWidget( exportWidget ), m_importViewer( importViewer ), m_exportViewer( exportViewer ){
259 void importData() const {
260 m_exportViewer( m_importWidget );
262 void exportData() const {
263 m_exportWidget( m_importViewer );
267 template<typename Widget, typename Viewer>
270 DialogDataList& m_data;
272 AddData( DialogDataList& data ) : m_data( data ){
274 void apply( typename Widget::Type& widget, typename Viewer::Type& viewer ) const {
276 new CallbackDialogData<typename Widget::Other>(
277 typename Widget::ImportCaller( widget ),
278 typename Widget::ExportCaller( widget ),
279 typename Viewer::ImportCaller( viewer ),
280 typename Viewer::ExportCaller( viewer )
286 template<typename Widget>
289 DialogDataList& m_data;
291 AddCustomData( DialogDataList& data ) : m_data( data ){
294 typename Widget::Type& widget,
295 const Callback1<typename Widget::Other>& importViewer,
296 const Callback1<const Callback1<typename Widget::Other>&>& exportViewer
299 new CallbackDialogData<typename Widget::Other>(
300 typename Widget::ImportCaller( widget ),
301 typename Widget::ExportCaller( widget ),
309 // =============================================================================
312 Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){
316 for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
321 ASSERT_MESSAGE( m_window == 0, "dialog window not destroyed" );
324 void Dialog::ShowDlg(){
325 ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" );
327 gtk_widget_show( GTK_WIDGET( m_window ) );
330 void Dialog::HideDlg(){
331 ASSERT_MESSAGE( m_window != 0, "dialog was not constructed" );
333 gtk_widget_hide( GTK_WIDGET( m_window ) );
336 static gint delete_event_callback( GtkWidget *widget, GdkEvent* event, gpointer data ){
337 reinterpret_cast<Dialog*>( data )->HideDlg();
338 reinterpret_cast<Dialog*>( data )->EndModal( eIDCANCEL );
342 void Dialog::Create(){
343 ASSERT_MESSAGE( m_window == 0, "dialog cannot be constructed" );
345 m_window = BuildDialog();
346 g_signal_connect( G_OBJECT( m_window ), "delete_event", G_CALLBACK( delete_event_callback ), this );
349 void Dialog::Destroy(){
350 ASSERT_MESSAGE( m_window != 0, "dialog cannot be destroyed" );
352 gtk_widget_destroy( GTK_WIDGET( m_window ) );
357 void Dialog::AddBoolToggleData( GtkToggleButton& widget, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
358 AddCustomData<BoolToggleImportExport>( m_data ).apply( widget, importViewer, exportViewer );
361 void Dialog::AddIntRadioData( GtkRadioButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
362 AddCustomData<IntRadioImportExport>( m_data ).apply( widget, importViewer, exportViewer );
365 void Dialog::AddTextEntryData( GtkEntry& widget, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
366 AddCustomData<TextEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
369 void Dialog::AddIntEntryData( GtkEntry& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
370 AddCustomData<IntEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
373 void Dialog::AddSizeEntryData( GtkEntry& widget, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
374 AddCustomData<SizeEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
377 void Dialog::AddFloatEntryData( GtkEntry& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
378 AddCustomData<FloatEntryImportExport>( m_data ).apply( widget, importViewer, exportViewer );
381 void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
382 AddCustomData<FloatSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
385 void Dialog::AddIntSpinnerData( GtkSpinButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
386 AddCustomData<IntSpinnerImportExport>( m_data ).apply( widget, importViewer, exportViewer );
389 void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
390 AddCustomData<IntAdjustmentImportExport>( m_data ).apply( widget, importViewer, exportViewer );
393 void Dialog::AddIntComboData( GtkComboBox& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
394 AddCustomData<IntComboImportExport>( m_data ).apply( widget, importViewer, exportViewer );
398 void Dialog::AddDialogData( GtkToggleButton& widget, bool& data ){
399 AddData<BoolToggleImportExport, BoolImportExport>( m_data ).apply( widget, data );
401 void Dialog::AddDialogData( GtkRadioButton& widget, int& data ){
402 AddData<IntRadioImportExport, IntImportExport>( m_data ).apply( widget, data );
404 void Dialog::AddDialogData( GtkEntry& widget, CopiedString& data ){
405 AddData<TextEntryImportExport, StringImportExport>( m_data ).apply( widget, data );
407 void Dialog::AddDialogData( GtkEntry& widget, int& data ){
408 AddData<IntEntryImportExport, IntImportExport>( m_data ).apply( widget, data );
410 void Dialog::AddDialogData( GtkEntry& widget, std::size_t& data ){
411 AddData<SizeEntryImportExport, SizeImportExport>( m_data ).apply( widget, data );
413 void Dialog::AddDialogData( GtkEntry& widget, float& data ){
414 AddData<FloatEntryImportExport, FloatImportExport>( m_data ).apply( widget, data );
416 void Dialog::AddDialogData( GtkSpinButton& widget, float& data ){
417 AddData<FloatSpinnerImportExport, FloatImportExport>( m_data ).apply( widget, data );
419 void Dialog::AddDialogData( GtkSpinButton& widget, int& data ){
420 AddData<IntSpinnerImportExport, IntImportExport>( m_data ).apply( widget, data );
422 void Dialog::AddDialogData( GtkAdjustment& widget, int& data ){
423 AddData<IntAdjustmentImportExport, IntImportExport>( m_data ).apply( widget, data );
425 void Dialog::AddDialogData( GtkComboBox& widget, int& data ){
426 AddData<IntComboImportExport, IntImportExport>( m_data ).apply( widget, data );
429 void Dialog::exportData(){
430 for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
432 ( *i )->exportData();
436 void Dialog::importData(){
437 for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
439 ( *i )->importData();
443 void Dialog::EndModal( EMessageBoxReturn code ){
448 EMessageBoxReturn Dialog::DoModal(){
453 EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal );
454 ASSERT_NOTNULL( m_window );
455 if ( ret == eIDOK ) {
459 gtk_widget_hide( GTK_WIDGET( m_window ) );
461 PostModal( m_modal.ret );
467 GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer ){
468 GtkWidget* check = gtk_check_button_new_with_label( flag );
469 gtk_widget_show( check );
470 AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), importViewer, exportViewer );
472 DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, check ) ) );
476 GtkWidget* Dialog::addCheckBox( GtkWidget* vbox, const char* name, const char* flag, bool& data ){
477 return addCheckBox( vbox, name, flag, BoolImportCaller( data ), BoolExportCaller( data ) );
480 void Dialog::addCombo( GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
481 GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
482 gtk_widget_show( alignment );
484 GtkWidget* combo = gtk_combo_box_new_text();
486 for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i )
488 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), *i );
491 AddIntComboData( *GTK_COMBO_BOX( combo ), importViewer, exportViewer );
493 gtk_widget_show( combo );
494 gtk_container_add( GTK_CONTAINER( alignment ), combo );
497 GtkTable* row = DialogRow_new( name, alignment );
498 DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
501 void Dialog::addCombo( GtkWidget* vbox, const char* name, int& data, StringArrayRange values ){
502 addCombo( vbox, name, values, IntImportCaller( data ), IntExportCaller( data ) );
505 void Dialog::addSlider( GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment ){
507 if ( draw_value == FALSE ) {
508 GtkWidget* hbox2 = gtk_hbox_new( FALSE, 0 );
509 gtk_widget_show( hbox2 );
510 gtk_box_pack_start( GTK_BOX( vbox ), GTK_WIDGET( hbox2 ), FALSE, FALSE, 0 );
512 GtkWidget* label = gtk_label_new( low );
513 gtk_widget_show( label );
514 gtk_box_pack_start( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
517 GtkWidget* label = gtk_label_new( high );
518 gtk_widget_show( label );
519 gtk_box_pack_end( GTK_BOX( hbox2 ), label, FALSE, FALSE, 0 );
525 GtkObject* adj = gtk_adjustment_new( value, lower, upper, step_increment, page_increment, 0 );
526 AddIntAdjustmentData( *GTK_ADJUSTMENT( adj ), IntImportCaller( data ), IntExportCaller( data ) );
529 GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 1.0, 0.0 );
530 gtk_widget_show( alignment );
532 GtkWidget* scale = gtk_hscale_new( GTK_ADJUSTMENT( adj ) );
533 gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT );
534 gtk_widget_show( scale );
535 gtk_container_add( GTK_CONTAINER( alignment ), scale );
537 gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value );
538 gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
540 GtkTable* row = DialogRow_new( name, alignment );
541 DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
544 void Dialog::addRadio( GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
545 GtkWidget* alignment = gtk_alignment_new( 0.0, 0.5, 0.0, 0.0 );
546 gtk_widget_show( alignment );
548 RadioHBox radioBox = RadioHBox_new( names );
549 gtk_container_add( GTK_CONTAINER( alignment ), GTK_WIDGET( radioBox.m_hbox ) );
550 AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), importViewer, exportViewer );
553 GtkTable* row = DialogRow_new( name, alignment );
554 DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
557 void Dialog::addRadio( GtkWidget* vbox, const char* name, int& data, StringArrayRange names ){
558 addRadio( vbox, name, names, IntImportCaller( data ), IntExportCaller( data ) );
561 void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
562 GtkWidget* table = gtk_table_new( 2, static_cast<guint>( icons.last - icons.first ), FALSE );
563 gtk_widget_show( table );
565 gtk_table_set_row_spacings( GTK_TABLE( table ), 5 );
566 gtk_table_set_col_spacings( GTK_TABLE( table ), 5 );
569 GtkWidget* radio = 0;
570 for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon )
572 guint pos = static_cast<guint>( icon - icons.first );
573 GtkImage* image = new_local_image( *icon );
574 gtk_widget_show( GTK_WIDGET( image ) );
575 gtk_table_attach( GTK_TABLE( table ), GTK_WIDGET( image ), pos, pos + 1, 0, 1,
576 (GtkAttachOptions) ( 0 ),
577 (GtkAttachOptions) ( 0 ), 0, 0 );
579 radio = gtk_radio_button_new( group );
580 gtk_widget_show( radio );
581 gtk_table_attach( GTK_TABLE( table ), radio, pos, pos + 1, 1, 2,
582 (GtkAttachOptions) ( 0 ),
583 (GtkAttachOptions) ( 0 ), 0, 0 );
585 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
588 AddIntRadioData( *GTK_RADIO_BUTTON( radio ), importViewer, exportViewer );
590 DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( DialogRow_new( name, table ) ) );
593 void Dialog::addRadioIcons( GtkWidget* vbox, const char* name, int& data, StringArrayRange icons ){
594 addRadioIcons( vbox, name, icons, IntImportCaller( data ), IntExportCaller( data ) );
597 GtkWidget* Dialog::addIntEntry( GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
598 DialogEntryRow row( DialogEntryRow_new( name ) );
599 AddIntEntryData( *row.m_entry, importViewer, exportViewer );
600 DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
604 GtkWidget* Dialog::addSizeEntry( GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer ){
605 DialogEntryRow row( DialogEntryRow_new( name ) );
606 AddSizeEntryData( *row.m_entry, importViewer, exportViewer );
607 DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
611 GtkWidget* Dialog::addFloatEntry( GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
612 DialogEntryRow row( DialogEntryRow_new( name ) );
613 AddFloatEntryData( *row.m_entry, importViewer, exportViewer );
614 DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
618 GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer ){
619 PathEntry pathEntry = PathEntry_new();
620 g_signal_connect( G_OBJECT( pathEntry.m_button ), "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
622 AddTextEntryData( *GTK_ENTRY( pathEntry.m_entry ), importViewer, exportViewer );
624 GtkTable* row = DialogRow_new( name, GTK_WIDGET( pathEntry.m_frame ) );
625 DialogVBox_packRow( GTK_VBOX( vbox ), GTK_WIDGET( row ) );
627 return GTK_WIDGET( row );
630 GtkWidget* Dialog::addPathEntry( GtkWidget* vbox, const char* name, CopiedString& data, bool browse_directory ){
631 return addPathEntry( vbox, name, browse_directory, StringImportCallback( StringImportCaller( data ) ), StringExportCallback( StringExportCaller( data ) ) );
634 GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer ){
635 DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
636 AddIntSpinnerData( *row.m_spin, importViewer, exportViewer );
637 DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );
641 GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper ){
642 return addSpinner( vbox, name, value, lower, upper, IntImportCallback( IntImportCaller( data ) ), IntExportCallback( IntExportCaller( data ) ) );
645 GtkWidget* Dialog::addSpinner( GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer ){
646 DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
647 AddFloatSpinnerData( *row.m_spin, importViewer, exportViewer );
648 DialogVBox_packRow( GTK_VBOX( vbox ), row.m_row );