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()
63 GtkEntry* entry = GTK_ENTRY(gtk_entry_new());
64 gtk_widget_show(GTK_WIDGET(entry));
65 gtk_widget_set_size_request(GTK_WIDGET(entry), 64, -1);
72 DialogEntryRow(GtkWidget* row, GtkEntry* entry) : m_row(row), m_entry(entry)
79 DialogEntryRow DialogEntryRow_new(const char* name)
81 GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
82 gtk_widget_show(alignment);
84 GtkEntry* entry = DialogEntry_new();
85 gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(entry));
87 return DialogEntryRow(GTK_WIDGET(DialogRow_new(name, alignment)), entry);
91 GtkSpinButton* DialogSpinner_new(double value, double lower, double upper, int fraction)
93 double step = 1.0 / double(fraction);
94 unsigned int digits = 0;
95 for(;fraction > 1; fraction /= 10)
99 GtkSpinButton* spin = GTK_SPIN_BUTTON(gtk_spin_button_new(GTK_ADJUSTMENT(gtk_adjustment_new(value, lower, upper, step, 10, 10)), step, digits));
100 gtk_widget_show(GTK_WIDGET(spin));
101 gtk_widget_set_size_request(GTK_WIDGET(spin), 64, -1);
105 class DialogSpinnerRow
108 DialogSpinnerRow(GtkWidget* row, GtkSpinButton* spin) : m_row(row), m_spin(spin)
112 GtkSpinButton* m_spin;
115 DialogSpinnerRow DialogSpinnerRow_new(const char* name, double value, double lower, double upper, int fraction)
117 GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
118 gtk_widget_show(alignment);
120 GtkSpinButton* spin = DialogSpinner_new(value, lower, upper, fraction);
121 gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(spin));
123 return DialogSpinnerRow(GTK_WIDGET(DialogRow_new(name, alignment)), spin);
131 void(*Import)(Type_&, Other_),
132 void(*Export)(Type_&, const Callback1<Other_>&)
138 typedef Other_ Other;
140 typedef ReferenceCaller1<Type, Other, Import> ImportCaller;
141 typedef ReferenceCaller1<Type, const Callback1<Other>&, Export> ExportCaller;
144 typedef ImportExport<bool, bool, BoolImport, BoolExport> BoolImportExport;
145 typedef ImportExport<int, int, IntImport, IntExport> IntImportExport;
146 typedef ImportExport<std::size_t, std::size_t, SizeImport, SizeExport> SizeImportExport;
147 typedef ImportExport<float, float, FloatImport, FloatExport> FloatImportExport;
148 typedef ImportExport<CopiedString, const char*, StringImport, StringExport> StringImportExport;
152 void BoolToggleImport(GtkToggleButton& widget, bool value)
154 gtk_toggle_button_set_active(&widget, value);
156 void BoolToggleExport(GtkToggleButton& widget, const BoolImportCallback& importCallback)
158 importCallback(gtk_toggle_button_get_active(&widget) != FALSE);
160 typedef ImportExport<GtkToggleButton, bool, BoolToggleImport, BoolToggleExport> BoolToggleImportExport;
163 void IntRadioImport(GtkRadioButton& widget, int index)
165 radio_button_set_active(&widget, index);
167 void IntRadioExport(GtkRadioButton& widget, const IntImportCallback& importCallback)
169 importCallback(radio_button_get_active(&widget));
171 typedef ImportExport<GtkRadioButton, int, IntRadioImport, IntRadioExport> IntRadioImportExport;
173 template<typename Type, typename Formatter>
176 StringOutputStream value;
178 StringFromType(const Type& type)
180 value << Formatter(type);
182 operator const char*() const
184 return value.c_str();
188 typedef StringFromType<const char*, ConvertLocaleToUTF8> LocaleToUTF8;
189 typedef StringFromType<const char*, ConvertUTF8ToLocale> UTF8ToLocale;
191 void TextEntryImport(GtkEntry& widget, const char* text)
193 gtk_entry_set_text(&widget, LocaleToUTF8(text));
195 void TextEntryExport(GtkEntry& widget, const StringImportCallback& importCallback)
197 importCallback(UTF8ToLocale(gtk_entry_get_text(&widget)));
199 typedef ImportExport<GtkEntry, const char*, TextEntryImport, TextEntryExport> TextEntryImportExport;
202 void IntEntryImport(GtkEntry& widget, int value)
204 entry_set_int(&widget, value);
206 void IntEntryExport(GtkEntry& widget, const IntImportCallback& importCallback)
208 importCallback(atoi(gtk_entry_get_text (&widget)));
210 typedef ImportExport<GtkEntry, int, IntEntryImport, IntEntryExport> IntEntryImportExport;
213 void SizeEntryImport(GtkEntry& widget, std::size_t value)
215 entry_set_int(&widget, int(value));
217 void SizeEntryExport(GtkEntry& widget, const SizeImportCallback& importCallback)
219 int value = atoi(gtk_entry_get_text(&widget));
224 importCallback(value);
226 typedef ImportExport<GtkEntry, std::size_t, SizeEntryImport, SizeEntryExport> SizeEntryImportExport;
229 void FloatEntryImport(GtkEntry& widget, float value)
231 entry_set_float(&widget, value);
233 void FloatEntryExport(GtkEntry& widget, const FloatImportCallback& importCallback)
235 importCallback((float)atof(gtk_entry_get_text(&widget)));
237 typedef ImportExport<GtkEntry, float, FloatEntryImport, FloatEntryExport> FloatEntryImportExport;
240 void FloatSpinnerImport(GtkSpinButton& widget, float value)
242 gtk_spin_button_set_value(&widget, value);
244 void FloatSpinnerExport(GtkSpinButton& widget, const FloatImportCallback& importCallback)
246 importCallback(float(gtk_spin_button_get_value_as_float(&widget)));
248 typedef ImportExport<GtkSpinButton, float, FloatSpinnerImport, FloatSpinnerExport> FloatSpinnerImportExport;
251 void IntSpinnerImport(GtkSpinButton& widget, int value)
253 gtk_spin_button_set_value(&widget, value);
255 void IntSpinnerExport(GtkSpinButton& widget, const IntImportCallback& importCallback)
257 importCallback(gtk_spin_button_get_value_as_int(&widget));
259 typedef ImportExport<GtkSpinButton, int, IntSpinnerImport, IntSpinnerExport> IntSpinnerImportExport;
262 void IntAdjustmentImport(GtkAdjustment& widget, int value)
264 gtk_adjustment_set_value(&widget, value);
266 void IntAdjustmentExport(GtkAdjustment& widget, const IntImportCallback& importCallback)
268 importCallback((int)gtk_adjustment_get_value(&widget));
270 typedef ImportExport<GtkAdjustment, int, IntAdjustmentImport, IntAdjustmentExport> IntAdjustmentImportExport;
273 void IntComboImport(GtkComboBox& widget, int value)
275 gtk_combo_box_set_active(&widget, value);
277 void IntComboExport(GtkComboBox& widget, const IntImportCallback& importCallback)
279 importCallback(gtk_combo_box_get_active(&widget));
281 typedef ImportExport<GtkComboBox, int, IntComboImport, IntComboExport> IntComboImportExport;
284 template<typename FirstArgument>
285 class CallbackDialogData : public DLG_DATA
288 typedef Callback1<FirstArgument> ImportCallback;
289 typedef Callback1<const ImportCallback&> ExportCallback;
292 ImportCallback m_importWidget;
293 ExportCallback m_exportWidget;
294 ImportCallback m_importViewer;
295 ExportCallback m_exportViewer;
298 CallbackDialogData(const ImportCallback& importWidget, const ExportCallback& exportWidget, const ImportCallback& importViewer, const ExportCallback& exportViewer)
299 : m_importWidget(importWidget), m_exportWidget(exportWidget), m_importViewer(importViewer), m_exportViewer(exportViewer)
306 void importData() const
308 m_exportViewer(m_importWidget);
310 void exportData() const
312 m_exportWidget(m_importViewer);
316 template<typename Widget, typename Viewer>
319 DialogDataList& m_data;
321 AddData(DialogDataList& data) : m_data(data)
324 void apply(typename Widget::Type& widget, typename Viewer::Type& viewer) const
327 new CallbackDialogData<typename Widget::Other>(
328 typename Widget::ImportCaller(widget),
329 typename Widget::ExportCaller(widget),
330 typename Viewer::ImportCaller(viewer),
331 typename Viewer::ExportCaller(viewer)
337 template<typename Widget>
340 DialogDataList& m_data;
342 AddCustomData(DialogDataList& data) : m_data(data)
346 typename Widget::Type& widget,
347 const Callback1<typename Widget::Other>& importViewer,
348 const Callback1<const Callback1<typename Widget::Other>&>& exportViewer
352 new CallbackDialogData<typename Widget::Other>(
353 typename Widget::ImportCaller(widget),
354 typename Widget::ExportCaller(widget),
362 // =============================================================================
365 Dialog::Dialog() : m_window(0), m_parent(0)
371 for(DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i)
376 ASSERT_MESSAGE(m_window == 0, "dialog window not destroyed");
379 void Dialog::ShowDlg()
381 ASSERT_MESSAGE(m_window != 0, "dialog was not constructed");
383 gtk_widget_show(GTK_WIDGET(m_window));
386 void Dialog::HideDlg()
388 ASSERT_MESSAGE(m_window != 0, "dialog was not constructed");
390 gtk_widget_hide(GTK_WIDGET(m_window));
393 static gint delete_event_callback(GtkWidget *widget, GdkEvent* event, gpointer data)
395 reinterpret_cast<Dialog*>(data)->HideDlg();
396 reinterpret_cast<Dialog*>(data)->EndModal(eIDCANCEL);
400 void Dialog::Create()
402 ASSERT_MESSAGE(m_window == 0, "dialog cannot be constructed");
404 m_window = BuildDialog();
405 g_signal_connect(G_OBJECT(m_window), "delete_event", G_CALLBACK(delete_event_callback), this);
408 void Dialog::Destroy()
410 ASSERT_MESSAGE(m_window != 0, "dialog cannot be destroyed");
412 gtk_widget_destroy(GTK_WIDGET(m_window));
417 void Dialog::AddBoolToggleData(GtkToggleButton& widget, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer)
419 AddCustomData<BoolToggleImportExport>(m_data).apply(widget, importViewer, exportViewer);
422 void Dialog::AddIntRadioData(GtkRadioButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
424 AddCustomData<IntRadioImportExport>(m_data).apply(widget, importViewer, exportViewer);
427 void Dialog::AddTextEntryData(GtkEntry& widget, const StringImportCallback& importViewer, const StringExportCallback& exportViewer)
429 AddCustomData<TextEntryImportExport>(m_data).apply(widget, importViewer, exportViewer);
432 void Dialog::AddIntEntryData(GtkEntry& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
434 AddCustomData<IntEntryImportExport>(m_data).apply(widget, importViewer, exportViewer);
437 void Dialog::AddSizeEntryData(GtkEntry& widget, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer)
439 AddCustomData<SizeEntryImportExport>(m_data).apply(widget, importViewer, exportViewer);
442 void Dialog::AddFloatEntryData(GtkEntry& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer)
444 AddCustomData<FloatEntryImportExport>(m_data).apply(widget, importViewer, exportViewer);
447 void Dialog::AddFloatSpinnerData(GtkSpinButton& widget, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer)
449 AddCustomData<FloatSpinnerImportExport>(m_data).apply(widget, importViewer, exportViewer);
452 void Dialog::AddIntSpinnerData(GtkSpinButton& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
454 AddCustomData<IntSpinnerImportExport>(m_data).apply(widget, importViewer, exportViewer);
457 void Dialog::AddIntAdjustmentData(GtkAdjustment& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
459 AddCustomData<IntAdjustmentImportExport>(m_data).apply(widget, importViewer, exportViewer);
462 void Dialog::AddIntComboData(GtkComboBox& widget, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
464 AddCustomData<IntComboImportExport>(m_data).apply(widget, importViewer, exportViewer);
468 void Dialog::AddDialogData(GtkToggleButton& widget, bool& data)
470 AddData<BoolToggleImportExport, BoolImportExport>(m_data).apply(widget, data);
472 void Dialog::AddDialogData(GtkRadioButton& widget, int& data)
474 AddData<IntRadioImportExport, IntImportExport>(m_data).apply(widget, data);
476 void Dialog::AddDialogData(GtkEntry& widget, CopiedString& data)
478 AddData<TextEntryImportExport, StringImportExport>(m_data).apply(widget, data);
480 void Dialog::AddDialogData(GtkEntry& widget, int& data)
482 AddData<IntEntryImportExport, IntImportExport>(m_data).apply(widget, data);
484 void Dialog::AddDialogData(GtkEntry& widget, std::size_t& data)
486 AddData<SizeEntryImportExport, SizeImportExport>(m_data).apply(widget, data);
488 void Dialog::AddDialogData(GtkEntry& widget, float& data)
490 AddData<FloatEntryImportExport, FloatImportExport>(m_data).apply(widget, data);
492 void Dialog::AddDialogData(GtkSpinButton& widget, float& data)
494 AddData<FloatSpinnerImportExport, FloatImportExport>(m_data).apply(widget, data);
496 void Dialog::AddDialogData(GtkSpinButton& widget, int& data)
498 AddData<IntSpinnerImportExport, IntImportExport>(m_data).apply(widget, data);
500 void Dialog::AddDialogData(GtkAdjustment& widget, int& data)
502 AddData<IntAdjustmentImportExport, IntImportExport>(m_data).apply(widget, data);
504 void Dialog::AddDialogData(GtkComboBox& widget, int& data)
506 AddData<IntComboImportExport, IntImportExport>(m_data).apply(widget, data);
509 void Dialog::exportData()
511 for(DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i)
517 void Dialog::importData()
519 for(DialogDataList::iterator i = m_data.begin(); i != m_data.end(); ++i)
525 void Dialog::EndModal (EMessageBoxReturn code)
531 EMessageBoxReturn Dialog::DoModal()
537 EMessageBoxReturn ret = modal_dialog_show(m_window, m_modal);
538 ASSERT_NOTNULL(m_window);
544 gtk_widget_hide(GTK_WIDGET(m_window));
546 PostModal(m_modal.ret);
552 GtkWidget* Dialog::addCheckBox(GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer)
554 GtkWidget* check = gtk_check_button_new_with_label(flag);
555 gtk_widget_show(check);
556 AddBoolToggleData(*GTK_TOGGLE_BUTTON(check), importViewer, exportViewer);
558 DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(DialogRow_new(name, check)));
562 GtkWidget* Dialog::addCheckBox(GtkWidget* vbox, const char* name, const char* flag, bool& data)
564 return addCheckBox(vbox, name, flag, BoolImportCaller(data), BoolExportCaller(data));
567 void Dialog::addCombo(GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
569 GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
570 gtk_widget_show(alignment);
572 GtkWidget* combo = gtk_combo_box_new_text();
574 for(StringArrayRange::Iterator i = values.first; i != values.last; ++i)
576 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), *i);
579 AddIntComboData(*GTK_COMBO_BOX(combo), importViewer, exportViewer);
581 gtk_widget_show (combo);
582 gtk_container_add(GTK_CONTAINER(alignment), combo);
585 GtkTable* row = DialogRow_new(name, alignment);
586 DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row));
589 void Dialog::addCombo(GtkWidget* vbox, const char* name, int& data, StringArrayRange values)
591 addCombo(vbox, name, values, IntImportCaller(data), IntExportCaller(data));
594 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, double page_size)
597 if(draw_value == FALSE)
599 GtkWidget* hbox2 = gtk_hbox_new (FALSE, 0);
600 gtk_widget_show (hbox2);
601 gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox2), FALSE, FALSE, 0);
603 GtkWidget* label = gtk_label_new (low);
604 gtk_widget_show (label);
605 gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
608 GtkWidget* label = gtk_label_new (high);
609 gtk_widget_show (label);
610 gtk_box_pack_end (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
616 GtkObject* adj = gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size);
617 AddIntAdjustmentData(*GTK_ADJUSTMENT(adj), IntImportCaller(data), IntExportCaller(data));
620 GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 1.0, 0.0);
621 gtk_widget_show(alignment);
623 GtkWidget* scale = gtk_hscale_new(GTK_ADJUSTMENT(adj));
624 gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_LEFT);
625 gtk_widget_show(scale);
626 gtk_container_add(GTK_CONTAINER(alignment), scale);
628 gtk_scale_set_draw_value(GTK_SCALE (scale), draw_value);
629 gtk_scale_set_digits(GTK_SCALE (scale), 0);
631 GtkTable* row = DialogRow_new(name, alignment);
632 DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row));
635 void Dialog::addRadio(GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
637 GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0);
638 gtk_widget_show(alignment);
640 RadioHBox radioBox = RadioHBox_new(names);
641 gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(radioBox.m_hbox));
642 AddIntRadioData(*GTK_RADIO_BUTTON(radioBox.m_radio), importViewer, exportViewer);
645 GtkTable* row = DialogRow_new(name, alignment);
646 DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row));
649 void Dialog::addRadio(GtkWidget* vbox, const char* name, int& data, StringArrayRange names)
651 addRadio(vbox, name, names, IntImportCaller(data), IntExportCaller(data));
654 void Dialog::addRadioIcons(GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
656 GtkWidget* table = gtk_table_new (2, static_cast<guint>(icons.last - icons.first), FALSE);
657 gtk_widget_show (table);
659 gtk_table_set_row_spacings (GTK_TABLE (table), 5);
660 gtk_table_set_col_spacings (GTK_TABLE (table), 5);
663 GtkWidget* radio = 0;
664 for(StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon)
666 guint pos = static_cast<guint>(icon - icons.first);
667 GtkImage* image = new_local_image(*icon);
668 gtk_widget_show(GTK_WIDGET(image));
669 gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(image), pos, pos+1, 0, 1,
670 (GtkAttachOptions) (0),
671 (GtkAttachOptions) (0), 0, 0);
673 radio = gtk_radio_button_new(group);
674 gtk_widget_show (radio);
675 gtk_table_attach (GTK_TABLE (table), radio, pos, pos+1, 1, 2,
676 (GtkAttachOptions) (0),
677 (GtkAttachOptions) (0), 0, 0);
679 group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio));
682 AddIntRadioData(*GTK_RADIO_BUTTON(radio), importViewer, exportViewer);
684 DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(DialogRow_new(name, table)));
687 void Dialog::addRadioIcons(GtkWidget* vbox, const char* name, int& data, StringArrayRange icons)
689 addRadioIcons(vbox, name, icons, IntImportCaller(data), IntExportCaller(data));
692 GtkWidget* Dialog::addIntEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
694 DialogEntryRow row(DialogEntryRow_new(name));
695 AddIntEntryData(*row.m_entry, importViewer, exportViewer);
696 DialogVBox_packRow(GTK_VBOX(vbox), row.m_row);
700 GtkWidget* Dialog::addSizeEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importViewer, const SizeExportCallback& exportViewer)
702 DialogEntryRow row(DialogEntryRow_new(name));
703 AddSizeEntryData(*row.m_entry, importViewer, exportViewer);
704 DialogVBox_packRow(GTK_VBOX(vbox), row.m_row);
708 GtkWidget* Dialog::addFloatEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer)
710 DialogEntryRow row(DialogEntryRow_new(name));
711 AddFloatEntryData(*row.m_entry, importViewer, exportViewer);
712 DialogVBox_packRow(GTK_VBOX(vbox), row.m_row);
716 GtkWidget* Dialog::addPathEntry(GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer)
718 PathEntry pathEntry = PathEntry_new();
719 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);
721 AddTextEntryData(*GTK_ENTRY(pathEntry.m_entry), importViewer, exportViewer);
723 GtkTable* row = DialogRow_new(name, GTK_WIDGET(pathEntry.m_frame));
724 DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row));
726 return GTK_WIDGET(row);
729 GtkWidget* Dialog::addPathEntry(GtkWidget* vbox, const char* name, CopiedString& data, bool browse_directory)
731 return addPathEntry(vbox, name, browse_directory, StringImportCallback(StringImportCaller(data)), StringExportCallback(StringExportCaller(data)));
734 GtkWidget* Dialog::addSpinner(GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importViewer, const IntExportCallback& exportViewer)
736 DialogSpinnerRow row(DialogSpinnerRow_new(name, value, lower, upper, 1));
737 AddIntSpinnerData(*row.m_spin, importViewer, exportViewer);
738 DialogVBox_packRow(GTK_VBOX(vbox), row.m_row);
742 GtkWidget* Dialog::addSpinner(GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper)
744 return addSpinner(vbox, name, value, lower, upper, IntImportCallback(IntImportCaller(data)), IntExportCallback(IntExportCaller(data)));
747 GtkWidget* Dialog::addSpinner(GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importViewer, const FloatExportCallback& exportViewer)
749 DialogSpinnerRow row(DialogSpinnerRow_new(name, value, lower, upper, 10));
750 AddFloatSpinnerData(*row.m_spin, importViewer, exportViewer);
751 DialogVBox_packRow(GTK_VBOX(vbox), row.m_row);