Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugal-tweak.git;a=commitdiff;h=e7ed02df01b8df3a4dcb9c7d161a38fdc94992e9

commit e7ed02df01b8df3a4dcb9c7d161a38fdc94992e9
Author: bouleetbil <bouleet...@frogdev.info>
Date:   Mon Sep 6 21:37:24 2010 +0200

*some clean up(start more quickly)
*added update list to treeview

diff --git a/frugal-mono-tools/Main.cs b/frugal-mono-tools/Main.cs
index 678f982..7b49cb2 100644
--- a/frugal-mono-tools/Main.cs
+++ b/frugal-mono-tools/Main.cs
@@ -57,6 +57,11 @@ namespace frugalmonotools

if (Update.CheckUpdate())
{
+                               if(Fen!=null)
+                               {
+                                       //update list to treeview
+                                       Fen.UpdateToTreeview();
+                               }
if(Debug.ModeDebug)
{
foreach (packageCheck pkg in Update.UpdatePkg)
@@ -64,6 +69,7 @@ namespace frugalmonotools
Console.WriteLine(pkg.packagename+" can be updated to "+pkg.packageversion);
}
}
+
if(configuration.Get_ShowNotif()) notif.ShowMessage("Frugalware","Some update 
are available.");
Console.WriteLine("Some packages can be updated.");
}
@@ -163,7 +169,7 @@ namespace frugalmonotools
aTimer = new System.Timers.Timer();
aTimer.Elapsed+=new ElapsedEventHandler(checkUpdate);
// Set the Interval to 1 hour.
-                                               aTimer.Interval=3600000;
+                                               aTimer.Interval=6000;//3600000;
aTimer.Enabled=true;
// Creation of the Icon
trayIcon = new StatusIcon(new Pixbuf ("/usr/share/pixmaps/FrugalTools.png"));
diff --git a/frugal-mono-tools/MainWindow.cs b/frugal-mono-tools/MainWindow.cs
index 35b50b7..225363d 100644
--- a/frugal-mono-tools/MainWindow.cs
+++ b/frugal-mono-tools/MainWindow.cs
@@ -367,6 +367,9 @@ public partial class MainWindow : Gtk.Window
INT_StartWithXSession.Active=MainClass.configuration.Get_StartWithX();
INT_ShowNotif.Active=MainClass.configuration.Get_ShowNotif();
INT_ShowSplash.Active=MainClass.configuration.Get_ShowSplash();
+
+               //update
+               UpdateToTreeview();
}

protected void OnDeleteEvent (object sender, DeleteEventArgs a)
@@ -741,7 +744,8 @@ public partial class MainWindow : Gtk.Window
foreach (Package package in packages)
{
// Add some data to the store
-                               pkgListStore.AppendValues 
(package.pkgname+"-"+package.pkgversion,package.pkggroup,package.pkgdescription);
+                               pkgListStore.AppendValues 
(package.GetPkgname()+"-"+package.GetPkgversion(),package.GetGroup()
+                                                               
,package.GetDescription());
}
}
catch{}
@@ -953,17 +957,18 @@ public partial class MainWindow : Gtk.Window

protected virtual void OnBTNRefreshClicked (object sender, System.EventArgs e)
{
-               UpdateListStore.Clear();
Update.CheckUpdate();
-
+               UpdateToTreeview();
+       }
+       public void UpdateToTreeview()
+       {
+               UpdateListStore.Clear();
foreach (packageCheck package in Update.UpdatePkg)
{
// Add some data to the store
UpdateListStore.AppendValues (package.packagename+"-"+package.packageversion);
}
-
}
-
protected virtual void OnBTNUpdateDatabaseClicked (object sender, 
System.EventArgs e)
{
Outils.Excecute("python","/usr/bin/PyFrugalVTE pacman-g2 -Sy 
"+packageSelected,false);
diff --git a/frugal-mono-tools/PacmanG2.cs b/frugal-mono-tools/PacmanG2.cs
index 5b675b5..a32ace6 100644
--- a/frugal-mono-tools/PacmanG2.cs
+++ b/frugal-mono-tools/PacmanG2.cs
@@ -28,18 +28,114 @@ namespace frugalmonotools

public class Package
{
-                       public string pkgname;
-                       public string pkgversion;
-                       public string pkggroup;
-                       public string pkgdescription;
-                       public bool force;
+                       private string _contentDesc="";
+                       private string _repo;
+                       public string GetRepo()
+                       {
+                               return _repo;
+                       }
+                       public void SetRepo(string repo)
+                       {
+                               _repo=repo;
+                       }
+                       private string _pkgname;
+                       public string GetPkgname()
+                       {
+                               return _pkgname;
+                       }
+                       public void SetPkgname(string pkgname)
+                       {
+                               _pkgname=pkgname;
+                       }
+                       private string _pkgversion;
+                       public string GetPkgversion(){
+                               return _pkgversion;
+                       }
+                       public void SetPkgverion(string version)
+                       {
+                               _pkgversion=version;
+                       }
+
+
+                       public Package(){
+                       }
+
+                       private void _setContent()
+                       {
+                               if(_contentDesc!="") return;
+                               string filedesc = 
PacmanG2.ROOT_PATH+PacmanG2.PACMANG2_BDD+"/"+this.GetRepo()+"/"+this.GetPkgname()+
+                                                                               
"-"+this.GetPkgversion()+"/desc";
+                               if (File.Exists(filedesc))
+                               {
+                                       _contentDesc=Outils.ReadFile(filedesc);
+                               }
+                               else
+                               {
+                                       filedesc = 
PacmanG2.ROOT_PATH+PacmanG2.PACMANG2_BDD+"/"+this.GetRepo()+"/"+this.GetPkgname()+"/desc";
+                                       _contentDesc=Outils.ReadFile(filedesc);
+                               }
+                       }
+                       public string GetDescription()
+                       {
+                               _setContent();
+                               if(_contentDesc=="") return "";
+                               string content="";
+                               string[] lines = _contentDesc.Split('\n');
+                               bool FindDescr = false;
+                   foreach (string line in lines)
+                   {
+                                       if(FindDescr)
+                                       {
+                                               content=line;
+                                               break;
+                                       }
+                                       if (line=="%DESC%")
+                                               FindDescr=true;
+
+                               }
+                               return content;
+                       }
+
+               public bool ShouldForce()
+               {
+                       _setContent();
+                       if(_contentDesc=="") return false;
+                       string[] lines = _contentDesc.Split('\n');
+                       foreach (string line in lines)
+            {
+                               if (line=="%FORCE%")
+                                       return true;
+                       }
+                       return false;
+               }
+
+               public string GetGroup()
+               {
+                       _setContent();
+                       string content="";
+                       if(_contentDesc=="") return "";
+                       string[] lines = _contentDesc.Split('\n');
+                       bool FindDescr = false;
+            foreach (string line in lines)
+            {
+                               if(FindDescr)
+                               {
+                                       content=line;
+                                       break;
+                               }
+                               if (line=="%GROUPS%")
+                                       FindDescr=true;
+
+                       }
+                       return content;

+               }
}
public class PacmanG2
{
//const
-               private const string ROOT_PATH="/";
-               private const string PACMANG2_BDD="var/lib/pacman-g2/";
+               public static  string ROOT_PATH="/";
+               public static string PACMANG2_BDD="var/lib/pacman-g2/";
private const string PACMANG2_LOCAL="local/";
private const int pm_errno = -1;
private const string cch_pacmanconf ="/etc/pacman-g2.conf";
@@ -120,39 +216,22 @@ namespace frugalmonotools
string dirpkg=ROOT_PATH+PACMANG2_BDD+repo+"/";
string[] dirs= Directory.GetDirectories(dirpkg, "*"+strSearch+"*");
if (repo=="") return null;
-
-                       //Console.WriteLine("The number of packages is {0}.", 
dirs.Length);
+
foreach (string dir in dirs)
{
Package package = new Package();

string tmpname=dir.Replace(dirpkg,"");
-                               package.pkgname=extractNamePackage(tmpname);
-                               
package.pkgversion=extractVersionPackage(tmpname);
-                               
package.pkgdescription=_getDescription(package.pkgname+"-"+package.pkgversion,repo);
+                               package.SetPkgname(extractNamePackage(tmpname));
+                               
package.SetPkgverion(extractVersionPackage(tmpname));
+                               package.SetRepo(repo);
+                               
/*package.pkgdescription=_getDescription(package.pkgname+"-"+package.pkgversion,repo);
package.pkggroup=_getGroup(package.pkgname+"-"+package.pkgversion,repo);
-                               
package.force=ShouldPackageForce(package.pkgname+"-"+package.pkgversion,repo);
+                               
package.force=ShouldPackageForce(package.pkgname+"-"+package.pkgversion,repo);*/
packages.Add(package);
}
return packages;
}
-               public static string SearchDescription(string Package,string 
repo)
-               {
-                       return _getDescription(Package, repo);
-
-               }
-               /// <summary>
-               ///
-               /// </summary>
-               /// <param name="Package">
-               /// A <see cref="PAckage contain version !"/>
-               /// </param>
-               /// <param name="repo">
-               /// A <see cref="System.String"/>
-               /// </param>
-               /// <returns>
-               /// A <see cref="System.Boolean"/>
-               /// </returns>
public static bool ShouldPackageForce(string Package,string repo)
{
string filedesc = ROOT_PATH+PACMANG2_BDD+"/"+repo+"/"+Package+"/desc";
@@ -165,46 +244,13 @@ namespace frugalmonotools
}
return false;
}
-               private static string _getDescription(string Package,string 
repo)
+       /*      public static string SearchDescription(string Package,string 
repo)
{
-                       string filedesc = 
ROOT_PATH+PACMANG2_BDD+"/"+repo+"/"+Package+"/desc";
-                       string content = Outils.ReadFile(filedesc);
-                       string[] lines = content.Split('\n');
-                       bool FindDescr = false;
-            foreach (string line in lines)
-            {
-                               if(FindDescr)
-                               {
-                                       content=line;
-                                       break;
-                               }
-                               if (line=="%DESC%")
-                                       FindDescr=true;
-
-                       }
-                       return content;
-
-               }
-               private static string _getGroup(string Package,string repo)
-               {
-                       string filedesc = 
ROOT_PATH+PACMANG2_BDD+"/"+repo+"/"+Package+"/desc";
-                       string content = Outils.ReadFile(filedesc);
-                       string[] lines = content.Split('\n');
-                       bool FindDescr = false;
-            foreach (string line in lines)
-            {
-                               if(FindDescr)
-                               {
-                                       content=line;
-                                       break;
-                               }
-                               if (line=="%GROUPS%")
-                                       FindDescr=true;
-
-                       }
-                       return content;
+                       return _getDescription(Package, repo);

-               }
+               }*/
+
+
public string extractNamePackage(string file)
{
string[] words = file.Split('-');
diff --git a/frugal-mono-tools/Update.cs b/frugal-mono-tools/Update.cs
index 73c388c..554d76b 100644
--- a/frugal-mono-tools/Update.cs
+++ b/frugal-mono-tools/Update.cs
@@ -49,6 +49,7 @@ namespace frugalmonotools
if(string.Compare(pkginstall.packageversion,pkg.packageversion)<0)
AddIt =true;
//check force read info only here for startup more quickly
+
if 
((PacmanG2.ShouldPackageForce(pkg.packagename+"-"+pkg.packageversion,pkg.repo)) 
&&
(pkginstall.packageversion!=pkg.packageversion))
AddIt=true;
@@ -98,8 +99,8 @@ namespace frugalmonotools
{
//for repo local we can added all packages
packageCheck pkgrepo = new packageCheck();
-                                       pkgrepo.packagename=package.pkgname;
-                                       
pkgrepo.packageversion=package.pkgversion;
+                                       
pkgrepo.packagename=package.GetPkgname();
+                                       
pkgrepo.packageversion=package.GetPkgversion();
pkgs.Add(pkgrepo);
}
else
@@ -107,8 +108,8 @@ namespace frugalmonotools
bool AddIt = true;
foreach (string pkgignore in MainClass.pacmanG2.ignorePkg)
{
-                                               
if(pkgignore==MainClass.pacmanG2.extractNamePackage(package.pkgname)) AddIt 
=false;
-                                               
if(MainClass.pacmanG2.extractNamePackage(pkgignore)==MainClass.pacmanG2.extractNamePackage(package.pkgname))
 AddIt =false;
+                                               
if(pkgignore==MainClass.pacmanG2.extractNamePackage(package.GetPkgname())) 
AddIt =false;
+                                               
if(MainClass.pacmanG2.extractNamePackage(pkgignore)==MainClass.pacmanG2.extractNamePackage(package.GetPkgname()))
 AddIt =false;

}

@@ -117,7 +118,7 @@ namespace frugalmonotools
bool findIt = false;
foreach (packageCheck pkg in pkgs)
{
-                                               
if(package.pkgname==pkg.packagename)
+                                               
if(package.GetPkgname()==pkg.packagename)
{
findIt=true;
break;
@@ -126,8 +127,8 @@ namespace frugalmonotools
if((!findIt)&&(AddIt))
{
packageCheck pkgrepo = new packageCheck();
-                                               
pkgrepo.packagename=package.pkgname;
-                                               
pkgrepo.packageversion=package.pkgversion;
+                                               
pkgrepo.packagename=package.GetPkgname();
+                                               
pkgrepo.packageversion=package.GetPkgversion();
pkgrepo.repo=repo;
pkgs.Add(pkgrepo);
}
diff --git a/frugal-mono-tools/gtk-gui/MainWindow.cs 
b/frugal-mono-tools/gtk-gui/MainWindow.cs
index 78f1531..0ab0aec 100644
--- a/frugal-mono-tools/gtk-gui/MainWindow.cs
+++ b/frugal-mono-tools/gtk-gui/MainWindow.cs
@@ -305,7 +305,7 @@ public partial class MainWindow
this.ONG_principal = new global::Gtk.Notebook ();
this.ONG_principal.CanFocus = true;
this.ONG_principal.Name = "ONG_principal";
-               this.ONG_principal.CurrentPage = 7;
+               this.ONG_principal.CurrentPage = 1;
// Container child ONG_principal.Gtk.Notebook+NotebookChild
this.vbox4 = new global::Gtk.VBox ();
this.vbox4.Name = "vbox4";
diff --git a/frugal-mono-tools/gtk-gui/gui.stetic 
b/frugal-mono-tools/gtk-gui/gui.stetic
index a7edff7..28eb593 100644
--- a/frugal-mono-tools/gtk-gui/gui.stetic
+++ b/frugal-mono-tools/gtk-gui/gui.stetic
@@ -27,7 +27,7 @@
<widget class="Gtk.Notebook" id="ONG_principal">
<property name="MemberName" />
<property name="CanFocus">True</property>
-        <property name="CurrentPage">7</property>
+        <property name="CurrentPage">1</property>
<child>
<widget class="Gtk.VBox" id="vbox4">
<property name="MemberName" />
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to