void statusRecord::appendToView(Gtk::TreeView* _treeview)
         {
            _treeview->append_column("Filename", filename);
            _treeview->append_column("Status",   status);
#if GTKMM_2_6_OR_BETTER
            // Add a progress bar, showing status.

            Gtk::CellRendererProgress* cell = Gtk::manage(new Gtk::CellRendererProgress);
            int last_count = _treeview->append_column("Progress", *cell);

            Gtk::TreeViewColumn* column = _treeview->get_column(last_count - 1);
            if (column)
               {
                  column->add_attribute(cell->property_value(), done);
                  column->add_attribute(cell->property_text(), doneText);
               }

#else
            // Old gtkmm version, so use boring text.
            _treeview->append_column("Progress", done);
#endif // GTKMM_2_6_OR_BETTER

            _treeview->append_column("Download", dn_rate);
            _treeview->append_column("Upload",   ul_rate);
            _treeview->append_column("Filesize", filesize);
            _treeview->append_column("Peers l/s", peers);
         }
void Portfolio::reflesh()
{
	  //Fill the TreeView's model
      m_refTreeModel->clear();
      m_TreeView.remove_all_columns();

	  //Add the TreeView's view columns:
	  m_TreeView.append_column("Currency", m_Columns.m_col_currency);
	  m_TreeView.append_column("Amount", m_Columns.m_col_amount);

	  vector<AccountDatum*> accountData = OutgoingRequest::requestAccountData();
	  vector<double> in_yens;
	  vector<double> percentages;
	  double sum;

	  for(size_t i=0; i<accountData.size(); i++)
	  {
		  string symbol = accountData.at(i)->currency;
		  double rate = lexical_cast<double>(OutgoingRequest::requestLatestRate(symbol, "JPY"));
		  double in_yen = accountData.at(i)->amount * rate;
		  in_yens.push_back(in_yen);
	  }

	  sum = boost::accumulate(in_yens, 0);

	  for(size_t i=0; i<accountData.size(); i++)
	  {
		  double percentage = in_yens.at(i)/sum * 100;
		  percentages.push_back(percentage);
	  }

	  Gtk::TreeModel::Row row;
	  for(size_t i=0; i<accountData.size(); i++){
		  row = *(m_refTreeModel->append());
		  row[m_Columns.m_col_currency] = accountData.at(i)->currency;
		  row[m_Columns.m_col_amount] = accountData.at(i)->amount;
		  row[m_Columns.m_col_percentage] = percentages.at(i);
	  }

	  Gtk::CellRendererProgress* cell = Gtk::manage(new Gtk::CellRendererProgress);
	  int cols_count = m_TreeView.append_column("Percentage", *cell);
	  Gtk::TreeViewColumn* pColumn = m_TreeView.get_column(cols_count - 1);
	  if(pColumn)
	  {
	    pColumn->add_attribute(cell->property_value(), m_Columns.m_col_percentage);
	  }

	  for(guint i = 0; i < 2; i++)
	  {
	    Gtk::TreeView::Column* pColumn = m_TreeView.get_column(i);
	    pColumn->set_reorderable();
	  }

	  show_all_children();
}
Exemple #3
0
void Frame_FilesTab::treeviewcolumn_fileprogress(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter)
{
    if(iter)
    {
        Gtk::TreeModel::Row row = *iter;
        int model_value = row[FilesColumns.Progress];

        Gtk::CellRendererProgress *crp = dynamic_cast<Gtk::CellRendererProgress*>(renderer);
        crp->set_property("value", model_value);
    }
}
// TODO REFACTOR THE LIVING HELL OUT OF THIS ABOMINATION -- nyanpasu
void GtkTorrentTreeView::setupColumns()
{
	Gtk::TreeViewColumn *col = nullptr;
	Gtk::CellRendererProgress *cell = nullptr;

	vector<pair<int, int>> columns; //First element id second element size
	columns.push_back(make_pair(this->append_column("#", m_cols.m_col_queue), 30));
	columns.push_back(make_pair(this->append_column("Status", m_cols.m_col_name), 200));
	columns.push_back(make_pair(this->append_column("Name", m_cols.m_col_name), 200));
	columns.push_back(make_pair(this->append_column("Size", m_cols.m_col_size), 80));
	columns.push_back(make_pair(this->append_column("Down", m_cols.m_col_dl_speed), 60));
	columns.push_back(make_pair(this->append_column("Up", m_cols.m_col_ul_speed), 60));
	columns.push_back(make_pair(this->append_column("Ratio", m_cols.m_col_dl_ratio), 60));
	columns.push_back(make_pair(this->append_column("Downloaded", m_cols.m_col_dl_total), 80));
	get_column(columns.back().first - 1)->set_visible(false);
	columns.push_back(make_pair(this->append_column("Uploaded", m_cols.m_col_ul_total), 80));
	get_column(columns.back().first - 1)->set_visible(false);
	columns.push_back(make_pair(this->append_column("Seed", m_cols.m_col_seeders), 60));
	columns.push_back(make_pair(this->append_column("Leech", m_cols.m_col_leechers), 60));
	columns.push_back(make_pair(this->append_column("Age", m_cols.m_col_age), 50));
	columns.push_back(make_pair(this->append_column("ETA", m_cols.m_col_eta), 80));
	cell = Gtk::manage(new Gtk::CellRendererProgress());
	columns.push_back(make_pair(this->append_column("Progress", *cell), 160));
	col = this->get_column(columns.back().first - 1);
	col->add_attribute(cell->property_value(), m_cols.m_col_percent);
	col->add_attribute(cell->property_text(), m_cols.m_col_percent_text);



	columns.push_back(make_pair(this->append_column("Remains", m_cols.m_col_remaining), 80));
	get_column(columns.back().first - 1)->set_visible(false);

	for (pair<int, int> colpair : columns)
	{
		Gtk::Button *butt = get_column(colpair.first - 1)->get_button();
		butt->signal_button_press_event().connect(sigc::mem_fun(*this, &GtkTorrentTreeView::torrentColumns_onClick));
		get_column(colpair.first - 1)->set_sizing(Gtk::TreeViewColumnSizing::TREE_VIEW_COLUMN_FIXED);
		get_column(colpair.first - 1)->set_alignment(0.5f);
		get_column(colpair.first - 1)->set_clickable();
		get_column(colpair.first - 1)->set_resizable();
		get_column(colpair.first - 1)->set_reorderable();
		get_column(colpair.first - 1)->set_fixed_width(colpair.second);

	}
}
void TorrentView::setTreeView(Gtk::TreeView *view_torrents) {
	this->view_torrents = view_torrents;

	//agrego la lista de torrents al tree view
	this->view_torrents->set_model(list_torrents);

	Gtk::TreeViewColumn* pColumn;
	int cols_count;

	//agrego columnas al Tree View
	this->view_torrents->append_column(COL_NAME, col_name);
	this->view_torrents->append_column(COL_SIZE, col_size);
	this->view_torrents->append_column(COL_STATUS, col_status);

	//mostrar una progress bar para el porcentaje de progreso
	Gtk::CellRendererProgress* cell =
		Gtk::manage(new Gtk::CellRendererProgress);
	cols_count = this->view_torrents->append_column(COL_PROGRESS, *cell);
	pColumn = this->view_torrents->get_column(cols_count - 1);
	if (pColumn) {
#ifdef GLIBMM_PROPERTIES_ENABLED
		pColumn->add_attribute(cell->property_value(), col_progress);
#else
		pColumn->add_attribute(*cell, "value", col_progress);
#endif
	}

	this->view_torrents->append_column(COL_COMPLETED, col_completed);
	this->view_torrents->append_column(COL_REMAINING, col_remaining);
	this->view_torrents->append_column(COL_DOWNSPEED, col_downspeed);
	this->view_torrents->append_column(COL_UPSPEED, col_upspeed);
	cols_count = this->view_torrents->append_column(COL_TIME, col_time);

	for (int i = 0; i < cols_count; i++) {
		pColumn = this->view_torrents->get_column(i);
		pColumn->set_resizable(true); //hago que sean columnas redimensionables
	}
	this->view_torrents->columns_autosize();

	selection = this->view_torrents->get_selection();
	selection->signal_changed().connect(sigc::mem_fun(*this,
			&TorrentView::on_row_selected));

}
void GtkTorrentTreeView::setupColumns()
{
	unsigned int cid = 0;
	Gtk::TreeViewColumn *col = nullptr;

	cid = this->append_column("Name", m_cols.m_col_name);
	col = this->get_column(cid - 1);
	col->set_fixed_width(250);

	cid = this->append_column("Seeders", m_cols.m_col_seeders);
	col = this->get_column(cid - 1);
	col->set_alignment(0.5);
	col->set_fixed_width(90);
	
	cid = this->append_column("Leechers", m_cols.m_col_leechers);
	col = this->get_column(cid - 1);
	col->set_alignment(0.5);
	col->set_fixed_width(90);

	cid = this->append_column("Rate (KB/s)", m_cols.m_col_dl_speed);
	col = this->get_column(cid - 1);
	col->set_alignment(0.5);
	col->set_fixed_width(95);

	Gtk::CellRendererProgress *cell = Gtk::manage(new Gtk::CellRendererProgress());
	cid = this->append_column("Progress", *cell);
	col = this->get_column(cid - 1);

	if (col) {
		col->add_attribute(cell->property_value(), m_cols.m_col_percent);
		col->add_attribute(cell->property_text(), m_cols.m_col_percent_text);
	}

	for (auto &c : this->get_columns()) {
		c->set_sizing(Gtk::TreeViewColumnSizing::TREE_VIEW_COLUMN_FIXED);
		c->set_clickable();
		c->set_resizable();
		c->set_reorderable();
	}
}
// TODO REFACTOR THE LIVING HELL OUT OF THIS ABOMINATION -- nyanpasu
void GtkTorrentTreeView::setupColumns()
{
	unsigned int cid = 0;
	Gtk::TreeViewColumn *col = nullptr;
	Gtk::CellRendererProgress *cell = nullptr;

	this->append_column("Queue", m_cols.m_col_queue);
	this->append_column("Age", m_cols.m_col_age);
	this->append_column("ETA", m_cols.m_col_eta);
	this->append_column("Name", m_cols.m_col_name);
	this->append_column("Seed", m_cols.m_col_seeders);
	this->append_column("Leech", m_cols.m_col_leechers);
	this->append_column("Upload Speed", m_cols.m_col_ul_speed);
	this->append_column("Download Speed", m_cols.m_col_dl_speed);
	this->append_column("Uploaded", m_cols.m_col_ul_total);
	this->append_column("Downloaded", m_cols.m_col_dl_total);
	this->append_column("Size", m_cols.m_col_size);
	this->append_column("Remains", m_cols.m_col_remaining);
	this->append_column("Ratio", m_cols.m_col_dl_ratio);

	cell = Gtk::manage(new Gtk::CellRendererProgress());
	cid = this->append_column("Progress", *cell);
	col = this->get_column(cid - 1);
	col->add_attribute(cell->property_value(), m_cols.m_col_percent);
	col->add_attribute(cell->property_text(), m_cols.m_col_percent_text);

	for (auto & c : this->get_columns())
	{
		Gtk::Button *butt = c->get_button();
		butt->signal_button_press_event().connect(sigc::mem_fun(*this, &GtkTorrentTreeView::torrentColumns_onClick));
		c->set_sizing(Gtk::TreeViewColumnSizing::TREE_VIEW_COLUMN_FIXED);
		c->set_alignment(0.5f);
		c->set_clickable();
		c->set_resizable();
		c->set_reorderable();
                c->set_fixed_width(96);
	}
}
         void statusRecord::appendToView(Gtk::TreeView* _treeview)
         {
            _treeview->append_column("Filename", filename);
            
            _treeview->append_column("Status",   status);

            // Add a progress bar, showing status.
            Gtk::CellRendererProgress* cell = Gtk::manage(new Gtk::CellRendererProgress);
            int last_count = _treeview->append_column("Progress", *cell);

            Gtk::TreeViewColumn* column = _treeview->get_column(last_count - 1);
            if (column)
               {
                  column->add_attribute(cell->property_value(), done);
                  column->add_attribute(cell->property_text(), doneText);
               }

            _treeview->append_column("Download", dn_rate);
            _treeview->append_column("Upload",   ul_rate);
            _treeview->append_column("Filesize", filesize);
            _treeview->append_column("Peers l/s", peers);
            
            headersSetResizable(*_treeview);
         }