def __init__(self, mateMenuWin, toggleButton): self.Win = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() #The Glade file for the plugin self.builder.add_from_file( os.path.join('/', 'usr', 'share', 'mate-menu', 'plugins', 'recent.glade')) #Set 'window' property for the plugin (Must be the root widget) self.window = self.builder.get_object("window1") #Set 'heading' property for plugin self.heading = _("Recent documents") #This should be the first item added to the window in glade self.content_holder = self.builder.get_object("eventbox1") self.recentBox = self.builder.get_object("RecentBox") self.recentVBox = self.builder.get_object("vbox1") self.itemstocolor = [ self.builder.get_object("viewport1"), self.builder.get_object("viewport2") ] #Specify plugin width self.width = 250 #Plugin icon self.icon = 'folder.png' self.settings = EasyGSettings("org.mate.mate-menu.plugins.recent") self.settings.notifyAdd('height', self.RegenPlugin) self.settings.notifyAdd('width', self.RegenPlugin) self.settings.notifyAdd('num-recent-docs', self.RegenPlugin) self.settings.notifyAdd('recent-font-size', self.RegenPlugin) self.FileList = [] self.RecManagerInstance = Gtk.RecentManager.get_default() self.recentManagerId = self.RecManagerInstance.connect( "changed", self.DoRecent) self.RegenPlugin() self.builder.get_object("RecentTabs").set_current_page(1) #Connect event handlers clr_btn = self.builder.get_object("ClrBtn") clr_btn.connect("clicked", self.clrmenu) clr_btn.connect("motion-notify-event", self.onMotion) clr_btn.connect("enter-notify-event", self.onEnter)
def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() self.builder.add_from_file( os.path.join('/', 'usr', 'share', 'mate-menu', 'plugins', '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 = 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 = self.builder.get_object("System") # Items to get custom colors self.itemstocolor = [self.builder.get_object("viewport2")] # Gconf stuff self.settings = EasyGSettings( "org.mate.mate-menu.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-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() self.content_holder.set_size_request(self.width, self.height)
def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton # Read UI file builder = Gtk.Builder() builder.add_from_file( os.path.join('/', 'usr', 'share', 'mate-menu', 'plugins', 'places.glade')) self.placesBtnHolder = builder.get_object("places_button_holder") self.editableBtnHolder = builder.get_object("editable_button_holder") self.scrolledWindow = builder.get_object("scrolledwindow2") # These properties are NECESSARY to maintain consistency # Set 'window' property for the plugin (Must be the root widget) self.window = builder.get_object("mainWindow") # Set 'heading' property for plugin self.heading = _("Places") # This should be the first item added to the window in glade self.content_holder = builder.get_object("Places") # Items to get custom colors self.itemstocolor = [builder.get_object("viewport2")] # Settings self.settings = EasyGSettings("org.mate.mate-menu.plugins.places") self.settings.notifyAdd("icon-size", self.RegenPlugin) self.settings.notifyAdd("show-computer", self.RegenPlugin) self.settings.notifyAdd("show-desktop", self.RegenPlugin) self.settings.notifyAdd("show-home_folder", self.RegenPlugin) self.settings.notifyAdd("show-network", self.RegenPlugin) self.settings.notifyAdd("show-trash", self.RegenPlugin) self.settings.notifyAdd("custom-names", self.RegenPlugin) self.settings.notifyAdd("allow-scrollbar", self.RegenPlugin) self.settings.notifyAdd("show-gtk-bookmarks", self.RegenPlugin) self.settings.notifyAdd("height", self.changePluginSize) self.settings.notifyAdd("width", self.changePluginSize) self.loadSettings() self.content_holder.set_size_request(self.width, self.height)
def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton # Read UI file builder = Gtk.Builder() builder.add_from_file( os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', 'places.glade' )) self.placesBtnHolder = builder.get_object( "places_button_holder" ) self.editableBtnHolder = builder.get_object( "editable_button_holder" ) self.scrolledWindow=builder.get_object("scrolledwindow2") # These properties are NECESSARY to maintain consistency # Set 'window' property for the plugin (Must be the root widget) self.window = builder.get_object( "mainWindow" ) # Set 'heading' property for plugin self.heading = _("Places") # This should be the first item added to the window in glade self.content_holder = builder.get_object( "Places" ) # Items to get custom colors self.itemstocolor = [ builder.get_object( "viewport2" ) ] # Settings self.settings = EasyGSettings("org.mate.mate-menu.plugins.places") self.settings.notifyAdd( "icon-size", self.RegenPlugin ) self.settings.notifyAdd( "show-computer", self.RegenPlugin ) self.settings.notifyAdd( "show-desktop", self.RegenPlugin ) self.settings.notifyAdd( "show-home_folder", self.RegenPlugin ) self.settings.notifyAdd( "show-network", self.RegenPlugin ) self.settings.notifyAdd( "show-trash", self.RegenPlugin ) self.settings.notifyAdd( "custom-names", self.RegenPlugin ) self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin ) self.settings.notifyAdd( "show-gtk-bookmarks", self.RegenPlugin ) self.settings.notifyAdd( "height", self.changePluginSize ) self.settings.notifyAdd( "width", self.changePluginSize ) self.loadSettings() self.content_holder.set_size_request( self.width, self.height )
def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() self.builder.add_from_file( os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', '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 = 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 = self.builder.get_object( "System" ) # Items to get custom colors self.itemstocolor = [ self.builder.get_object( "viewport2" ) ] # Gconf stuff self.settings = EasyGSettings( "org.mate.mate-menu.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-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() self.content_holder.set_size_request( self.width, self.height )
def __init__(self, mateMenuWin, toggleButton): self.Win = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() #The Glade file for the plugin self.builder.add_from_file (os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', 'recent.glade' )) #Set 'window' property for the plugin (Must be the root widget) self.window = self.builder.get_object( "window1" ) #Set 'heading' property for plugin self.heading = _("Recent documents") #This should be the first item added to the window in glade self.content_holder = self.builder.get_object( "eventbox1" ) self.recentBox = self.builder.get_object("RecentBox") self.recentVBox = self.builder.get_object( "vbox1" ) #Specify plugin width self.width = 250 #Plugin icon self.icon = 'mate-folder.png' self.settings = EasyGSettings ("org.mate.mate-menu.plugins.recent") self.settings.notifyAdd( 'height', self.RegenPlugin ) self.settings.notifyAdd( 'width', self.RegenPlugin ) self.settings.notifyAdd( 'num-recent-docs', self.RegenPlugin ) self.settings.notifyAdd( 'recent-font-size', self.RegenPlugin ) self.FileList=[] self.RecManagerInstance = Gtk.RecentManager.get_default() self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent) self.RegenPlugin() self.builder.get_object( "RecentTabs" ).set_current_page(1) #Connect event handlers self.builder.get_object("ClrBtn").connect("clicked", self.clrmenu)
def __init__(self): self.data_path = os.path.join('/', 'usr', 'share', 'mate-menu') # Load glade file and extract widgets self.builder = Gtk.Builder() self.builder.add_from_file( os.path.join(self.data_path, "mate-menu-config.glade")) self.mainWindow = self.builder.get_object("mainWindow") #i18n self.mainWindow.set_title(_("Menu preferences")) self.mainWindow.set_icon_from_file( "/usr/share/mate-menu/icons/mate-logo.svg") self.builder.get_object("startWithFavorites").set_label( _("Always start with favorites pane")) self.builder.get_object("showButtonIcon").set_label( _("Show button icon")) self.builder.get_object("useCustomColors").set_label( _("Use custom colors")) self.builder.get_object("showRecentPlugin").set_label( _("Show recent documents plugin")) self.builder.get_object("showApplicationsPlugin").set_label( _("Show applications plugin")) self.builder.get_object("showSystemPlugin").set_label( _("Show system plugin")) self.builder.get_object("showPlacesPlugin").set_label( _("Show places plugin")) self.builder.get_object("showAppComments").set_label( _("Show application comments")) self.builder.get_object("showCategoryIcons").set_label( _("Show category icons")) self.builder.get_object("hover").set_label(_("Hover")) self.builder.get_object("remember_filter").set_label( _("Remember the last category or search")) self.builder.get_object("swapGeneric").set_label( _("Swap name and generic name")) self.builder.get_object("label11").set_text(_("Border width:")) self.builder.get_object("label25").set_text(_("pixels")) self.builder.get_object("buttonTextLabel").set_text(_("Button text:")) self.builder.get_object("label1").set_text(_("Options")) self.builder.get_object("applicationsLabel").set_text( _("Applications")) self.builder.get_object("colorsLabel").set_text(_("Theme")) self.builder.get_object("favLabel").set_text(_("Favorites")) self.builder.get_object("mainbuttonLabel").set_text(_("Main button")) self.builder.get_object("pluginsLabel").set_text(_("Plugins")) self.builder.get_object("always_show_search").set_label( _("Always show search suggestions")) self.builder.get_object("searchEngineTitleLabel").set_text( _("Search Engines:")) self.builder.get_object("enable_ddg").set_label(_("DuckDuckGo")) self.builder.get_object("enable_google").set_label(_("Google")) self.builder.get_object("enable_wikipedia").set_label(_("Wikipedia")) self.builder.get_object("enable_dictionary").set_label(_("Dictionary")) self.builder.get_object("enable_computer").set_label(_("Computer")) self.builder.get_object("backgroundColorLabel").set_text( _("Background:")) self.builder.get_object("headingColorLabel").set_text(_("Headings:")) self.builder.get_object("borderColorLabel").set_text(_("Borders:")) self.builder.get_object("themeLabel").set_text(_("Theme:")) #self.builder.get_object("applicationsLabel").set_text(_("Applications")) #self.builder.get_object("favoritesLabel").set_text(_("Favorites")) self.builder.get_object("numberColumnsLabel").set_text( _("Number of columns:")) self.builder.get_object("iconSizeLabel").set_text(_("Icon size:")) self.builder.get_object("iconSizeLabel2").set_text(_("Icon size:")) self.builder.get_object("placesIconSizeLabel").set_text( _("Icon size:")) self.builder.get_object("systemIconSizeLabel").set_text( _("Icon size:")) self.builder.get_object("hoverLabel").set_text(_("Hover delay (ms):")) self.builder.get_object("label4").set_text(_("Button icon:")) self.builder.get_object("label5").set_text(_("Search command:")) self.builder.get_object("placesLabel").set_text(_("Places")) self.builder.get_object("allowscrollbarcheckbutton").set_label( _("Allow Scrollbar")) self.builder.get_object("showgtkbookmarkscheckbutton").set_label( _("Show GTK+ Bookmarks")) self.builder.get_object("placesHeightEntryLabel").set_text( _("Height:")) self.builder.get_object("defaultPlacesFrameLabel").set_text( _("Toggle Default Places:")) self.builder.get_object("computercheckbutton").set_label(_("Computer")) self.builder.get_object("homecheckbutton").set_label(_("Home Folder")) self.builder.get_object("networkcheckbutton").set_label(_("Network")) self.builder.get_object("desktopcheckbutton").set_label(_("Desktop")) self.builder.get_object("trashcheckbutton").set_label(_("Trash")) self.builder.get_object("customPlacesFrameLabel").set_text( _("Custom Places:")) self.builder.get_object("systemLabel").set_text(_("System")) self.builder.get_object("allowscrollbarcheckbutton1").set_label( _("Allow Scrollbar")) self.builder.get_object("systemHeightEntryLabel").set_text( _("Height:")) self.builder.get_object("defaultItemsFrameLabel").set_text( _("Toggle Default Items:")) self.builder.get_object("packagemanagercheckbutton").set_label( _("Package Manager")) self.builder.get_object("controlcentercheckbutton").set_label( _("Control Center")) self.builder.get_object("terminalcheckbutton").set_label(_("Terminal")) self.builder.get_object("lockcheckbutton").set_label(_("Lock Screen")) self.builder.get_object("logoutcheckbutton").set_label(_("Log Out")) self.builder.get_object("quitcheckbutton").set_label(_("Quit")) self.editPlaceDialogTitle = (_("Edit Place")) self.newPlaceDialogTitle = (_("New Place")) self.folderChooserDialogTitle = (_("Select a folder")) self.startWithFavorites = self.builder.get_object("startWithFavorites") self.showAppComments = self.builder.get_object("showAppComments") self.showCategoryIcons = self.builder.get_object("showCategoryIcons") self.showRecentPlugin = self.builder.get_object("showRecentPlugin") self.showApplicationsPlugin = self.builder.get_object( "showApplicationsPlugin") self.showSystemPlugin = self.builder.get_object("showSystemPlugin") self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin") self.swapGeneric = self.builder.get_object("swapGeneric") self.hover = self.builder.get_object("hover") self.hoverDelay = self.builder.get_object("hoverDelay") self.rememberFilter = self.builder.get_object("remember_filter") self.alwaysShowSearch = self.builder.get_object("always_show_search") self.enableDdg = self.builder.get_object("enable_ddg") self.enableGoogle = self.builder.get_object("enable_google") self.enableWikipedia = self.builder.get_object("enable_wikipedia") self.enableDictionary = self.builder.get_object("enable_dictionary") self.enableComputer = self.builder.get_object("enable_computer") self.iconSize = self.builder.get_object("iconSize") self.favIconSize = self.builder.get_object("favIconSize") self.placesIconSize = self.builder.get_object("placesIconSize") self.systemIconSize = self.builder.get_object("systemIconSize") self.favCols = self.builder.get_object("numFavCols") self.borderWidth = self.builder.get_object("borderWidth") self.useCustomColors = self.builder.get_object("useCustomColors") self.backgroundColor = self.builder.get_object("backgroundColor") self.borderColor = self.builder.get_object("borderColor") self.headingColor = self.builder.get_object("headingColor") self.backgroundColorLabel = self.builder.get_object( "backgroundColorLabel") self.borderColorLabel = self.builder.get_object("borderColorLabel") self.headingColorLabel = self.builder.get_object("headingColorLabel") self.showButtonIcon = self.builder.get_object("showButtonIcon") self.buttonText = self.builder.get_object("buttonText") self.hotkeyWidget = keybinding.KeybindingWidget( _("Keyboard shortcut:")) grid = self.builder.get_object("main_grid") grid.attach(self.hotkeyWidget, 0, 2, 2, 1) self.buttonIcon = self.builder.get_object("buttonIcon") self.buttonIconChooser = self.builder.get_object("button_icon_chooser") self.image_filter = Gtk.FileFilter() self.image_filter.set_name(_("Images")) self.image_filter.add_pattern("*.png") self.image_filter.add_pattern("*.jpg") self.image_filter.add_pattern("*.jpeg") self.image_filter.add_pattern("*.bmp") self.image_filter.add_pattern("*.ico") self.image_filter.add_pattern("*.xpm") self.image_filter.add_pattern("*.svg") self.buttonIconChooser.add_filter(self.image_filter) self.buttonIconChooser.set_filter(self.image_filter) self.buttonIconImage = self.builder.get_object("image_button_icon") self.searchCommand = self.builder.get_object("search_command") self.computertoggle = self.builder.get_object("computercheckbutton") self.homefoldertoggle = self.builder.get_object("homecheckbutton") self.networktoggle = self.builder.get_object("networkcheckbutton") self.desktoptoggle = self.builder.get_object("desktopcheckbutton") self.trashtoggle = self.builder.get_object("trashcheckbutton") self.customplacestree = self.builder.get_object("customplacestree") self.allowPlacesScrollbarToggle = self.builder.get_object( "allowscrollbarcheckbutton") self.showgtkbookmarksToggle = self.builder.get_object( "showgtkbookmarkscheckbutton") self.placesHeightButton = self.builder.get_object( "placesHeightSpinButton") if (self.allowPlacesScrollbarToggle.get_active() == False): self.placesHeightButton.set_sensitive(False) self.allowPlacesScrollbarToggle.connect("toggled", self.togglePlacesHeightEnabled) self.packageManagerToggle = self.builder.get_object( "packagemanagercheckbutton") self.controlCenterToggle = self.builder.get_object( "controlcentercheckbutton") self.terminalToggle = self.builder.get_object("terminalcheckbutton") self.lockToggle = self.builder.get_object("lockcheckbutton") self.logoutToggle = self.builder.get_object("logoutcheckbutton") self.quitToggle = self.builder.get_object("quitcheckbutton") self.allowSystemScrollbarToggle = self.builder.get_object( "allowscrollbarcheckbutton1") self.systemHeightButton = self.builder.get_object( "systemHeightSpinButton") if (self.allowSystemScrollbarToggle.get_active() == False): self.systemHeightButton.set_sensitive(False) self.allowSystemScrollbarToggle.connect("toggled", self.toggleSystemHeightEnabled) self.builder.get_object("closeButton").connect("clicked", Gtk.main_quit) self.settings = EasyGSettings("org.mate.mate-menu") self.settingsApplications = EasyGSettings( "org.mate.mate-menu.plugins.applications") self.settingsPlaces = EasyGSettings( "org.mate.mate-menu.plugins.places") self.settingsSystem = EasyGSettings( "org.mate.mate-menu.plugins.system_management") self.useCustomColors.connect("toggled", self.toggleUseCustomColors) self.bindGSettingsValueToWidget(self.settings, "bool", "start-with-favorites", self.startWithFavorites, "toggled", self.startWithFavorites.set_active, self.startWithFavorites.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-application-comments", self.showAppComments, "toggled", self.showAppComments.set_active, self.showAppComments.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-category-icons", self.showCategoryIcons, "toggled", self.showCategoryIcons.set_active, self.showCategoryIcons.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "categories-mouse-over", self.hover, "toggled", self.hover.set_active, self.hover.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "swap-generic-name", self.swapGeneric, "toggled", self.swapGeneric.set_active, self.swapGeneric.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "category-hover-delay", self.hoverDelay, "value-changed", self.hoverDelay.set_value, self.hoverDelay.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "icon-size", self.iconSize, "value-changed", self.iconSize.set_value, self.iconSize.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "favicon-size", self.favIconSize, "value-changed", self.favIconSize.set_value, self.favIconSize.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "fav-cols", self.favCols, "value-changed", self.favCols.set_value, self.favCols.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "remember-filter", self.rememberFilter, "toggled", self.rememberFilter.set_active, self.rememberFilter.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "always-show-search", self.alwaysShowSearch, "toggled", self.alwaysShowSearch.set_active, self.alwaysShowSearch.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-ddg", self.enableDdg, "toggled", self.enableDdg.set_active, self.enableDdg.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-google", self.enableGoogle, "toggled", self.enableGoogle.set_active, self.enableGoogle.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-wikipedia", self.enableWikipedia, "toggled", self.enableWikipedia.set_active, self.enableWikipedia.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-dictionary", self.enableDictionary, "toggled", self.enableDictionary.set_active, self.enableDictionary.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-computer", self.enableComputer, "toggled", self.enableComputer.set_active, self.enableComputer.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "int", "icon-size", self.placesIconSize, "value-changed", self.placesIconSize.set_value, self.placesIconSize.get_value) self.bindGSettingsValueToWidget(self.settingsSystem, "int", "icon-size", self.systemIconSize, "value-changed", self.systemIconSize.set_value, self.systemIconSize.get_value) self.bindGSettingsValueToWidget(self.settings, "int", "border-width", self.borderWidth, "value-changed", self.borderWidth.set_value, self.borderWidth.get_value_as_int) self.bindGSettingsValueToWidget(self.settings, "bool", "use-custom-color", self.useCustomColors, "toggled", self.useCustomColors.set_active, self.useCustomColors.get_active) self.bindGSettingsValueToWidget(self.settings, "color", "custom-color", self.backgroundColor, "color-set", self.backgroundColor.set_rgba, self.getBackgroundColor) self.bindGSettingsValueToWidget(self.settings, "color", "custom-heading-color", self.headingColor, "color-set", self.headingColor.set_rgba, self.getHeadingColor) self.bindGSettingsValueToWidget(self.settings, "color", "custom-border-color", self.borderColor, "color-set", self.borderColor.set_rgba, self.getBorderColor) self.bindGSettingsValueToWidget(self.settings, "bool", "hide-applet-icon", self.showButtonIcon, "toggled", self.setShowButtonIcon, self.getShowButtonIcon) self.bindGSettingsValueToWidget(self.settings, "string", "applet-text", self.buttonText, "changed", self.buttonText.set_text, self.buttonText.get_text) self.bindGSettingsValueToWidget(self.settings, "string", "hot-key", self.hotkeyWidget, "accel-edited", self.hotkeyWidget.set_val, self.hotkeyWidget.get_val) self.bindGSettingsValueToWidget(self.settings, "string", "applet-icon", self.buttonIconChooser, "file-set", self.setButtonIcon, self.buttonIconChooser.get_filename) self.bindGSettingsValueToWidget(self.settingsApplications, "string", "search-command", self.searchCommand, "changed", self.searchCommand.set_text, self.searchCommand.get_text) self.getPluginsToggle() self.showRecentPlugin.connect("toggled", self.setPluginsLayout) self.showApplicationsPlugin.connect("toggled", self.setPluginsLayout) self.showSystemPlugin.connect("toggled", self.setPluginsLayout) self.showPlacesPlugin.connect("toggled", self.setPluginsLayout) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-computer", self.computertoggle, "toggled", self.computertoggle.set_active, self.computertoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-home-folder", self.homefoldertoggle, "toggled", self.homefoldertoggle.set_active, self.homefoldertoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-network", self.networktoggle, "toggled", self.networktoggle.set_active, self.networktoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-desktop", self.desktoptoggle, "toggled", self.desktoptoggle.set_active, self.desktoptoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-trash", self.trashtoggle, "toggled", self.trashtoggle.set_active, self.trashtoggle.get_active) self.bindGSettingsValueToWidget( self.settingsPlaces, "int", "height", self.placesHeightButton, "value-changed", self.placesHeightButton.set_value, self.placesHeightButton.get_value_as_int) self.bindGSettingsValueToWidget( self.settingsPlaces, "bool", "allow-scrollbar", self.allowPlacesScrollbarToggle, "toggled", self.allowPlacesScrollbarToggle.set_active, self.allowPlacesScrollbarToggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-gtk-bookmarks", self.showgtkbookmarksToggle, "toggled", self.showgtkbookmarksToggle.set_active, self.showgtkbookmarksToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-package-manager", self.packageManagerToggle, "toggled", self.packageManagerToggle.set_active, self.packageManagerToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-control-center", self.controlCenterToggle, "toggled", self.controlCenterToggle.set_active, self.controlCenterToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-terminal", self.terminalToggle, "toggled", self.terminalToggle.set_active, self.terminalToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-lock-screen", self.lockToggle, "toggled", self.lockToggle.set_active, self.lockToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-logout", self.logoutToggle, "toggled", self.logoutToggle.set_active, self.logoutToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-quit", self.quitToggle, "toggled", self.quitToggle.set_active, self.quitToggle.get_active) self.bindGSettingsValueToWidget( self.settingsSystem, "int", "height", self.systemHeightButton, "value-changed", self.systemHeightButton.set_value, self.systemHeightButton.get_value_as_int) self.bindGSettingsValueToWidget( self.settingsSystem, "bool", "allow-scrollbar", self.allowSystemScrollbarToggle, "toggled", self.allowSystemScrollbarToggle.set_active, self.allowSystemScrollbarToggle.get_active) self.customplacepaths = self.settingsPlaces.get( "list-string", "custom-paths") self.customplacenames = self.settingsPlaces.get( "list-string", "custom-names") self.customplacestreemodel = Gtk.ListStore(str, str) self.cell = Gtk.CellRendererText() for count in range(len(self.customplacepaths)): self.customplacestreemodel.append( [self.customplacenames[count], self.customplacepaths[count]]) self.customplacestreemodel.connect("row-inserted", self.updatePlacesGSettings) self.customplacestreemodel.connect("row-deleted", self.updatePlacesGSettings) self.customplacestreemodel.connect("rows-reordered", self.updatePlacesGSettings) self.customplacestreemodel.connect("row-changed", self.updatePlacesGSettings) self.customplacestree.set_model(self.customplacestreemodel) self.namescolumn = Gtk.TreeViewColumn(_("Name"), self.cell, text=0) self.placescolumn = Gtk.TreeViewColumn(_("Path"), self.cell, text=1) self.customplacestree.append_column(self.namescolumn) self.customplacestree.append_column(self.placescolumn) self.builder.get_object("newButton").connect("clicked", self.newPlace) self.builder.get_object("editButton").connect("clicked", self.editPlace) self.builder.get_object("upButton").connect("clicked", self.moveUp) self.builder.get_object("downButton").connect("clicked", self.moveDown) self.builder.get_object("removeButton").connect( "clicked", self.removePlace) #Detect themes and show theme here theme_name = self.settings.get("string", "theme-name") process = subprocess.Popen( ['find', '/usr/share/themes', '-name', 'gtkrc'], stdout=subprocess.PIPE) out, err = process.communicate() themes = out.decode("utf-8").split("\n") model = Gtk.ListStore(str, str) self.builder.get_object("themesCombo").set_model(model) selected_theme = model.append([_("Desktop theme"), "default"]) for theme in sorted(themes): if theme.startswith("/usr/share/themes") and theme.endswith( "/gtk-2.0/gtkrc"): theme = theme.replace("/usr/share/themes/", "") theme = theme.replace("gtk-2.0", "") theme = theme.replace("gtkrc", "") theme = theme.replace("/", "") theme = theme.strip() iter = model.append([theme, theme]) if theme == theme_name: selected_theme = iter self.builder.get_object("themesCombo").set_active_iter(selected_theme) self.builder.get_object("themesCombo").connect("changed", self.set_theme) self.toggleUseCustomColors(self.useCustomColors) self.mainWindow.present() self.getBackgroundColor()
class mateMenuConfig(object): def __init__(self): self.data_path = os.path.join('/', 'usr', 'share', 'mate-menu') # Load glade file and extract widgets self.builder = Gtk.Builder() self.builder.add_from_file( os.path.join(self.data_path, "mate-menu-config.glade")) self.mainWindow = self.builder.get_object("mainWindow") #i18n self.mainWindow.set_title(_("Menu preferences")) self.mainWindow.set_icon_from_file( "/usr/share/mate-menu/icons/mate-logo.svg") self.builder.get_object("startWithFavorites").set_label( _("Always start with favorites pane")) self.builder.get_object("showButtonIcon").set_label( _("Show button icon")) self.builder.get_object("useCustomColors").set_label( _("Use custom colors")) self.builder.get_object("showRecentPlugin").set_label( _("Show recent documents plugin")) self.builder.get_object("showApplicationsPlugin").set_label( _("Show applications plugin")) self.builder.get_object("showSystemPlugin").set_label( _("Show system plugin")) self.builder.get_object("showPlacesPlugin").set_label( _("Show places plugin")) self.builder.get_object("showAppComments").set_label( _("Show application comments")) self.builder.get_object("showCategoryIcons").set_label( _("Show category icons")) self.builder.get_object("hover").set_label(_("Hover")) self.builder.get_object("remember_filter").set_label( _("Remember the last category or search")) self.builder.get_object("swapGeneric").set_label( _("Swap name and generic name")) self.builder.get_object("label11").set_text(_("Border width:")) self.builder.get_object("label25").set_text(_("pixels")) self.builder.get_object("buttonTextLabel").set_text(_("Button text:")) self.builder.get_object("label1").set_text(_("Options")) self.builder.get_object("applicationsLabel").set_text( _("Applications")) self.builder.get_object("colorsLabel").set_text(_("Theme")) self.builder.get_object("favLabel").set_text(_("Favorites")) self.builder.get_object("mainbuttonLabel").set_text(_("Main button")) self.builder.get_object("pluginsLabel").set_text(_("Plugins")) self.builder.get_object("always_show_search").set_label( _("Always show search suggestions")) self.builder.get_object("searchEngineTitleLabel").set_text( _("Search Engines:")) self.builder.get_object("enable_ddg").set_label(_("DuckDuckGo")) self.builder.get_object("enable_google").set_label(_("Google")) self.builder.get_object("enable_wikipedia").set_label(_("Wikipedia")) self.builder.get_object("enable_dictionary").set_label(_("Dictionary")) self.builder.get_object("enable_computer").set_label(_("Computer")) self.builder.get_object("backgroundColorLabel").set_text( _("Background:")) self.builder.get_object("headingColorLabel").set_text(_("Headings:")) self.builder.get_object("borderColorLabel").set_text(_("Borders:")) self.builder.get_object("themeLabel").set_text(_("Theme:")) #self.builder.get_object("applicationsLabel").set_text(_("Applications")) #self.builder.get_object("favoritesLabel").set_text(_("Favorites")) self.builder.get_object("numberColumnsLabel").set_text( _("Number of columns:")) self.builder.get_object("iconSizeLabel").set_text(_("Icon size:")) self.builder.get_object("iconSizeLabel2").set_text(_("Icon size:")) self.builder.get_object("placesIconSizeLabel").set_text( _("Icon size:")) self.builder.get_object("systemIconSizeLabel").set_text( _("Icon size:")) self.builder.get_object("hoverLabel").set_text(_("Hover delay (ms):")) self.builder.get_object("label4").set_text(_("Button icon:")) self.builder.get_object("label5").set_text(_("Search command:")) self.builder.get_object("placesLabel").set_text(_("Places")) self.builder.get_object("allowscrollbarcheckbutton").set_label( _("Allow Scrollbar")) self.builder.get_object("showgtkbookmarkscheckbutton").set_label( _("Show GTK+ Bookmarks")) self.builder.get_object("placesHeightEntryLabel").set_text( _("Height:")) self.builder.get_object("defaultPlacesFrameLabel").set_text( _("Toggle Default Places:")) self.builder.get_object("computercheckbutton").set_label(_("Computer")) self.builder.get_object("homecheckbutton").set_label(_("Home Folder")) self.builder.get_object("networkcheckbutton").set_label(_("Network")) self.builder.get_object("desktopcheckbutton").set_label(_("Desktop")) self.builder.get_object("trashcheckbutton").set_label(_("Trash")) self.builder.get_object("customPlacesFrameLabel").set_text( _("Custom Places:")) self.builder.get_object("systemLabel").set_text(_("System")) self.builder.get_object("allowscrollbarcheckbutton1").set_label( _("Allow Scrollbar")) self.builder.get_object("systemHeightEntryLabel").set_text( _("Height:")) self.builder.get_object("defaultItemsFrameLabel").set_text( _("Toggle Default Items:")) self.builder.get_object("packagemanagercheckbutton").set_label( _("Package Manager")) self.builder.get_object("controlcentercheckbutton").set_label( _("Control Center")) self.builder.get_object("terminalcheckbutton").set_label(_("Terminal")) self.builder.get_object("lockcheckbutton").set_label(_("Lock Screen")) self.builder.get_object("logoutcheckbutton").set_label(_("Log Out")) self.builder.get_object("quitcheckbutton").set_label(_("Quit")) self.editPlaceDialogTitle = (_("Edit Place")) self.newPlaceDialogTitle = (_("New Place")) self.folderChooserDialogTitle = (_("Select a folder")) self.startWithFavorites = self.builder.get_object("startWithFavorites") self.showAppComments = self.builder.get_object("showAppComments") self.showCategoryIcons = self.builder.get_object("showCategoryIcons") self.showRecentPlugin = self.builder.get_object("showRecentPlugin") self.showApplicationsPlugin = self.builder.get_object( "showApplicationsPlugin") self.showSystemPlugin = self.builder.get_object("showSystemPlugin") self.showPlacesPlugin = self.builder.get_object("showPlacesPlugin") self.swapGeneric = self.builder.get_object("swapGeneric") self.hover = self.builder.get_object("hover") self.hoverDelay = self.builder.get_object("hoverDelay") self.rememberFilter = self.builder.get_object("remember_filter") self.alwaysShowSearch = self.builder.get_object("always_show_search") self.enableDdg = self.builder.get_object("enable_ddg") self.enableGoogle = self.builder.get_object("enable_google") self.enableWikipedia = self.builder.get_object("enable_wikipedia") self.enableDictionary = self.builder.get_object("enable_dictionary") self.enableComputer = self.builder.get_object("enable_computer") self.iconSize = self.builder.get_object("iconSize") self.favIconSize = self.builder.get_object("favIconSize") self.placesIconSize = self.builder.get_object("placesIconSize") self.systemIconSize = self.builder.get_object("systemIconSize") self.favCols = self.builder.get_object("numFavCols") self.borderWidth = self.builder.get_object("borderWidth") self.useCustomColors = self.builder.get_object("useCustomColors") self.backgroundColor = self.builder.get_object("backgroundColor") self.borderColor = self.builder.get_object("borderColor") self.headingColor = self.builder.get_object("headingColor") self.backgroundColorLabel = self.builder.get_object( "backgroundColorLabel") self.borderColorLabel = self.builder.get_object("borderColorLabel") self.headingColorLabel = self.builder.get_object("headingColorLabel") self.showButtonIcon = self.builder.get_object("showButtonIcon") self.buttonText = self.builder.get_object("buttonText") self.hotkeyWidget = keybinding.KeybindingWidget( _("Keyboard shortcut:")) grid = self.builder.get_object("main_grid") grid.attach(self.hotkeyWidget, 0, 2, 2, 1) self.buttonIcon = self.builder.get_object("buttonIcon") self.buttonIconChooser = self.builder.get_object("button_icon_chooser") self.image_filter = Gtk.FileFilter() self.image_filter.set_name(_("Images")) self.image_filter.add_pattern("*.png") self.image_filter.add_pattern("*.jpg") self.image_filter.add_pattern("*.jpeg") self.image_filter.add_pattern("*.bmp") self.image_filter.add_pattern("*.ico") self.image_filter.add_pattern("*.xpm") self.image_filter.add_pattern("*.svg") self.buttonIconChooser.add_filter(self.image_filter) self.buttonIconChooser.set_filter(self.image_filter) self.buttonIconImage = self.builder.get_object("image_button_icon") self.searchCommand = self.builder.get_object("search_command") self.computertoggle = self.builder.get_object("computercheckbutton") self.homefoldertoggle = self.builder.get_object("homecheckbutton") self.networktoggle = self.builder.get_object("networkcheckbutton") self.desktoptoggle = self.builder.get_object("desktopcheckbutton") self.trashtoggle = self.builder.get_object("trashcheckbutton") self.customplacestree = self.builder.get_object("customplacestree") self.allowPlacesScrollbarToggle = self.builder.get_object( "allowscrollbarcheckbutton") self.showgtkbookmarksToggle = self.builder.get_object( "showgtkbookmarkscheckbutton") self.placesHeightButton = self.builder.get_object( "placesHeightSpinButton") if (self.allowPlacesScrollbarToggle.get_active() == False): self.placesHeightButton.set_sensitive(False) self.allowPlacesScrollbarToggle.connect("toggled", self.togglePlacesHeightEnabled) self.packageManagerToggle = self.builder.get_object( "packagemanagercheckbutton") self.controlCenterToggle = self.builder.get_object( "controlcentercheckbutton") self.terminalToggle = self.builder.get_object("terminalcheckbutton") self.lockToggle = self.builder.get_object("lockcheckbutton") self.logoutToggle = self.builder.get_object("logoutcheckbutton") self.quitToggle = self.builder.get_object("quitcheckbutton") self.allowSystemScrollbarToggle = self.builder.get_object( "allowscrollbarcheckbutton1") self.systemHeightButton = self.builder.get_object( "systemHeightSpinButton") if (self.allowSystemScrollbarToggle.get_active() == False): self.systemHeightButton.set_sensitive(False) self.allowSystemScrollbarToggle.connect("toggled", self.toggleSystemHeightEnabled) self.builder.get_object("closeButton").connect("clicked", Gtk.main_quit) self.settings = EasyGSettings("org.mate.mate-menu") self.settingsApplications = EasyGSettings( "org.mate.mate-menu.plugins.applications") self.settingsPlaces = EasyGSettings( "org.mate.mate-menu.plugins.places") self.settingsSystem = EasyGSettings( "org.mate.mate-menu.plugins.system_management") self.useCustomColors.connect("toggled", self.toggleUseCustomColors) self.bindGSettingsValueToWidget(self.settings, "bool", "start-with-favorites", self.startWithFavorites, "toggled", self.startWithFavorites.set_active, self.startWithFavorites.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-application-comments", self.showAppComments, "toggled", self.showAppComments.set_active, self.showAppComments.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "show-category-icons", self.showCategoryIcons, "toggled", self.showCategoryIcons.set_active, self.showCategoryIcons.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "categories-mouse-over", self.hover, "toggled", self.hover.set_active, self.hover.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "swap-generic-name", self.swapGeneric, "toggled", self.swapGeneric.set_active, self.swapGeneric.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "category-hover-delay", self.hoverDelay, "value-changed", self.hoverDelay.set_value, self.hoverDelay.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "icon-size", self.iconSize, "value-changed", self.iconSize.set_value, self.iconSize.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "favicon-size", self.favIconSize, "value-changed", self.favIconSize.set_value, self.favIconSize.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "int", "fav-cols", self.favCols, "value-changed", self.favCols.set_value, self.favCols.get_value) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "remember-filter", self.rememberFilter, "toggled", self.rememberFilter.set_active, self.rememberFilter.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "always-show-search", self.alwaysShowSearch, "toggled", self.alwaysShowSearch.set_active, self.alwaysShowSearch.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-ddg", self.enableDdg, "toggled", self.enableDdg.set_active, self.enableDdg.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-google", self.enableGoogle, "toggled", self.enableGoogle.set_active, self.enableGoogle.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-wikipedia", self.enableWikipedia, "toggled", self.enableWikipedia.set_active, self.enableWikipedia.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-dictionary", self.enableDictionary, "toggled", self.enableDictionary.set_active, self.enableDictionary.get_active) self.bindGSettingsValueToWidget(self.settingsApplications, "bool", "enable-computer", self.enableComputer, "toggled", self.enableComputer.set_active, self.enableComputer.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "int", "icon-size", self.placesIconSize, "value-changed", self.placesIconSize.set_value, self.placesIconSize.get_value) self.bindGSettingsValueToWidget(self.settingsSystem, "int", "icon-size", self.systemIconSize, "value-changed", self.systemIconSize.set_value, self.systemIconSize.get_value) self.bindGSettingsValueToWidget(self.settings, "int", "border-width", self.borderWidth, "value-changed", self.borderWidth.set_value, self.borderWidth.get_value_as_int) self.bindGSettingsValueToWidget(self.settings, "bool", "use-custom-color", self.useCustomColors, "toggled", self.useCustomColors.set_active, self.useCustomColors.get_active) self.bindGSettingsValueToWidget(self.settings, "color", "custom-color", self.backgroundColor, "color-set", self.backgroundColor.set_rgba, self.getBackgroundColor) self.bindGSettingsValueToWidget(self.settings, "color", "custom-heading-color", self.headingColor, "color-set", self.headingColor.set_rgba, self.getHeadingColor) self.bindGSettingsValueToWidget(self.settings, "color", "custom-border-color", self.borderColor, "color-set", self.borderColor.set_rgba, self.getBorderColor) self.bindGSettingsValueToWidget(self.settings, "bool", "hide-applet-icon", self.showButtonIcon, "toggled", self.setShowButtonIcon, self.getShowButtonIcon) self.bindGSettingsValueToWidget(self.settings, "string", "applet-text", self.buttonText, "changed", self.buttonText.set_text, self.buttonText.get_text) self.bindGSettingsValueToWidget(self.settings, "string", "hot-key", self.hotkeyWidget, "accel-edited", self.hotkeyWidget.set_val, self.hotkeyWidget.get_val) self.bindGSettingsValueToWidget(self.settings, "string", "applet-icon", self.buttonIconChooser, "file-set", self.setButtonIcon, self.buttonIconChooser.get_filename) self.bindGSettingsValueToWidget(self.settingsApplications, "string", "search-command", self.searchCommand, "changed", self.searchCommand.set_text, self.searchCommand.get_text) self.getPluginsToggle() self.showRecentPlugin.connect("toggled", self.setPluginsLayout) self.showApplicationsPlugin.connect("toggled", self.setPluginsLayout) self.showSystemPlugin.connect("toggled", self.setPluginsLayout) self.showPlacesPlugin.connect("toggled", self.setPluginsLayout) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-computer", self.computertoggle, "toggled", self.computertoggle.set_active, self.computertoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-home-folder", self.homefoldertoggle, "toggled", self.homefoldertoggle.set_active, self.homefoldertoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-network", self.networktoggle, "toggled", self.networktoggle.set_active, self.networktoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-desktop", self.desktoptoggle, "toggled", self.desktoptoggle.set_active, self.desktoptoggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-trash", self.trashtoggle, "toggled", self.trashtoggle.set_active, self.trashtoggle.get_active) self.bindGSettingsValueToWidget( self.settingsPlaces, "int", "height", self.placesHeightButton, "value-changed", self.placesHeightButton.set_value, self.placesHeightButton.get_value_as_int) self.bindGSettingsValueToWidget( self.settingsPlaces, "bool", "allow-scrollbar", self.allowPlacesScrollbarToggle, "toggled", self.allowPlacesScrollbarToggle.set_active, self.allowPlacesScrollbarToggle.get_active) self.bindGSettingsValueToWidget(self.settingsPlaces, "bool", "show-gtk-bookmarks", self.showgtkbookmarksToggle, "toggled", self.showgtkbookmarksToggle.set_active, self.showgtkbookmarksToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-package-manager", self.packageManagerToggle, "toggled", self.packageManagerToggle.set_active, self.packageManagerToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-control-center", self.controlCenterToggle, "toggled", self.controlCenterToggle.set_active, self.controlCenterToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-terminal", self.terminalToggle, "toggled", self.terminalToggle.set_active, self.terminalToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-lock-screen", self.lockToggle, "toggled", self.lockToggle.set_active, self.lockToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-logout", self.logoutToggle, "toggled", self.logoutToggle.set_active, self.logoutToggle.get_active) self.bindGSettingsValueToWidget(self.settingsSystem, "bool", "show-quit", self.quitToggle, "toggled", self.quitToggle.set_active, self.quitToggle.get_active) self.bindGSettingsValueToWidget( self.settingsSystem, "int", "height", self.systemHeightButton, "value-changed", self.systemHeightButton.set_value, self.systemHeightButton.get_value_as_int) self.bindGSettingsValueToWidget( self.settingsSystem, "bool", "allow-scrollbar", self.allowSystemScrollbarToggle, "toggled", self.allowSystemScrollbarToggle.set_active, self.allowSystemScrollbarToggle.get_active) self.customplacepaths = self.settingsPlaces.get( "list-string", "custom-paths") self.customplacenames = self.settingsPlaces.get( "list-string", "custom-names") self.customplacestreemodel = Gtk.ListStore(str, str) self.cell = Gtk.CellRendererText() for count in range(len(self.customplacepaths)): self.customplacestreemodel.append( [self.customplacenames[count], self.customplacepaths[count]]) self.customplacestreemodel.connect("row-inserted", self.updatePlacesGSettings) self.customplacestreemodel.connect("row-deleted", self.updatePlacesGSettings) self.customplacestreemodel.connect("rows-reordered", self.updatePlacesGSettings) self.customplacestreemodel.connect("row-changed", self.updatePlacesGSettings) self.customplacestree.set_model(self.customplacestreemodel) self.namescolumn = Gtk.TreeViewColumn(_("Name"), self.cell, text=0) self.placescolumn = Gtk.TreeViewColumn(_("Path"), self.cell, text=1) self.customplacestree.append_column(self.namescolumn) self.customplacestree.append_column(self.placescolumn) self.builder.get_object("newButton").connect("clicked", self.newPlace) self.builder.get_object("editButton").connect("clicked", self.editPlace) self.builder.get_object("upButton").connect("clicked", self.moveUp) self.builder.get_object("downButton").connect("clicked", self.moveDown) self.builder.get_object("removeButton").connect( "clicked", self.removePlace) #Detect themes and show theme here theme_name = self.settings.get("string", "theme-name") process = subprocess.Popen( ['find', '/usr/share/themes', '-name', 'gtkrc'], stdout=subprocess.PIPE) out, err = process.communicate() themes = out.decode("utf-8").split("\n") model = Gtk.ListStore(str, str) self.builder.get_object("themesCombo").set_model(model) selected_theme = model.append([_("Desktop theme"), "default"]) for theme in sorted(themes): if theme.startswith("/usr/share/themes") and theme.endswith( "/gtk-2.0/gtkrc"): theme = theme.replace("/usr/share/themes/", "") theme = theme.replace("gtk-2.0", "") theme = theme.replace("gtkrc", "") theme = theme.replace("/", "") theme = theme.strip() iter = model.append([theme, theme]) if theme == theme_name: selected_theme = iter self.builder.get_object("themesCombo").set_active_iter(selected_theme) self.builder.get_object("themesCombo").connect("changed", self.set_theme) self.toggleUseCustomColors(self.useCustomColors) self.mainWindow.present() self.getBackgroundColor() def set_theme(self, widget): model = widget.get_model() iter = widget.get_active_iter() theme_name = model.get_value(iter, 1) self.settings.set("string", "theme-name", theme_name) def getPluginsToggle(self): array = self.settings.get("list-string", "plugins-list") if "recent" in array: self.showRecentPlugin.set_active(True) else: self.showRecentPlugin.set_active(False) if "applications" in array: self.showApplicationsPlugin.set_active(True) else: self.showApplicationsPlugin.set_active(False) if "system_management" in array: self.showSystemPlugin.set_active(True) else: self.showSystemPlugin.set_active(False) if "places" in array: self.showPlacesPlugin.set_active(True) else: self.showPlacesPlugin.set_active(False) def setPluginsLayout(self, widget): visiblePlugins = [] if self.showPlacesPlugin.get_active(): visiblePlugins.append("places") if self.showSystemPlugin.get_active(): visiblePlugins.append("system_management") if self.showApplicationsPlugin.get_active(): if self.showPlacesPlugin.get_active( ) or self.showSystemPlugin.get_active(): visiblePlugins.append("newpane") visiblePlugins.append("applications") if self.showRecentPlugin.get_active(): if self.showApplicationsPlugin.get_active( ) or self.showPlacesPlugin.get_active( ) or self.showSystemPlugin.get_active(): visiblePlugins.append("newpane") visiblePlugins.append("recent") self.settings.set("list-string", "plugins-list", visiblePlugins) def setShowButtonIcon(self, value): self.showButtonIcon.set_active(not value) def setButtonIcon(self, value): self.buttonIconChooser.set_filename(value) pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(value, -1, 22) self.buttonIconImage.set_from_pixbuf(pixbuf) def getShowButtonIcon(self): return not self.showButtonIcon.get_active() def bindGSettingsValueToWidget(self, settings, setting_type, key, widget, changeEvent, setter, getter): settings.notifyAdd(key, self.callSetter, args=[setting_type, setter]) if setting_type == "color": color = Gdk.RGBA() color.parse(settings.get(setting_type, key)) setter(color) else: setter(settings.get(setting_type, key)) widget.connect( changeEvent, lambda *args: self.callGetter(settings, setting_type, key, getter)) def callSetter(self, settings, key, args): if args[0] == "bool": args[1](settings.get_boolean(key)) elif args[0] == "string": args[1](settings.get_string(key)) elif args[0] == "int": args[1](settings.get_int(key)) elif args[0] == "color": color = Gdk.RGBA() color.parse(settings.get_string(key)) args[1](color) def callGetter(self, settings, setting_type, key, getter): if (setting_type == "int"): settings.set(setting_type, key, int(getter())) else: settings.set(setting_type, key, getter()) def toggleUseCustomColors(self, widget): self.backgroundColor.set_sensitive(widget.get_active()) self.borderColor.set_sensitive(widget.get_active()) self.headingColor.set_sensitive(widget.get_active()) self.backgroundColorLabel.set_sensitive(widget.get_active()) self.borderColorLabel.set_sensitive(widget.get_active()) self.headingColorLabel.set_sensitive(widget.get_active()) def getBackgroundColor(self): color = self.backgroundColor.get_rgba() return self.gdkRGBAToString(color) def getBorderColor(self): color = self.borderColor.get_rgba() return self.gdkRGBAToString(color) def getHeadingColor(self): color = self.headingColor.get_rgba() return self.gdkRGBAToString(color) def gdkRGBAToString(self, gdkRGBA): return "#%.2X%.2X%.2X" % (int( gdkRGBA.red * 256), int( gdkRGBA.green * 256), int(gdkRGBA.blue * 256)) def moveUp(self, upButton): treeselection = self.customplacestree.get_selection() currentiter = (treeselection.get_selected())[1] if (treeselection != None): lagiter = self.customplacestreemodel.get_iter_first() nextiter = self.customplacestreemodel.get_iter_first() while ((self.customplacestreemodel.get_path(nextiter) != self.customplacestreemodel.get_path(currentiter)) & (nextiter != None)): lagiter = nextiter nextiter = self.customplacestreemodel.iter_next(nextiter) if (nextiter != None): self.customplacestreemodel.swap(currentiter, lagiter) return def newPlace(self, newButton): self.builder.get_object("label2").set_text(_("Name:")) self.builder.get_object("label1").set_text(_("Path:")) newPlaceDialog = self.builder.get_object("editPlaceDialog") folderChooserDialog = self.builder.get_object("fileChooserDialog") newPlaceDialog.set_transient_for(self.mainWindow) newPlaceDialog.set_icon_from_file( "/usr/share/mate-menu/icons/mate-logo.svg") newPlaceDialog.set_title(self.newPlaceDialogTitle) folderChooserDialog.set_title(self.folderChooserDialogTitle) newPlaceDialog.set_default_response(Gtk.ResponseType.OK) newPlaceName = self.builder.get_object("nameEntryBox") newPlacePath = self.builder.get_object("pathEntryBox") folderButton = self.builder.get_object("folderButton") def chooseFolder(folderButton): currentPath = newPlacePath.get_text() if (currentPath != ""): folderChooserDialog.select_filename(currentPath) response = folderChooserDialog.run() folderChooserDialog.hide() if (response == Gtk.ResponseType.OK): newPlacePath.set_text(folderChooserDialog.get_filenames()[0]) folderButton.connect("clicked", chooseFolder) response = newPlaceDialog.run() newPlaceDialog.hide() if (response == Gtk.ResponseType.OK): name = newPlaceName.get_text() path = newPlacePath.get_text() if (name != "" and path != ""): self.customplacestreemodel.append((name, path)) def editPlace(self, editButton): self.builder.get_object("label2").set_text(_("Name:")) self.builder.get_object("label1").set_text(_("Path:")) editPlaceDialog = self.builder.get_object("editPlaceDialog") folderChooserDialog = self.builder.get_object("fileChooserDialog") editPlaceDialog.set_transient_for(self.mainWindow) editPlaceDialog.set_icon_from_file( "/usr/share/mate-menu/icons/mate-logo.svg") editPlaceDialog.set_title(self.editPlaceDialogTitle) folderChooserDialog.set_title(self.folderChooserDialogTitle) editPlaceDialog.set_default_response(Gtk.ResponseType.OK) editPlaceName = self.builder.get_object("nameEntryBox") editPlacePath = self.builder.get_object("pathEntryBox") folderButton = self.builder.get_object("folderButton") treeselection = self.customplacestree.get_selection() currentiter = (treeselection.get_selected())[1] if (currentiter != None): initName = self.customplacestreemodel.get_value(currentiter, 0) initPath = self.customplacestreemodel.get_value(currentiter, 1) editPlaceName.set_text(initName) editPlacePath.set_text(initPath) def chooseFolder(folderButton): currentPath = editPlacePath.get_text() if (currentPath != ""): folderChooserDialog.select_filename(currentPath) response = folderChooserDialog.run() folderChooserDialog.hide() if (response == Gtk.ResponseType.OK): editPlacePath.set_text( folderChooserDialog.get_filenames()[0]) folderButton.connect("clicked", chooseFolder) response = editPlaceDialog.run() editPlaceDialog.hide() if (response == Gtk.ResponseType.OK): name = editPlaceName.get_text() path = editPlacePath.get_text() if (name != "" and path != ""): self.customplacestreemodel.set_value(currentiter, 0, name) self.customplacestreemodel.set_value(currentiter, 1, path) def moveDown(self, downButton): treeselection = self.customplacestree.get_selection() currentiter = (treeselection.get_selected())[1] nextiter = self.customplacestreemodel.iter_next(currentiter) if (nextiter != None): self.customplacestreemodel.swap(currentiter, nextiter) return def removePlace(self, removeButton): treeselection = self.customplacestree.get_selection() currentiter = (treeselection.get_selected())[1] if (currentiter != None): self.customplacestreemodel.remove(currentiter) return def togglePlacesHeightEnabled(self, toggle): if (toggle.get_active() == True): self.placesHeightButton.set_sensitive(True) else: self.placesHeightButton.set_sensitive(False) def toggleSystemHeightEnabled(self, toggle): if (toggle.get_active() == True): self.systemHeightButton.set_sensitive(True) else: self.systemHeightButton.set_sensitive(False) def updatePlacesGSettings(self, treemodel, path, iter=None, new_order=None): # Do only if not partway though an append operation; Append = insert+change+change and each creates a signal if ((iter == None) or (self.customplacestreemodel.get_value(iter, 1) != None)): treeiter = self.customplacestreemodel.get_iter_first() customplacenames = [] customplacepaths = [] while (treeiter != None): customplacenames = customplacenames + [ self.customplacestreemodel.get_value(treeiter, 0) ] customplacepaths = customplacepaths + [ self.customplacestreemodel.get_value(treeiter, 1) ] treeiter = self.customplacestreemodel.iter_next(treeiter) self.settingsPlaces.set("list-string", "custom-paths", customplacepaths) self.settingsPlaces.set("list-string", "custom-names", customplacenames)
class pluginclass: """This is the main class for the plugin""" """It MUST be named pluginclass""" def __init__(self, mateMenuWin, toggleButton): self.Win = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() #The Glade file for the plugin self.builder.add_from_file (os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', 'recent.glade' )) #Set 'window' property for the plugin (Must be the root widget) self.window = self.builder.get_object( "window1" ) #Set 'heading' property for plugin self.heading = _("Recent documents") #This should be the first item added to the window in glade self.content_holder = self.builder.get_object( "eventbox1" ) self.recentBox = self.builder.get_object("RecentBox") self.recentVBox = self.builder.get_object( "vbox1" ) #Specify plugin width self.width = 250 #Plugin icon self.icon = 'mate-folder.png' self.settings = EasyGSettings ("org.mate.mate-menu.plugins.recent") self.settings.notifyAdd( 'height', self.RegenPlugin ) self.settings.notifyAdd( 'width', self.RegenPlugin ) self.settings.notifyAdd( 'num-recent-docs', self.RegenPlugin ) self.settings.notifyAdd( 'recent-font-size', self.RegenPlugin ) self.FileList=[] self.RecManagerInstance = Gtk.RecentManager.get_default() self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent) self.RegenPlugin() self.builder.get_object( "RecentTabs" ).set_current_page(1) #Connect event handlers self.builder.get_object("ClrBtn").connect("clicked", self.clrmenu) def wake (self) : pass def destroy( self ): self.recentBox.destroy() self.recentVBox.destroy() self.builder.get_object( "RecentTabs" ).destroy() self.builder.get_object("ClrBtn").destroy() self.content_holder.destroy() self.settings.notifyRemoveAll() if self.recentManagerId: self.RecManagerInstance.disconnect(self.recentManagerId) def RegenPlugin( self, *args, **kargs ): self.GetGSettingsEntries() def GetGSettingsEntries( self ): self.recenth = self.settings.get( 'int', 'height' ) self.recentw = self.settings.get( 'int', 'width' ) self.numentries = self.settings.get( 'int', 'num-recent-docs' ) self.recentfontsize = self.settings.get( 'int', 'recent-font-size' ) # Plugin icon self.icon = self.settings.get( "string", 'icon' ) # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get( "bool", "sticky" ) self.minimized = self.settings.get( "bool", "minimized" ) self.RebuildPlugin() def SetHidden( self, state ): if state == True: self.settings.set( "bool", "minimized", True ) else: self.settings.set( "bool", "minimized", False ) def RebuildPlugin(self): self.content_holder.set_size_request(self.recentw, self.recenth ) self.DoRecent() def DoRecent( self, *args, **kargs ): for i in self.recentBox.get_children(): i.destroy() self.recentVBox.set_size_request( self.recentw, self.recenth ) if len( self.recentBox.get_children() ) < self.numentries: n=len( self.recentBox.get_children() )-1 else: n=self.numentries-1 while n >= 0: self.recentBox.remove( self.recentBox.get_children()[n] ) n-=1 self.FileList, self.IconList = self.GetRecent() loc = 0 for Name in self.FileList: if Name != None: self.AddRecentBtn( Name, self.IconList[loc] ) loc = loc + 1 return True def clrmenu(self, *args, **kargs): self.RecManagerInstance.purge_items() self.DoRecent() return def AddRecentBtn( self, Name, RecentImage ): DispName=os.path.basename( Name ) AButton = Gtk.Button( "", "ok", True ) AButton.remove( AButton.get_children()[0] ) AButton.set_size_request( 200, -1 ) AButton.set_relief( Gtk.ReliefStyle.NONE ) AButton.connect( "clicked", self.callback, Name ) Align1 = Gtk.Alignment() Align1.set( 0, 0.5, 0, 0) Align1.set_padding( 0, 0, 0, 0 ) HBox1 = Gtk.HBox( False, 5 ) VBox1 = Gtk.VBox( False, 2 ) VBox1.show() req = Gtk.Requisition() AButton.size_request(req) Label1 = Gtk.Label( DispName ) Label1.set_size_request( req.width-20, -1 ) Label1.set_ellipsize( Pango.EllipsizeMode.END ) Label1.show() VBox1.add( Label1 ) ButtonIcon = Gtk.Image() ButtonIcon.set_from_pixbuf(RecentImage) HBox1.add( ButtonIcon ) ButtonIcon.show() HBox1.add( VBox1 ) HBox1.show() Align1.add( HBox1 ) Align1.show() AButton.add( Align1 ) AButton.show() self.recentBox.pack_start( AButton, False, True, 0 ) def callback(self, widget, filename=None): self.Win.hide() x = os.system("gvfs-open \""+filename+"\"") if x == 256: dia = Gtk.Dialog('File not found!', None, #the toplevel wgt of your app Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, #binary flags or'ed together ("Ok", 77)) dia.vbox.pack_start(Gtk.Label('The location or file could not be found!'), False, False, 0) dia.vbox.show_all() dia.show() result = dia.run() if result == 77: dia.destroy() def GetRecent(self, *args, **kargs): FileString=[] IconString=[] RecentInfo=self.RecManagerInstance.get_items() # print RecentInfo[0].get_icon(gtk.ICON_SIZE_MENU) count=0 MaxEntries=self.numentries if self.numentries == -1: MaxEntries=len(RecentInfo) for items in RecentInfo: FileString.append(items.get_uri_display()) IconString.append(items.get_icon(Gtk.IconSize.MENU)) count+=1 if count >= MaxEntries: break return FileString, IconString def ButtonClicked( self, widget, event, Exec ): self.press_x = event.x self.press_y = event.y self.Exec = Exec def ButtonReleased( self, w, ev, ev2 ): if ev.button == 1: if not hasattr( self, "press_x" ) or \ not w.drag_check_threshold( int( self.press_x ), int( self.press_y ), int( ev.x ), int( ev.y ) ): if self.Win.pinmenu == False: self.Win.wTree.get_widget( "window1" ).hide() if "applications" in self.Win.plugins: self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus() Execute( w, self.Exec ) def do_plugin(self): self.DoRecent()
class pluginclass(object): def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() self.builder.add_from_file( os.path.join('/', 'usr', 'share', 'mate-menu', 'plugins', '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 = 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 = self.builder.get_object("System") # Items to get custom colors self.itemstocolor = [self.builder.get_object("viewport2")] # Gconf stuff self.settings = EasyGSettings( "org.mate.mate-menu.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-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() self.content_holder.set_size_request(self.width, self.height) def destroy(self): self.settings.notifyRemoveAll() def wake(self): pass 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) else: 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.GetGSettingsEntries() self.ClearAll() self.do_standard_items() def GetGSettingsEntries(self): 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.content_holder.set_size_request(self.width, self.height) self.iconsize = self.settings.get("int", "icon-size") # Check toggles 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") # Plugin icon self.icon = self.settings.get("string", "icon") # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get("bool", "sticky") self.minimized = self.settings.get("bool", "minimized") 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): def pathExists(file): if os.path.exists(file): return True for path in os.environ["PATH"].split(os.pathsep): if os.path.exists(os.path.join(path, file)): return True if (self.showPackageManager == True): if pathExists("synaptic-pkexec"): Button2 = easyButton("synaptic", self.iconsize, [_("Package Manager")], -1, -1) Button2.connect("clicked", self.ButtonClicked, "synaptic-pkexec") elif pathExists("gnome-software"): Button2 = easyButton("org.gnome.Software", self.iconsize, [_("Package Manager")], -1, -1) Button2.connect("clicked", self.ButtonClicked, "gnome-software") elif pathExists("software-center"): Button2 = easyButton("softwarecenter", self.iconsize, [_("Package Manager")], -1, -1) Button2.connect("clicked", self.ButtonClicked, "software-center") elif pathExists("ubuntu-mate-welcome"): Button2 = easyButton("system-software-install", self.iconsize, [_("Package Manager")], -1, -1) Button2.connect("clicked", self.ButtonClicked, "ubuntu-mate-welcome --software-only") try: Button2.show() self.systemBtnHolder.pack_start(Button2, False, False, 0) self.mateMenuWin.setTooltip( Button2, _("Install, remove and upgrade software packages")) except UnboundLocalError: pass if (self.showControlCenter == True): Button3 = easyButton("gtk-preferences", self.iconsize, [_("Control Center")], -1, -1) Button3.connect("clicked", self.ButtonClicked, "mate-control-center") Button3.show() self.systemBtnHolder.pack_start(Button3, False, False, 0) self.mateMenuWin.setTooltip(Button3, _("Configure your system")) if (self.showTerminal == True): Button4 = easyButton("terminal", self.iconsize, [_("Terminal")], -1, -1) if pathExists("mate-terminal"): Button4.connect("clicked", self.ButtonClicked, "mate-terminal") elif pathExists("xdg-terminal"): Button4.connect("clicked", self.ButtonClicked, "xdg-terminal") elif pathExists("x-terminal-emulator"): Button4.connect("clicked", self.ButtonClicked, "x-terminal-emulator") else: Button4.connect("clicked", self.ButtonClicked, "xterm") Button4.show() self.systemBtnHolder.pack_start(Button4, False, False, 0) self.mateMenuWin.setTooltip(Button4, _("Use the command line")) if (self.showLockScreen == True): Button5 = easyButton("system-lock-screen", self.iconsize, [_("Lock Screen")], -1, -1) if pathExists("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.mateMenuWin.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.mateMenuWin.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.mateMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate")) def ButtonClicked(self, widget, Exec): self.mateMenuWin.hide() if Exec: Execute(Exec) def do_plugin(self): self.do_standard_items()
class pluginclass: """This is the main class for the plugin""" """It MUST be named pluginclass""" def __init__(self, mateMenuWin, toggleButton): self.Win = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() #The Glade file for the plugin self.builder.add_from_file( os.path.join('/', 'usr', 'share', 'mate-menu', 'plugins', 'recent.glade')) #Set 'window' property for the plugin (Must be the root widget) self.window = self.builder.get_object("window1") #Set 'heading' property for plugin self.heading = _("Recent documents") #This should be the first item added to the window in glade self.content_holder = self.builder.get_object("eventbox1") self.recentBox = self.builder.get_object("RecentBox") self.recentVBox = self.builder.get_object("vbox1") #Specify plugin width self.width = 250 #Plugin icon self.icon = 'folder.png' self.settings = EasyGSettings("org.mate.mate-menu.plugins.recent") self.settings.notifyAdd('height', self.RegenPlugin) self.settings.notifyAdd('width', self.RegenPlugin) self.settings.notifyAdd('num-recent-docs', self.RegenPlugin) self.settings.notifyAdd('recent-font-size', self.RegenPlugin) self.FileList = [] self.RecManagerInstance = Gtk.RecentManager.get_default() self.recentManagerId = self.RecManagerInstance.connect( "changed", self.DoRecent) self.RegenPlugin() self.builder.get_object("RecentTabs").set_current_page(1) #Connect event handlers clr_btn = self.builder.get_object("ClrBtn") clr_btn.connect("clicked", self.clrmenu) clr_btn.connect("enter-notify-event", self.onEnter) clr_btn.connect("focus-in-event", self.onFocusIn) clr_btn.connect("focus-out-event", self.onFocusOut) def wake(self): pass def destroy(self): self.recentBox.destroy() self.recentVBox.destroy() self.builder.get_object("RecentTabs").destroy() self.builder.get_object("ClrBtn").destroy() self.content_holder.destroy() self.settings.notifyRemoveAll() if self.recentManagerId: self.RecManagerInstance.disconnect(self.recentManagerId) def RegenPlugin(self, *args, **kargs): self.GetGSettingsEntries() def GetGSettingsEntries(self): self.recenth = self.settings.get('int', 'height') self.recentw = self.settings.get('int', 'width') self.numentries = self.settings.get('int', 'num-recent-docs') self.recentfontsize = self.settings.get('int', 'recent-font-size') # Plugin icon self.icon = self.settings.get("string", 'icon') # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get("bool", "sticky") self.minimized = self.settings.get("bool", "minimized") self.RebuildPlugin() def SetHidden(self, state): if state == True: self.settings.set("bool", "minimized", True) else: self.settings.set("bool", "minimized", False) def RebuildPlugin(self): self.content_holder.set_size_request(self.recentw, self.recenth) self.DoRecent() def DoRecent(self, *args, **kargs): for i in self.recentBox.get_children(): i.destroy() self.recentVBox.set_size_request(self.recentw, self.recenth) if len(self.recentBox.get_children()) < self.numentries: n = len(self.recentBox.get_children()) - 1 else: n = self.numentries - 1 while n >= 0: self.recentBox.remove(self.recentBox.get_children()[n]) n -= 1 self.FileList, self.IconList = self.GetRecent() loc = 0 for Name in self.FileList: if Name != None: self.AddRecentBtn(Name, self.IconList[loc]) loc = loc + 1 return True def clrmenu(self, *args, **kargs): self.RecManagerInstance.purge_items() self.DoRecent() return def AddRecentBtn(self, Name, RecentImage): DispName = os.path.basename(Name) AButton = Gtk.Button("", "ok", True) AButton.remove(AButton.get_children()[0]) AButton.set_size_request(200, -1) AButton.set_relief(Gtk.ReliefStyle.NONE) AButton.connect("enter-notify-event", self.onEnter) AButton.connect("focus-in-event", self.onFocusIn) AButton.connect("focus-out-event", self.onFocusOut) AButton.connect("clicked", self.callback, Name) AButton.show() Box1 = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) ButtonIcon = Gtk.Image() ButtonIcon.set_size_request(20, -1) ButtonIcon.set_from_pixbuf(RecentImage) Box1.add(ButtonIcon) Label1 = Gtk.Label(DispName) Label1.set_ellipsize(Pango.EllipsizeMode.END) Box1.add(Label1) AButton.add(Box1) AButton.show_all() self.recentBox.pack_start(AButton, False, True, 0) def onEnter(self, widget, event): widget.grab_focus() def onFocusIn(self, widget, event): widget.set_state_flags(Gtk.StateFlags.PRELIGHT, False) def onFocusOut(self, widget, event): widget.unset_state_flags(Gtk.StateFlags.PRELIGHT) def callback(self, widget, filename=None): self.Win.hide() x = os.system("gio open \"" + filename + "\"") if x == 256: dia = Gtk.Dialog( 'File not found!', None, #the toplevel wgt of your app Gtk.DialogFlags.MODAL | Gtk.DialogFlags. DESTROY_WITH_PARENT, #binary flags or'ed together ("Ok", 77)) dia.vbox.pack_start( Gtk.Label('The location or file could not be found!'), False, False, 0) dia.vbox.show_all() dia.show() result = dia.run() if result == 77: dia.destroy() def GetRecent(self, *args, **kargs): FileString = [] IconString = [] RecentInfo = self.RecManagerInstance.get_items() # print(RecentInfo[0].get_icon(Gtk.IconSize.MENU)) count = 0 MaxEntries = self.numentries if self.numentries == -1: MaxEntries = len(RecentInfo) for items in RecentInfo: FileString.append(items.get_uri_display()) IconString.append(items.get_icon(Gtk.IconSize.MENU)) count += 1 if count >= MaxEntries: break return FileString, IconString def ButtonClicked(self, widget, event, Exec): self.press_x = event.x self.press_y = event.y self.Exec = Exec def ButtonReleased(self, w, ev, ev2): if ev.button == 1: if not hasattr( self, "press_x" ) or \ not w.drag_check_threshold( int( self.press_x ), int( self.press_y ), int( ev.x ), int( ev.y ) ): if self.Win.pinmenu == False: self.Win.wTree.get_widget("window1").hide() if "applications" in self.Win.plugins: self.Win.plugins["applications"].wTree.get_widget( "entry1").grab_focus() Execute(w, self.Exec) def do_plugin(self): self.DoRecent()
class pluginclass( object ): def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton # Read UI file builder = Gtk.Builder() builder.add_from_file( os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', 'places.glade' )) self.placesBtnHolder = builder.get_object( "places_button_holder" ) self.editableBtnHolder = builder.get_object( "editable_button_holder" ) self.scrolledWindow=builder.get_object("scrolledwindow2") # These properties are NECESSARY to maintain consistency # Set 'window' property for the plugin (Must be the root widget) self.window = builder.get_object( "mainWindow" ) # Set 'heading' property for plugin self.heading = _("Places") # This should be the first item added to the window in glade self.content_holder = builder.get_object( "Places" ) # Items to get custom colors self.itemstocolor = [ builder.get_object( "viewport2" ) ] # Settings self.settings = EasyGSettings("org.mate.mate-menu.plugins.places") self.settings.notifyAdd( "icon-size", self.RegenPlugin ) self.settings.notifyAdd( "show-computer", self.RegenPlugin ) self.settings.notifyAdd( "show-desktop", self.RegenPlugin ) self.settings.notifyAdd( "show-home_folder", self.RegenPlugin ) self.settings.notifyAdd( "show-network", self.RegenPlugin ) self.settings.notifyAdd( "show-trash", self.RegenPlugin ) self.settings.notifyAdd( "custom-names", self.RegenPlugin ) self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin ) self.settings.notifyAdd( "show-gtk-bookmarks", self.RegenPlugin ) self.settings.notifyAdd( "height", self.changePluginSize ) self.settings.notifyAdd( "width", self.changePluginSize ) self.loadSettings() self.content_holder.set_size_request( self.width, self.height ) def wake (self) : if ( self.showtrash == True ): self.refreshTrash() def destroy( self ): self.settings.notifyRemoveAll() def changePluginSize( self, settings, key, args = None): self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar" ) self.width = self.settings.get( "int", "width" ) if (self.allowScrollbar == False): self.height = -1 self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) else: 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 ) def RegenPlugin( self, *args, **kargs ): self.loadSettings() self.ClearAll() self.do_standard_places() self.do_custom_places() self.do_gtk_bookmarks() def loadSettings( self ): self.width = self.settings.get( "int", "width" ) self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar" ) self.showGTKBookmarks = self.settings.get( "bool", "show-gtk-bookmarks" ) 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) self.content_holder.set_size_request( self.width, self.height ) self.iconsize = self.settings.get( "int", "icon-size" ) # Check default items self.showcomputer = self.settings.get( "bool", "show-computer" ) self.showhomefolder = self.settings.get( "bool", "show-home-folder" ) self.shownetwork = self.settings.get( "bool", "show-network" ) self.showdesktop = self.settings.get( "bool", "show-desktop" ) self.showtrash = self.settings.get( "bool", "show-trash" ) # Get paths for custom items self.custompaths = self.settings.get( "list-string", "custom-paths" ) # Get names for custom items self.customnames = self.settings.get( "list-string", "custom-names" ) # Plugin icon self.icon = self.settings.get( "string", "icon" ) # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get( "bool", "sticky") self.minimized = self.settings.get( "bool", "minimized") def ClearAll(self): for child in self.placesBtnHolder.get_children(): child.destroy() for child in self.editableBtnHolder.get_children(): child.destroy() #Add standard places def do_standard_places( self ): if ( self.showcomputer == True ): Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 ) #FIXME: Check for caja on the path and fall back to xdg-open Button1.connect( "clicked", self.ButtonClicked, "caja computer:" ) #Button1.connect( "clicked", self.ButtonClicked, "xdg-open /" ) Button1.show() self.placesBtnHolder.pack_start( Button1, False, False, 0) self.mateMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") ) if ( self.showhomefolder == True ): Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 ) #FIXME: Check for caja on the path and fall back to xdg-open Button2.connect( "clicked", self.ButtonClicked, "caja %s " % home ) #Button2.connect( "clicked", self.ButtonClicked, "xdg-open %s " % home ) Button2.show() self.placesBtnHolder.pack_start( Button2, False, False, 0) self.mateMenuWin.setTooltip( Button2, _("Open your personal folder") ) if ( self.shownetwork == True): mate_settings = Gio.Settings.new("org.mate.interface") icon_theme = mate_settings.get_string( "icon-theme" ) Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1) #FIXME: Check for caja on the path and fall back to xdg-open Button3.connect( "clicked", self.ButtonClicked, "caja network:" ) #Button3.connect( "clicked", self.ButtonClicked, "xdg-open network:" ) Button3.show() self.placesBtnHolder.pack_start( Button3, False, False, 0) self.mateMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") ) if ( self.showdesktop == True ): # Determine where the Desktop folder is (could be localized) desktopDir = home + "/Desktop" try: from configobj import ConfigObj config = ConfigObj(home + "/.config/user-dirs.dirs") tmpdesktopDir = config['XDG_DESKTOP_DIR'] if os.path.exists(tmpdesktopDir): desktopDir = tmpdesktopDir except Exception, detail: print detail Button4 = easyButton( "desktop", self.iconsize, [_("Desktop")], -1, -1 ) #FIXME: Check for caja on the path and fall back to xdg-open Button4.connect( "clicked", self.ButtonClicked, "caja \"" + desktopDir + "\"") #Button4.connect( "clicked", self.ButtonClicked, "xdg-open \"" + desktopDir + "\"") Button4.show() self.placesBtnHolder.pack_start( Button4, False, False, 0) self.mateMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") ) if ( self.showtrash == True ): self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 ) #FIXME: Check for caja on the path and fall back to xdg-open self.trashButton.connect( "clicked", self.ButtonClicked, "caja trash:" ) #self.trashButton.connect( "clicked", self.ButtonClicked, "xdg-open trash:" ) self.trashButton.show() self.trashButton.connect( "button-release-event", self.trashPopup ) self.refreshTrash() self.placesBtnHolder.pack_start( self.trashButton, False, False, 0) self.mateMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )
class pluginclass( object ): def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton # Read UI file builder = Gtk.Builder() builder.add_from_file( os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', 'places.glade' )) self.placesBtnHolder = builder.get_object( "places_button_holder" ) self.editableBtnHolder = builder.get_object( "editable_button_holder" ) self.scrolledWindow=builder.get_object("scrolledwindow2") # These properties are NECESSARY to maintain consistency # Set 'window' property for the plugin (Must be the root widget) self.window = builder.get_object( "mainWindow" ) # Set 'heading' property for plugin self.heading = _("Places") # This should be the first item added to the window in glade self.content_holder = builder.get_object( "Places" ) # Items to get custom colors self.itemstocolor = [ builder.get_object( "viewport2" ) ] # Settings self.settings = EasyGSettings("org.mate.mate-menu.plugins.places") self.settings.notifyAdd( "icon-size", self.RegenPlugin ) self.settings.notifyAdd( "show-computer", self.RegenPlugin ) self.settings.notifyAdd( "show-desktop", self.RegenPlugin ) self.settings.notifyAdd( "show-home_folder", self.RegenPlugin ) self.settings.notifyAdd( "show-network", self.RegenPlugin ) self.settings.notifyAdd( "show-trash", self.RegenPlugin ) self.settings.notifyAdd( "custom-names", self.RegenPlugin ) self.settings.notifyAdd( "allow-scrollbar", self.RegenPlugin ) self.settings.notifyAdd( "show-gtk-bookmarks", self.RegenPlugin ) self.settings.notifyAdd( "height", self.changePluginSize ) self.settings.notifyAdd( "width", self.changePluginSize ) self.loadSettings() self.content_holder.set_size_request( self.width, self.height ) def wake (self) : if ( self.showtrash == True ): self.refreshTrash() def destroy( self ): self.settings.notifyRemoveAll() def changePluginSize( self, settings, key, args = None): self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar" ) self.width = self.settings.get( "int", "width" ) if (self.allowScrollbar == False): self.height = -1 self.scrolledWindow.set_policy( Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) else: 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 ) def RegenPlugin( self, *args, **kargs ): self.loadSettings() self.ClearAll() self.do_standard_places() self.do_custom_places() self.do_gtk_bookmarks() def loadSettings( self ): self.width = self.settings.get( "int", "width" ) self.allowScrollbar = self.settings.get( "bool", "allow-scrollbar" ) self.showGtkBookmarks = self.settings.get( "bool", "show-gtk-bookmarks" ) 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) self.content_holder.set_size_request( self.width, self.height ) self.iconsize = self.settings.get( "int", "icon-size" ) # Check default items self.showcomputer = self.settings.get( "bool", "show-computer" ) self.showhomefolder = self.settings.get( "bool", "show-home-folder" ) self.shownetwork = self.settings.get( "bool", "show-network" ) self.showdesktop = self.settings.get( "bool", "show-desktop" ) self.showtrash = self.settings.get( "bool", "show-trash" ) # Get paths for custom items self.custompaths = self.settings.get( "list-string", "custom-paths" ) # Get names for custom items self.customnames = self.settings.get( "list-string", "custom-names" ) # Plugin icon self.icon = self.settings.get( "string", "icon" ) # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get( "bool", "sticky") self.minimized = self.settings.get( "bool", "minimized") def ClearAll(self): for child in self.placesBtnHolder.get_children(): child.destroy() for child in self.editableBtnHolder.get_children(): child.destroy() #Add standard places def do_standard_places( self ): if ( self.showcomputer == True ): Button1 = easyButton( "computer", self.iconsize, [_("Computer")], -1, -1 ) Button1.connect("clicked", self.ButtonClicked, "xdg-open computer:") Button1.show() self.placesBtnHolder.pack_start( Button1, False, False, 0) self.mateMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer") ) if ( self.showhomefolder == True ): Button2 = easyButton( "user-home", self.iconsize, [_("Home Folder")], -1, -1 ) Button2.connect( "clicked", self.ButtonClicked, "xdg-open %s " % os.environ["HOME"]) Button2.show() self.placesBtnHolder.pack_start( Button2, False, False, 0) self.mateMenuWin.setTooltip( Button2, _("Open your personal folder") ) if ( self.shownetwork == True): mate_settings = Gio.Settings.new("org.mate.interface") icon_theme = mate_settings.get_string( "icon-theme" ) Button3 = easyButton( "network-workgroup", self.iconsize, [_("Network")], -1, -1) Button3.connect("clicked", self.ButtonClicked, "xdg-open network:") Button3.show() self.placesBtnHolder.pack_start( Button3, False, False, 0) self.mateMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations") ) if ( self.showdesktop == True ): # Determine where the Desktop folder is (could be localized) desktopDir = os.path.join(os.environ["HOME"] + "Desktop") try: from configobj import ConfigObj configPath = os.environ.get("XDG_CONFIG_HOME", os.path.join( os.environ["HOME"], ".config")) config = ConfigObj(os.path.join(configPath, "user-dirs.dirs")) tmpdesktopDir = os.path.expandvars(config['XDG_DESKTOP_DIR']) if os.path.exists(tmpdesktopDir): desktopDir = tmpdesktopDir except Exception as detail: print(detail) Button4 = easyButton( "desktop", self.iconsize, [_("Desktop")], -1, -1 ) Button4.connect("clicked", self.ButtonClicked, "xdg-open \"" + desktopDir + "\"") Button4.show() self.placesBtnHolder.pack_start( Button4, False, False, 0) self.mateMenuWin.setTooltip( Button4, _("Browse items placed on the desktop") ) if ( self.showtrash == True ): self.trashButton = easyButton( "user-trash", self.iconsize, [_("Trash")], -1, -1 ) self.trashButton.connect("clicked", self.ButtonClicked, "xdg-open trash:") self.trashButton.show() self.trashButton.connect( "button-release-event", self.trashPopup ) self.refreshTrash() self.placesBtnHolder.pack_start( self.trashButton, False, False, 0) self.mateMenuWin.setTooltip( self.trashButton, _("Browse deleted files") ) def do_custom_places( self ): for index in range( len(self.custompaths) ): path = self.custompaths[index] path = path.replace("~", os.environ["HOME"]) command = ("xdg-open \"" + path + "\"") 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, 0) def do_gtk_bookmarks( self ): if self.showGtkBookmarks: bookmarksFile = os.path.join(GLib.get_user_config_dir(), "gtk-3.0", "bookmarks") if not os.path.exists(bookmarksFile): bookmarksFile = os.path.join(GLib.get_home_dir(), ".gtk-bookmarks") if not os.path.exists(bookmarksFile): return bookmarks = [] with open(bookmarksFile, "r") as f: for line in f: #line = line.replace('file://', '') line = line.rstrip() if not line: continue parts = line.split(' ', 1) if len(parts) == 2: path, name = parts elif len(parts) == 1: path = parts[0] name = os.path.basename(os.path.normpath(path)) bookmarks.append((name, path)) for name, path in bookmarks: name = unquote(name) currentbutton = easyButton( "folder", self.iconsize, [name], -1, -1 ) currentbutton.connect( "clicked", self.launch_gtk_bookmark, path ) currentbutton.show() self.placesBtnHolder.pack_start( currentbutton, False, False, 0) def launch_gtk_bookmark (self, widget, path): self.mateMenuWin.hide() subprocess.Popen(['xdg-open', path]) def trashPopup( self, widget, event ): if event.button == 3: trashMenu = Gtk.Menu() emptyTrashMenuItem = Gtk.MenuItem(_("Empty trash")) trashMenu.append(emptyTrashMenuItem) trashMenu.show_all() emptyTrashMenuItem.connect ( "activate", self.emptyTrash, widget ) self.mateMenuWin.stopHiding() trashMenu.attach_to_widget(widget, None) trashMenu.popup(None, None, None, None, 3, 0) def emptyTrash( self, menu, widget): trash_info = os.path.join(os.path.expanduser('~'), '.local','share','Trash','info') trash_files = os.path.join(os.path.expanduser('~'), '.local','share','Trash','files') shutil.rmtree(trash_info) shutil.rmtree(trash_files) self.trashButton.setIcon('user-trash') def ButtonClicked( self, widget, Exec ): self.mateMenuWin.hide() if Exec: Execute( Exec ) def do_plugin( self ): self.do_standard_places() self.do_custom_places() self.do_gtk_bookmarks() def refreshTrash (self): iconName = 'user-trash' trash_info = os.path.join(os.path.expanduser('~'), '.local','share','Trash','info') if os.path.exists(trash_info) and os.listdir(trash_info): iconName = 'user-trash-full' self.trashButton.setIcon(iconName)
class pluginclass(object): def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton # Read UI file builder = Gtk.Builder() builder.add_from_file( os.path.join('/', 'usr', 'share', 'mate-menu', 'plugins', 'places.glade')) self.placesBtnHolder = builder.get_object("places_button_holder") self.editableBtnHolder = builder.get_object("editable_button_holder") self.scrolledWindow = builder.get_object("scrolledwindow2") # These properties are NECESSARY to maintain consistency # Set 'window' property for the plugin (Must be the root widget) self.window = builder.get_object("mainWindow") # Set 'heading' property for plugin self.heading = _("Places") # This should be the first item added to the window in glade self.content_holder = builder.get_object("Places") # Items to get custom colors self.itemstocolor = [builder.get_object("viewport2")] # Settings self.settings = EasyGSettings("org.mate.mate-menu.plugins.places") self.settings.notifyAdd("icon-size", self.RegenPlugin) self.settings.notifyAdd("show-computer", self.RegenPlugin) self.settings.notifyAdd("show-desktop", self.RegenPlugin) self.settings.notifyAdd("show-home_folder", self.RegenPlugin) self.settings.notifyAdd("show-network", self.RegenPlugin) self.settings.notifyAdd("show-trash", self.RegenPlugin) self.settings.notifyAdd("custom-names", self.RegenPlugin) self.settings.notifyAdd("allow-scrollbar", self.RegenPlugin) self.settings.notifyAdd("show-gtk-bookmarks", self.RegenPlugin) self.settings.notifyAdd("height", self.changePluginSize) self.settings.notifyAdd("width", self.changePluginSize) self.loadSettings() self.content_holder.set_size_request(self.width, self.height) def wake(self): if (self.showtrash == True): self.refreshTrash() def destroy(self): self.settings.notifyRemoveAll() def changePluginSize(self, settings, key, args=None): self.allowScrollbar = self.settings.get("bool", "allow-scrollbar") self.width = self.settings.get("int", "width") if (self.allowScrollbar == False): self.height = -1 self.scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) else: 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) def RegenPlugin(self, *args, **kargs): self.loadSettings() self.ClearAll() self.do_standard_places() self.do_custom_places() self.do_gtk_bookmarks() def loadSettings(self): self.width = self.settings.get("int", "width") self.allowScrollbar = self.settings.get("bool", "allow-scrollbar") self.showGtkBookmarks = self.settings.get("bool", "show-gtk-bookmarks") 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER) self.content_holder.set_size_request(self.width, self.height) self.iconsize = self.settings.get("int", "icon-size") # Check default items self.showcomputer = self.settings.get("bool", "show-computer") self.showhomefolder = self.settings.get("bool", "show-home-folder") self.shownetwork = self.settings.get("bool", "show-network") self.showdesktop = self.settings.get("bool", "show-desktop") self.showtrash = self.settings.get("bool", "show-trash") # Get paths for custom items self.custompaths = self.settings.get("list-string", "custom-paths") # Get names for custom items self.customnames = self.settings.get("list-string", "custom-names") # Plugin icon self.icon = self.settings.get("string", "icon") # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get("bool", "sticky") self.minimized = self.settings.get("bool", "minimized") def ClearAll(self): for child in self.placesBtnHolder.get_children(): child.destroy() for child in self.editableBtnHolder.get_children(): child.destroy() #Add standard places def do_standard_places(self): if (self.showcomputer == True): Button1 = easyButton("computer", self.iconsize, [_("Computer")], -1, -1) Button1.connect("clicked", self.ButtonClicked, "xdg-open computer:") Button1.show() self.placesBtnHolder.pack_start(Button1, False, False, 0) self.mateMenuWin.setTooltip( Button1, _("Browse all local and remote disks and folders accessible from this computer" )) if (self.showhomefolder == True): Button2 = easyButton("user-home", self.iconsize, [_("Home Folder")], -1, -1) Button2.connect("clicked", self.ButtonClicked, "xdg-open %s " % os.environ["HOME"]) Button2.show() self.placesBtnHolder.pack_start(Button2, False, False, 0) self.mateMenuWin.setTooltip(Button2, _("Open your personal folder")) if (self.shownetwork == True): mate_settings = Gio.Settings.new("org.mate.interface") icon_theme = mate_settings.get_string("icon-theme") Button3 = easyButton("network-workgroup", self.iconsize, [_("Network")], -1, -1) Button3.connect("clicked", self.ButtonClicked, "xdg-open network:") Button3.show() self.placesBtnHolder.pack_start(Button3, False, False, 0) self.mateMenuWin.setTooltip( Button3, _("Browse bookmarked and local network locations")) if (self.showdesktop == True): # Determine where the Desktop folder is (could be localized) desktopDir = os.path.join(os.environ["HOME"] + "Desktop") try: from configobj import ConfigObj configPath = os.environ.get( "XDG_CONFIG_HOME", os.path.join(os.environ["HOME"], ".config")) config = ConfigObj(os.path.join(configPath, "user-dirs.dirs")) tmpdesktopDir = os.path.expandvars(config['XDG_DESKTOP_DIR']) if os.path.exists(tmpdesktopDir): desktopDir = tmpdesktopDir except Exception, detail: print detail Button4 = easyButton("desktop", self.iconsize, [_("Desktop")], -1, -1) Button4.connect("clicked", self.ButtonClicked, "xdg-open \"" + desktopDir + "\"") Button4.show() self.placesBtnHolder.pack_start(Button4, False, False, 0) self.mateMenuWin.setTooltip( Button4, _("Browse items placed on the desktop")) if (self.showtrash == True): self.trashButton = easyButton("user-trash", self.iconsize, [_("Trash")], -1, -1) self.trashButton.connect("clicked", self.ButtonClicked, "xdg-open trash:") self.trashButton.show() self.trashButton.connect("button-release-event", self.trashPopup) self.refreshTrash() self.placesBtnHolder.pack_start(self.trashButton, False, False, 0) self.mateMenuWin.setTooltip(self.trashButton, _("Browse deleted files"))
class pluginclass( object ): def __init__(self, mateMenuWin, toggleButton): self.mateMenuWin = mateMenuWin self.toggleButton = toggleButton self.builder = Gtk.Builder() self.builder.add_from_file( os.path.join( '/', 'usr', 'share', 'mate-menu', 'plugins', '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 = 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 = self.builder.get_object( "System" ) # Items to get custom colors self.itemstocolor = [ self.builder.get_object( "viewport2" ) ] # Gconf stuff self.settings = EasyGSettings( "org.mate.mate-menu.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-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() self.content_holder.set_size_request( self.width, self.height ) def destroy( self ): self.settings.notifyRemoveAll() def wake (self) : pass 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) else: 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.GetGSettingsEntries() self.ClearAll() self.do_standard_items() def GetGSettingsEntries( self ): 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.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER ) self.content_holder.set_size_request( self.width, self.height ) self.iconsize = self.settings.get( "int","icon-size") # Check toggles 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") # Plugin icon self.icon = self.settings.get( "string", "icon" ) # Allow plugin to be minimized to the left plugin pane self.sticky = self.settings.get( "bool", "sticky") self.minimized = self.settings.get( "bool", "minimized") 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.showPackageManager == True ): if os.path.exists("/usr/bin/software-center") or os.path.exists("/usr/bin/synaptic-pkexec"): if os.path.exists("/usr/bin/synaptic-pkexec"): Button2 = easyButton("synaptic", self.iconsize, [_("Package Manager")], -1, -1 ) Button2.connect( "clicked", self.ButtonClicked, "/usr/bin/synaptic-pkexec" ) elif os.path.exists("/usr/bin/software-center"): Button2 = easyButton("softwarecenter", self.iconsize, [_("Package Manager")], -1, -1 ) Button2.connect( "clicked", self.ButtonClicked, "/usr/bin/software-center" ) Button2.show() self.systemBtnHolder.pack_start( Button2, False, False, 0 ) self.mateMenuWin.setTooltip( Button2, _("Install, remove and upgrade software packages") ) if ( self.showControlCenter == True ): Button3 = easyButton( "gtk-preferences", self.iconsize, [_("Control Center")], -1, -1 ) Button3.connect( "clicked", self.ButtonClicked, "mate-control-center" ) Button3.show() self.systemBtnHolder.pack_start( Button3, False, False, 0 ) self.mateMenuWin.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" ) else: Button4.connect( "clicked", self.ButtonClicked, "x-terminal-emulator" ) Button4.show() self.systemBtnHolder.pack_start( Button4, False, False, 0 ) self.mateMenuWin.setTooltip( Button4, _("Use the command line") ) 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.mateMenuWin.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.mateMenuWin.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.mateMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") ) def ButtonClicked( self, widget, Exec ): self.mateMenuWin.hide() if Exec: Execute( Exec ) def do_plugin( self ): self.do_standard_items()