예제 #1
0
void VRConceptWidget::on_select_property() {
    Gtk::TreeModel::iterator iter = treeview->get_selection()->get_selected();
    if (!iter) return;

    VRGuiSemantics_PropsColumns cols;
    Gtk::TreeModel::Row row = *iter;
    int flag = row.get_value(cols.flag);
    selected_property = flag ? 0 : concept->getProperty( row.get_value(cols.prop) );
    treeview->get_selection()->unselect_all(); // clear selection
    update();
}
예제 #2
0
void ProductoBox::actualizar(){
	Gtk::TreeModel::iterator iter =	selection -> get_selected();
	if(!iter)return;
	Gtk::TreeModel::Row row = *iter;
	Glib::ustring nombre;
	Glib::ustring descripcion;
	Glib::ustring icono;
	row.get_value(0,nombre);
	row.get_value(1,descripcion);
	row.get_value(2,icono);
	setProducto(nombre,descripcion,icono);
	graficoDeBarras->vaciar();
}
예제 #3
0
void PredicateDialog::onCursorChangeTreePredicateList() {
    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 name(row.get_value(m_viewscolumnrecord.name));
            savePreviousPredicate(mPredicateNameEntry->get_text());
            mPredicateNameEntry->set_text(name);

            if ( mPredicateFunction.find(name) != mPredicateFunction.end()) {
                mTextViewFunction->get_buffer()->
                        set_text(mPredicateFunction[ name ]);
                mHeaderPred->set_text( "bool " + name
                        + "() const {" );
            }
            else {
                mTextViewFunction->get_buffer()->set_text("");
            }

            setSensitivePredicate( true );
        }
    }
}
예제 #4
0
void AckFunctionDialog::onCursorChangeTreeAckList() {
    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 name(row.get_value(m_viewscolumnrecord.name));
            savePreviousAck(mAckNameEntry->get_text());
            mAckNameEntry->set_text(name);

            if ( mAckFunction.find(name) != mAckFunction.end() ) {
                mTextViewFunction->get_buffer()->
                        set_text(mAckFunction[ name ]);
                mHeaderAck->set_text("void " + name + "(const std::string&"\
                    "activityname,\n\t"\
                    "const ved::Activity& activity) {");
            }
            else {
                mTextViewFunction->get_buffer()->set_text("");
                mHeaderAck->set_text("void " + name + "(const std::string&"\
                    "activityname,\n\t"\
                    "const ved::Activity& activity) {");
            }

            setSensitiveAck( true );
        }
    }
}
예제 #5
0
파일: OpenVpzBox.cpp 프로젝트: rousse/vle
void OpenVpzBox::onApply()
{
    Glib::RefPtr<Gtk::TreeView::Selection> refSelection
	= mTreeView->get_selection();

    if (refSelection) {
	Gtk::TreeModel::iterator iter = refSelection->get_selected();

	if (iter) {
	    Gtk::TreeModel::Row row = *iter;
	    std::string name = row.get_value(mColumns.mName);
	    std::string pathFile = Glib::build_filename(
		utils::Path::path().getPackageExpDir(), name);

	    pathFile += ".vpz";

            mGVLE->parseXML(pathFile);
            mGVLE->getEditor()->openTabVpz(mModeling->getFileName(),
                                           mModeling->getTopModel());
            if (mModeling->getTopModel()) {
                mDialog->response(Gtk::RESPONSE_OK);
            }
        }
    }
    mDialog->hide_all();
}
예제 #6
0
void ProductoBox::imagenesProducto(){
	Gtk::TreeModel::iterator iter = selection -> get_selected();
	if(!iter)return;
	Gtk::TreeModel::Row row = *iter;
	std::string pId = row.get_value(id);
	sig_imagenesProducto.emit(pId);
}
예제 #7
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();
            }
        }
    }
}
예제 #8
0
Torrent* TorrentView::getSelectedTorrent() {
	Gtk::TreeModel::iterator iter = selection->get_selected();
	if (iter) {//si hay algo seleccionado
		Gtk::TreeModel::Row row = *iter;
		return row.get_value(col_torrent);
	} else {
		return NULL;
	}
}
예제 #9
0
파일: TreeViewValue.cpp 프로젝트: GG31/vle
void TreeViewValue::on_row_activated(const Gtk::TreeModel::Path& path,
                                     Gtk::TreeViewColumn* /*column*/)
{
    Gtk::TreeModel::iterator iter = m_refTreeModel->get_iter(path);
    if (iter) {
        Gtk::TreeModel::Row row = *iter;
        value::Value* v =  &*row.get_value(m_Columns.m_col_value);

        if (row[m_Columns.m_col_type] == _("map")) {
            value::Map* map = dynamic_cast<value::Map*>(v);
            ValueBox box(map);
            box.run();
        } else if (row[m_Columns.m_col_type] == _("set")) {
            value::Set* set = dynamic_cast<value::Set*>(v);
            ValueBox box(set);
            box.run();
        } else if (row[m_Columns.m_col_type] == _("boolean")) {
            value::Boolean* boolean = dynamic_cast<value::Boolean*>(v);
            BooleanBox box(boolean);
            box.run();
        } else if (row[m_Columns.m_col_type] == _("integer") or
                   row[m_Columns.m_col_type] == _("double") or
                   row[m_Columns.m_col_type] == _("string") or
                   row[m_Columns.m_col_type] == _("tuple")) {
            SimpleTypeBox box(v);
            box.run();
        } else if (row[m_Columns.m_col_type] == _("table")) {
            value::Table* table = dynamic_cast<value::Table*>(v);
            TableBox box(table);
            box.run();
        } else if (row[m_Columns.m_col_type] == _("matrix")) {
            value::Matrix* matrix = dynamic_cast<value::Matrix*>(v);
            MatrixBox box(matrix);
            box.run();
        } else if (row[m_Columns.m_col_type] == _("xml")) {
            value::Xml* xml = dynamic_cast<value::Xml*>(v);
            XmlTypeBox box(xml);
            box.run();
        }
        value::Value* val =  &*row.get_value(m_Columns.m_col_value);
        row[m_Columns.m_col_view] = boost::trim_copy(val->writeToString()).substr(0, GVLE::overview_max);
        refresh();
    }
}
예제 #10
0
파일: VRGuiNet.cpp 프로젝트: uagmw/polyvr
void VRGuiNet_on_argip_edited(GtkCellRendererText *cell, gchar *path_string, gchar *ip, gpointer d) {
    Glib::RefPtr<Gtk::TreeView> tree_view  = Glib::RefPtr<Gtk::TreeView>::cast_static(VRGuiBuilder()->get_object("treeview9"));
    Gtk::TreeModel::iterator iter = tree_view->get_selection()->get_selected();
    if(!iter) return;

    // set the cell with new name
    VRGuiNet_SocketCols cols;
    Gtk::TreeModel::Row row = *iter;
    row[cols.ip] = ip;

    VRSocket* socket = (VRSocket*)row.get_value(cols.obj);
    socket->setIP(ip);
}
예제 #11
0
void ProductoBox::modificarProducto(std::vector<std::string> imagenes){
	Glib::RefPtr<Gtk::Builder> builder = Gtk::Builder::create();
	builder -> add_from_file("glade/dialogoAgregarProducto.glade");
	DialogoAgregarProducto* dialogo;
	builder -> get_widget_derived("dialogoAgregarProducto", dialogo);
	Gtk::TreeModel::iterator iter = selection -> get_selected();
	if(!iter)return;
	Gtk::TreeModel::Row row = *iter;
	std::string producto = row.get_value(nombre);
	std::string descripcionS = row.get_value(descripcion);
	std::string iconoS = row.get_value(icono);	
	std::string idS = row.get_value(id);
	dialogo->precargarCampos(producto, descripcionS,iconoS,imagenes);
	int result = dialogo->run();
	if(result == Gtk::RESPONSE_CANCEL)return;
	dialogo -> close();
	std::vector<std::string> nuevasImagenes = dialogo->obtenerImagenes();
	std::string nuevoNombre = dialogo->obtenerNombreProducto();
	std::string nuevaDescripcion = dialogo->obtenerDescripcionProducto();
	std::string nuevoIcono = dialogo -> obtenerIcono();
	sig_modificarProducto.emit(idS,nuevoNombre,nuevaDescripcion,nuevoIcono,nuevasImagenes);
}
예제 #12
0
void MenuWidget::OnPassItemActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */)
{
	Gtk::TreeModel::iterator iter = m_PassTableTreeModel->get_iter(path);
	if (iter)
	{
		Gtk::TreeModel::Row row = *iter;

		std::cout << "Row activated: Name=" << row->get_value(m_TableColumn) << std::endl;

		if (iter->parent()->get_stamp())
		{
			char str[10];
			strncpy_s(str, 10, row->get_value(m_TableColumn).c_str(), 9);
			if (strcmp(str, "Object - ") == 0)
			{
				Gtk::FileChooserDialog modelDialog("Choose model file");
				modelDialog.add_button("Select", Gtk::RESPONSE_OK);
				int ret = modelDialog.run();
				if (ret == Gtk::RESPONSE_OK)
				{
					Renderer* render = Renderer::GetInstance();
					ResourceManager* resMan = render->GetResourceManager();
					const unsigned int vbIdx = resMan->CreateVertexBuffer(modelDialog.get_filename().c_str());
					for (unsigned int p = 0; p < m_arrShaderPassDesc.size(); p++)
						if (m_arrShaderPassDesc[p].name == row->parent()->get_value(m_TableColumn))
						{
							m_arrShaderPassDesc[p].model = resMan->GetVertexBuffer(vbIdx);
							break;
						}
				}
			}
		}
		else
		{
			onMenuAccess(row->get_value(m_TableColumn), row->get_value(m_TableColumn));
		}
	}
}
예제 #13
0
void ImportClassesBox::ClassesTreeView::on_drag_data_get(
    const Glib::RefPtr<Gdk::DragContext>& ,
    Gtk::SelectionData& selection_data, guint, guint)
{
    Glib::RefPtr<Gtk::TreeSelection> srcSelect(get_selection());
    if (srcSelect) {
	Gtk::TreeModel::iterator iter = srcSelect->get_selected();
	if (iter) {
	    Gtk::TreeModel::Row row = *iter;
	    std::string className = row.get_value(mColumns.m_col_name);
	    selection_data.set(selection_data.get_target(), className);
	}
    }
}
예제 #14
0
void VRGuiNet_on_name_edited(GtkCellRendererText *cell, gchar *path_string, gchar *new_name, gpointer d) {
    Glib::RefPtr<Gtk::TreeView> tree_view  = Glib::RefPtr<Gtk::TreeView>::cast_static(VRGuiBuilder()->get_object("treeview9"));
    Gtk::TreeModel::iterator iter = tree_view->get_selection()->get_selected();
    if(!iter) return;

    // get selected socket
    VRGuiNet_SocketCols cols;
    Gtk::TreeModel::Row row = *iter;
    string name = row.get_value(cols.name);
    row[cols.name] = new_name;

    // update key in map
    VRSceneManager::getCurrent()->changeSocketName(name, new_name);
}
예제 #15
0
void VRGuiBits_on_viewoption_changed(GtkComboBox* cb, gpointer data) {
    int i = gtk_combo_box_get_active(cb);
    if (i == -1) return;

    // get all in
    VRScene* scene = VRSceneManager::get()->getActiveScene();
    VRSetup* setup = VRSetupManager::get()->getCurrent();
    Glib::RefPtr<Gtk::ListStore> opt_list = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("view_options"));
    VRGuiSetup_ViewOptsColumns cols;
    Gtk::TreeModel::Row row = *getComboboxIter("combobox20");
    string opt = row.get_value(cols.option);
    bool b = row.get_value(cols.state);
    b = !b;

    // process option
    if (opt == "referentials") scene->showReferentials(b);
    if (opt == "setup") setup->showSetup(b);
    if (opt == "lights and cameras") scene->showLightsCameras(b);

    // update liststore toggle
    gtk_list_store_set (opt_list->gobj(), row.gobj(), 1, (int)b, -1);
    setCombobox("combobox20", -1);
}
예제 #16
0
void OpenModelingPluginBox::onApply()
{
    Glib::RefPtr<Gtk::TreeView::Selection> refSelection
	= mTreeView->get_selection();

    if (refSelection) {
	Gtk::TreeModel::iterator iter = refSelection->get_selected();

	if (iter) {
	    Gtk::TreeModel::Row row = *iter;

	    mPluginName = row.get_value(mColumns.mName);
            mDialog->response(Gtk::RESPONSE_OK);
	}
    }
    mDialog->hide_all();
}
예제 #17
0
int getListStorePos(string ls, string s) {
    Gtk::TreeModel::iterator iter;
    Gtk::TreeModel::Row row;
    LStore_ModelColumns mcols;
    Glib::RefPtr<Gtk::ListStore> store  = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object(ls.c_str()));
    int N = gtk_tree_model_iter_n_children( (GtkTreeModel*) store->gobj(), NULL );
    for (int i=0; i<N; i++) {
        stringstream ss; ss << i;
        iter = store->get_iter(ss.str());
        if (!iter) continue;

        row = *iter;
        string c = row.get_value(mcols.content);
        if (c == s) return i;
    }
    return -1;
}
예제 #18
0
void ProductoBox::bajaProducto(){
	Gtk::TreeModel::iterator iter = selection -> get_selected();
	if(!iter)return;
	Gtk::MessageDialog dialogo("¿Esta seguro de que desea eliminar?",false,Gtk::MESSAGE_QUESTION,Gtk::BUTTONS_OK_CANCEL);
	dialogo.set_secondary_text("Seguro?");
	int result = dialogo.run();
	switch(result){
		case Gtk::RESPONSE_OK:{
			Gtk::TreeModel::Row row = *iter;
			Glib::ustring id1;
			id1 = row.get_value(id);
			sig_bajaProducto.emit(id1);
			break;}
		case Gtk::RESPONSE_CANCEL:
			break;
	}
}
예제 #19
0
void ProductoBox::actualizarGrafico(){
	utils::StringUtils util;
	std::string s_desde = selectorFecha->obtenerDesde();
	std::string s_hasta = selectorFecha->obtenerHasta();
	Glib::DateTime fecha1 = util.stringToDate(s_desde);
	Glib::DateTime fecha2 = util.stringToDate(s_hasta);
	if(fecha2.compare(fecha1) != 1){
		Gtk::MessageDialog dialogo("La fecha final debe ser mayor a la fecha inicial",false,Gtk::MESSAGE_WARNING,Gtk::BUTTONS_OK);
		dialogo.run();
	}else{
	Gtk::TreeModel::iterator iter = selection -> get_selected();
	if(!iter)return;
		Gtk::TreeModel::Row row = *iter;
		std::string pId = row.get_value(id);
		sig_stockHistoricoProducto.emit(pId,s_desde,s_hasta);
	}
}
예제 #20
0
void
file_chooser::on_file_type_changed ()
{
  Glib::RefPtr< Gtk::TreeSelection > s (file_type_.get_selection ());
  if (!s) return;

  Gtk::TreeModel::iterator it (s->get_selected ());
  if (!it) return;

  Gtk::TreeModel::Row r (*it);
  extension_list      l (r[column->exts]);

  if (l.empty ())
    {
      expander_.set_label (_("File Type"));
    }
  else
    {
      expander_.set_label ((format (_("File type: %1%"))
                            % r.get_value (column->text)).str ());

      if (!count (l.begin (), l.end (), get_current_extension ()))
        set_current_extension (l.front ());
    }

  if (!single_image_mode_)
    {
      single_file_.set_sensitive (supports_multi_image (get_current_name ()));
      if (!supports_multi_image (get_current_name ()))
        {
          if (!regex_match (get_current_name (), filename_re))
            {
              fs::path path (get_current_name ());
              fs::path stem (path.stem ());
              fs::path ext  (path.extension ());

              path = stem;
              path = path.native () + default_pattern_;
              path.replace_extension (ext);

              set_current_name (path.string ());
            }
        }
      single_file_.set_active (requests_single_file (get_current_name ()));
    }
}
예제 #21
0
파일: VRGuiNet.cpp 프로젝트: uagmw/polyvr
void VRGuiNet_on_argtype_edited(GtkCellRendererCombo* crc, gchar *path_string, GtkTreeIter *new_iter, gpointer d) {
    Glib::RefPtr<Gtk::TreeView> tree_view  = Glib::RefPtr<Gtk::TreeView>::cast_static(VRGuiBuilder()->get_object("treeview9"));
    Gtk::TreeModel::iterator iter = tree_view->get_selection()->get_selected();
    if(!iter) return;

    // set the cell with new type
    Glib::RefPtr<Gtk::ListStore> combo_list = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("socket_type_list"));
    gchar *t;
    gtk_tree_model_get((GtkTreeModel*)combo_list->gobj(), new_iter, 0, &t, -1);
    string type = string(t);
    Gtk::TreeModel::Row row = *iter;
    VRGuiNet_SocketCols cols;
    row[cols.type] = type;

    VRSocket* socket = (VRSocket*)row.get_value(cols.obj);
    socket->setType(type);
    row[cols.sens] = socket->isClient();
}
예제 #22
0
void VRGuiNet_on_del_clicked(GtkButton*, gpointer data) {
    Glib::RefPtr<Gtk::TreeView> tree_view  = Glib::RefPtr<Gtk::TreeView>::cast_static(VRGuiBuilder()->get_object("treeview9"));
    Gtk::TreeModel::iterator iter = tree_view->get_selection()->get_selected();
    if(!iter) return;

    VRGuiNet_SocketCols cols;
    Gtk::TreeModel::Row row = *iter;
    string name = row.get_value(cols.name);

    string msg1 = "Delete socket " + name;
    if (!askUser(msg1, "Are you sure you want to delete this socket?")) return;
    VRSceneManager::getCurrent()->remSocket(name);

    Glib::RefPtr<Gtk::ListStore> list_store  = Glib::RefPtr<Gtk::ListStore>::cast_static(VRGuiBuilder()->get_object("Sockets"));
    list_store->erase(iter);

    Gtk::ToolButton* b;
    VRGuiBuilder()->get_widget("toolbutton15", b);
    b->set_sensitive(false);
}
예제 #23
0
파일: TreeViewValue.cpp 프로젝트: GG31/vle
void TreeViewValue::on_menu_duplicate()
{
    Glib::RefPtr<Gtk::TreeView::Selection> refSelection = get_selection();

    if (refSelection) {
        Gtk::TreeModel::iterator iter = refSelection->get_selected();

	if (iter) {
            Gtk::TreeModel::Row row = *iter;
            value::Value* base = &*row.get_value(m_Columns.m_col_value);

            if (mValue->getType() ==  value::Value::SET) {
                value::Set& set = mValue->toSet();
                value::VectorValue& vector = set.value();
                value::VectorValue::iterator it = vector.end();

                vector.insert(it, base->clone());

                refresh();
            } else if (mValue->getType() ==  value::Value::MAP) {
                value::Map& mp = mValue->toMap();
                value::MapValue& map = mp.value();
                std::string name = "" + row[m_Columns.m_col_name];
                int number = 1;
                std::string copy;
                value::MapValue::iterator it;
                do {
                    copy = name
                        + "_"
                        + boost::lexical_cast< std::string >(number);
                    ++number;
                    it = map.find(copy);
                } while (it != map.end());

                map[copy] = base->clone();

                refresh();
            }
        }
    }
}
예제 #24
0
파일: TreeViewValue.cpp 프로젝트: GG31/vle
void TreeViewValue::on_menu_remove()
{
    Glib::RefPtr<Gtk::TreeView::Selection> refSelection = get_selection();
    if (refSelection) {
        Gtk::TreeModel::iterator iter = refSelection->get_selected();
        if (iter) {
            Gtk::TreeModel::Row row = *iter;
            value::Value* base = &*row.get_value(m_Columns.m_col_value);

            if (mValue->getType() ==  value::Value::SET) {
                value::Set* set = dynamic_cast<value::Set*>(mValue);
                value::VectorValue& vector = set->value();

                value::VectorValue::iterator it = vector.begin();
                while (it != vector.end()) {
                    if (&**it == base)
                        break;
                    ++it;
                }

                if (it != vector.end()) {
                    vector.erase(it);
                    refresh();
                }

            } else if (mValue->getType() ==  value::Value::MAP) {
                value::Map* m  = dynamic_cast<value::Map*>(mValue);
                value::MapValue& map = m->value();
                std::string name = "" + row[m_Columns.m_col_name];

                value::MapValue::iterator it = map.find(name);
                if (it != map.end()) {
                    map.erase(it);
                    refresh();
                }

            }
        }
    }
}
예제 #25
0
void PredicateDialog::onDeletePredicate()
{
    Glib::RefPtr < Gtk::TreeView::Selection > ref = mTreePredicateList->
            get_selection();
    if (ref) {
        Gtk::TreeModel::iterator iter = ref->get_selected();
        if (iter) {
            if (Question(_("Are you sure you want to delete this predicate?"))) {
                mPredicateNameEntry->set_text("");
                mTextViewFunction->get_buffer()->set_text("");
                mHeaderPred->set_text("");
                Gtk::TreeModel::Row row = *iter;
                std::string name(row.get_value(m_viewscolumnrecord.name));
                m_model->erase(iter);

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

                // Delete the element in the vector
                for (std::vector < std::string > ::iterator it =
                        mPredicateName.begin();
                        it != mPredicateName.end(); ) {
                    if ( *it == name ) {
                        it = mPredicateName.erase(it);
                    }
                    else {
                        ++it;
                    }
                }

                if (mPredicateFunction.find(name) != mPredicateFunction.end()) {
                    mPredicateFunction.erase(name);
                }
                setSensitivePredicate(false);
            }
        }
    }
}
예제 #26
0
Glib::ustring uiFileDetailsTreeView::animalID(const Gtk::TreeModel::iterator& iter)
{
	Gtk::TreeModel::Row row = *iter;
	return row.get_value(m_Columns.m_col_animalID);
}
예제 #27
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();
                }
            }
        }
    }
}
예제 #28
0
파일: TreeViewValue.cpp 프로젝트: GG31/vle
void TreeViewValue::on_menu_insert(value::Value::type type)
{
    if (mValue->getType() ==  value::Value::SET) {
        value::Set* set = dynamic_cast<value::Set*>(mValue);
        value::VectorValue& vector = set->value();
        value::VectorValue::iterator it;

        Glib::RefPtr<Gtk::TreeView::Selection> refSelection = get_selection();
        if (refSelection) {
            Gtk::TreeModel::iterator iter = refSelection->get_selected();
            if (iter) {
                Gtk::TreeModel::Row row = *iter;
                value::Value* base = row.get_value(m_Columns.m_col_value);
                it = std::find(vector.begin(), vector.end(), base);
            } else {
                it = vector.end();
            }
        }
        switch (type) {
            using namespace value;
        case(Value::BOOLEAN):
                        vector.insert(it, Boolean::create());
            break;
        case(Value::INTEGER):
                        vector.insert(it, Integer::create());
            break;
        case(Value::DOUBLE):
                        vector.insert(it, Double::create());
            break;
        case(Value::STRING):
                        vector.insert(it, String::create());
            break;
        case(Value::SET):
                        vector.insert(it, Set::create());
            break;
        case(Value::MAP):
                        vector.insert(it, Map::create());
            break;
        case(Value::TUPLE):
                        vector.insert(it, Tuple::create());
            break;
        case(Value::TABLE): {
            SimpleTypeBox box(_("Width ?"), "1");
            int w = utils::to < int32_t >(box.run());
            SimpleTypeBox box2(_("Height ?)"), "1");
            int h = utils::to < int32_t >(box2.run());
            vector.insert(it, Table::create(w, h));
        }
        default:
            break;
        break;
        case(Value::XMLTYPE):
        vector.insert(it, Xml::create());
            break;
        case(Value::NIL):
                        vector.insert(it, Null::create());
            break;
        case(Value::MATRIX): {
            SimpleTypeBox box(_("columns ?"), "1");
            int cols = utils::to < int32_t >(box.run());
            SimpleTypeBox box2(_("rows ?"), "1");
            int rows = utils::to < int32_t >(box2.run());
            Matrix* matrix = Matrix::create(cols, rows, cols*2, rows*2, cols/5, rows/5);
            vector.insert(it, matrix);
        }
        break;
        }
        refresh();
    } else if (mValue->getType() ==  value::Value::MAP) {
        value::Map* map = dynamic_cast<value::Map*>(mValue);
        SimpleTypeBox box(_("name ?"), "");
        std::string name;
        do {
            name = box.run();
        } while (map->exist(name));

        switch (type) {
            using namespace value;
        case(Value::BOOLEAN):
                        map->addBoolean(name, false);
            break;
        case(Value::INTEGER):
                        map->addInt(name, 0);
            break;
        case(Value::DOUBLE):
                        map->addDouble(name, 0);
            break;
        case(Value::STRING):
                        map->addString(name, "");
            break;
        case(Value::SET):
                        map->addSet(name);
            break;
        case(Value::MAP):
                        map->addMap(name);
            break;
        case(Value::TUPLE):
                        map->addTuple(name);
            break;
        case(Value::TABLE): {
            SimpleTypeBox box(_("width ?"), "1");
            int w = utils::to < int32_t >(box.run());
            SimpleTypeBox box2(_("Height ?"), "1");
            int h = utils::to < int32_t >(box2.run());
            map->add(name, Table::create(w, h));
        }
        break;
        case(Value::XMLTYPE):
        map->addXml(name, "");
            break;
        case(Value::NIL):
            map->add(name, Null::create());
            break;
        case(Value::MATRIX): {
            SimpleTypeBox box(_("columns ?"), "1");
            int cols = utils::to < int32_t >(box.run());
            SimpleTypeBox box2(_("rows ?"), "1");
            int rows = utils::to < int32_t >(box2.run());
            Matrix* matrix = Matrix::create(cols, rows, cols*2, rows*2, cols/5,
                                            rows/5);
            map->add(name, matrix);
        }
        break;
        default:
        break;
        }
        refresh();
    }
}
예제 #29
0
void MenuWidget::OnConstantItemActivated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* /* column */)
{
	Gtk::TreeModel::iterator iter = m_ConstantTableTreeModel->get_iter(path);
	if (iter)
	{
		Gtk::TreeModel::Row row = *iter;

		if (!iter->parent()->get_stamp() || !iter->parent()->parent()->get_stamp())
			return; // Not good;

		std::cout << "Row activated: Name=" << row->get_value(m_TableColumn) << std::endl;

		for (unsigned int p = 0; p < m_arrShaderPassDesc.size(); p++)
		{
			if (m_arrShaderPassDesc[p].name == row->parent()->parent()->get_value(m_TableColumn))
			{
				for (unsigned int i = 0; i < m_arrShaderPassDesc[p].constants.size(); i++)
				{
					if (m_arrShaderPassDesc[p].constants[i].name == row->get_value(m_TableColumn))
					{
						switch (m_arrShaderPassDesc[p].constants[i].inputType)
						{
						case IT_BOOL:
						case IT_FLOAT:
						case IT_INT:
						{
							Gtk::Dialog matrixDialog;
							Gtk::VBox rowBox;
							Gtk::HBox colBox[4];
							Gtk::Entry entry[16];

							for (unsigned int j = 0; j < 16; j++)
							{
								char temp[32];
								sprintf_s(temp, "%f", m_arrShaderPassDesc[p].constants[i].valueFloat[j]);
								entry[j].set_text(temp);
							}

							unsigned int rows = m_arrShaderPassDesc[p].constants[i].rows;
							unsigned int cols = m_arrShaderPassDesc[p].constants[i].cols;
							unsigned int sizeOfArray = m_arrShaderPassDesc[p].constants[i].sizeOfArray;

							matrixDialog.get_vbox()->pack_start(rowBox);
							for (unsigned int r = 0; r < rows; r++)
							{
								rowBox.pack_start(colBox[r]);
								for (unsigned int c = 0; c < cols; c++)
								{
									colBox[r].pack_start(entry[r*cols + c]);
								}
							}

							matrixDialog.add_button(GTK_STOCK_OK, Gtk::RESPONSE_OK);
							matrixDialog.set_modal();
							matrixDialog.show_all();
							int ret = matrixDialog.run();
							if (ret == Gtk::RESPONSE_OK)
								for (unsigned int r = 0; r < rows; r++)
									for (unsigned int c = 0; c < cols; c++)
									{
										m_arrShaderPassDesc[p].constants[i].valueFloat[r*cols + c] = (float)atof(entry[r*cols + c].get_text().c_str());
									}

							break;
						}
						case IT_SAMPLER:
						case IT_SAMPLER1D:
						case IT_SAMPLER2D:
						case IT_SAMPLER3D:
						case IT_SAMPLERCUBE:
						{
							Gtk::FileChooserDialog textureDialog("Choose texture file");
							textureDialog.add_button("Select", Gtk::RESPONSE_OK);
							int ret = textureDialog.run();
							if (ret == Gtk::RESPONSE_OK)
							{
								Renderer* render = Renderer::GetInstance();
								ResourceManager* resMan = render->GetResourceManager();
								const unsigned int texIdx = resMan->CreateTexture(textureDialog.get_filename().c_str());
								m_arrShaderPassDesc[p].constants[i].sampler.boundTexture = resMan->GetTexture(texIdx);
							}

							break;
						}
						default:
							return;
						}

						return;
					}
				}

				return;
			}
		}
	}
}
예제 #30
0
파일: Info.cpp 프로젝트: VaysseB/openfluid
void Info::loadSelectedID(const Gtk::TreeModel::iterator& iter)
{
  Gtk::TreeModel::Row row = *iter;
  m_SelectedUnitId.insert(row.get_value(m_ModelColumnIDs.m_ID));

}