Esempio n. 1
0
void PredicateDialog::onAddPredicate() {
    SimpleTypeBox box( ("New predicate name?"), "");
    std::string name = boost::trim_copy(box.run());
    if (box.valid() and checkName(name)) {
        setSensitivePredicate(false);
        Gtk::TreeIter iter = m_model->append();
        if (iter) {
            savePreviousPredicate(mPredicateNameEntry->get_text());
            mPredicateNameEntry->set_text(name);
            Gtk::ListStore::Row row = *iter;
            row[m_viewscolumnrecord.name] = name;

            mTextViewFunction->get_buffer()->set_text("");
            mHeaderPred->set_text( "bool " + name
            + "() const {" );

            m_iter = iter;
            mTreePredicateList->set_cursor(m_model->get_path(iter));
            mPredicateName.push_back(name);
            setSensitivePredicate(true);
        }
    }
    else {
        Gtk::MessageDialog errorDial ("Name error !",
            false,
            Gtk::MESSAGE_ERROR,
            Gtk::BUTTONS_OK,
            true);
        errorDial.set_title("Error !");
        errorDial.run();
    }
}
Esempio n. 2
0
void PredicateDialog::onRenamePredicate() {
    Glib::RefPtr < Gtk::TreeView::Selection > ref = mTreePredicateList->
        get_selection();
    if (ref) {
        Gtk::TreeModel::iterator iter = ref->get_selected();
        if (iter) {
            Gtk::TreeModel::Row row = *iter;
            std::string oldName(row.get_value(m_viewscolumnrecord.name));
            savePreviousPredicate(oldName);

            SimpleTypeBox box(("Predicate new name?"), "");
            std::string name = boost::trim_copy(box.run());
            if (box.valid() and checkName(name)) {

                setSensitivePredicate(false);
                m_model->erase(iter);

                Gtk::TreeModel::Children children = m_model->children();
                m_iter = children.begin();

                iter = m_model->append();
                mPredicateNameEntry->set_text(name);
                Gtk::ListStore::Row row = *iter;
                row[m_viewscolumnrecord.name] = name;

                if (mPredicateFunction.find(oldName) !=
                        mPredicateFunction.end()) {
                    mTextViewFunction->get_buffer()->
                            set_text(mPredicateFunction[oldName]);
                    mPredicateFunction[name] = mPredicateFunction[oldName];
                    mPredicateFunction.erase(oldName);
                }

                mPredicateName.push_back(name);
                // Delete the element in the vector
                for (std::vector < std::string > ::iterator it =
                        mPredicateName.begin(); it != mPredicateName.end(); ) {
                    if ( *it == oldName ) {
                        it = mPredicateName.erase(it);
                    }
                    else {
                        ++it;
                    }
                }
                mTreePredicateList->set_cursor(m_model->get_path(iter));
                setSensitivePredicate(true);
            }
            else {
                Gtk::MessageDialog errorDial ("Name error !",
                    false,
                    Gtk::MESSAGE_ERROR,
                    Gtk::BUTTONS_OK,
                    true);
                errorDial.set_title("Error !");
                errorDial.run();
            }
        }
    }
}
Esempio n. 3
0
void AckFunctionDialog::onAddAck() {
    SimpleTypeBox box( ("New acknowledge function name?"), "");
    std::string name = boost::trim_copy(box.run());

    if (box.valid()) {
        if (checkName(name)) {
            setSensitiveAck(false);
            Gtk::TreeIter iter = m_model->append();
            if (iter) {
                savePreviousAck(mAckNameEntry->get_text());
                mAckNameEntry->set_text(name);
                Gtk::ListStore::Row row = *iter;
                row[m_viewscolumnrecord.name] = name;

                mHeaderAck->set_text("void " + name + "(const std::string&"\
                        "activityname,\n\t"\
                        "const ved::Activity& activity) {");

                std::string generatedFunc = "";

                mTextViewFunction->get_buffer()->set_text(generatedFunc);

                m_iter = iter;
                mTreeAckList->set_cursor(m_model->get_path(iter));
                mAckName.push_back(name);
                setSensitiveAck(true);
            }
        }
        else {
            Gtk::MessageDialog errorDial ("Name error !",
                false,
                Gtk::MESSAGE_ERROR,
                Gtk::BUTTONS_OK,
                true);
            errorDial.set_title("Error !");
            errorDial.run();
        }
    }
}
Esempio n. 4
0
void ErrorPopup::show_msg() {
    dialog = new Gtk::MessageDialog(msg, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_CLOSE);
    dialog->set_keep_above(true);
    //Gtk::VBox *ma = dialog->get_message_area(); // not in Gtkmm 0.20
    //FIXME: no comment :-)
    Gtk::VBox *ma = dynamic_cast<Gtk::VBox*>(
	*(++dynamic_cast<Gtk::HBox*>(
	      *dialog->get_vbox()->get_children().begin())->get_children().begin()));
    // add an alignment parent to the label widget inside the message area
    // should better define our own dialog instead of hacking MessageDialog...
    Gtk::Alignment *align = new Gtk::Alignment();
    align->show();
    dynamic_cast<Gtk::Label*>(*ma->get_children().begin())->reparent(*align);
    ma->pack_start(*manage(align));
    align->set_padding(50,20,0,10);
    Gtk::VBox *vbox = dynamic_cast<Gtk::VBox *>(dialog->get_child());
    vbox->set_redraw_on_allocate(true);
    vbox->signal_expose_event().connect(
	sigc::group(&gx_cairo::error_box_expose,GTK_WIDGET(vbox->gobj()),sigc::_1,(void*)0),false);
    dialog->set_title(_("GUITARIX ERROR"));
    dialog->signal_response().connect(
	sigc::mem_fun(*this, &ErrorPopup::on_response));
    dialog->show();
}
Esempio n. 5
0
void AckFunctionDialog::onRenameAck() {
    Glib::RefPtr < Gtk::TreeView::Selection > ref = mTreeAckList->
        get_selection();
    if (ref) {
        Gtk::TreeModel::iterator iter = ref->get_selected();
        if (iter) {
            Gtk::TreeModel::Row row = *iter;
            std::string oldName(row.get_value(m_viewscolumnrecord.name));
            savePreviousAck(oldName);

            SimpleTypeBox box(("Acknowledge function new name?"), "");
            std::string name = boost::trim_copy(box.run());
            if (box.valid()) {
                if (checkName(name)) {
                    setSensitiveAck(false);
                    m_model->erase(iter);

                    Gtk::TreeModel::Children children = m_model->children();
                    m_iter = children.begin();

                    iter = m_model->append();
                    mAckNameEntry->set_text(name);
                    Gtk::ListStore::Row row = *iter;
                    row[m_viewscolumnrecord.name] = name;

                    if (mAckFunction.find(oldName) != mAckFunction.end()) {
                        mTextViewFunction->get_buffer()->
                                set_text(mAckFunction[oldName]);
                        mAckFunction[name] = mAckFunction[oldName];
                        mAckFunction.erase(oldName);
                    }

                    mAckName.push_back(name);

                    mRenameList.push_back(std::make_pair(oldName, name));

                    mHeaderAck->set_text("void " + name + "(const std::string&"\
                        "activityname,\n\t"\
                        "const ved::Activity& activity) {");
                    // Delete the element in the vector
                    for (std::vector < std::string > ::iterator it =
                            mAckName.begin(); it != mAckName.end(); ) {
                        if ( *it == oldName ) {
                            it = mAckName.erase(it);
                        }
                        else {
                            ++it;
                        }
                    }
                    mTreeAckList->set_cursor(m_model->get_path(iter));
                    setSensitiveAck(true);
                }
                else {
                    Gtk::MessageDialog errorDial ("Name error !",
                        false,
                        Gtk::MESSAGE_ERROR,
                        Gtk::BUTTONS_OK,
                        true);
                    errorDial.set_title("Error !");
                    errorDial.run();
                }
            }
        }
    }
}