- moved repositoryid (old etpConst['repositoryname']) to repositories.conf
- internet connection check now done on the main repository database download URL with google.com as fallback - added live repositories add/removal backend functions to allow easy handling from third party applications - minor bug fixes and improvements Spritz: - added (almost done) repositories management widgets to let users add or remove stuff: use with care until the next commit git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@1046 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
@@ -419,9 +419,10 @@ class AboutDialog(gtk.Window):
|
||||
gobject.timeout_add(0, self.__scroll, begin)
|
||||
|
||||
|
||||
|
||||
def inputBox( parent, title, text):
|
||||
def inputBox( parent, title, text, input_text = None):
|
||||
dlg = EntryDialog( parent, title, text)
|
||||
if input_text:
|
||||
dlg.entry.set_text(input_text)
|
||||
rc = dlg.run()
|
||||
dlg.destroy()
|
||||
return rc
|
||||
|
||||
@@ -177,11 +177,14 @@ class UI(gtk.glade.XML):
|
||||
|
||||
class Controller:
|
||||
"""Base class for all controllers of glade-derived UIs."""
|
||||
def __init__(self, ui):
|
||||
def __init__(self, ui, addrepo_ui):
|
||||
"""Initialize a new instance.
|
||||
`ui' is the user interface to be controlled."""
|
||||
self.ui = ui
|
||||
self.addrepo_ui = addrepo_ui
|
||||
self.ui.signal_autoconnect(self._getAllMethods())
|
||||
self.addrepo_ui.signal_autoconnect(self._getAllMethods())
|
||||
self.addrepo_ui.addRepoWin.set_transient_for(self.ui.main)
|
||||
|
||||
def _getAllMethods(self):
|
||||
"""Get a dictionary of all methods in self's class hierarchy."""
|
||||
|
||||
+5
-4
@@ -277,6 +277,7 @@ class SpritzGUI:
|
||||
self.catPackages = EntropyPackageView(self.ui.tvCatPackages,self.queueView)
|
||||
self.catDesc = TextViewConsole(self.ui.catDesc)
|
||||
self.repoView = EntropyRepoView(self.ui.viewRepo)
|
||||
self.repoMirrorsView = EntropyRepositoryMirrorsView(self.addrepo_ui.mirrorsView)
|
||||
# Left Side Toolbar
|
||||
self.pageButtons = {} # Dict with page buttons
|
||||
self.firstButton = None # first button
|
||||
@@ -289,9 +290,9 @@ class SpritzGUI:
|
||||
self.packageRB = {}
|
||||
self.lastPkgPB = 'updates'
|
||||
self.tooltip = gtk.Tooltips()
|
||||
|
||||
# setup add repository window
|
||||
self.console_menu_xml = gtk.glade.XML( const.GLADE_FILE, "terminalMenu",domain="yumex" )
|
||||
self.console_menu = self.console_menu_xml.get_widget( "terminalMenu" )
|
||||
self.console_menu_xml.signal_autoconnect(self)
|
||||
|
||||
def setupGUI(self):
|
||||
''' Setup the GUI'''
|
||||
@@ -306,7 +307,7 @@ class SpritzGUI:
|
||||
self.console = SpritzConsole()
|
||||
self.console.set_scrollback_lines(1024)
|
||||
self.console.set_scroll_on_output(True)
|
||||
self.console.connect("button-press-event", self.console_click)
|
||||
self.console.connect("button-press-event", self.on_console_click)
|
||||
termScroll = gtk.VScrollbar(self.console.get_adjustment())
|
||||
self.ui.vteBox.pack_start(self.console, True, True)
|
||||
self.ui.termScrollBox.pack_start(termScroll, False)
|
||||
@@ -316,7 +317,7 @@ class SpritzGUI:
|
||||
self.ui.rbAll.hide()
|
||||
self.setupPkgFilter()
|
||||
|
||||
def console_click(self, widget, event):
|
||||
def on_console_click(self, widget, event):
|
||||
self.console_menu.popup( None, None, None, event.button, event.time )
|
||||
return True
|
||||
|
||||
|
||||
+616
-2905
File diff suppressed because it is too large
Load Diff
+77
-3
@@ -59,8 +59,9 @@ class SpritzController(Controller):
|
||||
self.etpbase = EntropyPackages(EquoConnection)
|
||||
# Create and ui object contains the widgets.
|
||||
ui = UI( const.GLADE_FILE , 'main', 'yumex' )
|
||||
addrepo_ui = UI( const.GLADE_FILE , 'addRepoWin', 'yumex' )
|
||||
# init the Controller Class to connect signals.
|
||||
Controller.__init__( self, ui )
|
||||
Controller.__init__( self, ui, addrepo_ui )
|
||||
|
||||
self.clipboard = gtk.Clipboard()
|
||||
self.pty = pty.openpty()
|
||||
@@ -92,11 +93,84 @@ class SpritzController(Controller):
|
||||
pass
|
||||
sys.exit( 1 ) # Terminate Program
|
||||
|
||||
def on_repoMirrorAdd_clicked( self, widget ):
|
||||
text = inputBox(self.addrepo_ui.addRepoWin, _("Insert URL"), _("Enter a download mirror, HTTP or FTP")+" ")
|
||||
# call liststore and tell to add
|
||||
if text:
|
||||
# validate url
|
||||
if not (text.startswith("http://") or text.startswith("ftp://")):
|
||||
okDialog( self.addrepo_ui.addRepoWin, _("You must enter either a HTTP or a FTP url.") )
|
||||
else:
|
||||
self.repoMirrorsView.add(text)
|
||||
|
||||
def on_repoMirrorRemove_clicked( self, widget ):
|
||||
selection = self.repoMirrorsView.view.get_selection()
|
||||
urldata = selection.get_selected()
|
||||
if urldata:
|
||||
self.repoMirrorsView.remove(urldata)
|
||||
|
||||
def on_repoMirrorEdit_clicked( self, widget ):
|
||||
selection = self.repoMirrorsView.view.get_selection()
|
||||
urldata = selection.get_selected()
|
||||
# get text
|
||||
if urldata[1] != None:
|
||||
text = self.repoMirrorsView.get_text(urldata)
|
||||
self.repoMirrorsView.remove(urldata)
|
||||
text = inputBox(self.addrepo_ui.addRepoWin, _("Insert URL"), _("Enter a download mirror, HTTP or FTP")+" ", input_text = text)
|
||||
# call liststore and tell to add
|
||||
self.repoMirrorsView.add(text)
|
||||
|
||||
def on_addRepo_clicked( self, widget ):
|
||||
print "add repo"
|
||||
self.addrepo_ui.repodbcformatEntry.set_active(0)
|
||||
self.addrepo_ui.repoidEntry.set_text("")
|
||||
self.addrepo_ui.repoDescEntry.set_text("")
|
||||
self.addrepo_ui.repodbEntry.set_text("")
|
||||
self.addrepo_ui.addRepoWin.show()
|
||||
self.repoMirrorsView.populate()
|
||||
|
||||
def on_repoSubmit_clicked( self, widget ):
|
||||
repodata = {}
|
||||
repodata['repoid'] = self.addrepo_ui.repoidEntry.get_text()
|
||||
repodata['description'] = self.addrepo_ui.repoDescEntry.get_text()
|
||||
repodata['packages'] = self.repoMirrorsView.get_all()
|
||||
repodata['dbcformat'] = self.addrepo_ui.repodbcformatEntry.get_active_text()
|
||||
repodata['database'] = self.addrepo_ui.repodbEntry.get_text()
|
||||
# validate
|
||||
errors = []
|
||||
if not repodata['repoid']:
|
||||
errors.append(_('No Repository Identifier'))
|
||||
if repodata['repoid'] and etpRepositories.has_key(repodata['repoid']):
|
||||
errors.append(_('Duplicated Repository Identifier'))
|
||||
if not repodata['description']:
|
||||
repodata['description'] = "No description"
|
||||
if not repodata['packages']:
|
||||
errors.append(_("No download mirrors"))
|
||||
if not repodata['database'] or not (repodata['database'].endswith("http://") or (not repodata['database'].endswith("ftp://"))):
|
||||
errors.append(_("Database URL must be HTTP or FTP"))
|
||||
if not errors:
|
||||
self.Equo.addRepository(repodata)
|
||||
initConfig_entropyConstants(etpSys['rootdir'])
|
||||
self.setupRepoView()
|
||||
self.addrepo_ui.addRepoWin.hide()
|
||||
else:
|
||||
okDialog( self.addrepo_ui.addRepoWin, _("Wrong entries, errors: %s") % (', '.join(errors),) )
|
||||
|
||||
def on_addRepoWin_delete_event(self, widget, path):
|
||||
return True
|
||||
|
||||
def on_repoCancel_clicked( self, widget ):
|
||||
self.addrepo_ui.addRepoWin.hide()
|
||||
|
||||
def on_removeRepo_clicked( self, widget ):
|
||||
print "remove repo"
|
||||
# get selected repo
|
||||
selection = self.repoView.view.get_selection()
|
||||
repodata = selection.get_selected()
|
||||
# get text
|
||||
if repodata[1] != None:
|
||||
repoid = self.repoView.get_repoid(repodata)
|
||||
self.Equo.removeRepository(repoid)
|
||||
initConfig_entropyConstants(etpSys['rootdir'])
|
||||
self.setupRepoView()
|
||||
|
||||
def on_terminal_clear_activate(self, widget):
|
||||
self.output.text_written = []
|
||||
|
||||
+67
-6
@@ -252,7 +252,7 @@ class YumexQueueView:
|
||||
self.view.append_column( column1 )
|
||||
|
||||
cell2 = gtk.CellRendererText()
|
||||
column2= gtk.TreeViewColumn( _( "Summary" ), cell2, text=1 )
|
||||
column2= gtk.TreeViewColumn( _( "Description" ), cell2, text=1 )
|
||||
column2.set_resizable( True )
|
||||
self.view.append_column( column2 )
|
||||
model.set_sort_column_id( 0, gtk.SORT_ASCENDING )
|
||||
@@ -484,7 +484,7 @@ class EntropyRepoView:
|
||||
# Setup Selection Column
|
||||
cell1 = gtk.CellRendererToggle() # Selection
|
||||
cell1.set_property( 'activatable', True )
|
||||
column1 = gtk.TreeViewColumn( "Active", cell1 )
|
||||
column1 = gtk.TreeViewColumn( "Selected", cell1 )
|
||||
column1.add_attribute( cell1, "active", 0 )
|
||||
column1.set_resizable( True )
|
||||
column1.set_sort_column_id( -1 )
|
||||
@@ -546,21 +546,23 @@ class EntropyRepoView:
|
||||
|
||||
def deselect_all( self ):
|
||||
iterator = self.store.get_iter_first()
|
||||
while iterator != None:
|
||||
while iterator != None:
|
||||
self.store.set_value( iterator, 0, False )
|
||||
iterator = self.store.iter_next( iterator )
|
||||
|
||||
def select_all( self ):
|
||||
iterator = self.store.get_iter_first()
|
||||
while iterator != None:
|
||||
while iterator != None:
|
||||
self.store.set_value( iterator, 0, True )
|
||||
iterator = self.store.iter_next( iterator )
|
||||
|
||||
def get_repoid(self, iterdata):
|
||||
model, iter = iterdata
|
||||
return model.get_value( iter, 2 )
|
||||
|
||||
def select_by_keys( self, keys):
|
||||
self.store
|
||||
iterator = self.store.get_iter_first()
|
||||
while iterator != None:
|
||||
while iterator != None:
|
||||
repoid = self.store.get_value( iterator, 1 )
|
||||
if repoid in keys:
|
||||
self.store.set_value( iterator, 0, True )
|
||||
@@ -568,6 +570,65 @@ class EntropyRepoView:
|
||||
self.store.set_value( iterator, 0, False)
|
||||
iterator = self.store.iter_next( iterator )
|
||||
|
||||
class EntropyRepositoryMirrorsView:
|
||||
"""
|
||||
This class controls the repo TreeView
|
||||
"""
|
||||
def __init__( self, widget):
|
||||
self.view = widget
|
||||
self.headers = [""]
|
||||
self.store = self.setup_view()
|
||||
|
||||
def setup_view( self ):
|
||||
""" Create models and columns for the Repo TextView """
|
||||
store = gtk.ListStore(str)
|
||||
self.view.set_model( store )
|
||||
|
||||
# Setup Repository URL column
|
||||
self.create_text_column( "", 0 )
|
||||
|
||||
# Setup reponame & repofile column's
|
||||
self.view.set_search_column( 1 )
|
||||
self.view.set_reorderable( False )
|
||||
return store
|
||||
|
||||
def create_text_column( self, hdr, colno):
|
||||
cell = gtk.CellRendererText() # Size Column
|
||||
column = gtk.TreeViewColumn( hdr, cell, text=colno )
|
||||
column.set_resizable( True )
|
||||
self.view.append_column( column )
|
||||
|
||||
def populate(self):
|
||||
""" Populate a repo liststore with data """
|
||||
self.store.clear()
|
||||
|
||||
def get_selected( self ):
|
||||
selected = []
|
||||
for elem in self.store:
|
||||
name = elem[0]
|
||||
if name:
|
||||
selected.append( name )
|
||||
return selected
|
||||
|
||||
def get_all( self ):
|
||||
all = [x[0] for x in self.store]
|
||||
return all
|
||||
|
||||
def add(self, url):
|
||||
self.store.append([str(url)])
|
||||
|
||||
def remove_selected(self):
|
||||
urls = self.get_selected()
|
||||
self.remove(urls)
|
||||
|
||||
def get_text(self, urldata):
|
||||
model, iter = urldata
|
||||
return model.get_value( iter, 0 )
|
||||
|
||||
def remove(self, urldata):
|
||||
model, iter = urldata
|
||||
self.store.remove(iter)
|
||||
|
||||
class YumexPluginView:
|
||||
def __init__( self, widget ):
|
||||
self.view = widget
|
||||
|
||||
Reference in New Issue
Block a user