initial cleanup with some debug messaging

This commit is contained in:
gm10 2019-01-19 11:24:32 +01:00
parent d3ce506d45
commit cc75da5868
No known key found for this signature in database
GPG Key ID: A981D4EA8CF993A9
9 changed files with 184 additions and 171 deletions

View File

@ -1,5 +1,12 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gc
import gettext
import os
import sys
import traceback
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
gi.require_version('MatePanelApplet', '4.0') gi.require_version('MatePanelApplet', '4.0')
@ -7,17 +14,12 @@ from gi.repository import Gtk, GdkPixbuf, Gdk, GObject
from gi.repository import MatePanelApplet from gi.repository import MatePanelApplet
from gi.repository import Gio from gi.repository import Gio
import sys
import os
import commands
import gettext
import traceback
import time
import gc
import xdg.Config import xdg.Config
import keybinding import keybinding
import pointerMonitor import pointerMonitor
import setproctitle import setproctitle
from plugins.execute import Execute
GObject.threads_init() GObject.threads_init()
@ -37,7 +39,6 @@ if not windowManager:
windowManager = "MATE" windowManager = "MATE"
xdg.Config.setWindowManager( windowManager.upper() ) xdg.Config.setWindowManager( windowManager.upper() )
from execute import *
class MainWindow( object ): class MainWindow( object ):
"""This is the main class for the application""" """This is the main class for the application"""
@ -92,9 +93,10 @@ class MainWindow( object ):
else: else:
self.tooltipsEnable( False ) self.tooltipsEnable( False )
self.PopulatePlugins(); self.PopulatePlugins()
self.firstTime = True; self.firstTime = True
@staticmethod
def on_window1_destroy (self, widget, data=None): def on_window1_destroy (self, widget, data=None):
Gtk.main_quit() Gtk.main_quit()
sys.exit(0) sys.exit(0)
@ -116,18 +118,18 @@ class MainWindow( object ):
else: else:
self.tooltipsEnable( False ) self.tooltipsEnable( False )
def toggleStartWithFavorites( self, settings, key, args = None ): def toggleStartWithFavorites( self, settings, key ):
self.startWithFavorites = settings.get_boolean(key) self.startWithFavorites = settings.get_boolean(key)
def toggleUseCustomColor( self, settings, key, args = None ): def toggleUseCustomColor( self, settings, key ):
self.usecustomcolor = settings.get_boolean(key) self.usecustomcolor = settings.get_boolean(key)
self.loadTheme() self.loadTheme()
def toggleCustomBackgroundColor( self, settings, key, args = None): def toggleCustomBackgroundColor( self, settings, key ):
self.customcolor = settings.get_string(key) self.customcolor = settings.get_string(key)
self.SetPaneColors( self.panesToColor ) self.SetPaneColors( self.panesToColor )
def toggleCustomHeadingColor( self, settings, key, args = None ): def toggleCustomHeadingColor( self, settings, key ):
self.customheadingcolor = settings.get_string(key) self.customheadingcolor = settings.get_string(key)
self.SetHeadingStyle( self.headingsToColor ) self.SetHeadingStyle( self.headingsToColor )
@ -147,7 +149,6 @@ class MainWindow( object ):
def PopulatePlugins( self ): def PopulatePlugins( self ):
self.panesToColor = [ ] self.panesToColor = [ ]
self.headingsToColor = [ ] self.headingsToColor = [ ]
start = time.time()
PluginPane = Gtk.EventBox() PluginPane = Gtk.EventBox()
PluginPane.show() PluginPane.show()
PaneLadder = Gtk.Box( orientation=Gtk.Orientation.VERTICAL ) PaneLadder = Gtk.Box( orientation=Gtk.Orientation.VERTICAL )
@ -186,7 +187,7 @@ class MainWindow( object ):
# Image1.show() # Image1.show()
#print u"Loading plugin '" + plugin + "' : sucessful" #print u"Loading plugin '" + plugin + "' : sucessful"
except Exception, e: except Exception:
MyPlugin = Gtk.EventBox() #Fake class for MyPlugin MyPlugin = Gtk.EventBox() #Fake class for MyPlugin
MyPlugin.heading = _("Couldn't load plugin:") + " " + plugin MyPlugin.heading = _("Couldn't load plugin:") + " " + plugin
MyPlugin.content_holder = Gtk.EventBox() MyPlugin.content_holder = Gtk.EventBox()
@ -265,8 +266,8 @@ class MainWindow( object ):
error = _("Couldn't initialize plugin") + " " + plugin + " : " + "\n".join(traceback.format_exception( info[0], info[1], info[2] )).replace("\\n", "\n") error = _("Couldn't initialize plugin") + " " + plugin + " : " + "\n".join(traceback.format_exception( info[0], info[1], info[2] )).replace("\\n", "\n")
msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, error ) msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, error )
msgDlg.run(); msgDlg.run()
msgDlg.destroy(); msgDlg.destroy()
self.plugins[plugin] = MyPlugin self.plugins[plugin] = MyPlugin
@ -540,14 +541,14 @@ class MenuWin( object ):
self.button_icon = Gtk.Image() self.button_icon = Gtk.Image()
self.do_image(self.buttonIcon, False) self.do_image(self.buttonIcon, False)
self.systemlabel = Gtk.Label(label= "%s " % self.buttonText ) self.systemlabel = Gtk.Label(label= "%s " % self.buttonText )
if os.path.exists("/etc/linuxmint/info"): if os.path.isfile("/etc/linuxmint/info"):
import commands info = open("/etc/linuxmint/info").readlines() #TODO py3 encoding="utf-8"
tooltip = commands.getoutput("cat /etc/linuxmint/info | grep DESCRIPTION") for line in info:
tooltip = tooltip.replace("DESCRIPTION", "") if line.startswith("DESCRIPTION="):
tooltip = tooltip.replace("=", "") tooltip = line.split("=",1)[1].replace('"','')
tooltip = tooltip.replace("\"", "") self.systemlabel.set_tooltip_text(tooltip)
self.systemlabel.set_tooltip_text(tooltip) self.button_icon.set_tooltip_text(tooltip)
self.button_icon.set_tooltip_text(tooltip) break
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
self.button_box = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL ) self.button_box = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
self.button_box.pack_start( self.button_icon, False, False, 0 ) self.button_box.pack_start( self.button_icon, False, False, 0 )
@ -605,7 +606,6 @@ class MenuWin( object ):
style_settings.set_property("gtk-theme-name", desktop_theme) style_settings.set_property("gtk-theme-name", desktop_theme)
def changeOrientation( self, *args, **kargs ): def changeOrientation( self, *args, **kargs ):
if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN: if self.applet.get_orient() == MatePanelApplet.AppletOrient.UP or self.applet.get_orient() == MatePanelApplet.AppletOrient.DOWN:
tmpbox = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL ) tmpbox = Gtk.Box( orientation=Gtk.Orientation.HORIZONTAL )
self.systemlabel.set_angle( 0 ) self.systemlabel.set_angle( 0 )
@ -644,7 +644,7 @@ class MenuWin( object ):
self.do_image(self.buttonIcon, False) self.do_image(self.buttonIcon, False)
self.sizeButton() self.sizeButton()
def hotkeyChanged (self, schema, key): def hotkeyChanged (self, schema, key ):
self.hotkeyText = self.settings.get_string( "hot-key" ) self.hotkeyText = self.settings.get_string( "hot-key" )
self.keybinder.rebind(self.hotkeyText) self.keybinder.rebind(self.hotkeyText)
@ -705,7 +705,7 @@ class MenuWin( object ):
# Execute( "mateconf-editor /apps/mintMenu" ) # Execute( "mateconf-editor /apps/mintMenu" )
Execute( os.path.join( PATH, "mintMenuConfig.py" ) ) Execute( os.path.join( PATH, "mintMenuConfig.py" ) )
def showMenuEditor( self, action, userdata = None ): def showMenuEditor( self, action, userdata = None):
Execute( "mozo" ) Execute( "mozo" )
def showMenu( self, widget=None, event=None ): def showMenu( self, widget=None, event=None ):
@ -781,7 +781,7 @@ class MenuWin( object ):
if newX < monitorGeometry.x: if newX < monitorGeometry.x:
newX = monitorGeometry.x newX = monitorGeometry.x
if applet_orient == MatePanelApplet.AppletOrient.RIGHT: if applet_orient == MatePanelApplet.AppletOrient.RIGHT:
newX -= entryWidth; newX -= entryWidth
# Bind to the bottom # Bind to the bottom
if newY + ourHeight > (monitorGeometry.y + monitorGeometry.height): if newY + ourHeight > (monitorGeometry.y + monitorGeometry.height):

View File

@ -1,28 +1,26 @@
#!/usr/bin/python2 #!/usr/bin/python2
import commands
import filecmp
import gettext
import os
import pipes
import string
import subprocess
import threading
import time
from user import home
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Pango, Gdk, Gio, GLib from gi.repository import Gtk, Pango, Gdk, Gio, GLib
import os
import time
import string
import gettext
import threading
import commands
import subprocess
import filecmp
from easybuttons import *
from execute import Execute
from easygsettings import EasyGSettings
from easyfiles import *
import recentHelper as RecentHelper
import pipes
import matemenu import matemenu
import plugins.recentHelper as RecentHelper
from user import home from plugins.easybuttons import (CategoryButton, FavApplicationLauncher,
MenuApplicationLauncher)
from plugins.easygsettings import EasyGSettings
from plugins.execute import Execute
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
@ -281,7 +279,7 @@ class pluginclass( object ):
self.builder.get_object("searchButton").connect( "button-press-event", self.searchPopup ) self.builder.get_object("searchButton").connect( "button-press-event", self.searchPopup )
self.icon_theme = Gtk.IconTheme.get_default(); self.icon_theme = Gtk.IconTheme.get_default()
self.icon_theme.connect("changed", self.on_icon_theme_changed) self.icon_theme.connect("changed", self.on_icon_theme_changed)
def refresh_apt_cache(self): def refresh_apt_cache(self):
@ -437,6 +435,8 @@ class pluginclass( object ):
self.Todos() self.Todos()
self.buildFavorites() self.buildFavorites()
# TODO all this runs whether the plugin is enabled or not
print "applications.RegenPlugin calling buildRecentApps"
RecentHelper.buildRecentApps() RecentHelper.buildRecentApps()
self.RebuildPlugin() self.RebuildPlugin()
@ -688,7 +688,7 @@ class pluginclass( object ):
name = pkg.name name = pkg.name
for word in keywords: for word in keywords:
if word != "": if word != "":
name = name.replace(word, "<b>%s</b>" % word); name = name.replace(word, "<b>%s</b>" % word)
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.apturl_install, pkg.name) suggestionButton.connect("clicked", self.apturl_install, pkg.name)
suggestionButton.set_text(_("Install package '%s'") % name) suggestionButton.set_text(_("Install package '%s'") % name)
@ -741,7 +741,7 @@ class pluginclass( object ):
name = pkg.name name = pkg.name
for word in keywords: for word in keywords:
if word != "": if word != "":
name = name.replace(word, "<b>%s</b>" % word); name = name.replace(word, "<b>%s</b>" % word)
suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "") suggestionButton = SuggestionButton(Gtk.STOCK_ADD, self.iconSize, "")
suggestionButton.connect("clicked", self.apturl_install, pkg.name) suggestionButton.connect("clicked", self.apturl_install, pkg.name)
suggestionButton.set_text(_("Install package '%s'") % name) suggestionButton.set_text(_("Install package '%s'") % name)
@ -816,7 +816,7 @@ class pluginclass( object ):
i.released() i.released()
i.set_relief( Gtk.ReliefStyle.NONE ) i.set_relief( Gtk.ReliefStyle.NONE )
allButton = self.categoriesBox.get_children()[0]; allButton = self.categoriesBox.get_children()[0]
allButton.set_relief( Gtk.ReliefStyle.HALF ) allButton.set_relief( Gtk.ReliefStyle.HALF )
self.activeFilter = (0, text, widget) self.activeFilter = (0, text, widget)
else: else:
@ -1082,11 +1082,12 @@ class pluginclass( object ):
self.focusSearchEntry(clear = False) self.focusSearchEntry(clear = False)
return True return True
def pos_func(self, menu=None): # TODO: Is this in use?
rect = self.searchButton.get_allocation() # def pos_func(self, menu=None):
x = rect.x + rect.width # rect = self.searchButton.get_allocation()
y = rect.y + rect.height # x = rect.x + rect.width
return (x, y, False) # y = rect.y + rect.height
# return (x, y, False)
def search_ddg(self, widget): def search_ddg(self, widget):
text = self.searchEntry.get_text() text = self.searchEntry.get_text()
@ -1261,7 +1262,6 @@ class pluginclass( object ):
self.favoritesAdd( self.favoritesBuildLauncher( uri ) ) self.favoritesAdd( self.favoritesBuildLauncher( uri ) )
def Search( self, widget ): def Search( self, widget ):
text = self.searchEntry.get_text().strip() text = self.searchEntry.get_text().strip()
if text != "": if text != "":
for app_button in self.applicationsBox.get_children(): for app_button in self.applicationsBox.get_children():
@ -1280,7 +1280,9 @@ class pluginclass( object ):
def do_plugin( self ): def do_plugin( self ):
self.Todos() self.Todos()
self.buildFavorites() self.buildFavorites()
RecentHelper.buildRecentApps() # TODO all this runs whether the plugin is enabled or not
# print "applications.do_plugin calling buildRecentApps"
# RecentHelper.buildRecentApps()
# Scroll button into view # Scroll button into view
def scrollItemIntoView( self, widget, event = None ): def scrollItemIntoView( self, widget, event = None ):
@ -1408,7 +1410,7 @@ class pluginclass( object ):
self.favoritesSave() self.favoritesSave()
except Exception, e: except Exception, e:
print e print e
def favoritesPositionOnGrid( self, favorite ): def favoritesPositionOnGrid( self, favorite ):
row = 0 row = 0
@ -1502,8 +1504,8 @@ class pluginclass( object ):
appListFile.close( ) appListFile.close( )
except Exception, e: except Exception, e:
msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" ) msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save favorites. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" )
msgDlg.run(); msgDlg.run()
msgDlg.destroy(); msgDlg.destroy()
def isLocationInFavorites( self, location ): def isLocationInFavorites( self, location ):
for fav in self.favorites: for fav in self.favorites:
@ -1533,6 +1535,7 @@ class pluginclass( object ):
self.menuChangedTimer = GLib.timeout_add( 1000, self.updateBoxes, True ) self.menuChangedTimer = GLib.timeout_add( 1000, self.updateBoxes, True )
@print_timing
def updateBoxes( self, menu_has_changed ): def updateBoxes( self, menu_has_changed ):
print ("updateBoxes") print ("updateBoxes")
# FIXME: This is really bad! # FIXME: This is really bad!

View File

@ -1,18 +1,22 @@
#!/usr/bin/python2 #!/usr/bin/python2
import os.path
import re
import shutil
import xdg.DesktopEntry
import xdg.Menu
import gi import gi
gi.require_version('MateDesktop', '2.0') gi.require_version('MateDesktop', '2.0')
from gi.repository import Gtk, Gdk, GLib from gi.repository import Gtk, Gdk, GLib
from gi.repository import Pango from gi.repository import Pango
from gi.repository import GObject from gi.repository import GObject
from gi.repository import MateDesktop from gi.repository import MateDesktop
import os.path
import shutil from plugins.execute import Execute
import re from plugins.filemonitor import monitor as filemonitor
from execute import *
import xdg.DesktopEntry
import xdg.Menu
from filemonitor import monitor as filemonitor
class IconManager(GObject.GObject): class IconManager(GObject.GObject):
@ -240,12 +244,13 @@ class ApplicationLauncher( easyButton ):
if isinstance( desktopFile, xdg.Menu.MenuEntry ): if isinstance( desktopFile, xdg.Menu.MenuEntry ):
desktopItem = desktopFile.DesktopEntry desktopItem = desktopFile.DesktopEntry
desktopFile = desktopItem.filename desktopFile = desktopItem.filename
self.appDirs = desktop.desktopFile.AppDirs self.appDirs = desktopFile.AppDirs
elif isinstance( desktopFile, xdg.Menu.DesktopEntry ): elif isinstance( desktopFile, xdg.Menu.DesktopEntry ):
desktopItem = desktopFile desktopItem = desktopFile
desktopFile = desktopItem.filename desktopFile = desktopItem.filename
self.appDirs = [ os.path.dirname( desktopItem.filename ) ] self.appDirs = [ os.path.dirname( desktopItem.filename ) ]
else: else:
# XXX: All menu entries on LM19.1 end here
desktopItem = xdg.DesktopEntry.DesktopEntry( desktopFile ) desktopItem = xdg.DesktopEntry.DesktopEntry( desktopFile )
self.appDirs = [ os.path.dirname( desktopFile ) ] self.appDirs = [ os.path.dirname( desktopFile ) ]
@ -278,8 +283,6 @@ class ApplicationLauncher( easyButton ):
self.connectSelf( "focus-out-event", self.onFocusOut ) self.connectSelf( "focus-out-event", self.onFocusOut )
self.connectSelf( "clicked", self.execute ) self.connectSelf( "clicked", self.execute )
def loadDesktopEntry( self, desktopItem ): def loadDesktopEntry( self, desktopItem ):
try: try:
self.appName = self.strip_accents(desktopItem.getName()) self.appName = self.strip_accents(desktopItem.getName())
@ -317,7 +320,6 @@ class ApplicationLauncher( easyButton ):
self.appDocPath = "" self.appDocPath = ""
self.startupMonitorId = 0 self.startupMonitorId = 0
def onFocusIn( self, widget, event ): def onFocusIn( self, widget, event ):
self.set_relief( Gtk.ReliefStyle.HALF ) self.set_relief( Gtk.ReliefStyle.HALF )
@ -358,8 +360,6 @@ class ApplicationLauncher( easyButton ):
return tooltip return tooltip
def dragDataGet( self, widget, context, selection, targetType, eventTime ): def dragDataGet( self, widget, context, selection, targetType, eventTime ):
if targetType == 100: # text/plain if targetType == 100: # text/plain
selection.set_text( "'" + self.desktopFile + "'", -1 ) selection.set_text( "'" + self.desktopFile + "'", -1 )
@ -394,39 +394,39 @@ class ApplicationLauncher( easyButton ):
def startupFileChanged( self, *args ): def startupFileChanged( self, *args ):
self.inStartup = os.path.exists( self.startupFilePath ) self.inStartup = os.path.exists( self.startupFilePath )
def addToStartup( self ): # def addToStartup( self ):
startupDir = os.path.join( os.path.expanduser("~"), ".config", "autostart" ); # startupDir = os.path.join( os.path.expanduser("~"), ".config", "autostart" )
if not os.path.exists( startupDir ): # if not os.path.exists( startupDir ):
os.makedirs( startupDir ) # os.makedirs( startupDir )
shutil.copyfile( self.desktopFile, self.startupFilePath ) # shutil.copyfile( self.desktopFile, self.startupFilePath )
# Remove %u, etc. from Exec entry, because MATE will not replace them when it starts the app # # Remove %u, etc. from Exec entry, because MATE will not replace them when it starts the app
item = MateDesktop.DesktopItem.new_from_uri(self.startupFilePath, MateDesktop.DesktopItemLoadFlags.ONLY_IF_EXISTS) # item = MateDesktop.DesktopItem.new_from_uri(self.startupFilePath, MateDesktop.DesktopItemLoadFlags.ONLY_IF_EXISTS)
if item: # if item:
r = re.compile("%[A-Za-z]"); # r = re.compile("%[A-Za-z]");
tmp = r.sub("", item.get_string( MateDesktop.DESKTOP_ITEM_EXEC ) ).strip() # tmp = r.sub("", item.get_string( MateDesktop.DESKTOP_ITEM_EXEC ) ).strip()
item.set_string( MateDesktop.DESKTOP_ITEM_EXEC, tmp ) # item.set_string( MateDesktop.DESKTOP_ITEM_EXEC, tmp )
item.save( self.startupFilePath, 0 ) # item.save( self.startupFilePath, 0 )
def removeFromStartup( self ): # def removeFromStartup( self ):
if os.path.exists( self.startupFilePath ): # if os.path.exists( self.startupFilePath ):
os.remove( self.startupFilePath ) # os.remove( self.startupFilePath )
def addToFavourites( self ): # def addToFavourites( self ):
favouritesDir = os.path.join( os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications" ); # favouritesDir = os.path.join( os.path.expanduser("~"), ".linuxmint", "mintMenu", "applications" )
if not os.path.exists( favouritesDir ): # if not os.path.exists( favouritesDir ):
os.makedirs( favouritesDir ) # os.makedirs( favouritesDir )
shutil.copyfile( self.desktopFile, self.favouritesFilePath ) # shutil.copyfile( self.desktopFile, self.favouritesFilePath )
def removeFromFavourites( self ): # def removeFromFavourites( self ):
if os.path.exists( self.favouritesFilePath ): # if os.path.exists( self.favouritesFilePath ):
os.remove( self.favouritesFilePath ) # os.remove( self.favouritesFilePath )
def isInStartup( self ): # def isInStartup( self ):
#return self.inStartup # #return self.inStartup
return os.path.exists( self.startupFilePath ) # return os.path.exists( self.startupFilePath )
def onDestroy( self, widget ): def onDestroy( self, widget ):
easyButton.onDestroy( self, widget ) easyButton.onDestroy( self, widget )

View File

@ -1,7 +1,5 @@
#!/usr/bin/python2 #!/usr/bin/python2
import os
import os.path
import urllib import urllib
def GetFilePath(uri): def GetFilePath(uri):

View File

@ -1,17 +1,19 @@
#!/usr/bin/python2 #!/usr/bin/python2
from gi.repository import Gtk, Gio, GLib from glob import glob
import gettext
import os import os
import string import string
import gettext
import commands
import time
from easybuttons import *
from easygsettings import EasyGSettings
from execute import Execute
from user import home
from urllib import unquote from urllib import unquote
from user import home
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Gio, GLib
from plugins.easybuttons import easyButton
from plugins.easygsettings import EasyGSettings
from plugins.execute import Execute
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")
@ -183,6 +185,7 @@ class pluginclass( object ):
self.trashButton.connect( "clicked", self.ButtonClicked, "xdg-open trash:" ) self.trashButton.connect( "clicked", self.ButtonClicked, "xdg-open trash:" )
self.trashButton.show() self.trashButton.show()
self.trashButton.connect( "button-release-event", self.trashPopup ) self.trashButton.connect( "button-release-event", self.trashPopup )
self.trash_path = os.path.join(home, "/.local/share/Trash/info")
self.refreshTrash() self.refreshTrash()
self.placesBtnHolder.pack_start( self.trashButton, False, False, 0) self.placesBtnHolder.pack_start( self.trashButton, False, False, 0)
self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") ) self.mintMenuWin.setTooltip( self.trashButton, _("Browse deleted files") )
@ -258,9 +261,8 @@ class pluginclass( object ):
self.do_gtk_bookmarks() self.do_gtk_bookmarks()
def refreshTrash (self): def refreshTrash (self):
iconName = "user-trash" if os.path.exists(self.trash_path) and glob(os.path.join(self.trash_path, "*")):
if (os.path.exists(home + "/.local/share/Trash/info")): iconName = "user-trash-full"
infoFiles = commands.getoutput("ls " + home + "/.local/share/Trash/info/ | wc -l") else:
if (int(infoFiles) > 0): iconName = "user-trash"
iconName = "user-trash-full"
self.trashButton.setIcon(iconName) self.trashButton.setIcon(iconName)

View File

@ -1,19 +1,20 @@
#!/usr/bin/python2 #!/usr/bin/python2
import os
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, Pango from gi.repository import Gtk, Pango
import os
from easygsettings import EasyGSettings from plugins.execute import Execute
from execute import Execute import plugins.recentHelper as RecentHelper
from easyfiles import * from plugins.easygsettings import EasyGSettings
from easybuttons import *
import recentHelper as RecentHelper
class pluginclass: class pluginclass:
"""This is the main class for the plugin""" """ This is the main class for the plugin.
"""It MUST be named pluginclass""" It MUST be named pluginclass
"""
def __init__( self, mintMenuWin, toggleButton, de ): def __init__( self, mintMenuWin, toggleButton, de ):
@ -37,9 +38,9 @@ class pluginclass:
self.recentBox = self.builder.get_object("RecentBox") self.recentBox = self.builder.get_object("RecentBox")
self.recentAppBox = self.builder.get_object("RecentApps") self.recentAppBox = self.builder.get_object("RecentApps")
RecentHelper.recentAppBox = self.recentAppBox RecentHelper.recentAppBox = self.recentAppBox
#self.recentApps = [] #self.recentApps = []
self.recentVBox = self.builder.get_object( "vbox1" ) self.recentVBox = self.builder.get_object( "vbox1" )
#Specify plugin width #Specify plugin width
@ -57,7 +58,7 @@ class pluginclass:
self.appSettings = EasyGSettings( "com.linuxmint.mintmenu.plugins.applications" ) self.appSettings = EasyGSettings( "com.linuxmint.mintmenu.plugins.applications" )
self.appSettings.notifyAdd( "icon-size", self.RegenPlugin ) self.appSettings.notifyAdd( "icon-size", self.RegenPlugin )
self.FileList=[] self.FileList=[]
self.RecManagerInstance = Gtk.RecentManager.get_default() self.RecManagerInstance = Gtk.RecentManager.get_default()
self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent) self.recentManagerId = self.RecManagerInstance.connect("changed", self.DoRecent)
@ -89,7 +90,7 @@ class pluginclass:
self.recentw = self.settings.get( 'int', 'width' ) self.recentw = self.settings.get( 'int', 'width' )
self.numentries = self.settings.get( 'int', 'num-recent-docs' ) self.numentries = self.settings.get( 'int', 'num-recent-docs' )
RecentHelper.numentries = self.numentries RecentHelper.numentries = self.numentries
self.recentfontsize = self.settings.get( 'int', 'recent-font-size' ) self.recentfontsize = self.settings.get( 'int', 'recent-font-size' )
# Hide vertical dotted separator # Hide vertical dotted separator
@ -108,16 +109,16 @@ class pluginclass:
else: else:
self.settings.set( "bool", "minimized", False ) self.settings.set( "bool", "minimized", False )
def RebuildPlugin(self): def RebuildPlugin(self):
self.content_holder.set_size_request(self.recentw, self.recenth ) self.content_holder.set_size_request(self.recentw, self.recenth )
# TODO
print "recent.RebuildPlugin calling recent.DoRecent"
self.DoRecent() self.DoRecent()
def DoRecent( self, *args, **kargs ): def DoRecent( self, *args, **kargs ):
for i in self.recentBox.get_children(): for i in self.recentBox.get_children():
i.destroy() i.destroy()
self.recentVBox.set_size_request( self.recentw, self.recenth ) self.recentVBox.set_size_request( self.recentw, self.recenth )
if len( self.recentBox.get_children() ) < self.numentries: if len( self.recentBox.get_children() ) < self.numentries:
n=len( self.recentBox.get_children() )-1 n=len( self.recentBox.get_children() )-1
@ -133,13 +134,17 @@ class pluginclass:
if Name != None: if Name != None:
self.AddRecentBtn( Name, self.IconList[loc] ) self.AddRecentBtn( Name, self.IconList[loc] )
loc = loc + 1 loc = loc + 1
# TODO
print "recent.DoRecent calling RecentHelper.doRecentApps"
RecentHelper.doRecentApps() RecentHelper.doRecentApps()
return True return True
def clrmenu(self, *args, **kargs): def clrmenu(self, *args, **kargs):
self.RecManagerInstance.purge_items() self.RecManagerInstance.purge_items()
# TODO
print "recent.clrmenu calling recent.DoRecent"
self.DoRecent() self.DoRecent()
return return
@ -185,8 +190,6 @@ class pluginclass:
if result == 77: if result == 77:
dia.destroy() dia.destroy()
def GetRecent(self, *args, **kargs): def GetRecent(self, *args, **kargs):
FileString=[] FileString=[]
IconString=[] IconString=[]
@ -204,7 +207,6 @@ class pluginclass:
break break
return FileString, IconString return FileString, IconString
def ButtonClicked( self, widget, event, Exec ): def ButtonClicked( self, widget, event, Exec ):
self.press_x = event.x self.press_x = event.x
self.press_y = event.y self.press_y = event.y
@ -223,6 +225,7 @@ class pluginclass:
self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus() self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus()
Execute( w, self.Exec ) Execute( w, self.Exec )
def do_plugin(self): # TODO - skipping this because we're already doing this on __init__
self.DoRecent() # def do_plugin(self):
# print "recent.do_plugin calling recent.DoRecent"
# self.DoRecent()

View File

@ -1,13 +1,13 @@
#!/usr/bin/python2 #!/usr/bin/python2
import os
from user import home
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
import os from plugins.easybuttons import ApplicationLauncher
import string
from user import home
from easyfiles import *
from easybuttons import *
recentApps = [] recentApps = []
mintMenuWin = None mintMenuWin = None
@ -41,21 +41,22 @@ def recentAppsSave():
recentAppListFile.close( ) recentAppListFile.close( )
except Exception, e: except Exception, e:
print e print e
msgDlg = Gtk.MessageDialog( None, gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save recent apps. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" ) msgDlg = Gtk.MessageDialog( None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, _("Couldn't save recent apps. Check if you have write access to ~/.linuxmint/mintMenu")+"\n(" + e.__str__() + ")" )
msgDlg.run(); msgDlg.run()
msgDlg.destroy(); msgDlg.destroy()
def recentAppBuildLauncher( location ): def recentAppBuildLauncher( location ):
try: try:
ButtonIcon = None
# For Folders and Network Shares # For Folders and Network Shares
location = string.join( location.split( "%20" ) ) location = "".join( location.split( "%20" ) )
if location.startswith( "file" ): # ButtonIcon = None
ButtonIcon = "mate-fs-directory"
if location.startswith( "smb" ) or location.startswith( "ssh" ) or location.startswith( "network" ): # if location.startswith( "file" ):
ButtonIcon = "mate-fs-network" # ButtonIcon = "mate-fs-directory"
# if location.startswith( "smb" ) or location.startswith( "ssh" ) or location.startswith( "network" ):
# ButtonIcon = "mate-fs-network"
#For Special locations #For Special locations
if location == "x-nautilus-desktop:///computer": if location == "x-nautilus-desktop:///computer":
@ -83,13 +84,16 @@ def recentAppBuildLauncher( location ):
def buildRecentApps(): def buildRecentApps():
print "-- recentHelper.buildRecentApps"
del recentApps[:] del recentApps[:]
try: try:
if (not os.path.exists(home + "/.linuxmint/mintMenu/recentApplications.list")): path = os.path.join(home, ".linuxmint/mintMenu/recentApplications.list")
os.system("touch " + home + "/.linuxmint/mintMenu/recentApplications.list") if not os.path.exists(path):
recentAppListFile = open( os.path.join( os.path.expanduser( "~"), ".linuxmint", "mintMenu", "recentApplications.list" ) , "r" ) print "does not exist"
#os.system("touch " + path)
recentApplicationsList = recentAppListFile.readlines() recentApplicationsList = []
else:
recentApplicationsList = open(path).readlines()
for app in recentApplicationsList : for app in recentApplicationsList :
app = app.strip() app = app.strip()
@ -109,6 +113,7 @@ def buildRecentApps():
return recentApps return recentApps
def doRecentApps(): def doRecentApps():
print "-- recentHelper.doRecentApps"
if recentAppBox is not None: if recentAppBox is not None:
# recentAppBox is initiated by the recent plugin # recentAppBox is initiated by the recent plugin
# only build UI widgets if it's enabled # only build UI widgets if it's enabled
@ -128,6 +133,7 @@ def doRecentApps():
return True return True
def applicationButtonClicked( widget ): def applicationButtonClicked( widget ):
# TODO all this runs whether the plugin is enabled or not
mintMenuWin.hide() mintMenuWin.hide()
recentAppsAdd(widget) recentAppsAdd(widget)
recentAppsSave() recentAppsSave()

View File

@ -1,16 +1,15 @@
#!/usr/bin/python2 #!/usr/bin/python2
import gettext
import os
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from gi.repository import Gtk from gi.repository import Gtk
import os
import string
import gettext
from easybuttons import * from plugins.easybuttons import easyButton
from execute import Execute from plugins.easygsettings import EasyGSettings
from easygsettings import EasyGSettings from plugins.execute import Execute
# i18n # i18n
gettext.install("mintmenu", "/usr/share/linuxmint/locale") gettext.install("mintmenu", "/usr/share/linuxmint/locale")

View File

@ -1,12 +1,14 @@
#!/usr/bin/python2 #!/usr/bin/python2
import threading
import gi import gi
gi.require_version("Gtk", "3.0") gi.require_version("Gtk", "3.0")
from Xlib.display import Display
from Xlib import X, error
from gi.repository import Gtk, Gdk, GObject, GLib from gi.repository import Gtk, Gdk, GObject, GLib
import threading
from Xlib import X
from Xlib.display import Display
class PointerMonitor(GObject.GObject, threading.Thread): class PointerMonitor(GObject.GObject, threading.Thread):
__gsignals__ = { __gsignals__ = {