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.execapp = self.gconf.get( "string", "execute_app", "nautilus" )
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
self.hideseparator = self.gconf.get( "bool", "hide_separator", False )
@ -101,51 +117,63 @@ class pluginclass( object ):
#Add standard places
def do_standard_places( self ):
Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 )
Button1.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop computer:" )
Button1.show()
self.placesBtnHolder.pack_start( Button1, False, False )
self.mintMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") )
if ( self.showcomputer == True ):
Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 )
Button1.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop computer:" )
Button1.show()
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 )
Button2.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop" )
Button2.show()
self.placesBtnHolder.pack_start( Button2, False, False )
self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") )
if ( self.showhomefolder == True ):
Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 )
Button2.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop" )
Button2.show()
self.placesBtnHolder.pack_start( Button2, False, False )
self.mintMenuWin.setTooltip( Button2, _("Open your personal folder") )
Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1 )
Button3.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop network:" )
Button3.show()
self.placesBtnHolder.pack_start( Button3, False, False )
self.mintMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") )
if ( self.shownetwork == True ):
Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1 )
Button3.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop network:" )
Button3.show()
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)
desktopDir = home + "/Desktop"
try:
import sys
sys.path.append('/usr/lib/linuxmint/mintSystem/python')
from configobj import ConfigObj
config = ConfigObj(home + "/.config/user-dirs.dirs")
tmpdesktopDir = config['XDG_DESKTOP_DIR']
tmpdesktopDir = commands.getoutput("echo " + tmpdesktopDir)
if os.path.exists(tmpdesktopDir):
desktopDir = tmpdesktopDir
except Exception, detail:
print detail
Button4 = easyButton( "gnome-fs-desktop", self.iconsize, [_("Desktop")], -1, -1 )
Button4.connect( "clicked", self.ButtonClicked, "nautilus " + desktopDir )
Button4.show()
self.placesBtnHolder.pack_start( Button4, False, False )
self.mintMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") )
if ( self.showdesktop == True ):
# Determine where the Desktop folder is (could be localized)
desktopDir = home + "/Desktop"
try:
import sys
sys.path.append('/usr/lib/linuxmint/mintSystem/python')
from configobj import ConfigObj
config = ConfigObj(home + "/.config/user-dirs.dirs")
tmpdesktopDir = config['XDG_DESKTOP_DIR']
tmpdesktopDir = commands.getoutput("echo " + tmpdesktopDir)
if os.path.exists(tmpdesktopDir):
desktopDir = tmpdesktopDir
except Exception, detail:
print detail
Button4 = easyButton( "gnome-fs-desktop", self.iconsize, [_("Desktop")], -1, -1 )
Button4.connect( "clicked", self.ButtonClicked, "nautilus " + desktopDir )
Button4.show()
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 )
self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop trash:" )
self.trashButton.show()
self.trashButton.connect( "button-release-event", self.trashPopup )
#self.refreshTrash()
if ( self.showtrash == True ):
self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 )
self.trashButton.connect( "clicked", self.ButtonClicked, "nautilus --no-desktop trash:" )
self.trashButton.show()
self.trashButton.connect( "button-release-event", self.trashPopup )
#self.refreshTrash()
self.placesBtnHolder.pack_start( self.trashButton, False, False )
self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )
self.placesBtnHolder.pack_start( self.trashButton, False, False )
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 ):
if event.button == 3: