]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/dialog.cpp
Group import/export callbacks
[xonotic/netradiant.git] / radiant / dialog.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 // Base dialog class, provides a way to run modal dialogs and
24 // set/get the widget values in member variables.
25 //
26 // Leonardo Zide (leo@lokigames.com)
27 //
28
29 #include "dialog.h"
30
31 #include <gtk/gtk.h>
32
33 #include "debugging/debugging.h"
34
35
36 #include "mainframe.h"
37
38 #include <stdlib.h>
39
40 #include "stream/stringstream.h"
41 #include "convert.h"
42 #include "gtkutil/dialog.h"
43 #include "gtkutil/button.h"
44 #include "gtkutil/entry.h"
45 #include "gtkutil/image.h"
46
47 #include "gtkmisc.h"
48
49
50 ui::Entry DialogEntry_new(){
51         auto entry = ui::Entry(ui::New);
52         entry.show();
53         entry.dimensions(64, -1);
54         return entry;
55 }
56
57 class DialogEntryRow
58 {
59 public:
60 DialogEntryRow( ui::Widget row, ui::Entry entry ) : m_row( row ), m_entry( entry ){
61 }
62 ui::Widget m_row;
63 ui::Entry m_entry;
64 };
65
66 DialogEntryRow DialogEntryRow_new( const char* name ){
67         auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
68         alignment.show();
69
70         auto entry = DialogEntry_new();
71         alignment.add(entry);
72
73         return DialogEntryRow( ui::Widget(DialogRow_new( name, alignment  )), entry );
74 }
75
76
77 ui::SpinButton DialogSpinner_new( double value, double lower, double upper, int fraction ){
78         double step = 1.0 / double(fraction);
79         unsigned int digits = 0;
80         for (; fraction > 1; fraction /= 10 )
81         {
82                 ++digits;
83         }
84         auto spin = ui::SpinButton( ui::Adjustment( value, lower, upper, step, 10, 0 ), step, digits );
85         spin.show();
86         spin.dimensions(64, -1);
87         return spin;
88 }
89
90 class DialogSpinnerRow
91 {
92 public:
93 DialogSpinnerRow( ui::Widget row, ui::SpinButton spin ) : m_row( row ), m_spin( spin ){
94 }
95 ui::Widget m_row;
96 ui::SpinButton m_spin;
97 };
98
99 DialogSpinnerRow DialogSpinnerRow_new( const char* name, double value, double lower, double upper, int fraction ){
100         auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
101         alignment.show();
102
103         auto spin = DialogSpinner_new( value, lower, upper, fraction );
104         alignment.add(spin);
105
106         return DialogSpinnerRow( ui::Widget(DialogRow_new( name, alignment  )), spin );
107 }
108
109
110 template<
111                 typename Type_,
112                 typename Other_ = Type_,
113                 class T = impexp<Type_, Other_>
114 >
115 class ImportExport {
116 public:
117         using Type = Type_;
118         using Other = Other_;
119
120         using ImportCaller = ReferenceCaller<Type, void(Other), T::Import>;
121         using ExportCaller = ReferenceCaller<Type, void(const Callback<void(Other)> &), T::Export>;
122 };
123
124
125 using BoolImportExport = ImportExport<bool>;
126
127 struct BoolToggle {
128         static void Import(GtkToggleButton &widget, bool value) {
129                 gtk_toggle_button_set_active(&widget, value);
130         }
131
132         static void Export(GtkToggleButton &widget, const ImportExportCallback<bool>::Import_t &importCallback) {
133                 importCallback(gtk_toggle_button_get_active(&widget) != FALSE);
134         }
135 };
136
137 using BoolToggleImportExport = ImportExport<GtkToggleButton, bool, BoolToggle>;
138
139 using IntImportExport = ImportExport<int>;
140
141 struct IntEntry {
142         static void Import(GtkEntry &widget, int value) {
143                 entry_set_int(ui::Entry(&widget), value);
144         }
145
146         static void Export(GtkEntry &widget, const ImportExportCallback<int>::Import_t &importCallback) {
147                 importCallback(atoi(gtk_entry_get_text(&widget)));
148         }
149 };
150
151 using IntEntryImportExport = ImportExport<GtkEntry, int, IntEntry>;
152
153 struct IntRadio {
154         static void Import(GtkRadioButton &widget, int index) {
155                 radio_button_set_active(ui::RadioButton(&widget), index);
156         }
157
158         static void Export(GtkRadioButton &widget, const ImportExportCallback<int>::Import_t &importCallback) {
159                 importCallback(radio_button_get_active(ui::RadioButton(&widget)));
160         }
161 };
162
163 using IntRadioImportExport = ImportExport<GtkRadioButton, int, IntRadio>;
164
165 struct IntCombo {
166         static void Import(GtkComboBox &widget, int value) {
167                 gtk_combo_box_set_active(&widget, value);
168         }
169
170         static void Export(GtkComboBox &widget, const ImportExportCallback<int>::Import_t &importCallback) {
171                 importCallback(gtk_combo_box_get_active(&widget));
172         }
173 };
174
175 using IntComboImportExport = ImportExport<GtkComboBox, int, IntCombo>;
176
177 struct IntAdjustment {
178         static void Import(GtkAdjustment &widget, int value) {
179                 gtk_adjustment_set_value(&widget, value);
180         }
181
182         static void Export(GtkAdjustment &widget, const ImportExportCallback<int>::Import_t &importCallback) {
183                 importCallback((int) gtk_adjustment_get_value(&widget));
184         }
185 };
186
187 using IntAdjustmentImportExport = ImportExport<GtkAdjustment, int, IntAdjustment>;
188
189 struct IntSpinner {
190         static void Import(GtkSpinButton &widget, int value) {
191                 gtk_spin_button_set_value(&widget, value);
192         }
193
194         static void Export(GtkSpinButton &widget, const ImportExportCallback<int>::Import_t &importCallback) {
195                 importCallback(gtk_spin_button_get_value_as_int(&widget));
196         }
197 };
198
199 using IntSpinnerImportExport = ImportExport<GtkSpinButton, int, IntSpinner>;
200
201 using StringImportExport = ImportExport<CopiedString, const char *>;
202
203 struct TextEntry {
204         static void Import(GtkEntry &widget, const char *text) {
205                 ui::Entry(&widget).text(text);
206         }
207
208         static void Export(GtkEntry &widget, const ImportExportCallback<const char *>::Import_t &importCallback) {
209                 importCallback(gtk_entry_get_text(&widget));
210         }
211 };
212
213 using TextEntryImportExport = ImportExport<GtkEntry, const char *, TextEntry>;
214
215 using SizeImportExport = ImportExport<std::size_t>;
216
217 struct SizeEntry {
218         static void Import(GtkEntry &widget, std::size_t value) {
219                 entry_set_int(ui::Entry(&widget), int(value));
220         }
221
222         static void Export(GtkEntry &widget, const ImportExportCallback<std::size_t>::Import_t &importCallback) {
223                 int value = atoi(gtk_entry_get_text(&widget));
224                 if (value < 0) {
225                         value = 0;
226                 }
227                 importCallback(value);
228         }
229 };
230
231 using SizeEntryImportExport = ImportExport<GtkEntry, std::size_t, SizeEntry>;
232
233 using FloatImportExport = ImportExport<float>;
234
235 struct FloatEntry {
236         static void Import(GtkEntry &widget, float value) {
237                 entry_set_float(ui::Entry(&widget), value);
238         }
239
240         static void Export(GtkEntry &widget, const ImportExportCallback<float>::Import_t &importCallback) {
241                 importCallback((float) atof(gtk_entry_get_text(&widget)));
242         }
243 };
244
245 using FloatEntryImportExport = ImportExport<GtkEntry, float, FloatEntry>;
246
247 struct FloatSpinner {
248         static void Import(GtkSpinButton &widget, float value) {
249                 gtk_spin_button_set_value(&widget, value);
250         }
251
252         static void Export(GtkSpinButton &widget, const ImportExportCallback<float>::Import_t &importCallback) {
253                 importCallback(float(gtk_spin_button_get_value(&widget)));
254         }
255 };
256
257 using FloatSpinnerImportExport = ImportExport<GtkSpinButton, float, FloatSpinner>;
258
259
260
261 template<typename T>
262 class CallbackDialogData : public DLG_DATA {
263         ImportExportCallback<T> m_cbWidget;
264         ImportExportCallback<T> m_cbViewer;
265
266 public:
267         CallbackDialogData(const ImportExportCallback<T> &cbWidget, const ImportExportCallback<T> &cbViewer)
268                         : m_cbWidget(cbWidget), m_cbViewer(cbViewer) {
269         }
270
271         void release() {
272                 delete this;
273         }
274
275         void importData() const {
276                 m_cbViewer.Export(m_cbWidget.Import);
277         }
278
279         void exportData() const {
280                 m_cbWidget.Export(m_cbViewer.Import);
281         }
282 };
283
284 template<typename Widget, typename Viewer>
285 void AddData(DialogDataList &data, typename Widget::Type &widget, typename Viewer::Type &viewer) {
286         data.push_back(
287                         new CallbackDialogData<typename Widget::Other>(
288                                         {typename Widget::ImportCaller(widget),
289                                          typename Widget::ExportCaller(widget)},
290                                         {typename Viewer::ImportCaller(viewer),
291                                          typename Viewer::ExportCaller(viewer)}
292                         )
293         );
294 }
295
296 template<typename Widget>
297 void AddCustomData(
298                 DialogDataList &data,
299                 typename Widget::Type &widget,
300                 ImportExportCallback<typename Widget::Other> const &cbViewer
301 ) {
302         data.push_back(
303                         new CallbackDialogData<typename Widget::Other>(
304                                         {typename Widget::ImportCaller(widget),
305                                          typename Widget::ExportCaller(widget)},
306                                         cbViewer
307                         )
308         );
309 }
310
311 // =============================================================================
312 // Dialog class
313
314 Dialog::Dialog() : m_window( 0 ), m_parent( 0 ){
315 }
316
317 Dialog::~Dialog(){
318         for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
319         {
320                 ( *i )->release();
321         }
322
323         ASSERT_MESSAGE( !m_window, "dialog window not destroyed" );
324 }
325
326 void Dialog::ShowDlg(){
327         ASSERT_MESSAGE( m_window, "dialog was not constructed" );
328         importData();
329         m_window.show();
330 }
331
332 void Dialog::HideDlg(){
333         ASSERT_MESSAGE( m_window, "dialog was not constructed" );
334         exportData();
335         m_window.hide();
336 }
337
338 static gint delete_event_callback( ui::Widget widget, GdkEvent* event, gpointer data ){
339         reinterpret_cast<Dialog*>( data )->HideDlg();
340         reinterpret_cast<Dialog*>( data )->EndModal( eIDCANCEL );
341         return TRUE;
342 }
343
344 void Dialog::Create(){
345         ASSERT_MESSAGE( !m_window, "dialog cannot be constructed" );
346
347         m_window = BuildDialog();
348         m_window.connect( "delete_event", G_CALLBACK( delete_event_callback ), this );
349 }
350
351 void Dialog::Destroy(){
352         ASSERT_MESSAGE( m_window, "dialog cannot be destroyed" );
353
354         m_window.destroy();
355         m_window = ui::Window{ui::null};
356 }
357
358
359 void Dialog::AddBoolToggleData( GtkToggleButton& widget, ImportExportCallback<bool> const &cb ){
360         AddCustomData<BoolToggleImportExport>( m_data, widget, cb );
361 }
362
363 void Dialog::AddIntRadioData( GtkRadioButton& widget, ImportExportCallback<int> const &cb ){
364         AddCustomData<IntRadioImportExport>( m_data, widget, cb );
365 }
366
367 void Dialog::AddTextEntryData( GtkEntry& widget, ImportExportCallback<const char *> const &cb ){
368         AddCustomData<TextEntryImportExport>( m_data, widget, cb );
369 }
370
371 void Dialog::AddIntEntryData( GtkEntry& widget, ImportExportCallback<int> const &cb ){
372         AddCustomData<IntEntryImportExport>( m_data, widget, cb );
373 }
374
375 void Dialog::AddSizeEntryData( GtkEntry& widget, ImportExportCallback<std::size_t> const &cb ){
376         AddCustomData<SizeEntryImportExport>( m_data, widget, cb );
377 }
378
379 void Dialog::AddFloatEntryData( GtkEntry& widget, ImportExportCallback<float> const &cb ){
380         AddCustomData<FloatEntryImportExport>( m_data, widget, cb );
381 }
382
383 void Dialog::AddFloatSpinnerData( GtkSpinButton& widget, ImportExportCallback<float> const &cb ){
384         AddCustomData<FloatSpinnerImportExport>( m_data, widget, cb );
385 }
386
387 void Dialog::AddIntSpinnerData( GtkSpinButton& widget, ImportExportCallback<int> const &cb ){
388         AddCustomData<IntSpinnerImportExport>( m_data, widget, cb );
389 }
390
391 void Dialog::AddIntAdjustmentData( GtkAdjustment& widget, ImportExportCallback<int> const &cb ){
392         AddCustomData<IntAdjustmentImportExport>( m_data, widget, cb );
393 }
394
395 void Dialog::AddIntComboData( GtkComboBox& widget, ImportExportCallback<int> const &cb ){
396         AddCustomData<IntComboImportExport>( m_data, widget, cb );
397 }
398
399
400 void Dialog::AddDialogData( GtkToggleButton& widget, bool& data ){
401         AddData<BoolToggleImportExport, BoolImportExport>( m_data, widget, data );
402 }
403 void Dialog::AddDialogData( GtkRadioButton& widget, int& data ){
404         AddData<IntRadioImportExport, IntImportExport>( m_data, widget, data );
405 }
406 void Dialog::AddDialogData( GtkEntry& widget, CopiedString& data ){
407         AddData<TextEntryImportExport, StringImportExport>( m_data, widget, data );
408 }
409 void Dialog::AddDialogData( GtkEntry& widget, int& data ){
410         AddData<IntEntryImportExport, IntImportExport>( m_data, widget, data );
411 }
412 void Dialog::AddDialogData( GtkEntry& widget, std::size_t& data ){
413         AddData<SizeEntryImportExport, SizeImportExport>( m_data, widget, data );
414 }
415 void Dialog::AddDialogData( GtkEntry& widget, float& data ){
416         AddData<FloatEntryImportExport, FloatImportExport>( m_data, widget, data );
417 }
418 void Dialog::AddDialogData( GtkSpinButton& widget, float& data ){
419         AddData<FloatSpinnerImportExport, FloatImportExport>( m_data, widget, data );
420 }
421 void Dialog::AddDialogData( GtkSpinButton& widget, int& data ){
422         AddData<IntSpinnerImportExport, IntImportExport>( m_data, widget, data );
423 }
424 void Dialog::AddDialogData( GtkAdjustment& widget, int& data ){
425         AddData<IntAdjustmentImportExport, IntImportExport>( m_data, widget, data );
426 }
427 void Dialog::AddDialogData( GtkComboBox& widget, int& data ){
428         AddData<IntComboImportExport, IntImportExport>( m_data, widget, data );
429 }
430
431 void Dialog::exportData(){
432         for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
433         {
434                 ( *i )->exportData();
435         }
436 }
437
438 void Dialog::importData(){
439         for ( DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i )
440         {
441                 ( *i )->importData();
442         }
443 }
444
445 void Dialog::EndModal( EMessageBoxReturn code ){
446         m_modal.loop = 0;
447         m_modal.ret = code;
448 }
449
450 EMessageBoxReturn Dialog::DoModal(){
451         importData();
452
453         PreModal();
454
455         EMessageBoxReturn ret = modal_dialog_show( m_window, m_modal );
456         ASSERT_TRUE( (bool) m_window );
457         if ( ret == eIDOK ) {
458                 exportData();
459         }
460
461         m_window.hide();
462
463         PostModal( m_modal.ret );
464
465         return m_modal.ret;
466 }
467
468
469 ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, ImportExportCallback<bool> const &cb ){
470         auto check = ui::CheckButton( flag );
471         check.show();
472         AddBoolToggleData( *GTK_TOGGLE_BUTTON( check ), cb );
473
474         DialogVBox_packRow( vbox, ui::Widget(DialogRow_new( name, check  ) ));
475         return check;
476 }
477
478 ui::CheckButton Dialog::addCheckBox( ui::VBox vbox, const char* name, const char* flag, bool& data ){
479         return addCheckBox(vbox, name, flag, mkImportExportCallback(data));
480 }
481
482 void Dialog::addCombo( ui::VBox vbox, const char* name, StringArrayRange values, ImportExportCallback<int> const &cb ){
483         auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
484         alignment.show();
485         {
486                 auto combo = ui::ComboBoxText(ui::New);
487
488                 for ( StringArrayRange::Iterator i = values.first; i != values.last; ++i )
489                 {
490                         gtk_combo_box_text_append_text( GTK_COMBO_BOX_TEXT( combo ), *i );
491                 }
492
493                 AddIntComboData( *GTK_COMBO_BOX( combo ), cb );
494
495                 combo.show();
496                 alignment.add(combo);
497         }
498
499         auto row = DialogRow_new( name, alignment );
500         DialogVBox_packRow( vbox, row );
501 }
502
503 void Dialog::addCombo( ui::VBox vbox, const char* name, int& data, StringArrayRange values ){
504         addCombo(vbox, name, values, mkImportExportCallback(data));
505 }
506
507 void Dialog::addSlider( ui::VBox 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 ){
508 #if 0
509         if ( draw_value == FALSE ) {
510                 auto hbox2 = ui::HBox( FALSE, 0 );
511                 hbox2.show();
512                 vbox.pack_start( hbox2 , FALSE, FALSE, 0 );
513                 {
514                         ui::Widget label = ui::Label( low );
515                         label.show();
516                         hbox2.pack_start( label, FALSE, FALSE, 0 );
517                 }
518                 {
519                         ui::Widget label = ui::Label( high );
520                         label.show();
521                         hbox2.pack_end(label, FALSE, FALSE, 0);
522                 }
523         }
524 #endif
525
526         // adjustment
527         auto adj = ui::Adjustment( value, lower, upper, step_increment, page_increment, 0 );
528         AddIntAdjustmentData(*GTK_ADJUSTMENT(adj), mkImportExportCallback(data));
529
530         // scale
531         auto alignment = ui::Alignment( 0.0, 0.5, 1.0, 0.0 );
532         alignment.show();
533
534         ui::Widget scale = ui::HScale( adj );
535         gtk_scale_set_value_pos( GTK_SCALE( scale ), GTK_POS_LEFT );
536         scale.show();
537         alignment.add(scale);
538
539         gtk_scale_set_draw_value( GTK_SCALE( scale ), draw_value );
540         gtk_scale_set_digits( GTK_SCALE( scale ), 0 );
541
542         auto row = DialogRow_new( name, alignment );
543         DialogVBox_packRow( vbox, row );
544 }
545
546 void Dialog::addRadio( ui::VBox vbox, const char* name, StringArrayRange names, ImportExportCallback<int> const &cb ){
547         auto alignment = ui::Alignment( 0.0, 0.5, 0.0, 0.0 );
548         alignment.show();;
549         {
550                 RadioHBox radioBox = RadioHBox_new( names );
551                 alignment.add(radioBox.m_hbox);
552                 AddIntRadioData( *GTK_RADIO_BUTTON( radioBox.m_radio ), cb );
553         }
554
555         auto row = DialogRow_new( name, alignment );
556         DialogVBox_packRow( vbox, row );
557 }
558
559 void Dialog::addRadio( ui::VBox vbox, const char* name, int& data, StringArrayRange names ){
560         addRadio(vbox, name, names, mkImportExportCallback(data));
561 }
562
563 void Dialog::addRadioIcons( ui::VBox vbox, const char* name, StringArrayRange icons, ImportExportCallback<int> const &cb ){
564     auto table = ui::Table(2, icons.last - icons.first, FALSE);
565     table.show();
566
567     gtk_table_set_row_spacings(table, 5);
568     gtk_table_set_col_spacings(table, 5);
569
570         GSList* group = 0;
571         ui::RadioButton radio{ui::null};
572         for ( StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon )
573         {
574                 guint pos = static_cast<guint>( icon - icons.first );
575                 auto image = new_local_image( *icon );
576                 image.show();
577         table.attach(image, {pos, pos + 1, 0, 1}, {0, 0});
578
579                 radio = ui::RadioButton(GTK_RADIO_BUTTON(gtk_radio_button_new( group )));
580                 radio.show();
581         table.attach(radio, {pos, pos + 1, 1, 2}, {0, 0});
582
583                 group = gtk_radio_button_get_group( GTK_RADIO_BUTTON( radio ) );
584         }
585
586         AddIntRadioData( *GTK_RADIO_BUTTON( radio ), cb );
587
588         DialogVBox_packRow( vbox, DialogRow_new( name, table ) );
589 }
590
591 void Dialog::addRadioIcons( ui::VBox vbox, const char* name, int& data, StringArrayRange icons ){
592         addRadioIcons(vbox, name, icons, mkImportExportCallback(data));
593 }
594
595 ui::Widget Dialog::addIntEntry( ui::VBox vbox, const char* name, ImportExportCallback<int> const &cb ){
596         DialogEntryRow row( DialogEntryRow_new( name ) );
597         AddIntEntryData( *GTK_ENTRY(row.m_entry), cb );
598         DialogVBox_packRow( vbox, row.m_row );
599         return row.m_row;
600 }
601
602 ui::Widget Dialog::addSizeEntry( ui::VBox vbox, const char* name, ImportExportCallback<std::size_t> const &cb ){
603         DialogEntryRow row( DialogEntryRow_new( name ) );
604         AddSizeEntryData( *GTK_ENTRY(row.m_entry), cb );
605         DialogVBox_packRow( vbox, row.m_row );
606         return row.m_row;
607 }
608
609 ui::Widget Dialog::addFloatEntry( ui::VBox vbox, const char* name, ImportExportCallback<float> const &cb ){
610         DialogEntryRow row( DialogEntryRow_new( name ) );
611         AddFloatEntryData( *GTK_ENTRY(row.m_entry), cb );
612         DialogVBox_packRow( vbox, row.m_row );
613         return row.m_row;
614 }
615
616 ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, bool browse_directory, ImportExportCallback<const char *> const &cb ){
617         PathEntry pathEntry = PathEntry_new();
618         pathEntry.m_button.connect( "clicked", G_CALLBACK( browse_directory ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file ), pathEntry.m_entry );
619
620         AddTextEntryData( *GTK_ENTRY(pathEntry.m_entry), cb );
621
622         auto row = DialogRow_new( name, ui::Widget(pathEntry.m_frame ) );
623         DialogVBox_packRow( vbox, row );
624
625         return row;
626 }
627
628 ui::Widget Dialog::addPathEntry( ui::VBox vbox, const char* name, CopiedString& data, bool browse_directory ){
629     return addPathEntry(vbox, name, browse_directory, mkImportExportCallback<CopiedString, const char *>(data));
630 }
631
632 ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, ImportExportCallback<int> const &cb ){
633         DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 1 ) );
634         AddIntSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), cb );
635         DialogVBox_packRow( vbox, row.m_row );
636         return row.m_spin;
637 }
638
639 ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, int& data, double value, double lower, double upper ){
640         return addSpinner(vbox, name, value, lower, upper, mkImportExportCallback(data));
641 }
642
643 ui::SpinButton Dialog::addSpinner( ui::VBox vbox, const char* name, double value, double lower, double upper, ImportExportCallback<float> const &cb ){
644         DialogSpinnerRow row( DialogSpinnerRow_new( name, value, lower, upper, 10 ) );
645         AddFloatSpinnerData( *GTK_SPIN_BUTTON(row.m_spin), cb );
646         DialogVBox_packRow( vbox, row.m_row );
647         return row.m_spin;
648 }