From 1b1781d78f997005241c116614caa30294752639 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Tue, 5 Mar 2013 21:14:11 -0500 Subject: [PATCH] Convert system management plugin --- .../mintMenu/plugins/applications.py | 72 +++++----- .../mintMenu/plugins/system_management.glade | 40 +++--- .../plugins/system_management.glade.old | 56 ++++++++ .../mintMenu/plugins/system_management.py | 129 +++++++++--------- .../com.linuxmint.mintmenu.gschema.xml | 93 +++++++++++++ 5 files changed, 271 insertions(+), 119 deletions(-) create mode 100644 usr/lib/linuxmint/mintMenu/plugins/system_management.glade.old diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index ae0ce63..b6875d9 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -868,7 +868,7 @@ class pluginclass( object ): insertBefore = True if widget.type == "location": - mTree = self.builder( "favoritesMenu" ) + mTree = self.builder.get_object( "favoritesMenu" ) #i18n desktopMenuItem = Gtk.MenuItem(_("Add to desktop")) @@ -899,44 +899,44 @@ class pluginclass( object ): propsMenuItem.connect( "activate", self.onPropsApp, widget) if self.de == "mate": - mTree.get_widget("favoritesMenu").append(desktopMenuItem) - mTree.get_widget("favoritesMenu").append(panelMenuItem) - mTree.get_widget("favoritesMenu").append(separator1) - mTree.get_widget("favoritesMenu").append(insertSpaceMenuItem) - mTree.get_widget("favoritesMenu").append(insertSeparatorMenuItem) - mTree.get_widget("favoritesMenu").append(separator2) - mTree.get_widget("favoritesMenu").append(startupMenuItem) - mTree.get_widget("favoritesMenu").append(separator3) - mTree.get_widget("favoritesMenu").append(launchMenuItem) - mTree.get_widget("favoritesMenu").append(removeFromFavMenuItem) - mTree.get_widget("favoritesMenu").append(separator4) - mTree.get_widget("favoritesMenu").append(propsMenuItem) + mTree.append(desktopMenuItem) + mTree.append(panelMenuItem) + mTree.append(separator1) + mTree.append(insertSpaceMenuItem) + mTree.append(insertSeparatorMenuItem) + mTree.append(separator2) + mTree.append(startupMenuItem) + mTree.append(separator3) + mTree.append(launchMenuItem) + mTree.append(removeFromFavMenuItem) + mTree.append(separator4) + mTree.append(propsMenuItem) - mTree.get_widget("favoritesMenu").show_all() + mTree.show_all() - mTree.get_widget( "favoritesMenu" ).popup( None, None, None, ev.button, ev.time ) + mTree.popup( None, None, None, ev.button, ev.time ) self.mintMenuWin.grab() else: - mTree = self.builder( "favoritesMenuExtra" ) + mTree = self.builder.get_object( "favoritesMenuExtra" ) #i18n removeMenuItem = Gtk.MenuItem(_("Remove")) insertSpaceMenuItem = Gtk.MenuItem(_("Insert space")) insertSeparatorMenuItem = Gtk.MenuItem(_("Insert separator")) - mTree.get_widget("favoritesMenuExtra").append(removeMenuItem) - mTree.get_widget("favoritesMenuExtra").append(insertSpaceMenuItem) - mTree.get_widget("favoritesMenuExtra").append(insertSeparatorMenuItem) - mTree.get_widget("favoritesMenuExtra").show_all() + mTree.append(removeMenuItem) + mTree.append(insertSpaceMenuItem) + mTree.append(insertSeparatorMenuItem) + mTree.show_all() removeMenuItem.connect( "activate", self.onFavoritesRemove, widget ) insertSpaceMenuItem.connect( "activate", self.onFavoritesInsertSpace, widget, insertBefore ) insertSeparatorMenuItem.connect( "activate", self.onFavoritesInsertSeparator, widget, insertBefore ) - mTree.get_widget( "favoritesMenuExtra" ).popup( None, None, None, ev.button, ev.time ) + mTree.popup( None, None, None, ev.button, ev.time ) self.mintMenuWin.grab() def menuPopup( self, widget, event ): if event.button == 3: - mTree = self.builder ( "applicationsMenu" ) + mTree = self.builder.get_object ( "applicationsMenu" ) #i18n desktopMenuItem = Gtk.MenuItem(_("Add to desktop")) @@ -952,26 +952,26 @@ class pluginclass( object ): propsMenuItem = Gtk.MenuItem(_("Edit properties")) if self.de == "mate": - mTree.get_widget("applicationsMenu").append(desktopMenuItem) - mTree.get_widget("applicationsMenu").append(panelMenuItem) - mTree.get_widget("applicationsMenu").append(separator1) + mTree.append(desktopMenuItem) + mTree.append(panelMenuItem) + mTree.append(separator1) - mTree.get_widget("applicationsMenu").append(favoriteMenuItem) - mTree.get_widget("applicationsMenu").append(startupMenuItem) + mTree.append(favoriteMenuItem) + mTree.append(startupMenuItem) - mTree.get_widget("applicationsMenu").append(separator2) + mTree.append(separator2) - mTree.get_widget("applicationsMenu").append(launchMenuItem) - mTree.get_widget("applicationsMenu").append(uninstallMenuItem) + mTree.append(launchMenuItem) + mTree.append(uninstallMenuItem) if home in widget.desktopFile: - mTree.get_widget("applicationsMenu").append(deleteMenuItem) + mTree.append(deleteMenuItem) deleteMenuItem.connect("activate", self.delete_from_menu, widget) - mTree.get_widget("applicationsMenu").append(separator3) + mTree.append(separator3) - mTree.get_widget("applicationsMenu").append(propsMenuItem) + mTree.append(propsMenuItem) - mTree.get_widget("applicationsMenu").show_all() + mTree.show_all() desktopMenuItem.connect("activate", self.add_to_desktop, widget) panelMenuItem.connect("activate", self.add_to_panel, widget) @@ -994,8 +994,8 @@ class pluginclass( object ): startupMenuItem.set_active( False ) startupMenuItem.connect( "toggled", self.onAddToStartup, widget ) - mTree.get_widget( "applicationsMenu" ).connect( 'deactivate', self.onMenuPopupDeactivate) - mTree.get_widget( "applicationsMenu" ).popup( None, None, None, event.button, event.time ) + mTree.connect( 'deactivate', self.onMenuPopupDeactivate) + mTree.popup( None, None, None, event.button, event.time ) def onMenuPopupDeactivate( self, widget): self.mintMenuWin.grab() diff --git a/usr/lib/linuxmint/mintMenu/plugins/system_management.glade b/usr/lib/linuxmint/mintMenu/plugins/system_management.glade index d43b425..467c4d9 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/system_management.glade +++ b/usr/lib/linuxmint/mintMenu/plugins/system_management.glade @@ -1,56 +1,56 @@ - + - - + + - + True - + True True automatic automatic - - - + + + - + True none - + True - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 2 - + 0 - + True start - + False False 1 - + - + - + - + - - + + diff --git a/usr/lib/linuxmint/mintMenu/plugins/system_management.glade.old b/usr/lib/linuxmint/mintMenu/plugins/system_management.glade.old new file mode 100644 index 0000000..d43b425 --- /dev/null +++ b/usr/lib/linuxmint/mintMenu/plugins/system_management.glade.old @@ -0,0 +1,56 @@ + + + + + + + + + True + + + True + True + automatic + automatic + + + + + + True + none + + + True + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 2 + + + 0 + + + + + True + start + + + False + False + 1 + + + + + + + + + + + + diff --git a/usr/lib/linuxmint/mintMenu/plugins/system_management.py b/usr/lib/linuxmint/mintMenu/plugins/system_management.py index c0e78d5..e629645 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/system_management.py +++ b/usr/lib/linuxmint/mintMenu/plugins/system_management.py @@ -1,14 +1,16 @@ #!/usr/bin/env python -import gtk -import gtk.glade +import gi +gi.require_version("Gtk", "2.0") + +from gi.repository import Gtk import os import string import gettext from easybuttons import * from execute import Execute -from easygconf import EasyGConf +from easygsettings import EasyGSettings # i18n gettext.install("mintmenu", "/usr/share/linuxmint/locale") @@ -21,103 +23,104 @@ class pluginclass( object ): self.toggleButton = toggleButton self.de = de - # Read GLADE file - gladefile = os.path.join( os.path.dirname( __file__ ), "system_management.glade" ) - wTree = gtk.glade.XML( gladefile, "mainWindow" ) - self.systemBtnHolder = wTree.get_widget( "system_button_holder" ) - self.editableBtnHolder = wTree.get_widget( "editable_button_holder" ) - self.scrolledWindow = wTree.get_widget( "scrolledwindow2" ) + + 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" ) # These properties are NECESSARY to maintain consistency # Set 'window' property for the plugin (Must be the root widget) - self.window = wTree.get_widget( "mainWindow" ) + self.window = self.builder.get_object( "mainWindow" ) # Set 'heading' property for plugin self.heading = _("System") # This should be the first item added to the window in glade - self.content_holder = wTree.get_widget( "System" ) + self.content_holder = self.builder.get_object( "System" ) # Items to get custom colors - self.itemstocolor = [ wTree.get_widget( "viewport2" ) ] + self.itemstocolor = [ self.builder.get_object( "viewport2" ) ] # Gconf stuff - self.gconf = EasyGConf( "/apps/mintMenu/plugins/system-management/" ) + self.settings = EasyGSettings( "com.linuxmint.mintmenu.plugins.system_management" ) - self.gconf.notifyAdd( "icon_size", self.RegenPlugin ) - self.gconf.notifyAdd( "show_control_center", self.RegenPlugin ) - self.gconf.notifyAdd( "show_lock_screen", self.RegenPlugin ) - self.gconf.notifyAdd( "show_logout", self.RegenPlugin ) - self.gconf.notifyAdd( "show_package_manager", self.RegenPlugin ) - self.gconf.notifyAdd( "show_software_manager", self.RegenPlugin ) - self.gconf.notifyAdd( "show_terminal", self.RegenPlugin ) - self.gconf.notifyAdd( "show_quit", self.RegenPlugin ) - self.gconf.notifyAdd( "allowScrollbar", self.RegenPlugin ) - self.gconf.notifyAdd( "height", self.changePluginSize ) - self.gconf.notifyAdd( "width", self.changePluginSize ) - self.gconf.bindGconfEntryToVar( "bool", "sticky", self, "sticky" ) + 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.GetGconfEntries() + self.GetGSettingsEntries() self.content_holder.set_size_request( self.width, self.height ) def destroy( self ): - self.gconf.notifyRemoveAll() + self.settings.notifyRemoveAll() def wake (self) : pass - def changePluginSize( self, client, connection_id, entry, args ): - self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False) - if entry.get_key() == self.gconf.gconfDir+"width": - self.width = entry.get_value().get_int() - elif entry.get_key() == self.gconf.gconfDir+"height": + 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": if (self.allowScrollbar == False): self.height = -1 - self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER ) + self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) else: - self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC ) - self.height = entry.get_value().get_int() + self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC ) + self.height = settings.get_int(key) self.content_holder.set_size_request( self.width, self.height ) - def RegenPlugin( self, *args, **kargs ): - self.GetGconfEntries() + def RegenPlugin( self, settings, key, args ): + self.GetGSettingsEntries() self.ClearAll() self.do_standard_items() - def GetGconfEntries( self ): + def GetGSettingsEntries( self ): - self.width = self.gconf.get( "int", "width", 200 ) - self.allowScrollbar = self.gconf.get( "bool", "allowScrollbar", False) - self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC ) - self.height = self.gconf.get( "int", "height", 180 ) + 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") self.content_holder.set_size_request( self.width, self.height ) if (self.allowScrollbar == False): self.height = -1 - self.scrolledWindow.set_policy( gtk.POLICY_AUTOMATIC, gtk.POLICY_NEVER ) + self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) self.content_holder.set_size_request( self.width, self.height ) - self.iconsize = self.gconf.get( "int","icon_size", 16 ) + self.iconsize = self.settings.get( "int","icon-size") # Check toggles - self.showSoftwareManager = self.gconf.get( "bool", "show_software_manager", True ) - self.showPackageManager = self.gconf.get( "bool", "show_package_manager", True ) - self.showControlCenter = self.gconf.get( "bool", "show_control_center", True ) - self.showTerminal = self.gconf.get( "bool", "show_terminal", True ) - self.showLockScreen = self.gconf.get( "bool", "show_lock_screen", True ) - self.showLogout = self.gconf.get( "bool", "show_logout", True ) - self.showQuit = self.gconf.get( "bool", "show_quit", True ) + 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") # Hide vertical dotted separator - self.hideseparator = self.gconf.get( "bool", "hide_separator", False ) + self.hideseparator = self.settings.get( "bool", "hide-separator") # Plugin icon - self.icon = self.gconf.get( "string", 'icon', "preferences-system" ) + self.icon = self.settings.get( "string", "icon" ) # Allow plugin to be minimized to the left plugin pane - self.sticky = self.gconf.get( "bool", "sticky", False ) - self.minimized = self.gconf.get( "bool", "minimized", False ) + self.sticky = self.settings.get( "bool", "sticky") + self.minimized = self.settings.get( "bool", "minimized") def ClearAll(self): for child in self.systemBtnHolder.get_children(): @@ -133,14 +136,14 @@ class pluginclass( object ): Button1 = easyButton( "/usr/lib/linuxmint/mintInstall/icon.svg", self.iconsize, [_("Software Manager")], -1, -1 ) Button1.connect( "clicked", self.ButtonClicked, "gksu mintinstall" ) Button1.show() - self.systemBtnHolder.pack_start( Button1, False, False ) + self.systemBtnHolder.pack_start( Button1, False, False, 0) 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() - self.systemBtnHolder.pack_start( Button2, False, False ) + self.systemBtnHolder.pack_start( Button2, False, False, 0 ) self.mintMenuWin.setTooltip( Button2, _("Install, remove and upgrade software packages") ) if ( self.showControlCenter == True ): @@ -150,7 +153,7 @@ class pluginclass( object ): else: Button3.connect( "clicked", self.ButtonClicked, "mate-control-center" ) Button3.show() - self.systemBtnHolder.pack_start( Button3, False, False ) + self.systemBtnHolder.pack_start( Button3, False, False, 0 ) self.mintMenuWin.setTooltip( Button3, _("Configure your system") ) if ( self.showTerminal == True ): @@ -160,14 +163,14 @@ class pluginclass( object ): else: Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" ) Button4.show() - self.systemBtnHolder.pack_start( Button4, False, False ) + self.systemBtnHolder.pack_start( Button4, False, False, 0 ) self.mintMenuWin.setTooltip( Button4, _("Use the command line") ) if self.de == "xfce": Button6 = easyButton( "system-log-out", self.iconsize, [_("Logout")], -1, -1 ) Button6.connect( "clicked", self.ButtonClicked, "xfce4-session-logout" ) Button6.show() - self.systemBtnHolder.pack_start( Button6, False, False ) + self.systemBtnHolder.pack_start( Button6, False, False, 0 ) self.mintMenuWin.setTooltip( Button6, _("Log out or switch user") ) else: if ( self.showLockScreen == True ): @@ -177,21 +180,21 @@ class pluginclass( object ): else: Button5.connect( "clicked", self.ButtonClicked, "xdg-screensaver lock" ) Button5.show() - self.systemBtnHolder.pack_start( Button5, False, False ) + 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 ) + 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 ) + self.systemBtnHolder.pack_start( Button7, False, False, 0 ) self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") ) def ButtonClicked( self, widget, Exec ): diff --git a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml index e7e04ef..3302484 100644 --- a/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml +++ b/usr/share/glib-2.0/schemas/com.linuxmint.mintmenu.gschema.xml @@ -312,9 +312,102 @@ + + + + + 200 + + + + + + 180 + + + + + + false + + + + + + 16 + + + + + + true + + + + + + true + + + + + + true + + + + + + true + + + + + + true + + + + + + true + + + + + + true + + + + + + false + + + + + + false + + + + + + false + + + + + + "preferences-system" + + + +