void Dialog::addRadioIcons(GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importViewer, const IntExportCallback& exportViewer) { GtkWidget* table = gtk_table_new (2, static_cast<guint>(icons.last - icons.first), FALSE); gtk_widget_show (table); gtk_table_set_row_spacings (GTK_TABLE (table), 5); gtk_table_set_col_spacings (GTK_TABLE (table), 5); GSList* group = 0; GtkWidget* radio = 0; for(StringArrayRange::Iterator icon = icons.first; icon != icons.last; ++icon) { guint pos = static_cast<guint>(icon - icons.first); GtkImage* image = new_local_image(*icon); gtk_widget_show(GTK_WIDGET(image)); gtk_table_attach(GTK_TABLE(table), GTK_WIDGET(image), pos, pos+1, 0, 1, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); radio = gtk_radio_button_new(group); gtk_widget_show (radio); gtk_table_attach (GTK_TABLE (table), radio, pos, pos+1, 1, 2, (GtkAttachOptions) (0), (GtkAttachOptions) (0), 0, 0); group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(radio)); } AddIntRadioData(*GTK_RADIO_BUTTON(radio), importViewer, exportViewer); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(DialogRow_new(name, table))); }
void Dialog::addCombo (GtkWidget* vbox, const std::string& name, const std::string& registryKey, const ComboBoxValueList& valueList) { GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); gtk_widget_show(alignment); { // Create a new combo box GtkWidget* combo = gtk_combo_box_new_text(); // Add all the string values to the combo box for (ComboBoxValueList::const_iterator i = valueList.begin(); i != valueList.end(); i++) { // Add the current string value to the combo box gtk_combo_box_append_text(GTK_COMBO_BOX(combo), i->c_str()); } // Connect the registry key to the newly created combo box _registryConnector.connectGtkObject(GTK_OBJECT(combo), registryKey); // Add it to the container and make it visible gtk_widget_show(combo); gtk_container_add(GTK_CONTAINER(alignment), combo); } // Add the widget to the dialog row GtkTable* row = DialogRow_new(name, alignment); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); }
/* greebo: This adds a horizontal slider and connects it to the value of the given registryKey */ void Dialog::addSlider (GtkWidget* vbox, const std::string& name, const std::string& registryKey, gboolean draw_value, double value, double lower, double upper, double step_increment, double page_increment, double page_size) { // Create a new adjustment with the boundaries <lower> and <upper> and all the increments GtkObject* adj = gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size); // Connect the registry key to this adjustment _registryConnector.connectGtkObject(adj, registryKey); // scale GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 1.0, 0.0); gtk_widget_show(alignment); GtkWidget* scale = gtk_hscale_new(GTK_ADJUSTMENT(adj)); gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_LEFT); gtk_widget_show(scale); gtk_container_add(GTK_CONTAINER(alignment), scale); gtk_scale_set_draw_value(GTK_SCALE (scale), draw_value); int digits = (step_increment < 1.0f) ? 2 : 0; gtk_scale_set_digits(GTK_SCALE (scale), digits); GtkTable* row = DialogRow_new(name, alignment); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); }
GtkWidget* Dialog::addCheckBox(GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importViewer, const BoolExportCallback& exportViewer) { GtkWidget* check = gtk_check_button_new_with_label(flag); gtk_widget_show(check); AddBoolToggleData(*GTK_TOGGLE_BUTTON(check), importViewer, exportViewer); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(DialogRow_new(name, check))); return check; }
DialogEntryRow DialogEntryRow_new(const char* name) { GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); gtk_widget_show(alignment); GtkEntry* entry = DialogEntry_new(); gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(entry)); return DialogEntryRow(GTK_WIDGET(DialogRow_new(name, alignment)), entry); }
DialogSpinnerRow DialogSpinnerRow_new(const char* name, double value, double lower, double upper, int fraction) { GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); gtk_widget_show(alignment); GtkSpinButton* spin = DialogSpinner_new(value, lower, upper, fraction); gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(spin)); return DialogSpinnerRow(GTK_WIDGET(DialogRow_new(name, alignment)), spin); }
GtkWidget* Dialog::addPathEntry(GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importViewer, const StringExportCallback& exportViewer) { PathEntry pathEntry = PathEntry_new(); 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); AddTextEntryData(*GTK_ENTRY(pathEntry.m_entry), importViewer, exportViewer); GtkTable* row = DialogRow_new(name, GTK_WIDGET(pathEntry.m_frame)); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); return GTK_WIDGET(row); }
/* greebo: This adds a checkbox to the given VBox and connects an XMLRegistry value to it. * The actual data is "imported" and "exported" via those templates. */ GtkWidget* Dialog::addCheckBox(GtkWidget* vbox, const std::string& name, const std::string& flag, const std::string& registryKey) { // Create a new checkbox with the given caption and display it GtkWidget* check = gtk_check_button_new_with_label(flag.c_str()); gtk_widget_show(check); // Connect the registry key to this toggle button _registryConnector.connectGtkObject(GTK_OBJECT(check), registryKey); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(DialogRow_new(name, check))); return check; }
void Dialog::addRadio(GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importViewer, const IntExportCallback& exportViewer) { GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); gtk_widget_show(alignment); { RadioHBox radioBox = RadioHBox_new(names); gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(radioBox.m_hbox)); AddIntRadioData(*GTK_RADIO_BUTTON(radioBox.m_radio), importViewer, exportViewer); } GtkTable* row = DialogRow_new(name, alignment); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); }
// greebo: Adds a PathEntry to choose files or directories (depending on the given boolean) GtkWidget* Dialog::addPathEntry (GtkWidget* vbox, const std::string& name, const std::string& registryKey, bool browseDirectories) { PathEntry pathEntry = PathEntry_new(); g_signal_connect(G_OBJECT(pathEntry.m_button), "clicked", G_CALLBACK(browseDirectories ? button_clicked_entry_browse_directory : button_clicked_entry_browse_file), pathEntry.m_entry); // Connect the registry key to the newly created input field _registryConnector.connectGtkObject(GTK_OBJECT(pathEntry.m_entry), registryKey); GtkTable* row = DialogRow_new(name, GTK_WIDGET(pathEntry.m_frame)); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); return GTK_WIDGET(row); }
void Dialog::addCombo(GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importViewer, const IntExportCallback& exportViewer) { GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); gtk_widget_show(alignment); { GtkWidget* combo = gtk_combo_box_new_text(); for(StringArrayRange::Iterator i = values.first; i != values.last; ++i) { gtk_combo_box_append_text(GTK_COMBO_BOX(combo), *i); } AddIntComboData(*GTK_COMBO_BOX(combo), importViewer, exportViewer); gtk_widget_show (combo); gtk_container_add(GTK_CONTAINER(alignment), combo); } GtkTable* row = DialogRow_new(name, alignment); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); }
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) { #if 0 if(draw_value == FALSE) { GtkWidget* hbox2 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox2); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(hbox2), FALSE, FALSE, 0); { GtkWidget* label = gtk_label_new (low); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0); } { GtkWidget* label = gtk_label_new (high); gtk_widget_show (label); gtk_box_pack_end (GTK_BOX (hbox2), label, FALSE, FALSE, 0); } } #endif // adjustment GtkObject* adj = gtk_adjustment_new(value, lower, upper, step_increment, page_increment, 0); AddIntAdjustmentData(*GTK_ADJUSTMENT(adj), IntImportCaller(data), IntExportCaller(data)); // scale GtkWidget* alignment = gtk_alignment_new(0.0, 0.5, 1.0, 0.0); gtk_widget_show(alignment); GtkWidget* scale = gtk_hscale_new(GTK_ADJUSTMENT(adj)); gtk_scale_set_value_pos(GTK_SCALE(scale), GTK_POS_LEFT); gtk_widget_show(scale); gtk_container_add(GTK_CONTAINER(alignment), scale); gtk_scale_set_draw_value(GTK_SCALE (scale), draw_value); gtk_scale_set_digits(GTK_SCALE (scale), 0); GtkTable* row = DialogRow_new(name, alignment); DialogVBox_packRow(GTK_VBOX(vbox), GTK_WIDGET(row)); }