Spritz: began code refactoring.
Spritz now warns if a repository has been added but not downloaded. Several initial code moves.
This commit is contained in:
@@ -5124,6 +5124,7 @@ class ConfirmationDialog:
|
||||
self.bottomTitle = self.xml.get_widget( "bottomTitle" )
|
||||
self.bottomData = self.xml.get_widget( "bottomData" )
|
||||
self.cancelbutton = self.xml.get_widget( "cancelbutton2" )
|
||||
self.okbutton = self.xml.get_widget( "okbutton2" )
|
||||
self.bottomtext = self.xml.get_widget( "bottomTitle" )
|
||||
self.lowerhbox = self.xml.get_widget( "hbox63" )
|
||||
|
||||
@@ -5179,7 +5180,7 @@ class ConfirmationDialog:
|
||||
def setup_simple_view(self, view ):
|
||||
model = gtk.TreeStore( gobject.TYPE_STRING )
|
||||
view.set_model( model )
|
||||
self.create_text_column( _( "Package" ), view, 0 )
|
||||
self.create_text_column( _( "Item" ), view, 0 )
|
||||
return model
|
||||
|
||||
def create_text_column( self, hdr, view, colno, min_width=0, max_width=0 ):
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
# -*- coding: iso-8859-1 -*-
|
||||
# It was: Yum Exteder (yumex) - A GUI for yum
|
||||
# Copyright (C) 2006 Tim Lauridsen < tim<AT>yum-extender<DOT>org >
|
||||
# Now is: Spritz (Entropy Interface)
|
||||
# Copyright: (C) 2007-2009 Fabio Erculiani < lxnay<AT>sabayonlinux<DOT>org >
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
from spritz_setup import cleanMarkupString
|
||||
|
||||
class ProgressTotal:
|
||||
|
||||
def __init__(self, widget):
|
||||
self.progress = widget
|
||||
self.steps = []
|
||||
self.nowProgres = 0.0
|
||||
self.numSteps = 0
|
||||
self.currentStep = 0
|
||||
self.stepError = False
|
||||
self.lastFrac = -1
|
||||
self.clear()
|
||||
|
||||
def setup(self, steps):
|
||||
self.steps = steps
|
||||
self.numSteps = len(steps)
|
||||
self.currentStep = 0
|
||||
self.nowProgress = 0.0
|
||||
self.stepError = False
|
||||
self.clear()
|
||||
|
||||
def hide(self):
|
||||
self.progress.hide()
|
||||
|
||||
def show(self):
|
||||
self.progress.show()
|
||||
|
||||
def next(self):
|
||||
now = 0.0
|
||||
if self.currentStep < self.numSteps:
|
||||
self.currentStep += 1
|
||||
for i in xrange(0, self.currentStep):
|
||||
now += self.steps[i]
|
||||
self.nowProgress = now
|
||||
self.setAbsProgress(now)
|
||||
return True
|
||||
return False
|
||||
|
||||
def _percent(self, total, now):
|
||||
if total == 0:
|
||||
return 0
|
||||
return (now*100L)/total
|
||||
|
||||
def clear( self ):
|
||||
self.progress.set_fraction(0)
|
||||
self.progress.set_text(" ")
|
||||
self.lastFrac = -1
|
||||
|
||||
def setProgress(self, now, total, prefix = None):
|
||||
relStep = float(now)/float(total)
|
||||
curStep = self.steps[self.currentStep]
|
||||
absStep = curStep * relStep
|
||||
absProgress = self.nowProgress + absStep
|
||||
self.setAbsProgress(absProgress, prefix)
|
||||
|
||||
def setAbsProgress( self, now, prefix = None ):
|
||||
if (now == self.lastFrac) or (now >= 1.0) or (now < 0.0):
|
||||
return
|
||||
self.gtk_loop()
|
||||
self.lastFrac = now+0.01
|
||||
percent = long(self._percent(1, now))
|
||||
self.progress.set_fraction(now)
|
||||
if prefix:
|
||||
text = "%s : %3i%%" % (prefix, percent)
|
||||
else:
|
||||
text = "%3i%%" % (percent,)
|
||||
self.progress.set_text( text )
|
||||
|
||||
def gtk_loop(self):
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
|
||||
class SpritzProgress:
|
||||
|
||||
def __init__( self, ui, set_page_func, parent ):
|
||||
self.ui = ui
|
||||
self.set_page_func = set_page_func
|
||||
self.parent = parent
|
||||
self.ui.progressMainLabel.set_text( "" )
|
||||
self.ui.progressSubLabel.set_text( "" )
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
self.total = ProgressTotal( self.ui.totalProgressBar )
|
||||
self.ui.progressBar.set_fraction( 0 )
|
||||
self.ui.progressBar.set_text( " " )
|
||||
self.lastFrac = -1
|
||||
|
||||
def show( self ):
|
||||
def run():
|
||||
self.ui.progressBox.show()
|
||||
self.set_page_func( 'output' )
|
||||
self.lastFrac = -1
|
||||
gobject.timeout_add(0, run)
|
||||
|
||||
def reset_progress( self ):
|
||||
def run():
|
||||
self.lastFrac = -1
|
||||
self.ui.progressBar.set_fraction( 0 )
|
||||
self.ui.progressBar.set_text(" ")
|
||||
gobject.timeout_add(0, run)
|
||||
|
||||
def hide( self, clean=False ):
|
||||
def run():
|
||||
self.ui.progressBox.hide()
|
||||
if clean:
|
||||
self.ui.progressMainLabel.set_text( "" )
|
||||
self.ui.progressSubLabel.set_text( "" )
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
self.ui.progressBar.set_fraction( 0 )
|
||||
self.ui.progressBar.set_text( " " )
|
||||
gobject.timeout_add(0, run)
|
||||
|
||||
def setTotal( self, now, total ):
|
||||
def run(now, total):
|
||||
self.total.setProgress( now, total )
|
||||
gobject.timeout_add(0, run, now, total)
|
||||
|
||||
def set_progress( self, frac, text=None ):
|
||||
def run(frac, text):
|
||||
if frac == self.lastFrac: return
|
||||
if frac > 1 or frac == 0.0: return
|
||||
if frac >= 0 and frac <= 1:
|
||||
self.ui.progressBar.set_fraction( frac )
|
||||
else:
|
||||
self.ui.progressBar.set_fraction( 0 )
|
||||
if text != None:
|
||||
self.ui.progressBar.set_text( text )
|
||||
self.lastFrac = frac
|
||||
self.gtk_loop()
|
||||
|
||||
gobject.timeout_add(0, run, frac, text)
|
||||
|
||||
def set_text(self, text):
|
||||
def run(text):
|
||||
self.ui.progressBar.set_text( text )
|
||||
gobject.timeout_add(0, run, text)
|
||||
|
||||
def set_mainLabel( self, text ):
|
||||
def run(text):
|
||||
self.ui.progressMainLabel.set_markup( "<b>%s</b>" % (text,) )
|
||||
self.ui.progressSubLabel.set_text( "" )
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
gobject.timeout_add(0, run, text)
|
||||
|
||||
def set_subLabel( self, text ):
|
||||
def run(text):
|
||||
mytxt = unicode(text)
|
||||
if len(mytxt) > 80:
|
||||
mytxt = mytxt[:80].strip()+"..."
|
||||
self.ui.progressSubLabel.set_markup( "%s" % (cleanMarkupString(mytxt),) )
|
||||
self.ui.progressExtraLabel.set_text( "" )
|
||||
gobject.timeout_add(0, run, text)
|
||||
|
||||
def set_extraLabel( self, text ):
|
||||
def run(text):
|
||||
mytxt = unicode(text)
|
||||
if len(mytxt) > 80:
|
||||
mytxt = mytxt[:80].strip()+"..."
|
||||
self.ui.progressExtraLabel.set_markup( "<span size=\"small\">%s</span>" % cleanMarkupString(mytxt) )
|
||||
self.lastFrac = -1
|
||||
gobject.timeout_add(0, run, text)
|
||||
|
||||
def gtk_loop(self):
|
||||
while gtk.events_pending():
|
||||
gtk.main_iteration()
|
||||
+1657
-1678
File diff suppressed because it is too large
Load Diff
+1047
-1263
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user