Added get_system_item_paths function to retrieve XDG_DATA_DIRS
Changed Logic in onPropsApp to iterate through all XDG_DATA_DIRS Removed filecmp import
This commit is contained in:
parent
9551b3fb88
commit
1cbff0b2ed
@ -12,7 +12,7 @@ import gettext
|
|||||||
import gnomevfs
|
import gnomevfs
|
||||||
import threading
|
import threading
|
||||||
import commands
|
import commands
|
||||||
import filecmp
|
import subprocess
|
||||||
|
|
||||||
from easybuttons import *
|
from easybuttons import *
|
||||||
from execute import Execute
|
from execute import Execute
|
||||||
@ -88,6 +88,15 @@ def get_user_item_path():
|
|||||||
|
|
||||||
return item_dir
|
return item_dir
|
||||||
|
|
||||||
|
def get_system_item_paths():
|
||||||
|
item_dir = None
|
||||||
|
|
||||||
|
if os.environ.has_key('XDG_DATA_DIRS'):
|
||||||
|
item_dirs = os.environ['XDG_DATA_DIRS'].split(":")
|
||||||
|
else:
|
||||||
|
item_dirs = [os.path.join('usr', 'share')]
|
||||||
|
|
||||||
|
return item_dirs
|
||||||
|
|
||||||
def rel_path(target, base=os.curdir):
|
def rel_path(target, base=os.curdir):
|
||||||
|
|
||||||
@ -763,23 +772,30 @@ class pluginclass( object ):
|
|||||||
|
|
||||||
def onPropsApp( self, menu, widget ):
|
def onPropsApp( self, menu, widget ):
|
||||||
|
|
||||||
relPath = rel_path(widget.desktopFile, "/usr/share/applications")
|
sysPaths = get_system_item_paths()
|
||||||
|
|
||||||
if widget.desktopFile == os.path.join("/usr/share/applications" , relPath):
|
for path in sysPaths:
|
||||||
filePath = os.path.join(get_user_item_path(), relPath)
|
|
||||||
(head,tail) = os.path.split(filePath)
|
|
||||||
|
|
||||||
if not os.path.isdir(head):
|
path += "applications"
|
||||||
os.makedirs(head)
|
|
||||||
|
|
||||||
if not os.path.isfile(filePath):
|
relPath = os.path.relpath(widget.desktopFile, path)
|
||||||
data = open(widget.desktopFile).read()
|
|
||||||
open(filePath, 'w').write(data)
|
|
||||||
|
|
||||||
else:
|
if widget.desktopFile == os.path.join(path, relPath):
|
||||||
filePath = widget.desktopFile
|
filePath = os.path.join(get_user_item_path(), relPath)
|
||||||
|
(head,tail) = os.path.split(filePath)
|
||||||
|
|
||||||
pid = os.spawnlp(os.P_NOWAIT, "/usr/bin/gnome-desktop-item-edit", "gnome-desktop-item-edit", filePath)
|
if not os.path.isdir(head):
|
||||||
|
os.makedirs(head)
|
||||||
|
|
||||||
|
if not os.path.isfile(filePath):
|
||||||
|
data = open(widget.desktopFile).read()
|
||||||
|
open(filePath, 'w').write(data)
|
||||||
|
break
|
||||||
|
|
||||||
|
else:
|
||||||
|
filePath = widget.desktopFile
|
||||||
|
|
||||||
|
pid = subprocess.Popen(["/usr/bin/gnome-desktop-item-edit", filePath]).pid
|
||||||
|
|
||||||
self.mintMenuWin.hide()
|
self.mintMenuWin.hide()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user