[Vala] treeview - liststore settings



Hi ,

I  am a newbie with vala and I have a couple of problems  :

1. I installed valaide 4.0 windows version but I dont have code completion working., nor a list of packages in option project. How can I accomplish this.?

2.
I am working with treeview .liststore and I want to create a listview with :
- alternate line color background
- column fore color
- column bitmap
. column resize
- column text align for numbers

I read all the google doc available but vala api may differ from standard gtk+ /glade functions and in any case in not clear for me having a windows background. Need help please .


I create a simple function like this to read packages from my distribution :

public int readPackages ( TreeView View, ListStore listStore)
{

string LISTDIR = "x:/Progetti_VALA/packages/unleashed";
string DEADLIST= "x:/Progetti_VALA/packages/deadpackages.txt";
string PACKAGES= "x:/Progetti_VALA/packages/packages.txt";

 View.set_model (listStore);

 var cell1 = new CellRendererText ();
 cell1.set ("width-chars", 35, null);
 cell1.set ("height", 15, null);
 cell1.set ("font", "Sans italic bold 8");
 cell1.set ( "set_resizable", true);

int nCol = View.insert_column_with_attributes (-1, "Package Name", cell1, "text", 0, null);
 TreeViewColumn PackCOL = View.get_column( nCol);
PackCOL.add_attribute ( cell1, "background", 10); // this line dont do nothing // SLCOL_TIMECOLOR

 var cell2 = new CellRendererText ();
 cell2.set ("width-chars", 15, null);
 cell2.set ("height", 15, null);
 cell2.set ( "set_resizable", true);
View.insert_column_with_attributes (-1, "Description", cell2, "text", null);

 var cell3 = new CellRendererText ();
 cell3.set ("foreground_set", true, null);
 cell3.set ("width-chars", 25, null);
 cell3.set ("height", 15, null);
View.insert_column_with_attributes (-1, "Dimension", cell3, "text", 2, "foreground", 3, null);

var file = File.new_for_path (LISTDIR); // A reference to unleashed dir
   if (!file.query_exists (null)) {
       stderr.printf ("ERROR: '%s' does not exist.  Maybe.\n", LISTDIR );
       return 1;
   }

var fileDead = File.new_for_path (DEADLIST); // A reference to our file
   if (fileDead.query_exists (null)) {
var file_info = fileDead.query_info ("*", FileQueryInfoFlags.NONE, null); if ( file_info.get_size () == 0 )
         copyEnabled = true;
}
   else
       copyEnabled = true;
if ( copyEnabled ) {
         var filePack = File.new_for_path (PACKAGES);
         var destination = File.new_for_path (DEADLIST);
         filePack.copy (destination, FileCopyFlags.NONE, null, null);
   }
   /* Only want to show the ones that are actually installed
   *  important: also search for the quotes and spaces around the on!
   */
   try {
       // Open file for reading and wrap returned FileInputStream into a
       // DataInputStream, so we can read line by line
       var in_stream = new DataInputStream (fileDead.read (null));
       string line;
       // Read lines until end of file (null) is reached
       while ((line = in_stream.read_line (null, null)) != null) {
           if ( line.contains(" on ") )
           {
string[] token = ReadTokens( line ); // read packages tokens string[] pack = ReadVersion( token[0] ); // read pack name and version
             TreeIter iter;
             listStore.append (out iter);
listStore.set (iter, 0, pack[0], 1, pack[1], 2, token[3], 3, "red", -1);
           }
       }
   } catch (IOError e) {
       error ("%s", e.message);
   }
 return 0;
}





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]