Start converting mintMenuConfig

This commit is contained in:
Michael Webster 2013-03-07 21:42:50 -05:00
parent 1fa7cd8817
commit bb5a90b943
3 changed files with 2690 additions and 565 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,14 +2,13 @@
import sys
import gi
gi.require_version("Gtk", "2.0")
from gi.repository import Gtk
try:
import pygtk
pygtk.require( "2.0" )
except:
pass
try:
import gtk
import gtk.glade
import gettext
import os
import commands
@ -34,119 +33,120 @@ class mintMenuConfig( object ):
self.path = os.path.abspath( os.path.dirname( sys.argv[0] ) )
# Load glade file and extract widgets
gladefile = os.path.join( self.path, "mintMenuConfig.glade" )
wTree = gtk.glade.XML( gladefile, "mainWindow" )
self.mainWindow=wTree.get_widget("mainWindow")
self.builder = Gtk.Builder()
self.builder.add_from_file (self.path, "mintMenuConfig.glade" ))
self.mainWindow=self.builder.get_object("mainWindow")
#i18n
self.mainWindow.set_title(_("Menu preferences"))
self.mainWindow.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
wTree.get_widget("startWithFavorites").set_label(_("Always start with favorites pane"))
wTree.get_widget("showButtonIcon").set_label(_("Show button icon"))
wTree.get_widget("useCustomColors").set_label(_("Use custom colors"))
wTree.get_widget("showRecentPlugin").set_label(_("Show recent documents plugin"))
wTree.get_widget("showApplicationsPlugin").set_label(_("Show applications plugin"))
wTree.get_widget("showSystemPlugin").set_label(_("Show system plugin"))
wTree.get_widget("showPlacesPlugin").set_label(_("Show places plugin"))
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"))
wTree.get_widget("showAppComments").set_label(_("Show application comments"))
wTree.get_widget("showCategoryIcons").set_label(_("Show category icons"))
wTree.get_widget("hover").set_label(_("Hover"))
wTree.get_widget("use_apt").set_label(_("Search for packages to install"))
wTree.get_widget("swapGeneric").set_label(_("Swap name and generic name"))
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("use_apt").set_label(_("Search for packages to install"))
self.builder.get_object("swapGeneric").set_label(_("Swap name and generic name"))
wTree.get_widget("label11").set_text(_("Border width:"))
wTree.get_widget("label2").set_text(_("pixels"))
self.builder.get_object("label11").set_text(_("Border width:"))
self.builder.get_object("label2").set_text(_("pixels"))
wTree.get_widget("label8").set_text(_("Opacity:"))
wTree.get_widget("label9").set_text("%")
self.builder.get_object("label8").set_text(_("Opacity:"))
self.builder.get_object("label9").set_text("%")
wTree.get_widget("buttonTextLabel").set_text(_("Button text:"))
wTree.get_widget("label1").set_text(_("Options"))
wTree.get_widget("label23").set_text(_("Applications"))
self.builder.get_object("buttonTextLabel").set_text(_("Button text:"))
self.builder.get_object("label1").set_text(_("Options"))
self.builder.get_object("label23").set_text(_("Applications"))
wTree.get_widget("colorsLabel").set_text(_("Theme"))
wTree.get_widget("favLabel").set_text(_("Favorites"))
wTree.get_widget("label3").set_text(_("Main button"))
self.builder.get_object("colorsLabel").set_text(_("Theme"))
self.builder.get_object("favLabel").set_text(_("Favorites"))
self.builder.get_object("label3").set_text(_("Main button"))
wTree.get_widget("backgroundColorLabel").set_text(_("Background:"))
wTree.get_widget("headingColorLabel").set_text(_("Headings:"))
wTree.get_widget("borderColorLabel").set_text(_("Borders:"))
wTree.get_widget("themeLabel").set_text(_("Theme:"))
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:"))
#wTree.get_widget("applicationsLabel").set_text(_("Applications"))
#wTree.get_widget("favoritesLabel").set_text(_("Favorites"))
wTree.get_widget("numberColumnsLabel").set_text(_("Number of columns:"))
wTree.get_widget("iconSizeLabel").set_text(_("Icon size:"))
wTree.get_widget("iconSizeLabel2").set_text(_("Icon size:"))
wTree.get_widget("placesIconSizeLabel").set_text(_("Icon size:"))
wTree.get_widget("systemIconSizeLabel").set_text(_("Icon size:"))
wTree.get_widget("hoverLabel").set_text(_("Hover delay (ms):"))
wTree.get_widget("label4").set_text(_("Button icon:"))
wTree.get_widget("label5").set_text(_("Search command:"))
#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:"))
wTree.get_widget("placesLabel").set_text(_("Places"))
wTree.get_widget("allowscrollbarcheckbutton").set_label(_("Allow Scrollbar"))
wTree.get_widget("showgtkbookmarkscheckbutton").set_label(_("Show GTK Bookmarks"))
wTree.get_widget("placesHeightEntryLabel").set_text(_("Height:"))
wTree.get_widget("defaultPlacesFrameLabel").set_text(_("Toggle Default Places:"))
wTree.get_widget("computercheckbutton").set_label(_("Computer"))
wTree.get_widget("homecheckbutton").set_label(_("Home Folder"))
wTree.get_widget("networkcheckbutton").set_label(_("Network"))
wTree.get_widget("desktopcheckbutton").set_label(_("Desktop"))
wTree.get_widget("trashcheckbutton").set_label(_("Trash"))
wTree.get_widget("customPlacesFrameLabel").set_text(_("Custom Places:"))
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:"))
wTree.get_widget("systemLabel").set_text(_("System"))
wTree.get_widget("allowscrollbarcheckbutton1").set_label(_("Allow Scrollbar"))
wTree.get_widget("systemHeightEntryLabel").set_text(_("Height:"))
wTree.get_widget("defaultItemsFrameLabel").set_text(_("Toggle Default Items:"))
wTree.get_widget("softwaremanagercheckbutton").set_label(_("Software Manager"))
wTree.get_widget("packagemanagercheckbutton").set_label(_("Package Manager"))
wTree.get_widget("controlcentercheckbutton").set_label(_("Control Center"))
wTree.get_widget("terminalcheckbutton").set_label(_("Terminal"))
wTree.get_widget("lockcheckbutton").set_label(_("Lock Screen"))
wTree.get_widget("logoutcheckbutton").set_label(_("Log Out"))
wTree.get_widget("quitcheckbutton").set_label(_("Quit"))
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("softwaremanagercheckbutton").set_label(_("Software Manager"))
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"))
wTree.get_widget("hotkey_label").set_text(_("Keyboard shortcut:"))
self.builder.get_object("hotkey_label").set_text(_("Keyboard shortcut:"))
self.startWithFavorites = wTree.get_widget( "startWithFavorites" )
self.showAppComments = wTree.get_widget( "showAppComments" )
self.useAPT = wTree.get_widget( "use_apt" )
self.showCategoryIcons = wTree.get_widget( "showCategoryIcons" )
self.showRecentPlugin = wTree.get_widget( "showRecentPlugin" )
self.showApplicationsPlugin = wTree.get_widget( "showApplicationsPlugin" )
self.showSystemPlugin = wTree.get_widget( "showSystemPlugin" )
self.showPlacesPlugin = wTree.get_widget( "showPlacesPlugin" )
self.swapGeneric = wTree.get_widget("swapGeneric")
self.hover = wTree.get_widget( "hover" )
self.hoverDelay = wTree.get_widget( "hoverDelay" )
self.iconSize = wTree.get_widget( "iconSize" )
self.favIconSize = wTree.get_widget( "favIconSize" )
self.placesIconSize = wTree.get_widget( "placesIconSize" )
self.systemIconSize = wTree.get_widget( "systemIconSize" )
self.favCols = wTree.get_widget( "numFavCols" )
self.borderWidth = wTree.get_widget( "borderWidth" )
self.opacity = wTree.get_widget( "opacity" )
self.useCustomColors = wTree.get_widget( "useCustomColors" )
self.backgroundColor = wTree.get_widget( "backgroundColor" )
self.borderColor = wTree.get_widget( "borderColor" )
self.headingColor = wTree.get_widget( "headingColor" )
self.backgroundColorLabel = wTree.get_widget( "backgroundColorLabel" )
self.borderColorLabel = wTree.get_widget( "borderColorLabel" )
self.headingColorLabel = wTree.get_widget( "headingColorLabel" )
self.showButtonIcon = wTree.get_widget( "showButtonIcon" )
self.buttonText = wTree.get_widget( "buttonText" )
self.hotkeyText = wTree.get_widget( "hotkeyText" )
self.buttonIcon = wTree.get_widget( "buttonIcon" )
self.buttonIconChooser = wTree.get_widget( "button_icon_chooser" )
self.image_filter = gtk.FileFilter()
self.startWithFavorites = self.builder.get_object( "startWithFavorites" )
self.showAppComments = self.builder.get_object( "showAppComments" )
self.useAPT = self.builder.get_object( "use_apt" )
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.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.opacity = self.builder.get_object( "opacity" )
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.hotkeyText = self.builder.get_object( "hotkeyText" )
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")
@ -157,38 +157,38 @@ class mintMenuConfig( object ):
self.image_filter.add_pattern("*.svg")
self.buttonIconChooser.add_filter(self.image_filter)
self.buttonIconChooser.set_filter(self.image_filter)
self.buttonIconImage = wTree.get_widget("image_button_icon")
self.searchCommand = wTree.get_widget( "search_command" )
self.computertoggle = wTree.get_widget( "computercheckbutton" )
self.homefoldertoggle = wTree.get_widget( "homecheckbutton" )
self.networktoggle = wTree.get_widget( "networkcheckbutton" )
self.desktoptoggle = wTree.get_widget( "desktopcheckbutton" )
self.trashtoggle = wTree.get_widget( "trashcheckbutton" )
self.customplacestree = wTree.get_widget( "customplacestree" )
self.allowPlacesScrollbarToggle = wTree.get_widget( "allowscrollbarcheckbutton" )
self.showgtkbookmarksToggle = wTree.get_widget( "showgtkbookmarkscheckbutton" )
self.placesHeightButton = wTree.get_widget( "placesHeightSpinButton" )
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.softwareManagerToggle = wTree.get_widget( "softwaremanagercheckbutton" )
self.packageManagerToggle = wTree.get_widget( "packagemanagercheckbutton" )
self.controlCenterToggle = wTree.get_widget( "controlcentercheckbutton" )
self.packageManagerToggle = wTree.get_widget( "packagemanagercheckbutton" )
self.terminalToggle = wTree.get_widget( "terminalcheckbutton" )
self.lockToggle = wTree.get_widget( "lockcheckbutton" )
self.logoutToggle = wTree.get_widget( "logoutcheckbutton" )
self.quitToggle = wTree.get_widget( "quitcheckbutton" )
self.allowSystemScrollbarToggle = wTree.get_widget( "allowscrollbarcheckbutton1" )
self.systemHeightButton = wTree.get_widget( "systemHeightSpinButton" )
self.softwareManagerToggle = self.builder.get_object( "softwaremanagercheckbutton" )
self.packageManagerToggle = self.builder.get_object( "packagemanagercheckbutton" )
self.controlCenterToggle = self.builder.get_object( "controlcentercheckbutton" )
self.packageManagerToggle = self.builder.get_object( "packagemanagercheckbutton" )
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 )
if os.path.exists("/usr/lib/linuxmint/mintInstall/icon.svg"):
wTree.get_widget( "softwaremanagercheckbutton" ).show()
self.builder.get_object( "softwaremanagercheckbutton" ).show()
else:
wTree.get_widget( "softwaremanagercheckbutton" ).hide()
self.builder.get_object( "softwaremanagercheckbutton" ).hide()
wTree.get_widget( "closeButton" ).connect("clicked", gtk.main_quit )
self.builder.get_object( "closeButton" ).connect("clicked", Gtk.main_quit )
self.gconf = EasyGConf( "/apps/mintMenu/" )
@ -268,18 +268,18 @@ class mintMenuConfig( object ):
self.placescolumn = gtk.TreeViewColumn( _("Path"), self.cell, text = 1 )
self.customplacestree.append_column( self.namescolumn )
self.customplacestree.append_column( self.placescolumn )
wTree.get_widget("newButton").connect("clicked", self.newPlace)
wTree.get_widget("editButton").connect("clicked", self.editPlace)
wTree.get_widget("upButton").connect("clicked", self.moveUp)
wTree.get_widget("downButton").connect("clicked", self.moveDown)
wTree.get_widget("removeButton").connect("clicked", self.removePlace)
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 = commands.getoutput("mateconftool-2 --get /apps/mintMenu/theme_name").strip()
themes = commands.getoutput("find /usr/share/themes -name gtkrc")
themes = themes.split("\n")
model = gtk.ListStore(str, str)
wTree.get_widget("themesCombo").set_model(model)
self.builder.get_object("themesCombo").set_model(model)
selected_theme = model.append([_("Desktop theme"), "default"])
for theme in themes:
if theme.startswith("/usr/share/themes") and theme.endswith("/gtk-2.0/gtkrc"):
@ -291,8 +291,8 @@ class mintMenuConfig( object ):
iter = model.append([theme, theme])
if theme == theme_name:
selected_theme = iter
wTree.get_widget("themesCombo").set_active_iter(selected_theme)
wTree.get_widget("themesCombo").connect("changed", self.set_theme)
self.builder.get_object("themesCombo").set_active_iter(selected_theme)
self.builder.get_object("themesCombo").connect("changed", self.set_theme)
self.mainWindow.present()
self.getBackgroundColor()
@ -418,19 +418,19 @@ class mintMenuConfig( object ):
def newPlace(self, newButton):
gladefile = os.path.join( self.path, "mintMenuConfig.glade" )
wTree = gtk.glade.XML( gladefile, "editPlaceDialog" )
wTree.get_widget("label2").set_text(_("Name:"))
wTree.get_widget("label1").set_text(_("Path:"))
self.builder.get_object("label2").set_text(_("Name:"))
self.builder.get_object("label1").set_text(_("Path:"))
folderChooserTree = gtk.glade.XML( gladefile, "fileChooserDialog" )
newPlaceDialog = wTree.get_widget( "editPlaceDialog" )
newPlaceDialog = self.builder.get_object( "editPlaceDialog" )
folderChooserDialog = folderChooserTree.get_widget( "fileChooserDialog" )
newPlaceDialog.set_transient_for(self.mainWindow)
newPlaceDialog.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
newPlaceDialog.set_title(self.newPlaceDialogTitle)
folderChooserDialog.set_title(self.folderChooserDialogTitle)
newPlaceDialog.set_default_response(gtk.RESPONSE_OK)
newPlaceName = wTree.get_widget( "nameEntryBox" )
newPlacePath = wTree.get_widget( "pathEntryBox" )
folderButton = wTree.get_widget( "folderButton" )
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!=""):
@ -452,19 +452,19 @@ class mintMenuConfig( object ):
def editPlace(self, editButton):
gladefile = os.path.join( self.path, "mintMenuConfig.glade" )
wTree = gtk.glade.XML( gladefile, "editPlaceDialog" )
wTree.get_widget("label2").set_text(_("Name:"))
wTree.get_widget("label1").set_text(_("Path:"))
self.builder.get_object("label2").set_text(_("Name:"))
self.builder.get_object("label1").set_text(_("Path:"))
folderChooserTree = gtk.glade.XML( gladefile, "fileChooserDialog" )
editPlaceDialog = wTree.get_widget( "editPlaceDialog" )
editPlaceDialog = self.builder.get_object( "editPlaceDialog" )
folderChooserDialog = folderChooserTree.get_widget( "fileChooserDialog" )
editPlaceDialog.set_transient_for(self.mainWindow)
editPlaceDialog.set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg")
editPlaceDialog.set_title(self.editPlaceDialogTitle)
folderChooserDialog.set_title(self.folderChooserDialogTitle)
editPlaceDialog.set_default_response(gtk.RESPONSE_OK)
editPlaceName = wTree.get_widget( "nameEntryBox" )
editPlacePath = wTree.get_widget( "pathEntryBox" )
folderButton = wTree.get_widget( "folderButton" )
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]