示例#1
0
bool ApplicationList::addApplication(Application* app)
{
    typedef Gtk::TreeModel::Children type_children;

    type_children children = m_refTreeModel->children();
    for(type_children::iterator iter = children.begin(); iter != children.end(); ++iter)
    {
      Gtk::TreeModel::Row row = *iter;
      if(row[m_appColumns.m_col_name] == Glib::ustring("Applications"))
      {
        type_children appchild = row->children();
        for(type_children::iterator itrapp = appchild.begin(); itrapp!= appchild.end(); ++itrapp)
        {
            Gtk::TreeModel::Row childrow = *itrapp;
            if(childrow[m_appColumns.m_col_name] == Glib::ustring(app->getName()))
                return false;
        }
      }
    }

    Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(m_appRow.children()));
    childrow[m_appColumns.m_col_type] = APPLICATION;
    childrow[m_appColumns.m_col_name] = app->getName();
    childrow[m_appColumns.m_col_filename] = app->getXmlFile();
    childrow.set_value(0, Gdk::Pixbuf::create_from_data(application_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            application_ico.width,
                                            application_ico.height,
                                            application_ico.bytes_per_pixel*application_ico.width));
    
    string fname;
    string fpath = app->getXmlFile();
    size_t pos = fpath.rfind(PATH_SEPERATOR);
    if(pos!=string::npos)
        fname = fpath.substr(pos+1);
    else
        fname = fpath;
     fname = fname + string(" (") + fpath + string(")"); 
    
    Gtk::TreeModel::Row descrow = *(m_refTreeModel->append(childrow.children()));
    descrow[m_appColumns.m_col_type] = NODE_FILENAME;
    descrow[m_appColumns.m_col_name] = fname;
    descrow[m_appColumns.m_col_filename] = app->getXmlFile();
    descrow.set_value(0, Gdk::Pixbuf::create_from_data(document_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            document_ico.width,
                                            document_ico.height,
                                            document_ico.bytes_per_pixel*document_ico.width));
    return true;
}
示例#2
0
/**
 Inicia las opcions basicas del menu de preferencias.
 */
void Preferencias::iniciadorPreferencias()
{
	treeviewGeneral->set_headers_visible(false);
	refTreeModelDialog = Gtk::TreeStore::create(columModel);
	treeviewGeneral->set_model(refTreeModelDialog);
	
	Gtk::TreeModel::Row row;
	Gtk::TreeModel::Row childrow;
	
	row = *(refTreeModelDialog->append());
	//row[columModel.nomCol] = "Clasificaciones";
	row[columModel.nomCol] = "Classifications";
	childrow = *(refTreeModelDialog->append(row.children()));
	//childrow[columModel.nomCol] = "Clases";
	childrow[columModel.nomCol] = "Classes";
	childrow = *(refTreeModelDialog->append(row.children()));
	//childrow[columModel.nomCol] = "Estados";
	childrow[columModel.nomCol] = "States";
	row = *(refTreeModelDialog->append());
	
	//row[columModel.nomCol] = "Directorios";
	row[columModel.nomCol] = "Folders";
	row = *(refTreeModelDialog->append());
	
	row[columModel.nomCol] = "Editor";
	row = *(refTreeModelDialog->append());
	
	//row[columModel.nomCol] = "Rejilla";
	row[columModel.nomCol] = "Grid";
	childrow = *(refTreeModelDialog->append(row.children()));
	//childrow[columModel.nomCol] = "Rejilla Completa";
	childrow[columModel.nomCol] = "Complete grid";
	childrow = *(refTreeModelDialog->append(row.children()));
	//childrow[columModel.nomCol] = "Rejilla Personalizada";
	childrow[columModel.nomCol] = "Custom grid";
	row = *(refTreeModelDialog->append());
	
	//row[columModel.nomCol] = "Base de Datos";
	row[columModel.nomCol] = "Database";
	row = *(refTreeModelDialog->append());

	row[columModel.nomCol] = "Secure FTP";
	row = *(refTreeModelDialog->append());
	
	//row[columModel.nomCol] = "Cache de imagenes";
	row[columModel.nomCol] = "Image cache";
	row = *(refTreeModelDialog->append());
	
	treeviewGeneral->append_column("",columModel.nomCol);
}
示例#3
0
Gtk::TreeModel::Row EditStrategyWindow::findActionRow(rfiStrategy::Action *action)
{
	std::deque<Gtk::TreeModel::Row> rows;
	Gtk::TreeNodeChildren children = _store->children();
	for(Gtk::TreeModel::const_iterator iter = children.begin();iter!=children.end();++iter)
	{
		const Gtk::TreeModel::Row &row = (*iter);
		rows.push_back(row);
	}
	while(!rows.empty())
	{
		Gtk::TreeModel::Row row = rows.front();
		rows.pop_front();
		if(row[_columns.action] == action)
		{
			return row;
		}
		Gtk::TreeNodeChildren rowChildren = row.children();
		for(Gtk::TreeModel::const_iterator iter = rowChildren.begin();iter != rowChildren.end();++iter)
		{
			Gtk::TreeModel::Row childRow = *iter;
			rows.push_back(childRow);
		}
	}
	throw BadUsageException("Could not find row in view");
}
示例#4
0
bool ApplicationList::addComputer(Computer* comp)
{   
    typedef Gtk::TreeModel::Children type_children;

    //type_children children = m_refTreeModel->children();
    type_children reschild = m_resRow->children();
    for(type_children::iterator itr = reschild.begin(); itr!= reschild.end(); ++itr)
    {
        Gtk::TreeModel::Row childrow = *itr;
        if(childrow[m_appColumns.m_col_name] == Glib::ustring(comp->getName()))
            return false;
    }


    Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(m_resRow.children()));
    childrow[m_appColumns.m_col_type] = RESOURCE;
    childrow[m_appColumns.m_col_name] = comp->getName();
    childrow[m_appColumns.m_col_filename] = comp->getXmlFile();

    if(comp->getDisable())
        childrow.set_value(0, Gdk::Pixbuf::create_from_data(computer_disable_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            computer_disable_ico.width,
                                            computer_disable_ico.height,
                                            computer_disable_ico.bytes_per_pixel*computer_disable_ico.width)); 
    else
        childrow.set_value(0, Gdk::Pixbuf::create_from_data(computer_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            computer_ico.width,
                                            computer_ico.height,
                                            computer_ico.bytes_per_pixel*computer_ico.width));
    
    string fname;
    string fpath = comp->getXmlFile();
    size_t pos = fpath.rfind(PATH_SEPERATOR);
    if(pos!=string::npos)
        fname = fpath.substr(pos+1);
    else
        fname = fpath;
     fname = fname + string(" (") + fpath + string(")"); 
 
    Gtk::TreeModel::Row descrow = *(m_refTreeModel->append(childrow.children()));
    descrow[m_appColumns.m_col_type] = NODE_FILENAME;
    descrow[m_appColumns.m_col_name] = fname;
    descrow[m_appColumns.m_col_filename] = comp->getXmlFile();
    descrow.set_value(0, Gdk::Pixbuf::create_from_data(document_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            document_ico.width,
                                            document_ico.height,
                                            document_ico.bytes_per_pixel*document_ico.width));
                                                                   
    return true;
}
示例#5
0
void RFO::update_model()
{
  // re-build the model each time for ease ...
  m_model->clear();

  size_t psep;
  std::string root_label = m_filename;
  if (!root_label.length())
    root_label = _("Unsaved file");
  else if ((psep = m_filename.find_last_of("/\\")) != string::npos)
    root_label = m_filename.substr(psep + 1);

  Gtk::TreeModel::iterator root;
  root = m_model->append();
  Gtk::TreeModel::Row row = *root;
  row[m_cols->m_name] = root_label;
  row[m_cols->m_object] = -1;
  row[m_cols->m_file] = -1;
  row[m_cols->m_pickindex] = 0;

  gint index = 1; // pick/select index. matches computation in draw()

  for (guint i = 0; i < Objects.size(); i++) {
    Objects[i].idx = i;

    Gtk::TreeModel::iterator obj = m_model->append(row.children());
    Gtk::TreeModel::Row orow = *obj;
    orow[m_cols->m_name] = Objects[i].name;
    orow[m_cols->m_object] = i;
    orow[m_cols->m_file] = -1;
    orow[m_cols->m_pickindex] = index++;

    for (guint j = 0; j < Objects[i].files.size(); j++) {
      Objects[i].files[j].idx = j;
      Gtk::TreeModel::iterator iter = m_model->append(orow.children());
      row = *iter;
      row[m_cols->m_name] = Objects[i].files[j].location;
      row[m_cols->m_object] = i;
      row[m_cols->m_file] = j;
      row[m_cols->m_pickindex] = index++;
    }
  }
}
示例#6
0
文件: dom.cpp 项目: shinnya/jd-mirror
//
// Gtk::TreeModel::Children からノードツリーを生成
//
// ただし列は SKELETON::EditColumns を継承したものであること
//
void Dom::parse( const Gtk::TreeModel::Children& children, SKELETON::EditColumns& columns )
{
    if( ! this || children.empty() ) return;

    // Gtk::TreeModel::Children を走査
    Gtk::TreeModel::iterator it = children.begin();
    while( it != children.end() )
    {
        Gtk::TreeModel::Row row = *it;

        // 各値を取得( skeleton/editcolumns.h を参照 )
        const int type = row[ columns.m_type ];
        const Glib::ustring url = row[ columns.m_url ];
        const Glib::ustring data = row[ columns.m_data ];
        const Glib::ustring name = row[ columns.m_name ];
        const size_t dirid = row[ columns.m_dirid ];
        const bool expand = row[ columns.m_expand ];

        if( type != TYPE_UNKNOWN )
        {
            // タイプにより要素名を決定( board や link など)
            const std::string node_name = XML::get_name( type );

            if( ! node_name.empty() )
            {
                Dom* node = appendChild( NODE_TYPE_ELEMENT, node_name );
                if( type == TYPE_DIR && expand ) node->setAttribute( "open", "y" );
                if( ! name.empty() ) node->setAttribute( "name", name );
                if( ! url.empty() ) node->setAttribute( "url", url );
                if( ! data.empty() ) node->setAttribute( "data", data );
                if( dirid ) node->setAttribute( "dirid", dirid );

                // 再帰
                if( ! row.children().empty() ) node->parse( row.children(), columns );
            }
        }

        ++it;
    }
}
示例#7
0
void InheritanceWindow::descendTypeTree(Eris::TypeInfo * node,
                                        Gtk::TreeModel::Row & row)
{
    assert(node != NULL);

    std::cout << "Node " << node->getName() << std::endl << std::flush;
    row[*m_nameColumn] = node->getName();
    const Eris::TypeInfoSet & children = node->getChildren();
    Eris::TypeInfoSet::const_iterator I = children.begin();
    for (; I != children.end(); I++) {
        Gtk::TreeModel::Row childrow = *(m_treeModel->append(row.children()));
        descendTypeTree(*I, childrow);
    }

}
示例#8
0
void EditStrategyWindow::fillStore(Gtk::TreeModel::Row &row, Action &action, size_t childIndex)
{
	Gtk::TreeModel::iterator iter = _store->append(row.children());
	Gtk::TreeModel::Row newRow = *iter;
	newRow[_columns.action] = &action;
	newRow[_columns.description] = action.Description();
	newRow[_columns.childIndex] = childIndex;
	ActionContainer *container = dynamic_cast<ActionContainer*>(&action);
	if(container != 0)
	{
		for(size_t i = 0;i<container->GetChildCount();++i)
		{
			fillStore(newRow, container->GetChild(i), i);
		}
	}
}
示例#9
0
void Cal3dOptions::insertType(Eris::TypeInfo * const ti, Gtk::TreeModel::Row row)
{
    assert(ti != 0);


    row[*m_nameColumn] = Glib::ustring(ti->getName());
    row[*m_ptrColumn] = ti;

    const Eris::TypeInfoSet & children = ti->getChildren();
    Eris::TypeInfoSet::const_iterator I = children.begin();
    Eris::TypeInfoSet::const_iterator Iend = children.end();
    for (; I != Iend; ++I) {
        Gtk::TreeModel::Row childrow = *(m_treeModel->append(row.children()));
        insertType(*I, childrow);
    }
}
示例#10
0
文件: dom.cpp 项目: shinnya/jd-mirror
//
// ノードを分解して Gtk::TreeStore へ Gtk::TreeModel::Row を追加
//
// ただし列は SKELETON::EditColumns を継承したものであること
//
// list_path_expand は開いてるツリーを格納するための参照渡し
//
void Dom::append_treestore( Glib::RefPtr< Gtk::TreeStore >& treestore,
                            SKELETON::EditColumns& columns,
                             std::list< Gtk::TreePath >& list_path_expand,
                             const Gtk::TreeModel::Row& parent )
{
    if( ! this ) return;

    // ノードの子要素を走査
    std::list< Dom* >::iterator it = m_childNodes.begin();
    while( it != m_childNodes.end() )
    {
        const int node_type = (*it)->nodeType();

        if( node_type == NODE_TYPE_ELEMENT )
        {
            const int type = XML::get_type( (*it)->nodeName() );

            if( type != TYPE_UNKNOWN )
            {
                Gtk::TreeModel::Row row;

                // Gtk::TreeStore::append() の追加ポイント
                if( parent ) row = *( treestore->append( parent.children() ) );
                else row = *( treestore->append() );

                // 各値をセット
                columns.setup_row( row, (*it)->getAttribute( "url" ), (*it)->getAttribute( "name" ), (*it)->getAttribute( "data" ), type, 0 );

                if( type == TYPE_DIR ){

                    row[ columns.m_dirid ] = atoi( (*it)->getAttribute( "dirid" ).c_str() );

                    // 開いているツリーを追加
                    if( (*it)->getAttribute( "open" ) == "y" ) list_path_expand.push_back( treestore->get_path( row ) );
                }

                // 再帰
                if( (*it)->hasChildNodes() ) (*it)->append_treestore( treestore, columns, list_path_expand, row );
            }
        }

        ++it;
    }
}
void ArbitratorPropertyWindow::update(Glib::RefPtr<PortArbitratorModel> &arbPort)
{
    m_arbPort = arbPort;
    Arbitrator& arbitrator = m_arbPort->getArbitrator();
    m_refTreeModel->clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
    
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Port";
    row[m_Columns.m_col_value] = arbitrator.getPort();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;

    row = *(m_refTreeModel->append());
    rulesRow = row;
    row[m_Columns.m_col_name] = "Rules";
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;

    std::map<string, string> &rules = arbitrator.getRuleMap();
    std::map<string, string>::iterator itr;
    for(itr=rules.begin(); itr!=rules.end(); itr++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = (itr->first).c_str();
        childrow[m_Columns.m_col_value] = (itr->second).c_str();
        childrow[m_Columns.m_col_editable] = true;
        if(!arbitrator.trainWeights((itr->first).c_str()))
            childrow[m_Columns.m_col_color_value] = Gdk::Color("#FF0000");
        else
            childrow[m_Columns.m_col_color_value] = Gdk::Color("#000000");
    }

    m_arbPort->setErrorMode(!arbitrator.validate());

    m_TreeView.expand_all();
    m_pParent->reportErrors();
}
示例#12
0
void ObsAndViewBox::makeObs()
{
    mRefTreeObs->clear();
    const vpz::ObservablePortList& port_list = mObs->observableportlist();
    vpz::ObservablePortList::const_iterator it_port = port_list.begin();
    while (it_port != port_list.end()) {
        Gtk::TreeModel::Row row = *(mRefTreeObs->append());
        row[mColumnsObs.m_col_name] = it_port->first;
        row[mColumnsObs.m_col_type] = it_port->second.getType();

        const vpz::ViewNameList& view_list = it_port->second.viewnamelist();
        vpz::ViewNameList::const_iterator it_view = view_list.begin();
        while (it_view != view_list.end()) {
            Gtk::TreeModel::Row childrow = *(mRefTreeObs->append(row.children()));
            childrow[mColumnsObs.m_col_name] = *it_view;
            childrow[mColumnsObs.m_col_type] = vpz::Base::VLE_VPZ_VIEW;

            ++it_view;
        }

        ++it_port;
    }
    mTreeViewObs->expand_all();
}
示例#13
0
void
CanvasTreeStore::refresh_row(Gtk::TreeModel::Row &row, bool do_children)
{
	synfigapp::ValueDesc value_desc=row[model.value_desc];

	if(value_desc)
	{
		if((bool)row[model.is_value_node] != value_desc.is_value_node() ||
			(!bool(row[model.is_value_node]) && row[model.link_count]!=0))
		{
			set_row(row,value_desc,do_children);
			return;
		}

		if(row[model.is_value_node])
		{
			ValueNode::Handle value_node(value_desc.get_value_node());

			if(ValueNode::Handle(row[model.value_node])!=value_node)
			{
				rebuild_row(row,do_children);
				return;
			}

			//row[model.id]=value_node->get_id();

			// Setup the row's label
			/*
			if(value_node->get_id().empty())
				row[model.label] = Glib::ustring(row[model.name]);
			else if(Glib::ustring(row[model.name]).empty())
				row[model.label] = value_node->get_id();
			else
				row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
			*/

			LinkableValueNode::Handle linkable;
			linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
			if(do_children && linkable && ((int)row[model.link_count] != linkable->link_count()))
			{
	//			Gtk::TreeModel::Children children = row.children();
	//			while(!children.empty() && erase(children.begin()));

				set_row(row,value_desc);
				return;
			}
		}
		else
		{
			//row[model.label] = Glib::ustring(row[model.name]);
			//row[model.is_value_node] = false;
			//row[model.is_editable] = true;
		}
	}
	if(!do_children)
		return;

	Gtk::TreeModel::Children children = row.children();
	Gtk::TreeModel::Children::iterator iter;

	if(!children.empty())
	for(iter = children.begin(); iter != children.end(); ++iter)
	{
		Gtk::TreeRow row=*iter;
		refresh_row(row);
	}
}
示例#14
0
void ModuleWindow::updateWidget()
{
    Module* m_pModule = ModuleWindow::m_pModule;
    m_refTreeModel->clear();


    size_t width = 20;
    for(int i=0; i<m_pModule->inputCount(); i++)
    {
        if(strlen(m_pModule->getInputAt(i).getPort()) > width)
            width = strlen(m_pModule->getInputAt(i).getPort());
    }
    for(int i=0; i<m_pModule->outputCount(); i++)
    {
        if(strlen(m_pModule->getOutputAt(i).getPort()) > width)
            width = strlen(m_pModule->getOutputAt(i).getPort());
    }
    width *= 8;

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
    Gtk::TreeModel::Row cchildrow;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pModule->getName();
    row[m_Columns.m_col_width] = width;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Version";
    row[m_Columns.m_col_value] = m_pModule->getVersion();
    row[m_Columns.m_col_width] = width;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pModule->getDescription();
    row[m_Columns.m_col_width] = width;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Parameters";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;

    for(int i=0; i<m_pModule->argumentCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam();
        childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getDescription();
        childrow[m_Columns.m_col_width] = width;

    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Authors";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;

    //char buff[64];
    for(int i=0; i<m_pModule->authorCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        //sprintf(buff, "%d", i+1);
        childrow[m_Columns.m_col_name] = m_pModule->getAuthorAt(i).getName();
        childrow[m_Columns.m_col_value] = m_pModule->getAuthorAt(i).getEmail();
        childrow[m_Columns.m_col_width] = width;
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Inputs";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;
    for(int i=0; i<m_pModule->inputCount(); i++)
    {
        InputData in = m_pModule->getInputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Port";
        childrow[m_Columns.m_col_value] = in.getPort();
        childrow[m_Columns.m_col_width] = width;

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Type";
        cchildrow[m_Columns.m_col_value] = in.getName();
        cchildrow[m_Columns.m_col_width] = width;


        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = in.getDescription();
        cchildrow[m_Columns.m_col_width] = width;

        childrow = *(m_refTreeModel->append(childrow.children()));
        childrow[m_Columns.m_col_name] = "Required";
        childrow[m_Columns.m_col_value] = (in.isRequired())?"Yes":"No";
        childrow[m_Columns.m_col_width] = 200;
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Outputs";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_width] = width;
    for(int i=0; i<m_pModule->outputCount(); i++)
    {
        OutputData out = m_pModule->getOutputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Port";
        childrow[m_Columns.m_col_value] = out.getPort();
        childrow[m_Columns.m_col_width] = width;

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Type";
        cchildrow[m_Columns.m_col_value] = out.getName();
        cchildrow[m_Columns.m_col_width] = width;

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = out.getDescription();
        cchildrow[m_Columns.m_col_width] = width;
    }

}
示例#15
0
void ModuleWindow::updateWidget()
{
    Module* m_pModule = ModuleWindow::m_pModule;
    m_refTreeModel->clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
    Gtk::TreeModel::Row cchildrow;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pModule->getName();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Version";
    row[m_Columns.m_col_value] = m_pModule->getVersion();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pModule->getDescription();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Parameters";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->argumentCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam();
        childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getDescription();
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Authors";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->authorCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getAuthorAt(i).getName();
        childrow[m_Columns.m_col_value] = m_pModule->getAuthorAt(i).getEmail();
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Inputs";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->inputCount(); i++)
    {
        InputData in = m_pModule->getInputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Type";
        childrow[m_Columns.m_col_value] = in.getName();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Port";
        cchildrow[m_Columns.m_col_value] = in.getPort();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = in.getDescription();

        childrow = *(m_refTreeModel->append(childrow.children()));
        childrow[m_Columns.m_col_name] = "Required";
        childrow[m_Columns.m_col_value] = (in.isRequired())?"Yes":"No";
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Outputs";
    row[m_Columns.m_col_value] = "";
    for(int i=0; i<m_pModule->outputCount(); i++)
    {
        OutputData out = m_pModule->getOutputAt(i);

        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = "Type";
        childrow[m_Columns.m_col_value] = out.getName();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Port";
        cchildrow[m_Columns.m_col_value] = out.getPort();

        cchildrow = *(m_refTreeModel->append(childrow.children()));
        cchildrow[m_Columns.m_col_name] = "Description";
        cchildrow[m_Columns.m_col_value] = out.getDescription();
    }

}
示例#16
0
void ApplicationPropertyWindow::update(Application* application)
{
    m_pApplication = application;
    //Application* m_pApplication = ApplicationPropertyWindow::m_pApplication;
    m_refTreeModel->clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
//    Gtk::TreeModel::Row cchildrow;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pApplication->getName();
    row[m_Columns.m_col_editable] = false;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pApplication->getDescription();
    if(m_pAppWindow && m_pAppWindow->getApplication() == m_pApplication)
         row[m_Columns.m_col_editable] = true;
    else
    {
        row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
        row[m_Columns.m_col_editable] = false;
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Version";
    row[m_Columns.m_col_value] = m_pApplication->getVersion();
    if(m_pAppWindow && m_pAppWindow->getApplication() == m_pApplication)
         row[m_Columns.m_col_editable] = true;
    else
    {
        row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
        row[m_Columns.m_col_editable] = false;
    }


    if(m_pAppWindow && m_pAppWindow->getApplication() != m_pApplication)
    {
        row = *(m_refTreeModel->append());
        row[m_Columns.m_col_name] = "Prefix";
        row[m_Columns.m_col_value] = m_pApplication->getBasePrefix();
        row[m_Columns.m_col_editable] = true;
    }

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Authors";
    row[m_Columns.m_col_value] = "";
    row[m_Columns.m_col_editable] = false;
    for(int i=0; i<m_pApplication->authorCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pApplication->getAuthorAt(i).getName();
        childrow[m_Columns.m_col_value] = m_pApplication->getAuthorAt(i).getEmail();
        if(m_pAppWindow && m_pAppWindow->getApplication() == m_pApplication)
             childrow[m_Columns.m_col_editable] = true;
        else
        {
            childrow[m_Columns.m_col_color_value] = Gdk::Color("#888888");
            childrow[m_Columns.m_col_editable] = false;
        }
    }

    m_TreeView.expand_all();

}
示例#17
0
// Cringe.
void GtkTorrentSideBar::setupColumns()
{
	int cid = 0;
	Gtk::TreeViewColumn     *col = nullptr;
	Gtk::CellRendererText   *cell = Gtk::manage(new Gtk::CellRendererText());
	Gtk::CellRendererPixbuf *cellp = Gtk::manage(new Gtk::CellRendererPixbuf());

	cell->set_alignment(0, 0.5);
	cell->signal_edited().connect([this](const std::string& path,const std::string& name){ addedItem(path, name); });

	cid = append_column(*Gtk::manage(new Gtk::TreeViewColumn("Name")));	
	col = get_column(cid - 1);
	col->pack_start(*cellp);
	col->pack_start(*cell);
	col->add_attribute(cell->property_markup(), m_cols.name);
	col->add_attribute(cell->property_editable(), m_cols.editable);
	col->add_attribute(cellp->property_pixbuf(), m_cols.icon);

        // This really isn't "setupColumns" anymore from this point.
        // TODO Move to own function
	m_torrent_row = *(m_liststore->append());
	m_torrent_row[m_cols.name] = "Torrents";
	m_torrent_row[m_cols.editable] = false;
	m_torrent_row[m_cols.clickCallback] = [](){}; // clicks on titles don't do shit

	auto torrent_icon = Gdk::Pixbuf::create_from_resource("/org/gtk/gtorrent/icon-torrent.png");
	auto torrent_icon_scaled =  torrent_icon->scale_simple(16, 16, Gdk::INTERP_BILINEAR);
	m_torrent_row[m_cols.icon] = torrent_icon_scaled;

        // XXX TMP WILL REMOVE AND REPLACE WITH PROPER FUNCTION
        // Yes this is horrible. Bear with it for now.
        auto g = Application::getSingleton()->getCore()->getAllTorrents();
	Gtk::TreeModel::Row row = *(m_liststore->append(m_torrent_row.children()));
	row[m_cols.name] = "All";
	row[m_cols.title] = "All";
	row[m_cols.group] = g;
	row[m_cols.group_vector] = &g->m_torrents_all;

	Gtk::TreeModel::Row row2 = *(m_liststore->append(row.children()));
	row2[m_cols.name] = "Downloading";
	row2[m_cols.title] = "Downloading";
	row2[m_cols.group_vector] = &g->m_torrents_downloading;
        row2 = *(m_liststore->append(row.children()));
        row2[m_cols.name] = "Seeding";
        row2[m_cols.title] = "Seeding";
        row2[m_cols.group_vector] = &g->m_torrents_seeding;
        row2 = *(m_liststore->append(row.children()));
        row2[m_cols.name] = "Checking";
        row2[m_cols.title] = "Checking";
        row2[m_cols.group_vector] = &g->m_torrents_checking;
        row2 = *(m_liststore->append(row.children()));
        row2[m_cols.name] = "Finished";
        row2[m_cols.title] = "Finished";
        row2[m_cols.group_vector] = &g->m_torrents_finished;
        row2 = *(m_liststore->append(row.children()));
        row2[m_cols.name] = "Stopped";
        row2[m_cols.title] = "Stopped";
        row2[m_cols.group_vector] = &g->m_torrents_stopped;
        row2 = *(m_liststore->append(row.children()));
        row2[m_cols.name] = "Paused";
        row2[m_cols.title] = "Paused";
        row2[m_cols.group_vector] = &g->m_torrents_paused;

        // End of new horrible code
        // Continue horrible code from before
	//row = *(m_liststore->append(m_torrent_row.children()));
	//row[m_cols.name] = "Add a label";
	//row[m_cols.editable] = true;
	//row[m_cols.icon] = Gtk::IconTheme::get_default()->lookup_icon("list-add-symbolic", 16, Gtk::ICON_LOOKUP_USE_BUILTIN).load_icon();
	//row[m_cols.clickCallback] = [row](){};

	m_rssfeed_row = *(m_liststore->append());
	m_rssfeed_row[m_cols.name] = "RSS Feeds";
	m_rssfeed_row[m_cols.editable] = false;
	m_rssfeed_row[m_cols.clickCallback] = [](){};

	auto rss_icon = Gdk::Pixbuf::create_from_resource("/org/gtk/gtorrent/icon-rss.png");
	auto rss_icon_scaled =  rss_icon->scale_simple(16, 16, Gdk::INTERP_BILINEAR);
	m_rssfeed_row[m_cols.icon] = rss_icon_scaled;

	for(auto fg : Application::getSingleton()->getCore()->m_feeds)
	{
		row = *(m_liststore->append(m_rssfeed_row.children()));
		row[m_cols.name] = fg->name;
		row[m_cols.editable] = false;
		// TODO change icon to some sort of generic RSS icon
		row[m_cols.clickCallback] = [this, fg](){m_rss->run(fg->name);m_rss->hide();};

	}
	
	row = *(m_liststore->append(m_rssfeed_row.children()));
	row[m_cols.name] = "Add an RSS group";
	row[m_cols.editable] = true;

	row[m_cols.icon] = Gtk::IconTheme::get_default()->lookup_icon("list-add-symbolic", 16, Gtk::ICON_LOOKUP_USE_BUILTIN).load_icon();
	row[m_cols.clickCallback] = [row](){};

	//Maybe migrate settings there
/*	row = *(m_liststore->append());
	row[m_cols.name] = "Settings";
	row[m_cols.title] = true;
	row[m_cols.clickCallback] = [](){}; // clicks on titles don't do shit*/
}
示例#18
0
InheritanceWindow::InheritanceWindow(MainWindow & mw): OptionBox("Inheritance"),
                                                       m_currentServer(0),
                                                       m_mainWindow(mw)
{
    // destroy.connect(slot(this, &InheritanceWindow::destroy_handler));
    // Gtk::VBox * vbox = manage( new Gtk::VBox(false, 2) );
    Gtk::VBox * vbox = this;

    Gtk::HBox * tophbox = manage( new Gtk::HBox() );

    tophbox->pack_start(*(manage( new Gtk::Label("Model:") ) ), Gtk::PACK_SHRINK, 2);
    m_serverMenu = manage( new Gtk::OptionMenu() );
    tophbox->pack_start(*m_serverMenu, Gtk::PACK_EXPAND_WIDGET, 2);
    tophbox->pack_start(*(manage( new Gtk::Label("WOOT") ) ), Gtk::PACK_SHRINK, 2);
   
    vbox->pack_start(*tophbox, Gtk::PACK_SHRINK, 2);

    m_columns = new Gtk::TreeModelColumnRecord();
    m_nameColumn = new Gtk::TreeModelColumn<Glib::ustring>();
    // m_valueColumn = new Gtk::TreeModelColumn<Glib::ustring>();
    m_columns->add(*m_nameColumn);
    // m_columns->add(*m_valueColumn);

    m_treeModel = Gtk::TreeStore::create(*m_columns);

    Gtk::TreeModel::Row row = *(m_treeModel->append());
    row[*m_nameColumn] = "test name";
    // row[*m_valueColumn] = Glib::ustring("test value");

    Gtk::TreeModel::Row childrow = *(m_treeModel->append(row.children()));
    childrow[*m_nameColumn] = "test child";

    Gtk::TreeModel::Row grandchildrow = *(m_treeModel->append(childrow.children()));
    grandchildrow[*m_nameColumn] = "test child";

    m_treeView = manage( new Gtk::TreeView() );

    m_treeView->set_model( m_treeModel );

    m_treeView->append_column("name", *m_nameColumn);
    // m_treeView->append_column("name", *m_valueColumn);
    
    Gtk::ScrolledWindow *scrolled_window = manage(new Gtk::ScrolledWindow());
    scrolled_window->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    // FIXME Add this in a way that won't cause an error
    scrolled_window->add(*m_treeView);
    // scrolled_window->add(*m_classTree);

    vbox->pack_start(*scrolled_window, Gtk::PACK_EXPAND_WIDGET, 2);

    Atlas::Message::MapType test;
    test["Footle"] = Atlas::Message::ListType(1, "foo");
    test["foo"] = 23;
    test["bar"] = 0.1;
    test["baz"] = "hello";
    test["mim"] = Atlas::Message::ListType(1, 235);
    test["grep"] = Atlas::Message::ListType(1, 0.4556);
    m_attributeTree = manage( new AtlasMapWidget(/* titles, */ test) );
    // m_attributeTree->set_column_width (0, 100);
    // m_attributeTree->set_column_width (1, 100);

    vbox->pack_start(*manage(new Gtk::HSeparator()), Gtk::PACK_SHRINK, 0);

    scrolled_window = manage(new Gtk::ScrolledWindow());
    scrolled_window->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    scrolled_window->add(*m_attributeTree);

    vbox->pack_start(*scrolled_window, Gtk::PACK_EXPAND_WIDGET, 2);

    Gtk::HBox * bothbox = manage( new Gtk::HBox() );
    //Gtk::Button * b = manage( new Gtk::Button("New...") );
    //b->clicked.connect(slot(this, &InheritanceWindow::newLayer));
    //bothbox->pack_start(*b, true, true, 0);

    vbox->pack_start(*bothbox, Gtk::PACK_SHRINK, 2);

    // add(*vbox);
    // set_title("Inheritance");
    set_sensitive(false);

    mw.serverAdded.connect(sigc::mem_fun(*this, &InheritanceWindow::serverAdded));

    signal_delete_event().connect(sigc::mem_fun(*this, &InheritanceWindow::deleteEvent));
}
示例#19
0
void ResourceWindow::updateWidget()
{
    m_refTreeModel->clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
//    Gtk::TreeModel::Row cchildrow;

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pComputer->getName();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pComputer->getDescription();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Disable";
    if(!m_pComputer->getDisable())
    {
        row[m_Columns.m_col_value] = "No";
        row.set_value(0, Gdk::Pixbuf::create_from_data(computer_ico.pixel_data, 
                                                Gdk::COLORSPACE_RGB,
                                                true,
                                                8,
                                                computer_ico.width,
                                                computer_ico.height,
                                                computer_ico.bytes_per_pixel*computer_ico.width));
    }
    else
    {
        row[m_Columns.m_col_value] = "Yes";
        row.set_value(0, Gdk::Pixbuf::create_from_data(computer_disable_ico.pixel_data, 
                                                Gdk::COLORSPACE_RGB,
                                                true,
                                                8,
                                                computer_disable_ico.width,
                                                computer_disable_ico.height,
                                                computer_disable_ico.bytes_per_pixel*computer_disable_ico.width));
    }


    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Availablity";
    if(m_pComputer->getAvailability())
    {
        row[m_Columns.m_col_value] = "Yes";
        row.set_value(0, Gdk::Pixbuf::create_from_data(yesres_ico.pixel_data, 
                                                Gdk::COLORSPACE_RGB,
                                                true,
                                                8,
                                                yesres_ico.width,
                                                yesres_ico.height,
                                                yesres_ico.bytes_per_pixel*yesres_ico.width));
    }
    else
    {
        row[m_Columns.m_col_value] = "No";
        row.set_value(0, Gdk::Pixbuf::create_from_data(nores_ico.pixel_data, 
                                                Gdk::COLORSPACE_RGB,
                                                true,
                                                8,
                                                nores_ico.width,
                                                nores_ico.height,
                                                nores_ico.bytes_per_pixel*nores_ico.width));
        return;
    }

    // platform 
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Platform";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(module_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            module_ico.width,
                                            module_ico.height,
                                            module_ico.bytes_per_pixel*module_ico.width));
     
    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Name";
    childrow[m_Columns.m_col_value] = m_pComputer->getPlatform().getName();
   
    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Distribution";
    childrow[m_Columns.m_col_value] = m_pComputer->getPlatform().getDistribution();

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Release";
    childrow[m_Columns.m_col_value] = m_pComputer->getPlatform().getRelease();

    // processor
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Processor";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(processor_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            processor_ico.width,
                                            processor_ico.height,
                                            processor_ico.bytes_per_pixel*processor_ico.width));

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Model";
    childrow[m_Columns.m_col_value] = m_pComputer->getProcessor().getModel();
  
    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Architecture";
    childrow[m_Columns.m_col_value] = m_pComputer->getProcessor().getArchitecture();
    
    char buff[64];
    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Cores";
    sprintf(buff, "%d", (int)m_pComputer->getProcessor().getCores());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Siblings";
    sprintf(buff, "%d", (int)m_pComputer->getProcessor().getSiblings());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Frequency";
    sprintf(buff, "%.2f", (float)m_pComputer->getProcessor().getFrequency());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    // CPU Load
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "CPU Load";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(cpuload_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            cpuload_ico.width,
                                            cpuload_ico.height,
                                            cpuload_ico.bytes_per_pixel*cpuload_ico.width));

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Load instant";
    if(compareString(m_pComputer->getPlatform().getName(), "WINDOWS"))
        sprintf(buff, "%.1f%%", (float)m_pComputer->getProcessor().getCPULoad().loadAverageInstant);
    else
    {
        float sibling = (float)m_pComputer->getProcessor().getSiblings();
        if(!sibling) sibling = 1.0F;
        float loadP = (float)(m_pComputer->getProcessor().getCPULoad().loadAverageInstant / sibling)*100.0F;
        if(loadP > 100.0F) loadP = 100.0F;
        sprintf(buff, "%.1f%%", loadP);
    }
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    float sibling = (float)m_pComputer->getProcessor().getSiblings();
    if(!sibling) sibling = 1.0F;
    float load1P = ((float)m_pComputer->getProcessor().getCPULoad().loadAverage1 / sibling)*100.0F;
    if(load1P > 100.0F) load1P = 100.0F; 
    float load5P = ((float)m_pComputer->getProcessor().getCPULoad().loadAverage5 / sibling)*100.0F;
    if(load5P > 100.0F) load5P = 100.0F; 
    float load15P = ((float)m_pComputer->getProcessor().getCPULoad().loadAverage15 / sibling)*100.0F;
    if(load15P > 100.0F) load15P = 100.0F; 
  
    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Load average 1";
    sprintf(buff, "%.1f%%", load1P);
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Load average 5";
    sprintf(buff, "%.1f%%", load5P);
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Load average 15";
    sprintf(buff, "%.1f%%", load15P);
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);
    m_TreeView.expand_row(m_refTreeModel->get_path(row), true);

    // Memory
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Memory";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(memory_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            memory_ico.width,
                                            memory_ico.height,
                                            memory_ico.bytes_per_pixel*memory_ico.width));

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Total space";
    sprintf(buff, "%ldKB", (long)m_pComputer->getMemory().getTotalSpace());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Free space";
    sprintf(buff, "%ldKB", (long)m_pComputer->getMemory().getFreeSpace());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    // Storage
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Storage";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(storage_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            storage_ico.width,
                                            storage_ico.height,
                                            storage_ico.bytes_per_pixel*storage_ico.width));

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Total space";
    sprintf(buff, "%ldKB", (long)m_pComputer->getStorage().getTotalSpace());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    childrow = *(m_refTreeModel->append(row.children()));
    childrow[m_Columns.m_col_name] = "Free space";
    sprintf(buff, "%ldKB", (long)m_pComputer->getStorage().getFreeSpace());
    childrow[m_Columns.m_col_value] = Glib::ustring(buff);

    // Peripherals
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Peripheral devices";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(device_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            device_ico.width,
                                            device_ico.height,
                                            device_ico.bytes_per_pixel*device_ico.width));
    for(int i=0; i<m_pComputer->peripheralCount(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pComputer->getPeripheralAt(i).getTypeName();
        childrow[m_Columns.m_col_value] = m_pComputer->getPeripheralAt(i).getName();
    }

    // Processes
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Processes";
    row[m_Columns.m_col_value] = "";
    row.set_value(0, Gdk::Pixbuf::create_from_data(process_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            process_ico.width,
                                            process_ico.height,
                                            process_ico.bytes_per_pixel*process_ico.width));

    ProcessContainer processes = m_pComputer->getProcesses();
    for(unsigned int i=0; i<processes.size(); i++)
    {
        childrow = *(m_refTreeModel->append(row.children()));
        char buff[64];
        sprintf(buff, "%d", processes[i].pid);
        childrow[m_Columns.m_col_name] = Glib::ustring(buff);
        childrow[m_Columns.m_col_value] = processes[i].command;
    }

}
示例#20
0
void
CanvasTreeStore::rebuild_row(Gtk::TreeModel::Row &row, bool do_children)
{
	synfigapp::ValueDesc value_desc=(synfigapp::ValueDesc)row[model.value_desc];

	if(value_desc && value_desc.get_value_node())
	{
		ValueNode::Handle value_node;
		value_node=value_desc.get_value_node();

		assert(value_node);if(!value_node)return;

		if(value_node && value_node!=(ValueNode::Handle)row[model.value_node])
		{
//			Gtk::TreeModel::Children children = row.children();
//			while(!children.empty() && erase(children.begin()));

			set_row(row,value_desc,do_children);
			return;
		}

		LinkableValueNode::Handle linkable;
		linkable=LinkableValueNode::Handle::cast_dynamic(value_node);

		if( do_children && linkable && (int)row[model.link_count] != linkable->link_count())
		{
//			Gtk::TreeModel::Children children = row.children();
//			while(!children.empty() && erase(children.begin()));

			set_row(row,value_desc);
			return;
		}

		//if(!value_node)
		//	value_node=row[model.value_node];

		row[model.id]=value_node->get_id();

		// Setup the row's label
		if(value_node->get_id().empty())
			row[model.label] = Glib::ustring(row[model.name]);
		else if(Glib::ustring(row[model.name]).empty())
			row[model.label] = value_node->get_id();
		else
			row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
	}
	else
	{
		row[model.label] = Glib::ustring(row[model.name]);
		row[model.is_value_node] = false;
		row[model.is_editable] = true;
		Gtk::TreeModel::Children children = row.children();
		while(!children.empty() && erase(children.begin()))
			;
	}
	if(!do_children)
		return;

	Gtk::TreeModel::Children children = row.children();
	Gtk::TreeModel::Children::iterator iter;
	if(!children.empty())
	for(iter = children.begin(); iter != children.end(); ++iter)
	{
		Gtk::TreeRow row=*iter;
		rebuild_row(row);
	}
}
示例#21
0
Gtk::TreeIter
ConfigTreeView::get_iter(const char* p)
{
  char* path;
  char* full_path;

  if (asprintf(&full_path, "%s", p) == -1) {
    throw OutOfMemoryException("get_iter(): asprintf() failed");
  }
  char* node = strtok(full_path, "/");

  if (asprintf(&path, "/%s", node) == -1) {
    throw OutOfMemoryException("get_iter(): asprintf() failed");
  }

  Gtk::TreeModel::Children children = m_config_tree->children();
  Gtk::TreeIter iter = children.begin();

  while ( node != NULL )
    {
      bool found = false;
      iter = children.begin();

      while ( !found && iter != children.end() )
	{
	  Gtk::TreeModel::Row row = *iter;

	  Glib::ustring r = row[m_config_record.node];
	  if ( strcmp(r.c_str(), node) == 0 )
	    {
	      found = true;
	      children = row.children();
	      iter = children.begin();
	    }
	  else
	    { ++iter; }
	}

      if ( !found )
      {
	iter = m_config_tree->append(children);
	Gtk::TreeModel::Row row = *iter;
	row[m_config_record.node] = Glib::ustring(node);
	row[m_config_record.path] = Glib::ustring(path);
	
	children = row.children();
      }

      node = strtok(NULL, "/");

      char* t;
      if (asprintf(&t, "%s/%s", path, node) == -1) {
	throw OutOfMemoryException("get_iter(): asprintf() failed");
      }
      free(path);
      path = t;
    }

  free(path);
  free(full_path);

  return iter;
}
ExampleWindow::ExampleWindow()
: m_VBox(Gtk::ORIENTATION_VERTICAL),
  m_Button_Quit(Gtk::Stock::QUIT)
{
  set_title("Gtk::TreeView (Drag and Drop) example");
  set_border_width(5);
  set_default_size(400, 200);

  add(m_VBox);

  //Add the TreeView, inside a ScrolledWindow, with the button underneath:
  m_ScrolledWindow.add(m_TreeView);

  //Only show the scrollbars when they are necessary:
  m_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);

  m_VBox.pack_start(m_ScrolledWindow);
  m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);

  m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
  m_ButtonBox.set_border_width(5);
  m_ButtonBox.set_layout(Gtk::BUTTONBOX_END);
  m_Button_Quit.signal_clicked().connect(sigc::mem_fun(*this,
              &ExampleWindow::on_button_quit) );

  //Create the Tree model:
  //Use our derived model, which overrides some Gtk::TreeDragDest and
  //Gtk::TreeDragSource virtual functions:
  //The columns are declared in the overridden TreeModel.
  m_refTreeModel = TreeModel_Dnd::create();
  m_TreeView.set_model(m_refTreeModel);

  //Enable Drag-and-Drop of TreeView rows:
  //See also the derived TreeModel's *_vfunc overrides.
  m_TreeView.enable_model_drag_source();
  m_TreeView.enable_model_drag_dest();

  //Fill the TreeView's model
  Gtk::TreeModel::Row row = *(m_refTreeModel->append());
  row[m_refTreeModel->m_Columns.m_col_id] = 1;
  row[m_refTreeModel->m_Columns.m_col_name] = "Billy Bob";
  row[m_refTreeModel->m_Columns.m_col_draggable] = true;
  row[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;

  Gtk::TreeModel::Row childrow = *(m_refTreeModel->append(row.children()));
  childrow[m_refTreeModel->m_Columns.m_col_id] = 11;
  childrow[m_refTreeModel->m_Columns.m_col_name] = "Billy Bob Junior";
  childrow[m_refTreeModel->m_Columns.m_col_draggable] = true;
  childrow[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;

  childrow = *(m_refTreeModel->append(row.children()));
  childrow[m_refTreeModel->m_Columns.m_col_id] = 12;
  childrow[m_refTreeModel->m_Columns.m_col_name] = "Sue Bob";
  childrow[m_refTreeModel->m_Columns.m_col_draggable] = true;
  childrow[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;

  row = *(m_refTreeModel->append());
  row[m_refTreeModel->m_Columns.m_col_id] = 2;
  row[m_refTreeModel->m_Columns.m_col_name] = "Joey Jojo";
  row[m_refTreeModel->m_Columns.m_col_draggable] = true;
  row[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;

  row = *(m_refTreeModel->append());
  row[m_refTreeModel->m_Columns.m_col_id] = 3;
  row[m_refTreeModel->m_Columns.m_col_name] = "Rob McRoberts";
  row[m_refTreeModel->m_Columns.m_col_draggable] = true;
  row[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;

  childrow = *(m_refTreeModel->append(row.children()));
  childrow[m_refTreeModel->m_Columns.m_col_id] = 31;
  childrow[m_refTreeModel->m_Columns.m_col_name] = "Xavier McRoberts";
  childrow[m_refTreeModel->m_Columns.m_col_draggable] = true;
  childrow[m_refTreeModel->m_Columns.m_col_receivesdrags] = true;

  //Add the TreeView's view columns:
  m_TreeView.append_column("ID", m_refTreeModel->m_Columns.m_col_id);
  m_TreeView.append_column("Name", m_refTreeModel->m_Columns.m_col_name);
  m_TreeView.append_column_editable("Draggable",
          m_refTreeModel->m_Columns.m_col_draggable);
  m_TreeView.append_column_editable("Receives Drags",
          m_refTreeModel->m_Columns.m_col_receivesdrags);

  show_all_children();
}
示例#23
0
void ModulePropertyWindow::update(Module* module)
{
    m_pModule = module;
    m_refTreeModel->clear();
    m_refModelCombos.clear();

    Gtk::TreeModel::Row row;
    Gtk::TreeModel::Row childrow;
//    Gtk::TreeModel::Row cchildrow;

    Glib::RefPtr<Gtk::ListStore> m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    //row = *(m_refCombo->append());
    //row[m_ColumnsCombo.m_col_choice] = "---";
    m_refModelCombos.push_back(m_refCombo);


    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Name";
    row[m_Columns.m_col_value] = m_pModule->getName();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    /*
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Description";
    row[m_Columns.m_col_value] = m_pModule->getDescription();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();
    */

    //node
    m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    row = *(m_refCombo->append());
    row[m_ColumnsCombo.m_col_choice] = "localhost";
    ResourcePContainer resources = m_pManager->getKnowledgeBase()->getResources();
    for(ResourcePIterator itr=resources.begin(); itr!=resources.end(); itr++)
    {
        Computer* comp = dynamic_cast<Computer*>(*itr);
        if(comp && !compareString(comp->getName(), "localhost"))
        {
            row = *(m_refCombo->append());
            row[m_ColumnsCombo.m_col_choice] = comp->getName();          
        }
    }
 
    m_refModelCombos.push_back(m_refCombo);
    
    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Node";
    row[m_Columns.m_col_value] = m_pModule->getHost();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Stdio";
    row[m_Columns.m_col_value] = m_pModule->getStdio();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    m_refModelCombos.push_back(m_refCombo);

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Workdir";
    row[m_Columns.m_col_value] = m_pModule->getWorkDir();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Prefix";
    row[m_Columns.m_col_value] = m_pModule->getBasePrefix();
    row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    //Deployer
    m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
    if(compareString(m_pModule->getBroker(), "yarpdev"))
    {
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "yarpdev";
    }
    else if(compareString(m_pModule->getBroker(), "icubmoddev"))
    {
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "icubmoddev";
    }
    else
    {
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "local";
        row = *(m_refCombo->append());
        row[m_ColumnsCombo.m_col_choice] = "yarprun";
    }
    m_refModelCombos.push_back(m_refCombo);

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Deployer";
    if(strlen(m_pModule->getBroker()))
        row[m_Columns.m_col_value] = m_pModule->getBroker();
    else if(compareString(m_pModule->getHost(), "localhost"))
        row[m_Columns.m_col_value] = "local";
        
    if(m_pModule->getNeedDeployer())
    {  
        row[m_Columns.m_col_editable] = false;
        row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    }    
    else
        row[m_Columns.m_col_editable] = true;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    row = *(m_refTreeModel->append());
    row[m_Columns.m_col_name] = "Parameters";
    row[m_Columns.m_col_value] = m_pModule->getParam();
    row[m_Columns.m_col_color_value] = Gdk::Color("#888888");
    row[m_Columns.m_col_editable] = false;
    row[m_Columns.m_col_choices] = m_refModelCombos.back();

    for(int i=0; i<m_pModule->argumentCount(); i++)
    {
        Gtk::TreeModel::Row comboRow;
        m_refCombo = Gtk::ListStore::create(m_ColumnsCombo);
        comboRow = *(m_refCombo->append());
        if(!m_pModule->getArgumentAt(i).isSwitch())
            comboRow[m_ColumnsCombo.m_col_choice] = m_pModule->getArgumentAt(i).getDefault();
        else
        {
            comboRow[m_ColumnsCombo.m_col_choice] = "on";    
            comboRow = *(m_refCombo->append());
            comboRow[m_ColumnsCombo.m_col_choice] = "off";
        }
        m_refModelCombos.push_back(m_refCombo);
     
        childrow = *(m_refTreeModel->append(row.children()));
        childrow[m_Columns.m_col_name] = m_pModule->getArgumentAt(i).getParam();
        childrow[m_Columns.m_col_value] = m_pModule->getArgumentAt(i).getValue();
        Glib::ustring strval = childrow[m_Columns.m_col_value];
        if(m_pModule->getArgumentAt(i).isRequired() 
            && !strval.size())
            childrow[m_Columns.m_col_color_item] = Gdk::Color("#BF0303");
        childrow[m_Columns.m_col_editable] = true;
        childrow[m_Columns.m_col_choices] = m_refModelCombos.back();
    }
    
    //updateParamteres();

    m_TreeView.expand_all();

}