Enabled technical ability to add custom items.

This commit is contained in:
clhodapp 2009-08-01 23:13:51 -04:00
parent 2257fe4a05
commit 62e210c2a3

View File

@ -83,6 +83,22 @@ class pluginclass( object ):
self.height = self.gconf.get( "int", "height", 155 ) self.height = self.gconf.get( "int", "height", 155 )
self.execapp = self.gconf.get( "string", "execute_app", "nautilus" ) self.execapp = self.gconf.get( "string", "execute_app", "nautilus" )
self.iconsize = self.gconf.get( "int","icon_size", 2 ) self.iconsize = self.gconf.get( "int","icon_size", 2 )
# Check default items
self.showcomputer = self.gconf.get( "bool", "show_computer", True )
self.showhomefolder = self.gconf.get( "bool", "show_home_folder", True )
self.shownetwork = self.gconf.get( "bool", "show_network", True )
self.showdesktop = self.gconf.get( "bool", "show_desktop", True )
self.showtrash = self.gconf.get( "bool", "show_trash", True )
# Get paths for custom items
self.custompaths = self.gconf.get( "list-string", "custom_paths", [ ] )
# Get names for custom items
self.customnames = self.gconf.get( "list-string", "custom-names", [ ] )
# Hide vertical dotted separator # Hide vertical dotted separator
self.hideseparator = self.gconf.get( "bool", "hide_separator", False ) self.hideseparator = self.gconf.get( "bool", "hide_separator", False )
@ -101,51 +117,63 @@ class pluginclass( object ):
#Add standard places #Add standard places
def do_standard_places( self ): def do_standard_places( self ):
Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 ) if ( self.showcomputer == True ):
Button1.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop computer:" ) Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 )
Button1.show() Button1.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop computer:" )
self.placesBtnHolder.pack_start( Button1, False, False ) Button1.show()
self.mintMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") ) self.placesBtnHolder.pack_start( Button1, False, False )
self.mintMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") )
Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 ) if ( self.showhomefolder == True ):
Button2.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop" ) Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 )
Button2.show() Button2.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop" )
self.placesBtnHolder.pack_start( Button2, False, False ) Button2.show()
self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") ) self.placesBtnHolder.pack_start( Button2, False, False )
self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") )
Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1 ) if ( self.shownetwork == True ):
Button3.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop network:" ) Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1 )
Button3.show() Button3.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop network:" )
self.placesBtnHolder.pack_start( Button3, False, False ) Button3.show()
self.mintMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") ) self.placesBtnHolder.pack_start( Button3, False, False )
self.mintMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") )
# Determine where the Desktop folder is (could be localized) if ( self.showdesktop == True ):
desktopDir = home + "/Desktop" # Determine where the Desktop folder is (could be localized)
try: desktopDir = home + "/Desktop"
import sys try:
sys.path.append('/usr/lib/linuxmint/mintSystem/python') import sys
from configobj import ConfigObj sys.path.append('/usr/lib/linuxmint/mintSystem/python')
config = ConfigObj(home + "/.config/user-dirs.dirs") from configobj import ConfigObj
tmpdesktopDir = config['XDG_DESKTOP_DIR'] config = ConfigObj(home + "/.config/user-dirs.dirs")
tmpdesktopDir = commands.getoutput("echo " + tmpdesktopDir) tmpdesktopDir = config['XDG_DESKTOP_DIR']
if os.path.exists(tmpdesktopDir): tmpdesktopDir = commands.getoutput("echo " + tmpdesktopDir)
desktopDir = tmpdesktopDir if os.path.exists(tmpdesktopDir):
except Exception, detail: desktopDir = tmpdesktopDir
print detail except Exception, detail:
Button4 = easyButton( "gnome-fs-desktop", self.iconsize, [_("Desktop")], -1, -1 ) print detail
Button4.connect( "clicked", self.ButtonClicked, "nautilus " + desktopDir ) Button4 = easyButton( "gnome-fs-desktop", self.iconsize, [_("Desktop")], -1, -1 )
Button4.show() Button4.connect( "clicked", self.ButtonClicked, "nautilus " + desktopDir )
self.placesBtnHolder.pack_start( Button4, False, False ) Button4.show()
self.mintMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") ) self.placesBtnHolder.pack_start( Button4, False, False )
self.mintMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") )
self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 ) if ( self.showtrash == True ):
self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop trash:" ) self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 )
self.trashButton.show() self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop trash:" )
self.trashButton.connect( "button-release-event", self.trashPopup ) self.trashButton.show()
#self.refreshTrash() self.trashButton.connect( "button-release-event", self.trashPopup )
#self.refreshTrash()
self.placesBtnHolder.pack_start( self.trashButton, False, False ) self.placesBtnHolder.pack_start( self.trashButton, False, False )
self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") ) self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )
for index in range( len(self.custompaths) ):
command = ( "nautilus --no-desktop " + self.custompaths[index] )
currentbutton = easyButton( "folder", self.iconsize, [_(self.customnames[index])], -1, -1 )
currentbutton.connect( "clicked", self.ButtonClicked, command )
currentbutton.show()
self.placesBtnHolder.pack_start( currentbutton, False, False )
def trashPopup( self, widget, event ): def trashPopup( self, widget, event ):
if event.button == 3: if event.button == 3: