Clean up and add debugging info

This commit is contained in:
Clement Lefebvre 2016-05-21 18:08:09 +01:00
parent 877ce3640b
commit 3f1e04c577
4 changed files with 154 additions and 200 deletions

5
README Normal file
View File

@ -0,0 +1,5 @@
DEBUGGING
---------
- Remove mintmenu from the panel (it should not run anywhere else).
- Run ./test

4
test
View File

@ -4,4 +4,6 @@ sudo rm -rf /usr/lib/linuxmint/mintMenu
sudo cp -R usr / sudo cp -R usr /
sudo glib-compile-schemas /usr/share/glib-2.0/schemas sudo glib-compile-schemas /usr/share/glib-2.0/schemas
python /usr/lib/linuxmint/mintMenu/mintMenu.py mate-terminal --maximize -e /usr/lib/linuxmint/mintMenu/mintMenu.py
mate-panel-test-applets --iid MintMenuAppletFactory::MintMenuApplet

View File

@ -2,7 +2,7 @@
import gi import gi
gi.require_version("Gtk", "2.0") gi.require_version("Gtk", "2.0")
gi.require_version('MatePanelApplet', '4.0')
from gi.repository import Gtk, GdkPixbuf, Gdk, GObject 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

View File

@ -22,10 +22,6 @@ from easyfiles import *
gtk = CDLL("libgtk-x11-2.0.so.0") gtk = CDLL("libgtk-x11-2.0.so.0")
from filemonitor import monitor as filemonitor
#import xdg.Menu
import matemenu import matemenu
from user import home from user import home
@ -48,53 +44,6 @@ def print_timing(func):
return res return res
return wrapper return wrapper
# Evil patching
#def xdgParsePatched(filename=None):
# # conver to absolute path
# if filename and not os.path.isabs(filename):
# filename = xdg.Menu.__getFileName(filename)
#
# # use default if no filename given
# if not filename:
# filename = xdg.Menu.__getFileName("applications.menu")
#
# if not filename:
# raise xdg.Menu.ParsingError(_("File not found"), "/etc/xdg/menus/applications.menu")
#
# # check if it is a .menu file
# if not os.path.splitext(filename)[1] == ".menu":
# raise xdg.Menu.ParsingError(_("Not a .menu file"), filename)
#
# # create xml parser
# try:
# doc = xdg.Menu.xml.dom.minidom.parse(filename)
# except xdg.Menu.xml.parsers.expat.ExpatError:
# raise xdg.Menu.ParsingError(_("Not a valid .menu file"), filename)
#
# # parse menufile
# xdg.Menu.tmp["Root"] = ""
# xdg.Menu.tmp["mergeFiles"] = []
# xdg.Menu.tmp["DirectoryDirs"] = []
# xdg.Menu.tmp["cache"] = xdg.Menu.MenuEntryCache()
#
# xdg.Menu.__parse(doc, filename, xdg.Menu.tmp["Root"])
# xdg.Menu.__parsemove(xdg.Menu.tmp["Root"])
# xdg.Menu.__postparse(xdg.Menu.tmp["Root"])
#
# xdg.Menu.tmp["Root"].Doc = doc
# xdg.Menu.tmp["Root"].Filename = filename
#
# # generate the menu
# xdg.Menu.__genmenuNotOnlyAllocated(xdg.Menu.tmp["Root"])
# xdg.Menu.__genmenuOnlyAllocated(xdg.Menu.tmp["Root"])
#
# # and finally sort
# xdg.Menu.sort(xdg.Menu.tmp["Root"])
# xdg.Menu.tmp["Root"].Files = xdg.Menu.tmp["mergeFiles"] + [ xdg.Menu.tmp["Root"].Filename ]
# return xdg.Menu.tmp["Root"]
#
#xdg.Menu.parse = xdgParsePatched
# Helper function for retrieving the user's location for storing new or modified menu items # Helper function for retrieving the user's location for storing new or modified menu items
def get_user_item_path(): def get_user_item_path():
item_dir = None item_dir = None
@ -312,7 +261,6 @@ class pluginclass( object ):
self.categoryList = [] self.categoryList = []
self.applicationList = [] self.applicationList = []
#self.menuFileMonitors = []
#dirty ugly hack, to get favorites drag origin position #dirty ugly hack, to get favorites drag origin position
self.drag_origin = None self.drag_origin = None
@ -325,10 +273,6 @@ class pluginclass( object ):
for mainitems in [ "mate-applications.menu", "mate-settings.menu" ]: for mainitems in [ "mate-applications.menu", "mate-settings.menu" ]:
mymenu = Menu( mainitems ) mymenu = Menu( mainitems )
mymenu.tree.add_monitor( self.menuChanged, None ) mymenu.tree.add_monitor( self.menuChanged, None )
#for f in mymenu.directory.Files:
# self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) )
#for f in mymenu.directory.AppDirs:
# self.menuFileMonitors.append( filemonitor.addMonitor(f, self.onMenuChanged, mymenu.directory.Filename ) )
self.refresh_apt_cache() self.refresh_apt_cache()
self.suggestions = [] self.suggestions = []
@ -380,9 +324,6 @@ class pluginclass( object ):
self.settings.notifyRemoveAll() self.settings.notifyRemoveAll()
#for mId in self.menuFileMonitors:
# filemonitor.removeMonitor( mId )
def changePluginSize( self, settings, key, args ): def changePluginSize( self, settings, key, args ):
if key == "width": if key == "width":
self.width = settings.get_int(key) self.width = settings.get_int(key)
@ -1606,13 +1547,15 @@ class pluginclass( object ):
self.favoritesReorder( self.drag_origin, widget.position ) self.favoritesReorder( self.drag_origin, widget.position )
def menuChanged( self, x, y ): def menuChanged( self, x, y ):
# wait some miliseconds because there a multiple events send at the same time and we don't want to rebuild the menu for each print ("menuChanged")
# wait 1s, to avoid building the menu multiple times concurrently
if self.menuChangedTimer: if self.menuChangedTimer:
GLib.source_remove( self.menuChangedTimer ) GLib.source_remove( self.menuChangedTimer )
self.menuChangedTimer = GLib.timeout_add( 100, self.updateBoxes, True ) self.menuChangedTimer = GLib.timeout_add( 1000, self.updateBoxes, True )
def updateBoxes( self, menu_has_changed ): def updateBoxes( self, menu_has_changed ):
print ("updateBoxes")
# FIXME: This is really bad! # FIXME: This is really bad!
if self.rebuildLock: if self.rebuildLock:
return return
@ -1621,6 +1564,8 @@ class pluginclass( object ):
self.menuChangedTimer = None self.menuChangedTimer = None
try:
self.loadMenuFiles() self.loadMenuFiles()
# Find added and removed categories than update the category list # Find added and removed categories than update the category list
@ -1774,6 +1719,8 @@ class pluginclass( object ):
button.hide() button.hide()
else: else:
launcherNames.append(launcherName) launcherNames.append(launcherName)
except Exception, e:
print e
self.rebuildLock = False self.rebuildLock = False