void GtkTorrentSideBar::addedItem(std::string path, std::string name)
{
	// Depending on the parent, we create a label or an rss group
	// TreeRows are iterators, so comparison is valid.
	Gtk::TreeModel::Row row = *m_liststore->get_iter(path);
	if(row->parent() && *row->parent() == m_torrent_row)
	{
		Gtk::TreeModel::Row newrow = *(m_liststore->insert(row));
		newrow[m_cols.name] = name + " (" + '0' + ")";
		newrow[m_cols.editable] = true;
		newrow[m_cols.icon] = Glib::RefPtr<Gdk::Pixbuf>();
		newrow[m_cols.clickCallback] = [row](){};
		// TODO: Pop up a new label dialog.
		// Torrent should be added a label by drag and dropping them into the sidebar
		// see enable_model_drag_source
		// and enable_model_drag_dest
	}
	else if(row->parent() && *row->parent() == m_rssfeed_row)
	{
		Gtk::TreeModel::Row newrow = *(m_liststore->insert(row));
		newrow[m_cols.name] = name + " (" + '0' + ")";
		newrow[m_cols.editable] = true;
		newrow[m_cols.icon] = Glib::RefPtr<Gdk::Pixbuf>();
		newrow[m_cols.clickCallback] = [this, name](){m_rss->run(name);	m_rss->hide();};
		m_rss->set_default_response(1);
		int code = m_rss->run(name);
		m_rss->hide();
		if(code == 1)
			Application::getSingleton()->getCore()->m_feeds.push_back(m_rss->feedg);
		// TODO: implement RSS dialog and pop it up here
	}
}
Beispiel #2
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));
		}
	}
}
Beispiel #3
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;
			}
		}
	}
}