Add Cinnamon support
We can use mintmenu in fallback mode
This commit is contained in:
parent
9747e2ec81
commit
4dc179d3ed
@ -10,9 +10,11 @@ location:/usr/share/applications/xed.desktop
|
||||
location:/usr/share/applications/mate-terminal.desktop
|
||||
location:/usr/share/applications/gnome-terminal.desktop
|
||||
location:/usr/share/applications/mate-volume-control.desktop
|
||||
location:/usr/share/applications/cinnamon-settings-sound.desktop
|
||||
location:/usr/share/applications/xfce4-mixer.desktop
|
||||
separator
|
||||
location:/usr/share/applications/mate-display-properties.desktop
|
||||
location:/usr/share/applications/cinnamon-display-panel.desktop
|
||||
location:/usr/share/applications/xfce-display-settings.desktop
|
||||
location:/usr/share/applications/mate-system-monitor.desktop
|
||||
location:/usr/share/applications/gnome-system-monitor.desktop
|
||||
|
@ -46,14 +46,14 @@ from execute import *
|
||||
class MainWindow( object ):
|
||||
"""This is the main class for the application"""
|
||||
|
||||
def __init__( self, toggleButton, settings, keybinder ):
|
||||
def __init__( self, toggleButton, settings, keybinder, de ):
|
||||
|
||||
self.settings = settings
|
||||
self.keybinder = keybinder
|
||||
self.path = PATH
|
||||
sys.path.append( os.path.join( self.path, "plugins") )
|
||||
|
||||
self.detect_desktop_environment()
|
||||
self.de = de
|
||||
|
||||
self.icon = "/usr/lib/linuxmint/mintMenu/visualisation-logo.png"
|
||||
|
||||
@ -172,20 +172,6 @@ class MainWindow( object ):
|
||||
self.window.modify_bg( Gtk.StateType.NORMAL, defaultStyle.lookup_color('bg_color')[1] )
|
||||
self.border.set_padding( self.borderwidth, self.borderwidth, self.borderwidth, self.borderwidth )
|
||||
|
||||
def detect_desktop_environment (self):
|
||||
self.de = "mate"
|
||||
try:
|
||||
de = os.environ["DESKTOP_SESSION"]
|
||||
if de in ["gnome", "gnome-shell", "mate", "kde", "xfce"]:
|
||||
self.de = de
|
||||
else:
|
||||
if os.path.exists("/usr/bin/caja"):
|
||||
self.de = "mate"
|
||||
elif os.path.exists("/usr/bin/thunar"):
|
||||
self.de = "xfce"
|
||||
except Exception, detail:
|
||||
print detail
|
||||
|
||||
def PopulatePlugins( self ):
|
||||
self.panesToColor = [ ]
|
||||
self.headingsToColor = [ ]
|
||||
@ -459,6 +445,7 @@ class MainWindow( object ):
|
||||
class MenuWin( object ):
|
||||
def __init__( self, applet, iid ):
|
||||
self.applet = applet
|
||||
self.detect_desktop_environment()
|
||||
self.settings = Gio.Settings.new("com.linuxmint.mintmenu")
|
||||
self.keybinder = keybinding.GlobalKeyBinding()
|
||||
self.settings.connect( "changed::applet-text", self.reloadSettings )
|
||||
@ -480,7 +467,8 @@ class MenuWin( object ):
|
||||
self.applet.connect( "change-orient", self.changeOrientation )
|
||||
self.applet.connect("enter-notify-event", self.enter_notify)
|
||||
self.applet.connect("leave-notify-event", self.leave_notify)
|
||||
self.mainwin = MainWindow( self.button_box, self.settings, self.keybinder )
|
||||
|
||||
self.mainwin = MainWindow( self.button_box, self.settings, self.keybinder, self.de )
|
||||
self.mainwin.window.connect( "map-event", self.onWindowMap )
|
||||
self.mainwin.window.connect( "unmap-event", self.onWindowUnmap )
|
||||
self.mainwin.window.connect( "realize", self.onRealize )
|
||||
@ -587,7 +575,7 @@ class MenuWin( object ):
|
||||
|
||||
def loadSettings( self, *args, **kargs ):
|
||||
self.hideIcon = self.settings.get_boolean( "hide-applet-icon" )
|
||||
self.buttonText = self.settings.get_string( "applet-text" )
|
||||
self.buttonText = self.settings.get_string("applet-text")
|
||||
self.theme_name = self.settings.get_string( "theme-name" )
|
||||
self.hotkeyText = self.settings.get_string( "hot-key" )
|
||||
self.buttonIcon = self.settings.get_string( "applet-icon" )
|
||||
@ -815,6 +803,22 @@ class MenuWin( object ):
|
||||
xml = os.path.join( os.path.join( os.path.dirname( __file__ )), "popup.xml" )
|
||||
self.applet.setup_menu_from_file(xml, action_group)
|
||||
|
||||
def detect_desktop_environment (self):
|
||||
self.de = "mate"
|
||||
try:
|
||||
de = os.environ["XDG_CURRENT_DESKTOP"].lower()
|
||||
if de in ["gnome", "gnome-shell", "mate", "kde", "xfce"]:
|
||||
self.de = de
|
||||
elif de in ['cinnamon', 'x-cinnamon']:
|
||||
self.de = 'cinnamon'
|
||||
else:
|
||||
if os.path.exists("/usr/bin/caja"):
|
||||
self.de = "mate"
|
||||
elif os.path.exists("/usr/bin/thunar"):
|
||||
self.de = "xfce"
|
||||
except Exception, detail:
|
||||
print detail
|
||||
|
||||
def applet_factory( applet, iid, data ):
|
||||
MenuWin( applet, iid )
|
||||
applet.show()
|
||||
|
@ -105,7 +105,6 @@ class pluginclass( object ):
|
||||
self.iconsize = self.settings.get( "int","icon-size")
|
||||
|
||||
# Check toggles
|
||||
|
||||
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")
|
||||
@ -114,6 +113,27 @@ class pluginclass( object ):
|
||||
self.showLogout = self.settings.get( "bool", "show-logout")
|
||||
self.showQuit = self.settings.get( "bool", "show-quit")
|
||||
|
||||
if self.de == "cinnamon":
|
||||
self.lock_cmd = "cinnamon-screensaver-command --lock"
|
||||
self.logout_cmd = "cinnamon-session-quit --logout"
|
||||
self.shutdown_cmd = "cinnamon-session-quit --power-off"
|
||||
self.terminal_cmd = "/usr/bin/gnome-terminal"
|
||||
self.settings_cmd = "cinnamon-settings"
|
||||
elif self.de == "xfce":
|
||||
self.lock_cmd = "xdg-screensaver lock"
|
||||
self.logout_cmd = "xfce4-session-logout"
|
||||
self.shutdown_cmd = ""
|
||||
self.terminal_cmd = "/usr/bin/gnome-terminal"
|
||||
self.settings_cmd = "xfce4-settings-manager"
|
||||
self.showLockScreen = False
|
||||
self.showQuit = False
|
||||
else:
|
||||
self.lock_cmd = "mate-screensaver-command -l"
|
||||
self.logout_cmd = "mate-session-save --logout-dialog"
|
||||
self.shutdown_cmd = "mate-session-save --shutdown-dialog"
|
||||
self.terminal_cmd = "/usr/bin/mate-terminal"
|
||||
self.settings_cmd = "mate-control-center"
|
||||
|
||||
# Hide vertical dotted separator
|
||||
self.hideseparator = self.settings.get( "bool", "hide-separator")
|
||||
# Plugin icon
|
||||
@ -148,54 +168,41 @@ class pluginclass( object ):
|
||||
|
||||
if ( self.showControlCenter == True ):
|
||||
Button3 = easyButton( "gtk-preferences", self.iconsize, [_("Control Center")], -1, -1 )
|
||||
if self.de == "xfce":
|
||||
Button3.connect( "clicked", self.ButtonClicked, "xfce4-settings-manager" )
|
||||
else:
|
||||
Button3.connect( "clicked", self.ButtonClicked, "mate-control-center" )
|
||||
Button3.connect( "clicked", self.ButtonClicked, self.settings_cmd )
|
||||
Button3.show()
|
||||
self.systemBtnHolder.pack_start( Button3, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button3, _("Configure your system") )
|
||||
|
||||
if ( self.showTerminal == True ):
|
||||
Button4 = easyButton( "terminal", self.iconsize, [_("Terminal")], -1, -1 )
|
||||
if os.path.exists("/usr/bin/mate-terminal"):
|
||||
Button4.connect( "clicked", self.ButtonClicked, "mate-terminal" )
|
||||
if os.path.exists(self.terminal_cmd):
|
||||
Button4.connect( "clicked", self.ButtonClicked, self.terminal_cmd )
|
||||
else:
|
||||
Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" )
|
||||
Button4.show()
|
||||
self.systemBtnHolder.pack_start( Button4, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button4, _("Use the command line") )
|
||||
|
||||
if ( self.showLockScreen == True ):
|
||||
Button5 = easyButton( "system-lock-screen", self.iconsize, [_("Lock Screen")], -1, -1 )
|
||||
Button5.connect( "clicked", self.ButtonClicked, self.lock_cmd )
|
||||
Button5.show()
|
||||
self.systemBtnHolder.pack_start( Button5, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button5, _("Requires password to unlock") )
|
||||
|
||||
if self.de == "xfce":
|
||||
if ( self.showLogout == True ):
|
||||
Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 )
|
||||
Button6.connect( "clicked", self.ButtonClicked, "xfce4-session-logout" )
|
||||
Button6.connect( "clicked", self.ButtonClicked, self.logout_cmd )
|
||||
Button6.show()
|
||||
self.systemBtnHolder.pack_start( Button6, False, False, 0 )
|
||||
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 )
|
||||
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" )
|
||||
Button5.show()
|
||||
self.systemBtnHolder.pack_start( Button5, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button5, _("Requires password to unlock") )
|
||||
|
||||
if ( self.showLogout == True ):
|
||||
Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 )
|
||||
Button6.connect( "clicked", self.ButtonClicked, "mate-session-save --logout-dialog" )
|
||||
Button6.show()
|
||||
self.systemBtnHolder.pack_start( Button6, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button6, _("Log out or switch user") )
|
||||
|
||||
if ( self.showQuit == True ):
|
||||
Button7 = easyButton( "system-shutdown", self.iconsize, [_("Quit")], -1, -1 )
|
||||
Button7.connect( "clicked", self.ButtonClicked, "mate-session-save --shutdown-dialog" )
|
||||
Button7.show()
|
||||
self.systemBtnHolder.pack_start( Button7, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") )
|
||||
if ( self.showQuit == True ):
|
||||
Button7 = easyButton( "system-shutdown", self.iconsize, [_("Quit")], -1, -1 )
|
||||
Button7.connect( "clicked", self.ButtonClicked, self.shutdown_cmd )
|
||||
Button7.show()
|
||||
self.systemBtnHolder.pack_start( Button7, False, False, 0 )
|
||||
self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") )
|
||||
|
||||
def ButtonClicked( self, widget, Exec ):
|
||||
self.mintMenuWin.hide()
|
||||
|
Loading…
Reference in New Issue
Block a user