Exemplo n.º 1
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;
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void setup_model(){
	{
		//treeview
		treemodel = Gtk::ListStore::create(columns);	
		treeview1->set_model(treemodel);
		treeview1->append_column("Filename", columns.Filename);
		treeview1->append_column("Url", columns.url);
		treeview1->append_column("Size", columns.size);
		treeview1->append_column("%", columns.percentage_complete);
		treeview1->append_column("Time Left", columns.time_left);
		treeview1->append_column("Action", columns.action);

		//make all columns resizeable and set width
		std::vector<Gtk::TreeViewColumn*> tv_columns = treeview1->get_columns();	
		std::vector<Gtk::TreeViewColumn*>::iterator iter = tv_columns.begin();
		int count = 0;
		for (; iter!=tv_columns.end(); iter++, count++){
			Gtk::TreeViewColumn* col = *iter;
			col->set_resizable(true);
			col->set_fixed_width(column_widths[count]);
		}
		Gtk::TreeModel::Row row = *(treemodel->append());
		row[columns.Filename] = "33";
		row[columns.url] = "SFDSD";

		Gtk::TreeModel::Children children = treemodel->children();
		for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter){
			Gtk::TreeModel::Row row = *iter;
			row->set_value(0, (Glib::ustring)"asdfaksdhfakshdfklasjdfhklsafdhlaskjdhflksajdhfasdfads");
			row->set_value(4, (Glib::ustring)"asdfads");
		}
	}
	{
		comboboxmodel = Gtk::ListStore::create(combo_columns);	
		combobox_size->set_model(comboboxmodel);
		Gtk::TreeModel::Row row = *(comboboxmodel->append());
		combobox_size->set_id_column(0);
		Gtk::CellRendererText *cell = new Gtk::CellRendererText(); 
		combobox_size->pack_start(*cell);
		combobox_size->add_attribute(*cell, "text", combo_columns.size); 
		row[combo_columns.size] = "kB";
		(*(comboboxmodel->append()))[combo_columns.size] = "MB";
		combobox_size->set_active(0);
	}
}
Exemplo n.º 4
0
void MessagesList::addWarning( const char* warning)
{
    OSTRINGSTREAM msg;
    msg<<"[WAR]:   "<<warning;
    Gtk::TreeModel::Row row = *(m_refListStore->append());
    row.set_value(0, Glib::ustring(msg.str()));
    row[m_Columns.m_col_color] = Gdk::Color("#FFF6C8");
    m_TreeView.scroll_to_row( m_refListStore->get_path(row));
}
Exemplo n.º 5
0
void MessagesList::addError(const char* error)
{
    OSTRINGSTREAM msg;
    msg<<"[ERR]:   "<<error;
    Gtk::TreeModel::Row row = *(m_refListStore->append());
    row.set_value(0, Glib::ustring(msg.str()));
    row[m_Columns.m_col_color] = Gdk::Color("#F9CCCA");
    m_TreeView.scroll_to_row( m_refListStore->get_path(row));
}
Exemplo n.º 6
0
bool ApplicationList::addAppTemplate(AppTemplate* temp)
{ 
    typedef Gtk::TreeModel::Children type_children;
    string fname = temp->name + string(" (") + temp->tmpFileName + string(")"); 
    Gtk::TreeModel::Row descrow = *(m_refTreeModel->append(m_tempRow.children()));
    descrow[m_appColumns.m_col_type] = NODE_APPTEMPLATE;
    descrow[m_appColumns.m_col_name] = fname;
    descrow[m_appColumns.m_col_filename] = temp->tmpFileName;
    descrow.set_value(0, Gdk::Pixbuf::create_from_data(apptemplate_ico.pixel_data, 
                                            Gdk::COLORSPACE_RGB,
                                            true,
                                            8,
                                            apptemplate_ico.width,
                                            apptemplate_ico.height,
                                            apptemplate_ico.bytes_per_pixel*apptemplate_ico.width));   
    return true;
}
Exemplo n.º 7
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;
    }

}