Changeset 3 for trunk/src/CreateKit.py

Show
Ignore:
Timestamp:
11-09-2008 17:17:52 (5 years ago)
Author:
pcabido
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/CreateKit.py

    r2 r3  
    3131apt_pkg.init() 
    3232 
     33class ProgressBar(): 
     34    def __init__(self, dialogName, pbobj): 
     35        self._progressbar = pbobj 
     36        self._dialog = dialogName 
     37     
     38    def progressbarTimeout(self, pbobj): 
     39        pbobj.pulse() 
     40        return True 
     41     
     42    def start(self): 
     43        self._dialog.show() 
     44        self._timer = gobject.timeout_add(100, self.progressbarTimeout, self._progressbar) 
     45         
     46    def stop(self): 
     47        gobject.source_remove(self._timer) 
     48        self._timer = 0 
     49        self._dialog.hide() 
     50 
     51 
    3352class CreateKitGTK(threading.Thread): 
    3453     
     
    4564    # 
    4665    # Package list 
    47     # 
    48     def progressbarTimeout(pbobj, val): 
    49         print pbobj 
    50         print val 
    51         if pbobj.activity_check.get_active(): 
    52             pbobj.pulse() 
    53         else: 
    54             # Calculate the value of the progress bar using the 
    55             # value range set in the adjustment object 
    56             new_val = pbobj.get_fraction() + 0.01 
    57             if new_val > 1.0: 
    58                 new_val = 0.0 
    59             # Set the new value 
    60             pbobj.set_fraction(new_val) 
    61      
    62         # As this is a timeout function, return TRUE so that it 
    63         # continues to get called 
    64         return True 
    65  
     66    #         
    6667    def setupPackageList(self, ignore=True): 
    67         self.window.set_sensitive(False) 
     68        self.cpbar = ProgressBar(self.dialogProgress, self.pbar) 
     69        self.cpbar.start() 
     70             
    6871        self.treeStore = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) 
    69         self.dialogProgress.show() 
    70         self.pbar.pulse() 
    71         self.pbar.set_fraction(0.0) 
    72         #t = gobject.timeout_add(100, self.progressbarTimeout, self.pbar) 
    7372         
    7473        time.sleep(1) 
    75         self.stopthread = threading.Event() 
    7674        cache = apt_pkg.GetCache(progress.TextProgress()) 
    7775        records = apt_pkg.GetPkgRecords(cache) 
     
    7977        pkgList = [] 
    8078        #while not self.stopthread.isSet(): 
    81  
     79        count=0 
    8280        gtk.gdk.threads_enter() 
    8381        for pkg in packages: 
    8482            for pkgInfo in pkg.VersionList: 
    8583                for packFile, index in pkgInfo.FileList: 
     84                    count += 1 
     85                    print count 
    8686                    records.Lookup((packFile,index)) 
    8787                    if packFile.IndexType != 'Debian Package Index' and ignore: 
    8888                        continue 
    8989                    pkgList.append((None,(None, pkg.Name, pkgInfo.VerStr, records.ShortDesc))) 
     90                     
     91                    #self.pbar.set_fraction(util.pbarFraction(count, cache.PackageCount)) 
     92                    #print self.pbar.get_fraction() 
     93                     
    9094                    #print (None, pkg.Name, pkgInfo.VerStr, records.ShortDesc, packFile.IndexType)               
    9195         
     
    114118         
    115119        gtk.gdk.threads_leave() 
    116         self.dialogProgress.hide() 
    117         self.window.set_sensitive(True) 
    118         #self.stopthread.set() 
     120        self.stopthread.set() 
     121         
     122        self.stopthread.set() 
     123         
     124        #self.window.set_sensitive(True) 
    119125         
    120126    def colToggledClicked( self, cell, path, model ): 
     
    163169        self.gladefile = "CreateKit.glade" 
    164170        self.wTree = gtk.glade.XML(self.gladefile) 
     171         
     172        self.stopthread = threading.Event() 
    165173         
    166174        #botoes do notebook 
     
    229237             
    230238            #treeview 
    231             #self.setupPackageList() 
     239            #self.cpbar = ProgressBar(self.dialogProgress, self.pbar) 
     240            #self.cpbar.start() 
    232241            threading.Thread(name="self.setupPackageList", target=self.setupPackageList).start() 
     242             
    233243            #self.ProgTest() 
    234244