コード例 #1
0
ファイル: libraryView.cpp プロジェクト: jjkrol/ZPR
/// @fn void LibraryView::loadImagesByDirectory()
/// @brief Method (signal handler) responsible for updating thumbnails in right panel.
///        Called when directory from directory view is clicked.
/// @param path Path to selected row, provided by signal system.
/// @param column Clicked column, provided by signal system, not used.
void LibraryView::loadImagesByDirectory(const Gtk::TreeModel::Path &path,
    Gtk::TreeViewColumn *column) {
  Gtk::TreeModel::iterator row = directory_tree->get_iter(path);
  std::stack<Glib::ustring> buffer;
  boost::filesystem::path dir_path;
  if(!row) return;

  //storing directory path
  while(row) {
    buffer.push((*row)[dir_columns.name]);
    row = row->parent();
  }

  //writing directory path in reverse order
  while(!buffer.empty()) {
    dir_path /= Glib::filename_from_utf8(buffer.top());
    buffer.pop();
  }

  //loading photos
  if(core->hasPhotos(dir_path)) {
    core->setCurrentDirectory(dir_path);
    window->showEditView();
  }
}
コード例 #2
0
Gtk::TreeIter
ConfigTreeView::search_path( const char* path )
{
  Gtk::TreeModel::Children children = m_config_tree->children();
  Gtk::TreeModel::iterator iter = children.begin();
  
  while ( iter != children.end() )
  {
    Gtk::TreeModel::Row row = *iter;
    Glib::ustring p = row[ m_config_record.path ];
    size_t len = strlen( p.c_str() );

    if ( strncmp( p.c_str(), path, len) == 0 )
    {
      if ( strcmp( p.c_str(), path ) == 0 )
      { return iter; }
      else
      { iter = iter->children().begin(); }
    }
    else
    { ++iter; }
  }

  return m_config_tree->children().end();
}
コード例 #3
0
ファイル: JSTreeView.cpp プロジェクト: artcom/y60
JSBool
JSTreeView::getPropertySwitch(NATIVE & theNative, unsigned long theID,
        JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
    switch (theID) {
        case PROP_selected_row:
            try {
                Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = theNative.get_selection();
                Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
                if (iter) {
                    asl::Ptr<Gtk::TreeIter> myRow = asl::Ptr<Gtk::TreeIter>(new Gtk::TreeIter(iter));
                    *vp = as_jsval(cx, myRow, myRow.get());

                } else {
                    *vp = JSVAL_NULL;
                }
                return JS_TRUE;
            } HANDLE_CPP_EXCEPTION;
        case PROP_selected_row_values:
            try {
                Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = theNative.get_selection();
                Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
                if (iter) {
                    int myColCount = theNative.get_model()->get_n_columns();
                    vector<Glib::ustring> myStrings;
                    for (int i=1; i < myColCount; ++i) {
                        Glib::ustring myValue;
                        iter->get_value(i, myValue);
                        myStrings.push_back(myValue);
                    }
                    *vp = as_jsval(cx, myStrings);
                } else {
                    *vp = JSVAL_NULL;
                }
                return JS_TRUE;
            } HANDLE_CPP_EXCEPTION;
        case PROP_column_count:
            *vp = as_jsval(cx, theNative.get_columns().size());
            return JS_TRUE;
        case PROP_headers_visible:
            *vp = as_jsval(cx, theNative.get_headers_visible());
            return JS_TRUE;
        case PROP_signal_cursor_changed:
            {
            JSSignalProxy0<void>::OWNERPTR mySignal( new
                JSSignalProxy0<void>::NATIVE(theNative.signal_cursor_changed()));
            *vp = jslib::as_jsval(cx, mySignal);
            }
            return JS_TRUE;
        default:
            return JSBASE::getPropertySwitch(theNative, theID, cx, obj, id, vp);
    }
}
コード例 #4
0
void EntityChooser::onSelectionChanged()
{
	// Prepare to check for a selection
	Gtk::TreeModel::iterator iter = _selection->get_selected();

	if (iter)
	{
		_selectedEntityName = iter->get_value(_listColumns.name);
	}
	else
	{
		_selectedEntityName.clear();
	}
}
コード例 #5
0
ファイル: gx_jack_options.cpp プロジェクト: dafx/guitarix
void SelectJackControlPgm::on_starter_changed() {
    Gtk::TreeModel::iterator i = startercombo->get_active();
    if (!i) {
	return;
    }
    Glib::ustring s;
    i->get_value(2,s);
    description->set_markup(s);
    i->get_value(1, s);
    if (s == "other") {
	customstarter->show();
    } else {
	customstarter->hide();
    }
}
コード例 #6
0
ファイル: JSTreeView.cpp プロジェクト: artcom/y60
JSBool
JSTreeView::setPropertySwitch(NATIVE & theNative, unsigned long theID,
        JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
    switch (theID) {
        case PROP_selected_row:
            try {
                Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = theNative.get_selection();
                asl::Ptr<Gtk::TreeIter> myRow;
                convertFrom(cx, *vp, myRow);
                refTreeSelection->select(*myRow);
                return JS_TRUE;
            } HANDLE_CPP_EXCEPTION;
        case PROP_headers_visible:
            try {
                bool theFlag;
                convertFrom(cx, *vp, theFlag);
                theNative.set_headers_visible(theFlag);
                return JS_TRUE;
            } HANDLE_CPP_EXCEPTION;
        case PROP_selected_row_values:
            try {
                Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = theNative.get_selection();
                Gtk::TreeModel::iterator iter = refTreeSelection->get_selected();
                if (iter) {
                    vector<Glib::ustring> myStrings;
                    convertFrom(cx, *vp, myStrings);

                    unsigned int myColCount = theNative.get_model()->get_n_columns();
                    if (myColCount != myStrings.size()+1) {
                        JS_ReportError(cx,"selected_row_values: expected %d strings, got %d",
                                myColCount-1, myStrings.size());
                        return JS_FALSE;
                    }
                    for (unsigned int i=1; i < myColCount; ++i) {
                        iter->set_value(i, myStrings[i-1]);
                    }
                }
                return JS_TRUE;
            } HANDLE_CPP_EXCEPTION;
        default:
            return JSBASE::setPropertySwitch(theNative, theID, cx, obj, id, vp);
    }
}
コード例 #7
0
ファイル: Menu.cpp プロジェクト: iftodebogdan/ShaderEditor
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));
		}
	}
}
コード例 #8
0
ファイル: NewModelClassBox.cpp プロジェクト: SJasson/vle
void NewModelClassBox::on_apply()
{
    vpz::Classes& classes = mModeling->vpz().project().classes();

    std::string class_name = mEntryClassName->get_text();
    boost::trim(class_name);

    if (class_name.empty() || classes.exist(class_name)) {
        Error(_("Enter a VALID class name."));
        return;
    }

    Gtk::TreeModel::iterator iter = mComboTypeModel->get_active();
    if (not iter) {
        Error(_("Choose a model type."));
        return;
    }
    std::string model_type = iter->get_value(mColumns.m_col_type);

    std::string model_name = mEntryModelName->get_text();
    boost::trim(model_name);
    if (model_name.empty()) {
        Error(_("Enter a model name."));
        return;
    }

    vpz::Class& new_class = classes.add(class_name);
    if (model_type == "Atomic") {
        vpz::BaseModel* model = new vpz::AtomicModel(model_name, NULL);
        new_class.setModel(model);
    } else {
        new_class.setModel(new vpz::CoupledModel(model_name, NULL));
    }

    mGVLE->redrawModelClassBox();
    mDialog->hide_all();
}
コード例 #9
0
const GraphTreeNodePtr& GraphTreeModel::insert(const scene::INodePtr& node)
{
	// Create a new GraphTreeNode
	GraphTreeNodePtr gtNode(new GraphTreeNode(node));

	// Insert this iterator below a possible parent iterator
	Gtk::TreeModel::iterator parentIter = findParentIter(node);

	gtNode->getIter() = parentIter ? _model->append(parentIter->children()) : _model->append();

	// Fill in the values
	Gtk::TreeModel::Row row = *gtNode->getIter();

	row[_columns.node] = node.get();
	row[_columns.name] = node->name();

	// Insert this iterator into the node map to facilitate lookups
	std::pair<NodeMap::iterator, bool> result = _nodemap.insert(
		NodeMap::value_type(scene::INodeWeakPtr(node), gtNode)
	);

	// Return the GraphTreeNode reference
	return result.first->second;
}
コード例 #10
0
  void ArtistsWidget::on_itemClick(Gtk::TreeModel::Path p) {
    Gtk::TreeModel::iterator i = treeModel->get_iter(p);
    Glib::ustring s;
    int isArtist;

    MPD::Song* song;
    i->get_value(0, s);
    i->get_value(2, isArtist);
    i->get_value(3, song);



    // if is artist, load artist's songs
    if (isArtist == 1) {
      loadArtistsSongs(s.c_str());
    } else if (isArtist == 0) {
      // add to queue and play
      MPD::Client::GetInstance()->AddSong(*song, MPD::Client::GetInstance()->GetPlaylistLength());
      MPD::Client::GetInstance()->Play(MPD::Client::GetInstance()->GetPlaylistLength());
    } else {
      loadArtists();
    }

  }
コード例 #11
0
ファイル: Menu.cpp プロジェクト: iftodebogdan/ShaderEditor
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;
			}
		}
	}
}