int ZLGtkDialogManager::internalBox(const gchar *icon, const std::string &title, const std::string &message, const ZLResourceKey &button0, const ZLResourceKey &button1, const ZLResourceKey &button2) const { GtkDialog *dialog = createGtkDialog(title); if (!button0.Name.empty()) { gtk_dialog_add_button(dialog, gtkString(buttonName(button0)).c_str(), 0); } if (!button1.Name.empty()) { gtk_dialog_add_button(dialog, gtkString(buttonName(button1)).c_str(), 1); } if (!button2.Name.empty()) { gtk_dialog_add_button(dialog, gtkString(buttonName(button2)).c_str(), 2); } GtkWidget *contents = gtk_hbox_new(false, 10); gtk_container_set_border_width(GTK_CONTAINER(contents), 10); GtkWidget *image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0); GtkWidget *label = gtk_label_new(message.c_str()); gtk_label_set_line_wrap(GTK_LABEL(label), true); gtk_box_pack_start(GTK_BOX(contents), image, false, false, 0); gtk_box_pack_start(GTK_BOX(contents), label, true, true, 0); gtk_box_pack_start(GTK_BOX(dialog->vbox), contents, true, true, 0); gtk_widget_show_all(GTK_WIDGET(dialog)); gint response = gtk_dialog_run(dialog); destroyGtkDialog(dialog); return (response < 0) ? -1 : response; }
void BooleanOptionView::_createItem() { if (ZLDeviceInfo::isKeyboardPresented()) { myCheckBox = gtk_check_button_new_with_mnemonic(gtkString(myOption->name(), true).c_str()); } else { myCheckBox = gtk_check_button_new_with_label(gtkString(myOption->name(), false).c_str()); } gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(myCheckBox), ((ZLBooleanOptionEntry*)myOption)->initialState()); g_signal_connect(myCheckBox, "toggled", G_CALLBACK(_onValueChange), this); myTab->addItem(myCheckBox, myRow, myFromColumn, myToColumn); }
GtkOptionsDialog::GtkOptionsDialog(const std::string &id, const std::string &caption) : ZLDesktopOptionsDialog(id) { myDialog = createGtkDialog(caption); std::string okString = gtkString("&Ok"); std::string cancelString = gtkString("&Cancel"); gtk_dialog_add_button (myDialog, okString.c_str(), GTK_RESPONSE_ACCEPT); gtk_dialog_add_button (myDialog, cancelString.c_str(), GTK_RESPONSE_REJECT); myNotebook = GTK_NOTEBOOK(gtk_notebook_new()); gtk_container_set_border_width(GTK_CONTAINER(myNotebook), 8); gtk_box_pack_start(GTK_BOX(myDialog->vbox), GTK_WIDGET(myNotebook), TRUE, TRUE, 0); gtk_widget_show(GTK_WIDGET(myNotebook)); }
ZLGtkOpenFileDialog::ZLGtkOpenFileDialog(const std::string &title, const std::string &directoryPath, const std::string &filePath, const Filter &filter) { myDialog = GTK_DIALOG(gtk_file_chooser_dialog_new( title.c_str(), 0, GTK_FILE_CHOOSER_ACTION_OPEN, gtkString(ZLDialogManager::buttonName(ZLDialogManager::CANCEL_BUTTON)).c_str(), GTK_RESPONSE_CANCEL, gtkString(ZLDialogManager::buttonName(ZLDialogManager::OK_BUTTON)).c_str(), GTK_RESPONSE_ACCEPT, 0 )); GtkFileChooser *chooser = GTK_FILE_CHOOSER(myDialog); gtk_file_chooser_set_current_folder(chooser, directoryPath.c_str()); gtk_file_chooser_set_filename(chooser, filePath.c_str()); GtkFileFilter *gtkFilter = gtk_file_filter_new(); gtk_file_filter_add_custom(gtkFilter, (GtkFileFilterFlags)(GTK_FILE_FILTER_FILENAME | GTK_FILE_FILTER_MIME_TYPE), filterHandler, (void*)&filter, 0); gtk_file_chooser_set_filter(chooser, gtkFilter); }
void GtkCommonDialog::addButton(const std::string &text) { std::string buttonText = gtkString(text); gtk_dialog_add_button(myDialog, buttonText.c_str(), GTK_RESPONSE_ACCEPT); }
void Boolean3OptionView::_createItem() { myCheckBox = GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic(gtkString(name()).c_str())); setState(((ZLBoolean3OptionEntry&)*myOption).initialState()); g_signal_connect(GTK_WIDGET(myCheckBox), "released", G_CALLBACK(_onReleased), this); myHolder.attachWidget(*this, GTK_WIDGET(myCheckBox)); }
void BooleanOptionView::_createItem() { myCheckBox = GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic(gtkString(name()).c_str())); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(myCheckBox), ((ZLBooleanOptionEntry&)*myOption).initialState()); g_signal_connect(GTK_WIDGET(myCheckBox), "toggled", G_CALLBACK(_onValueChanged), this); myHolder.attachWidget(*this, GTK_WIDGET(myCheckBox)); }
static GtkLabel *gtkLabel(const std::string &name) { GtkLabel *label = GTK_LABEL(gtk_label_new((gtkString(name) + ":").c_str())); gtk_label_set_justify(label, GTK_JUSTIFY_RIGHT); return label; }
std::string gtkString(const std::string &str) { return gtkString(str, true); }
void BooleanOptionView::_createItem() { myCheckBox = GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic(gtkString(ZLOptionView::name()).c_str())); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(myCheckBox), ((ZLBooleanOptionEntry&)*myOption).initialState()); g_signal_connect(GTK_WIDGET(myCheckBox), "toggled", G_CALLBACK(_onValueChanged), this); myTab->addItem(GTK_WIDGET(myCheckBox), myRow, myFromColumn, myToColumn); }
void Boolean3OptionView::_createItem() { myCheckBox = GTK_CHECK_BUTTON(gtk_check_button_new_with_mnemonic(gtkString(name()).c_str())); setState(((ZLBoolean3OptionEntry&)*myOption).initialState()); g_signal_connect(GTK_WIDGET(myCheckBox), "released", G_CALLBACK(_onReleased), this); myTab->addItem(GTK_WIDGET(myCheckBox), myRow, myFromColumn, myToColumn); }
std::string gtkString(const std::string &str) { return gtkString(str, ZLDeviceInfo::isKeyboardPresented()); }
void ZLGtkDialog::addButton(const ZLResourceKey &key, bool accept) { std::string buttonText = gtkString(ZLDialogManager::buttonName(key)); gtk_dialog_add_button(myDialog, buttonText.c_str(), accept ? GTK_RESPONSE_ACCEPT : GTK_RESPONSE_REJECT); }