Added early stages of icon toggle
This commit is contained in:
parent
233111bf38
commit
a668bf991b
Binary file not shown.
@ -46,9 +46,8 @@ class Main:
|
||||
win.set_default_size(mon.width, mon.height)
|
||||
win.set_size_request(mon.width, mon.height)
|
||||
win.set_resizable(False)
|
||||
|
||||
|
||||
win.move(mon.x, mon.y)
|
||||
|
||||
win.show()
|
||||
i += 1
|
||||
|
||||
|
@ -76,12 +76,13 @@ class Signals(CPUDrawMixin, MainMenuMixin, TaskbarMixin, GridMixin):
|
||||
# Program Menu Parts
|
||||
self.menuWindow = self.builder.get_object("menuWindow")
|
||||
self.menuWindow.set_keep_above(True);
|
||||
self.showIcons = False
|
||||
|
||||
self.iconFactory = Icon(self.settings)
|
||||
self.grpDefault = "Accessories"
|
||||
self.progGroup = self.grpDefault
|
||||
HOME_APPS = os.path.expanduser('~') + "/.local/share/applications/"
|
||||
paths = ["/usr/share/applications/", HOME_APPS]
|
||||
paths = ["/opt/", "/usr/share/applications/", HOME_APPS]
|
||||
self.menuData = self.getDesktopFilesInfo(paths)
|
||||
self.desktopObjs = []
|
||||
self.getSubgroup()
|
||||
|
@ -71,8 +71,11 @@ class MainMenuMixin:
|
||||
for obj in self.desktopObjs:
|
||||
title = obj[0]
|
||||
dirPath = obj[1]
|
||||
image = self.iconFactory.parseDesktopFiles(dirPath) # .get_pixbuf()
|
||||
self.addToProgramListView(widget, title, image)
|
||||
if self.showIcons:
|
||||
image = self.iconFactory.parseDesktopFiles(dirPath) # .get_pixbuf()
|
||||
self.addToProgramListView(widget, title, image)
|
||||
else:
|
||||
self.addToProgramListViewAsText(widget, title)
|
||||
|
||||
|
||||
@threaded
|
||||
@ -95,10 +98,27 @@ class MainMenuMixin:
|
||||
button.show_all()
|
||||
glib.idle_add(widget.add, (button))
|
||||
|
||||
@threaded
|
||||
def addToProgramListViewAsText(self, widget, title):
|
||||
button = gtk.Button(label=title)
|
||||
button.connect("clicked", self.executeProgram)
|
||||
|
||||
children = button.get_children()
|
||||
label = children[0]
|
||||
|
||||
label.set_halign(1)
|
||||
label.set_line_wrap(True)
|
||||
label.set_max_width_chars(38)
|
||||
label.set_size_request(640, 64)
|
||||
|
||||
button.show_all()
|
||||
glib.idle_add(widget.add, (button))
|
||||
|
||||
|
||||
def executeProgram(self, widget):
|
||||
"""
|
||||
Need to refactor and pull out the sub loop that is used in both cases...
|
||||
# TODO:
|
||||
Need to refactor and pull out the sub loop that is used in both cases...
|
||||
"""
|
||||
entry = widget.get_label().strip()
|
||||
group = self.progGroup
|
||||
@ -176,50 +196,60 @@ class MainMenuMixin:
|
||||
}
|
||||
|
||||
for path in paths:
|
||||
for f in listdir(path):
|
||||
fPath = path + f
|
||||
flags = ["mimeinfo.cache", "defaults.list"]
|
||||
if not f in flags and isfile(fPath):
|
||||
xdgObj = DesktopEntry(fPath)
|
||||
|
||||
title = xdgObj.getName()
|
||||
groups = xdgObj.getCategories()
|
||||
comment = xdgObj.getComment()
|
||||
icon = xdgObj.getIcon()
|
||||
mainExec = xdgObj.getExec()
|
||||
tryExec = xdgObj.getTryExec()
|
||||
|
||||
group = ""
|
||||
if "Accessories" in groups or "Utility" in groups:
|
||||
group = "Accessories"
|
||||
elif "Multimedia" in groups or "Video" in groups or "Audio" in groups:
|
||||
group = "Multimedia"
|
||||
elif "Development" in groups:
|
||||
group = "Development"
|
||||
elif "Game" in groups:
|
||||
group = "Game"
|
||||
elif "Internet" in groups or "Network" in groups:
|
||||
group = "Internet"
|
||||
elif "Graphics" in groups:
|
||||
group = "Graphics"
|
||||
elif "Office" in groups:
|
||||
group = "Office"
|
||||
elif "System" in groups:
|
||||
group = "System"
|
||||
elif "Settings" in groups:
|
||||
group = "Settings"
|
||||
elif "Wine" in groups:
|
||||
group = "Wine"
|
||||
else:
|
||||
group = "Other"
|
||||
|
||||
menuObjs[group].append( {"title": title, "groups": groups,
|
||||
"comment": comment, "exec": mainExec,
|
||||
"tryExec": tryExec, "fileName": f,
|
||||
"filePath": fPath, "icon": icon})
|
||||
if not "/opt/" in path:
|
||||
self.listAndUpdateDesktopFiles(path, menuObjs);
|
||||
else:
|
||||
for folder in listdir(path):
|
||||
try:
|
||||
fPath = path + folder + "/"
|
||||
self.listAndUpdateDesktopFiles(fPath, menuObjs);
|
||||
except Exception as e:
|
||||
print( repr(e) )
|
||||
|
||||
return menuObjs
|
||||
|
||||
def listAndUpdateDesktopFiles(self, path, menuObjs):
|
||||
for f in listdir(path):
|
||||
fPath = path + f
|
||||
if isfile(fPath) and f.endswith(".desktop"):
|
||||
xdgObj = DesktopEntry(fPath)
|
||||
|
||||
title = xdgObj.getName()
|
||||
groups = xdgObj.getCategories()
|
||||
comment = xdgObj.getComment()
|
||||
icon = xdgObj.getIcon()
|
||||
mainExec = xdgObj.getExec()
|
||||
tryExec = xdgObj.getTryExec()
|
||||
|
||||
group = ""
|
||||
if "Accessories" in groups or "Utility" in groups:
|
||||
group = "Accessories"
|
||||
elif "Multimedia" in groups or "Video" in groups or "Audio" in groups:
|
||||
group = "Multimedia"
|
||||
elif "Development" in groups:
|
||||
group = "Development"
|
||||
elif "Game" in groups:
|
||||
group = "Game"
|
||||
elif "Internet" in groups or "Network" in groups:
|
||||
group = "Internet"
|
||||
elif "Graphics" in groups:
|
||||
group = "Graphics"
|
||||
elif "Office" in groups:
|
||||
group = "Office"
|
||||
elif "System" in groups:
|
||||
group = "System"
|
||||
elif "Settings" in groups:
|
||||
group = "Settings"
|
||||
elif "Wine" in groups:
|
||||
group = "Wine"
|
||||
else:
|
||||
group = "Other"
|
||||
|
||||
menuObjs[group].append( {"title": title, "groups": groups,
|
||||
"comment": comment, "exec": mainExec,
|
||||
"tryExec": tryExec, "fileName": f,
|
||||
"filePath": fPath, "icon": icon})
|
||||
|
||||
|
||||
def getSubgroup(self, query = ""):
|
||||
"""
|
||||
|
@ -90,7 +90,6 @@ class Icon:
|
||||
print( repr(e) )
|
||||
return gtk.Image.new_from_file(self.INTERNAL_ICON_PTH)
|
||||
|
||||
|
||||
def parseDesktopFiles(self, fullPath):
|
||||
try:
|
||||
xdgObj = DesktopEntry(fullPath)
|
||||
@ -117,12 +116,12 @@ class Icon:
|
||||
proc = subprocess.Popen(["wget", "-O", hashImgPth, imageLink])
|
||||
proc.wait()
|
||||
|
||||
# Use video sizes since headers are bigger
|
||||
# Use video thumbnail sizes since headers are bigger
|
||||
return self.createScaledImage(hashImgPth, self.viIconWH)
|
||||
elif os.path.exists(icon):
|
||||
return self.createScaledImage(icon, self.systemIconImageWH)
|
||||
else:
|
||||
iconsDirs = ["/usr/share/pixmaps", self.usrHome + "/.icons", "/usr/share/icons" ,]
|
||||
iconsDirs = ["/usr/share/pixmaps", "/usr/share/icons", self.usrHome + "/.icons" ,]
|
||||
altIconPath = ""
|
||||
|
||||
for iconsDir in iconsDirs:
|
||||
@ -181,6 +180,18 @@ class Icon:
|
||||
print( repr(e) )
|
||||
return None
|
||||
|
||||
def createFromFile(self, path):
|
||||
try:
|
||||
return gtk.Image.new_from_file(path)
|
||||
except Exception as e:
|
||||
print("Image from file Issue:")
|
||||
print( repr(e) )
|
||||
return None
|
||||
|
||||
def returnGenericIcon(self):
|
||||
return gtk.Image.new_from_file(self.INTERNAL_ICON_PTH)
|
||||
|
||||
|
||||
def generateVideoThumbnail(self, fullPath, hashImgPth):
|
||||
proc = None
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user