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_default_size(mon.width, mon.height)
|
||||||
win.set_size_request(mon.width, mon.height)
|
win.set_size_request(mon.width, mon.height)
|
||||||
win.set_resizable(False)
|
win.set_resizable(False)
|
||||||
|
|
||||||
|
|
||||||
win.move(mon.x, mon.y)
|
win.move(mon.x, mon.y)
|
||||||
|
|
||||||
win.show()
|
win.show()
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
@ -76,12 +76,13 @@ class Signals(CPUDrawMixin, MainMenuMixin, TaskbarMixin, GridMixin):
|
|||||||
# Program Menu Parts
|
# Program Menu Parts
|
||||||
self.menuWindow = self.builder.get_object("menuWindow")
|
self.menuWindow = self.builder.get_object("menuWindow")
|
||||||
self.menuWindow.set_keep_above(True);
|
self.menuWindow.set_keep_above(True);
|
||||||
|
self.showIcons = False
|
||||||
|
|
||||||
self.iconFactory = Icon(self.settings)
|
self.iconFactory = Icon(self.settings)
|
||||||
self.grpDefault = "Accessories"
|
self.grpDefault = "Accessories"
|
||||||
self.progGroup = self.grpDefault
|
self.progGroup = self.grpDefault
|
||||||
HOME_APPS = os.path.expanduser('~') + "/.local/share/applications/"
|
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.menuData = self.getDesktopFilesInfo(paths)
|
||||||
self.desktopObjs = []
|
self.desktopObjs = []
|
||||||
self.getSubgroup()
|
self.getSubgroup()
|
||||||
|
@ -71,8 +71,11 @@ class MainMenuMixin:
|
|||||||
for obj in self.desktopObjs:
|
for obj in self.desktopObjs:
|
||||||
title = obj[0]
|
title = obj[0]
|
||||||
dirPath = obj[1]
|
dirPath = obj[1]
|
||||||
|
if self.showIcons:
|
||||||
image = self.iconFactory.parseDesktopFiles(dirPath) # .get_pixbuf()
|
image = self.iconFactory.parseDesktopFiles(dirPath) # .get_pixbuf()
|
||||||
self.addToProgramListView(widget, title, image)
|
self.addToProgramListView(widget, title, image)
|
||||||
|
else:
|
||||||
|
self.addToProgramListViewAsText(widget, title)
|
||||||
|
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
@ -95,9 +98,26 @@ class MainMenuMixin:
|
|||||||
button.show_all()
|
button.show_all()
|
||||||
glib.idle_add(widget.add, (button))
|
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):
|
def executeProgram(self, widget):
|
||||||
"""
|
"""
|
||||||
|
# TODO:
|
||||||
Need to refactor and pull out the sub loop that is used in both cases...
|
Need to refactor and pull out the sub loop that is used in both cases...
|
||||||
"""
|
"""
|
||||||
entry = widget.get_label().strip()
|
entry = widget.get_label().strip()
|
||||||
@ -176,10 +196,22 @@ class MainMenuMixin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
for path in paths:
|
for path in paths:
|
||||||
|
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):
|
for f in listdir(path):
|
||||||
fPath = path + f
|
fPath = path + f
|
||||||
flags = ["mimeinfo.cache", "defaults.list"]
|
if isfile(fPath) and f.endswith(".desktop"):
|
||||||
if not f in flags and isfile(fPath):
|
|
||||||
xdgObj = DesktopEntry(fPath)
|
xdgObj = DesktopEntry(fPath)
|
||||||
|
|
||||||
title = xdgObj.getName()
|
title = xdgObj.getName()
|
||||||
@ -218,8 +250,6 @@ class MainMenuMixin:
|
|||||||
"tryExec": tryExec, "fileName": f,
|
"tryExec": tryExec, "fileName": f,
|
||||||
"filePath": fPath, "icon": icon})
|
"filePath": fPath, "icon": icon})
|
||||||
|
|
||||||
return menuObjs
|
|
||||||
|
|
||||||
|
|
||||||
def getSubgroup(self, query = ""):
|
def getSubgroup(self, query = ""):
|
||||||
"""
|
"""
|
||||||
|
@ -90,7 +90,6 @@ class Icon:
|
|||||||
print( repr(e) )
|
print( repr(e) )
|
||||||
return gtk.Image.new_from_file(self.INTERNAL_ICON_PTH)
|
return gtk.Image.new_from_file(self.INTERNAL_ICON_PTH)
|
||||||
|
|
||||||
|
|
||||||
def parseDesktopFiles(self, fullPath):
|
def parseDesktopFiles(self, fullPath):
|
||||||
try:
|
try:
|
||||||
xdgObj = DesktopEntry(fullPath)
|
xdgObj = DesktopEntry(fullPath)
|
||||||
@ -117,12 +116,12 @@ class Icon:
|
|||||||
proc = subprocess.Popen(["wget", "-O", hashImgPth, imageLink])
|
proc = subprocess.Popen(["wget", "-O", hashImgPth, imageLink])
|
||||||
proc.wait()
|
proc.wait()
|
||||||
|
|
||||||
# Use video sizes since headers are bigger
|
# Use video thumbnail sizes since headers are bigger
|
||||||
return self.createScaledImage(hashImgPth, self.viIconWH)
|
return self.createScaledImage(hashImgPth, self.viIconWH)
|
||||||
elif os.path.exists(icon):
|
elif os.path.exists(icon):
|
||||||
return self.createScaledImage(icon, self.systemIconImageWH)
|
return self.createScaledImage(icon, self.systemIconImageWH)
|
||||||
else:
|
else:
|
||||||
iconsDirs = ["/usr/share/pixmaps", self.usrHome + "/.icons", "/usr/share/icons" ,]
|
iconsDirs = ["/usr/share/pixmaps", "/usr/share/icons", self.usrHome + "/.icons" ,]
|
||||||
altIconPath = ""
|
altIconPath = ""
|
||||||
|
|
||||||
for iconsDir in iconsDirs:
|
for iconsDir in iconsDirs:
|
||||||
@ -181,6 +180,18 @@ class Icon:
|
|||||||
print( repr(e) )
|
print( repr(e) )
|
||||||
return None
|
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):
|
def generateVideoThumbnail(self, fullPath, hashImgPth):
|
||||||
proc = None
|
proc = None
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user