Skip to content

Commit

Permalink
Link.gTank binned at last
Browse files Browse the repository at this point in the history
  • Loading branch information
Utumno committed Feb 23, 2015
1 parent c5f50a8 commit 6d260f0
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 49 deletions.
6 changes: 2 additions & 4 deletions Mopy/bash/balt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,7 @@ def _initData(self, window, data):
Called from AppendToMenu - DO NOT call directly. If you need to use the
initialized data in setting instance attributes (such as text) override
and always _call super_ when overriding. ##: Needs work (Tank, docs)
and always _call super_ when overriding. ##: Needs work (docs)
:param window: the element the menu is being popped from (usually a
UIList subclass)
:param data: the selected items when the menu is appended or None.
Expand All @@ -2274,8 +2274,6 @@ def _initData(self, window, data):
# Tank, List, Panel, wx.Button, BashStatusbar etc instances
self.window = window
self.selected = data
if isinstance(window,Tank): # TODO(ut): eliminate this
self.gTank = window

def AppendToMenu(self,menu,window,data):
"""Creates a wx menu item and appends it to :menu.
Expand Down Expand Up @@ -2563,7 +2561,7 @@ class Tank_Delete(ItemLink): # was used in BAIN would not refresh - used in Peop

def Execute(self,event):
with BusyCursor():
self.gTank.DeleteSelected()
self.window.DeleteSelected()

# wx Wrappers -----------------------------------------------------------------
#------------------------------------------------------------------------------
Expand Down
23 changes: 13 additions & 10 deletions Mopy/bash/basher/files_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def __init__(self, sortCol, prefix=''):

def _check(self): return self.window.sort == self.sortCol

def Execute(self,event):
if hasattr(self, 'gTank'):
self.gTank.SortItems(self.sortCol,'INVERT')
def Execute(self, event):
if isinstance(self.window, balt.Tank): # TODO(ut): grotesque
self.window.SortItems(self.sortCol, 'INVERT')
else:
self.window.PopulateItems(self.sortCol,-1)
self.window.PopulateItems(self.sortCol, -1)

class Files_Unhide(ItemLink):
"""Unhide file(s). (Move files back to Data Files or Save directory.)"""
Expand All @@ -95,17 +95,19 @@ def Execute(self,event):
srcDir = window.data.bashDir.join(u'Hidden')
destDir = window.data.dir
elif self.type == 'installer':
window = self.gTank
wildcard = bush.game.displayName+u' '+_(u'Mod Archives')+u' (*.7z;*.zip;*.rar)|*.7z;*.zip;*.rar'
destDir = bosh.dirs['installers']
srcPaths = balt.askOpenMulti(window,_(u'Unhide files:'),srcDir, u'.Folder Selection.', wildcard)
srcPaths = self._askOpenMulti(
title=_(u'Unhide files:'), defaultDir=srcDir,
defaultFile=u'.Folder Selection.', wildcard=wildcard)
else:
wildcard = u'*.*'
isSave = (destDir == bosh.saveInfos.dir)
#--File dialog
srcDir.makedirs()
if not self.type == 'installer':
srcPaths = balt.askOpenMulti(window,_(u'Unhide files:'),srcDir, u'', wildcard)
srcPaths = self._askOpenMulti(_(u'Unhide files:'),
defaultDir=srcDir, wildcard=wildcard)
if not srcPaths: return
#--Iterate over Paths
srcFiles = []
Expand All @@ -115,7 +117,8 @@ def Execute(self,event):
#--Copy from dest directory?
(newSrcDir,srcFileName) = srcPath.headTail
if newSrcDir == destDir:
balt.showError(window,_(u"You can't unhide files from this directory."))
self._showError(
_(u"You can't unhide files from this directory."))
return
#--Folder selection?
if srcFileName.csbody == u'.folder selection':
Expand All @@ -127,8 +130,8 @@ def Execute(self,event):
#--File already unhidden?
destPath = destDir.join(srcFileName)
if destPath.exists():
balt.showWarning(window,_(u"File skipped: %s. File is already present.")
% (srcFileName.s,))
self._showWarning(_(u"File skipped: %s. File is already "
u"present.") % (srcFileName.s,))
#--Move it?
else:
srcFiles.append(srcPath)
Expand Down
41 changes: 21 additions & 20 deletions Mopy/bash/basher/installer_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# =============================================================================

"""Menu items for the __item__ menu of the installer tab. Check before using
BashFrame.iniList - can be None (ini panel not shown)."""
BashFrame.iniList - can be None (ini panel not shown). Their window attribute
points to the InstallersList singleton."""

import StringIO
import copy
Expand Down Expand Up @@ -147,7 +148,7 @@ def _pack(self, archive, installer, project, release=False):
self.idata.moveArchives([archive], installer.order + 1)
#--Refresh UI
self.idata.refresh(what='I')
self.gTank.RefreshUI()
self.window.RefreshUI()

#------------------------------------------------------------------------------
class Installer_EditWizard(_InstallerLink):
Expand Down Expand Up @@ -379,8 +380,8 @@ class Installer_Delete(_InstallerLink):
text = _(u'Delete')
help = _(u'Delete selected item(s)')

def Execute(self, event): self.gTank.DeleteSelected(shellUI=False,
noRecycle=False)
def Execute(self, event): self.window.DeleteSelected(shellUI=False,
noRecycle=False)

class Installer_Duplicate(OneItemLink, _InstallerLink):
"""Duplicate selected Installer."""
Expand Down Expand Up @@ -427,7 +428,7 @@ def Execute(self,event):
with balt.BusyCursor():
self.idata.copy(curName,newName)
self.idata.refresh(what='N')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_Hide(_InstallerLink):
"""Hide selected Installers."""
Expand Down Expand Up @@ -458,7 +459,7 @@ def Execute(self,event):
file = bosh.dirs['installers'].join(curName)
file.moveTo(newName)
self.idata.refresh(what='ION')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_Rename(_InstallerLink):
"""Renames files by pattern."""
Expand Down Expand Up @@ -499,7 +500,7 @@ def Execute(self,event):
installer.refreshDataSizeCrc()
installer.refreshStatus(self.idata)
self.idata.refresh(what='N')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_OverrideSkips(CheckLink, _InstallerLink):
"""Toggle overrideSkips flag on installer."""
Expand All @@ -524,7 +525,7 @@ def Execute(self,event):
installer.refreshDataSizeCrc()
installer.refreshStatus(self.idata)
self.idata.refresh(what='N')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_SkipRefresh(CheckLink, _InstallerLink):
"""Toggle skipRefresh flag on installer."""
Expand All @@ -548,7 +549,7 @@ def Execute(self,event):
installer.refreshBasic(file)
installer.refreshStatus(self.idata)
self.idata.refresh(what='N')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_Install(_InstallerLink):
"""Install selected packages."""
Expand Down Expand Up @@ -630,7 +631,7 @@ def Execute(self,event):
elif newPos < 0: newPos = len(self.idata.data)
self.idata.moveArchives(self.selected,newPos)
self.idata.refresh(what='N')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_Open(_InstallerLink):
"""Open selected file(s)."""
Expand Down Expand Up @@ -742,7 +743,7 @@ def Execute(self,event):
# User canceled the refresh
pass
self.idata.refresh(what='NSC')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_SkipVoices(CheckLink, _InstallerLink):
"""Toggle skipVoices flag on installer."""
Expand All @@ -759,7 +760,7 @@ def Execute(self,event):
installer.skipVoices ^= True
installer.refreshDataSizeCrc()
self.idata.refresh(what='NS')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installer_Uninstall(_InstallerLink):
"""Uninstall selected Installers."""
Expand Down Expand Up @@ -877,7 +878,7 @@ def Execute(self,event):
if iProject.order == -1:
data.moveArchives([project],srcInstaller.order + 1)
data.refresh(what='I') # InstallersData.refresh()
self.gTank.RefreshUI()
self.window.RefreshUI()

#------------------------------------------------------------------------------
# InstallerDetails Espm Links -------------------------------------------------
Expand Down Expand Up @@ -1087,7 +1088,7 @@ def Execute(self,event):
if iProject.order == -1:
self.idata.moveArchives([project],installer.order+1)
self.idata.refresh(what='NS')
self.gTank.RefreshUI()
self.window.RefreshUI()
#pProject.start()
else:
for archive in self.selected:
Expand All @@ -1107,7 +1108,7 @@ def Execute(self,event):
if iProject.order == -1:
self.idata.moveArchives([project],installer.order+1)
self.idata.refresh(what='NS')
self.gTank.RefreshUI()
self.window.RefreshUI()

#------------------------------------------------------------------------------
# InstallerProject Links ------------------------------------------------------
Expand All @@ -1121,8 +1122,8 @@ def _enable(self): return self.isSingleProject()

def Execute(self,event):
project = self.selected[0]
dialog =InstallerProject_OmodConfigDialog(self.gTank,self.idata,project)
dialog.Show()
(InstallerProject_OmodConfigDialog(self.window, self.idata,
project)).Show()

#------------------------------------------------------------------------------
class InstallerProject_Sync(_InstallerLink):
Expand Down Expand Up @@ -1154,7 +1155,7 @@ def Execute(self,event):
installer.refreshed = False
installer.refreshBasic(pProject,SubProgress(progress,0.1,0.99),True)
self.idata.refresh(what='NS')
self.gTank.RefreshUI()
self.window.RefreshUI()

#------------------------------------------------------------------------------
class InstallerProject_Pack(AppendableLink, _InstallerLink):
Expand Down Expand Up @@ -1283,7 +1284,7 @@ def Execute(self,event):
lastInstaller = self.idata[self.selected[-1]]
self.idata.moveArchives([destArchive],lastInstaller.order+1)
self.idata.refresh(what='I')
self.gTank.RefreshUI()
self.window.RefreshUI()

#------------------------------------------------------------------------------
class InstallerConverter_ApplyEmbedded(_InstallerLink):
Expand Down Expand Up @@ -1321,7 +1322,7 @@ def Execute(self,event):
lastInstaller = self.idata[self.selected[-1]]
self.idata.moveArchives([destArchive],lastInstaller.order+1)
self.idata.refresh(what='I')
self.gTank.RefreshUI()
self.window.RefreshUI()

class InstallerConverter_Create(_InstallerLink):
"""Create BAIN conversion file."""
Expand Down
25 changes: 14 additions & 11 deletions Mopy/bash/basher/installers_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#
# =============================================================================

"""Menu items for the _main_ menu of the installer tab - their window attribute
points to the InstallersList singleton."""

import copy
from .. import bosh, balt, bush
from ..balt import fill, BoolLink, AppendableLink, Link
Expand Down Expand Up @@ -63,7 +66,7 @@ class Installers_AddMarker(Installers_Link):

def Execute(self,event):
"""Add a Marker."""
self.gTank.addMarker()
self.window.addMarker()

class Installers_MonitorInstall(Installers_Link):
"""Monitors Data folder for external installation."""
Expand Down Expand Up @@ -145,7 +148,7 @@ def Execute(self,event):
_(u'These files were deleted. BAIN does not have the capability to remove files when installing.'),
]
group.extend(delFiles)
dialog = ListBoxes(self.gTank,_(u'External Installation'),
dialog = ListBoxes(self.window,_(u'External Installation'),
_(u'The following changes were detected in the Data directory'),
checklists,changedlabels={ListBoxes.ID_OK:_(u'Create Project')})
choice = dialog.ShowModal()
Expand Down Expand Up @@ -191,7 +194,7 @@ def Execute(self,event):
# Refresh UI
gInstallers.RefreshUIMods()
# Select new installer
self.gTank.SelectLast()
self.window.SelectLast()

class Installers_ListPackages(Installers_Link):
"""Copies list of Bain files to clipboard."""
Expand Down Expand Up @@ -311,7 +314,7 @@ class Installers_AutoWizard(Installers_Link, BoolLink):
class _Installers_BoolLink_Refresh(Installers_Link, BoolLink):
def Execute(self,event):
super(_Installers_BoolLink_Refresh, self).Execute(event)
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installers_WizardOverlay(_Installers_BoolLink_Refresh):
"""Toggle using the wizard overlay icon"""
Expand Down Expand Up @@ -372,7 +375,7 @@ def Execute(self,event):
installer.refreshBasic(apath,SubProgress(progress,index,index+1),True)
gInstallers.data.hasChanged = True
gInstallers.data.refresh(what='NSC')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installers_Enabled(Installers_Link, BoolLink):
"""Flips installer state."""
Expand All @@ -393,9 +396,9 @@ def Execute(self,event):
if enabled:
gInstallers.refreshed = False
gInstallers.ShowPanel()
self.gTank.RefreshUI()
self.window.RefreshUI()
else:
self.gTank.DeleteAllItems() ##: TODO(ut): crude
self.window.DeleteAllItems() ##: crude
gInstallers.RefreshDetails(None)

class Installers_BsaRedirection(AppendableLink, Installers_Link, BoolLink):
Expand Down Expand Up @@ -449,7 +452,7 @@ class Installers_SortActive(Installers_Link, BoolLink):

def Execute(self,event):
super(Installers_SortActive, self).Execute(event)
self.gTank.SortItems()
self.window.SortItems()

class Installers_SortProjects(Installers_Link, BoolLink):
"""Sort dirs to the top."""
Expand All @@ -458,15 +461,15 @@ class Installers_SortProjects(Installers_Link, BoolLink):

def Execute(self,event):
super(Installers_SortProjects, self).Execute(event)
self.gTank.SortItems()
self.window.SortItems()

class Installers_SortStructure(Installers_Link, BoolLink):
"""Sort by type."""
text, key = _(u'Sort by Structure'), 'bash.installers.sortStructure'

def Execute(self,event):
super(Installers_SortStructure, self).Execute(event)
self.gTank.SortItems()
self.window.SortItems()

#------------------------------------------------------------------------------
# Installers_Skip Links -------------------------------------------------------
Expand All @@ -481,7 +484,7 @@ def Execute(self,event):
progress(index,_(u'Refreshing Packages...')+u'\n'+dataItem[0].s)
dataItem[1].refreshDataSizeCrc()
self.idata.refresh(what='NS')
self.gTank.RefreshUI()
self.window.RefreshUI()

class Installers_SkipScreenshots(Installers_Skip):
"""Toggle skipScreenshots setting and update."""
Expand Down
8 changes: 4 additions & 4 deletions Mopy/bash/basher/misc_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def Execute(self,event):
if name in self.pdata: return self._showInfo(
name + _(u" already exists."), title=self.dialogTitle)
self.pdata[name] = (time.time(),0,u'')
self.gTank.RefreshUI(details=name) ##: select it !
self.gTank.EnsureVisible(name)
self.window.RefreshUI(details=name) ##: select it !
self.window.EnsureVisible(name)
self.pdata.setChanged()

#------------------------------------------------------------------------------
Expand Down Expand Up @@ -239,7 +239,7 @@ def Execute(self,event):
newNames = self.pdata.loadText(path)
self._showInfo(_(u"People imported: %d") % len(newNames),
title=self.dialogTitle)
self.gTank.RefreshUI()
self.window.RefreshUI()

#------------------------------------------------------------------------------
class People_Karma(People_Link, ChoiceLink):
Expand All @@ -258,7 +258,7 @@ def DoList(self,event):
for item in self.selected:
text = self.pdata[item][2]
self.pdata[item] = (time.time(),karma,text)
self.gTank.RefreshUI()
self.window.RefreshUI()
self.pdata.setChanged()

# Masters Links ---------------------------------------------------------------
Expand Down

0 comments on commit 6d260f0

Please sign in to comment.