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;
}
Beispiel #2
0
void MainWindow::onAddedMaterial(std::string material)
{
    std::map<std::string,int>::const_iterator it = storage->materials().find(material);
    if(it != storage->materials().end()) {
        QString buttonName(material.c_str());
        QPushButton* pb = ui->storage->findChild<QPushButton*>(buttonName);

        if(pb == 0) {
            int buttons = storage->materials().size();
            QPushButton *pb = new QPushButton(buttonName);
            pb->setObjectName(buttonName);
            connect(pb, SIGNAL(clicked()), signalMapper, SLOT(map()));
            signalMapper->setMapping(pb, buttonName);
            QSize buttonSize(90, 70);
            ui->storageLayout->addWidget(pb, (buttons - 1) / 7, (buttons - 1) % 7);
            pb->setFixedSize(buttonSize);
        } else if (!pb->isEnabled()) {
            pb->setEnabled(true);
        }
    }
}