2009-07-27 11:45:34 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "2.0")
|
|
|
|
|
|
|
|
from gi.repository import Gtk
|
2009-07-27 11:45:34 +01:00
|
|
|
import os
|
|
|
|
import string
|
|
|
|
import gettext
|
|
|
|
|
|
|
|
from easybuttons import *
|
|
|
|
from execute import Execute
|
2013-03-06 02:14:11 +00:00
|
|
|
from easygsettings import EasyGSettings
|
2009-07-27 11:45:34 +01:00
|
|
|
|
|
|
|
# i18n
|
2009-11-03 11:29:52 +00:00
|
|
|
gettext.install("mintmenu", "/usr/share/linuxmint/locale")
|
2009-07-27 11:45:34 +01:00
|
|
|
|
|
|
|
class pluginclass( object ):
|
|
|
|
|
2011-03-29 18:51:59 +01:00
|
|
|
def __init__( self, mintMenuWin, toggleButton, de ):
|
|
|
|
|
|
|
|
self.mintMenuWin = mintMenuWin
|
|
|
|
self.toggleButton = toggleButton
|
|
|
|
self.de = de
|
2009-07-27 11:45:34 +01:00
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
|
|
|
|
self.builder = Gtk.Builder()
|
|
|
|
self.builder.add_from_file (os.path.join( os.path.dirname( __file__ ), "system_management.glade" ))
|
|
|
|
|
|
|
|
self.systemBtnHolder = self.builder.get_object( "system_button_holder" )
|
|
|
|
self.editableBtnHolder = self.builder.get_object( "editable_button_holder" )
|
|
|
|
self.scrolledWindow = self.builder.get_object( "scrolledwindow2" )
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
# These properties are NECESSARY to maintain consistency
|
|
|
|
|
|
|
|
# Set 'window' property for the plugin (Must be the root widget)
|
2013-03-06 02:14:11 +00:00
|
|
|
self.window = self.builder.get_object( "mainWindow" )
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
# Set 'heading' property for plugin
|
|
|
|
self.heading = _("System")
|
|
|
|
|
|
|
|
# This should be the first item added to the window in glade
|
2013-03-06 02:14:11 +00:00
|
|
|
self.content_holder = self.builder.get_object( "System" )
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
# Items to get custom colors
|
2013-03-06 02:14:11 +00:00
|
|
|
self.itemstocolor = [ self.builder.get_object( "viewport2" ) ]
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
# Gconf stuff
|
2013-03-06 02:14:11 +00:00
|
|
|
self.settings = EasyGSettings( "com.linuxmint.mintmenu.plugins.system_management" )
|
|
|
|
|
|
|
|
self.settings.notifyAdd( "icon_size", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_control_center", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_lock_screen", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_logout", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_package_manager", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_software_manager", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_terminal", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "show_quit", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin )
|
|
|
|
self.settings.notifyAdd( "height", self.changePluginSize )
|
|
|
|
self.settings.notifyAdd( "width", self.changePluginSize )
|
|
|
|
self.settings.bindGSettingsEntryToVar( "bool", "sticky", self, "sticky" )
|
|
|
|
|
|
|
|
self.GetGSettingsEntries()
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
self.content_holder.set_size_request( self.width, self.height )
|
|
|
|
|
|
|
|
def destroy( self ):
|
2013-03-06 02:14:11 +00:00
|
|
|
self.settings.notifyRemoveAll()
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
def wake (self) :
|
|
|
|
pass
|
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
def changePluginSize( self, settings, key, args ):
|
|
|
|
self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar")
|
|
|
|
if key == "width":
|
|
|
|
self.width = settings.get_int(key)
|
|
|
|
elif key == "height":
|
2011-03-29 18:51:59 +01:00
|
|
|
if (self.allowScrollbar == False):
|
|
|
|
self.height = -1
|
2013-03-06 02:14:11 +00:00
|
|
|
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
|
2011-03-29 18:51:59 +01:00
|
|
|
else:
|
2013-03-06 02:14:11 +00:00
|
|
|
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC )
|
|
|
|
self.height = settings.get_int(key)
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
self.content_holder.set_size_request( self.width, self.height )
|
|
|
|
|
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
def RegenPlugin( self, settings, key, args ):
|
|
|
|
self.GetGSettingsEntries()
|
2011-03-29 18:51:59 +01:00
|
|
|
self.ClearAll()
|
|
|
|
self.do_standard_items()
|
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
def GetGSettingsEntries( self ):
|
2011-03-29 18:51:59 +01:00
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
self.width = self.settings.get( "int", "width")
|
|
|
|
self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar")
|
|
|
|
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC )
|
|
|
|
self.height = self.settings.get( "int", "height")
|
2011-03-29 18:51:59 +01:00
|
|
|
self.content_holder.set_size_request( self.width, self.height )
|
|
|
|
if (self.allowScrollbar == False):
|
|
|
|
self.height = -1
|
2013-03-06 02:14:11 +00:00
|
|
|
self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER )
|
2011-03-29 18:51:59 +01:00
|
|
|
self.content_holder.set_size_request( self.width, self.height )
|
2013-03-06 02:14:11 +00:00
|
|
|
self.iconsize = self.settings.get( "int","icon-size")
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
# Check toggles
|
|
|
|
|
2013-03-06 02:14:11 +00:00
|
|
|
self.showSoftwareManager = self.settings.get( "bool", "show-software-manager")
|
|
|
|
self.showPackageManager = self.settings.get( "bool", "show-package-manager")
|
|
|
|
self.showControlCenter = self.settings.get( "bool", "show-control-center")
|
|
|
|
self.showTerminal = self.settings.get( "bool", "show-terminal")
|
|
|
|
self.showLockScreen = self.settings.get( "bool", "show-lock-screen")
|
|
|
|
self.showLogout = self.settings.get( "bool", "show-logout")
|
|
|
|
self.showQuit = self.settings.get( "bool", "show-quit")
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
# Hide vertical dotted separator
|
2013-03-06 02:14:11 +00:00
|
|
|
self.hideseparator = self.settings.get( "bool", "hide-separator")
|
2011-03-29 18:51:59 +01:00
|
|
|
# Plugin icon
|
2013-03-06 02:14:11 +00:00
|
|
|
self.icon = self.settings.get( "string", "icon" )
|
2011-03-29 18:51:59 +01:00
|
|
|
# Allow plugin to be minimized to the left plugin pane
|
2013-03-06 02:14:11 +00:00
|
|
|
self.sticky = self.settings.get( "bool", "sticky")
|
|
|
|
self.minimized = self.settings.get( "bool", "minimized")
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
def ClearAll(self):
|
|
|
|
for child in self.systemBtnHolder.get_children():
|
|
|
|
child.destroy()
|
|
|
|
for child in self.editableBtnHolder.get_children():
|
|
|
|
child.destroy()
|
|
|
|
|
|
|
|
#Add standard items
|
|
|
|
def do_standard_items( self ):
|
|
|
|
|
|
|
|
if ( self.showSoftwareManager == True ):
|
|
|
|
if os.path.exists("/usr/lib/linuxmint/mintInstall/icon.svg"):
|
2011-05-01 17:43:50 +01:00
|
|
|
Button1 = easyButton( "/usr/lib/linuxmint/mintInstall/icon.svg", self.iconsize, [_("Software Manager")], -1, -1 )
|
2012-11-02 15:01:12 +00:00
|
|
|
Button1.connect( "clicked", self.ButtonClicked, "gksu mintinstall" )
|
2011-03-29 18:51:59 +01:00
|
|
|
Button1.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button1, False, False, 0)
|
2011-03-29 18:51:59 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button1, _("Browse and install available software") )
|
|
|
|
|
|
|
|
if ( self.showPackageManager == True ):
|
|
|
|
Button2 = easyButton( "applications-system", self.iconsize, [_("Package Manager")], -1, -1 )
|
|
|
|
Button2.connect( "clicked", self.ButtonClicked, "gksu /usr/sbin/synaptic" )
|
|
|
|
Button2.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button2, False, False, 0 )
|
2011-03-29 18:51:59 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button2, _("Install, remove and upgrade software packages") )
|
|
|
|
|
|
|
|
if ( self.showControlCenter == True ):
|
|
|
|
Button3 = easyButton( "gtk-preferences", self.iconsize, [_("Control Center")], -1, -1 )
|
2011-03-29 19:46:08 +01:00
|
|
|
if self.de == "xfce":
|
|
|
|
Button3.connect( "clicked", self.ButtonClicked, "xfce4-settings-manager" )
|
|
|
|
else:
|
2011-11-18 10:42:20 +00:00
|
|
|
Button3.connect( "clicked", self.ButtonClicked, "mate-control-center" )
|
2011-03-29 18:51:59 +01:00
|
|
|
Button3.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button3, False, False, 0 )
|
2011-03-29 18:51:59 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button3, _("Configure your system") )
|
|
|
|
|
|
|
|
if ( self.showTerminal == True ):
|
2012-05-22 16:43:20 +01:00
|
|
|
Button4 = easyButton( "terminal", self.iconsize, [_("Terminal")], -1, -1 )
|
2011-11-28 12:44:49 +00:00
|
|
|
if os.path.exists("/usr/bin/mate-terminal"):
|
|
|
|
Button4.connect( "clicked", self.ButtonClicked, "mate-terminal" )
|
|
|
|
else:
|
|
|
|
Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" )
|
2011-03-29 18:51:59 +01:00
|
|
|
Button4.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button4, False, False, 0 )
|
2011-03-29 18:51:59 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button4, _("Use the command line") )
|
|
|
|
|
2011-03-29 19:46:08 +01:00
|
|
|
if self.de == "xfce":
|
|
|
|
Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 )
|
|
|
|
Button6.connect( "clicked", self.ButtonClicked, "xfce4-session-logout" )
|
|
|
|
Button6.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button6, False, False, 0 )
|
2011-03-29 19:46:08 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button6, _("Log out or switch user") )
|
|
|
|
else:
|
|
|
|
if ( self.showLockScreen == True ):
|
|
|
|
Button5 = easyButton( "system-lock-screen", self.iconsize, [_("Lock Screen")], -1, -1 )
|
2012-04-18 11:04:43 +01:00
|
|
|
if os.path.exists("/usr/bin/mate-screensaver-command"):
|
|
|
|
Button5.connect( "clicked", self.ButtonClicked, "mate-screensaver-command -l" )
|
|
|
|
else:
|
|
|
|
Button5.connect( "clicked", self.ButtonClicked, "xdg-screensaver lock" )
|
2011-03-29 19:46:08 +01:00
|
|
|
Button5.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button5, False, False, 0 )
|
2011-03-29 19:46:08 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button5, _("Requires password to unlock") )
|
|
|
|
|
|
|
|
if ( self.showLogout == True ):
|
|
|
|
Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 )
|
2011-11-18 10:42:20 +00:00
|
|
|
Button6.connect( "clicked", self.ButtonClicked, "mate-session-save --logout-dialog" )
|
2011-03-29 19:46:08 +01:00
|
|
|
Button6.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button6, False, False, 0 )
|
2011-03-29 19:46:08 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button6, _("Log out or switch user") )
|
|
|
|
|
|
|
|
if ( self.showQuit == True ):
|
|
|
|
Button7 = easyButton( "system-shutdown", self.iconsize, [_("Quit")], -1, -1 )
|
2011-11-18 10:42:20 +00:00
|
|
|
Button7.connect( "clicked", self.ButtonClicked, "mate-session-save --shutdown-dialog" )
|
2011-03-29 19:46:08 +01:00
|
|
|
Button7.show()
|
2013-03-06 02:14:11 +00:00
|
|
|
self.systemBtnHolder.pack_start( Button7, False, False, 0 )
|
2011-03-29 19:46:08 +01:00
|
|
|
self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") )
|
2011-03-29 18:51:59 +01:00
|
|
|
|
|
|
|
def ButtonClicked( self, widget, Exec ):
|
|
|
|
self.mintMenuWin.hide()
|
|
|
|
if Exec:
|
|
|
|
Execute( Exec )
|
|
|
|
|
|
|
|
def do_plugin( self ):
|
|
|
|
self.do_standard_items()
|