diff --git a/python/bin/gwinwrap-0-0-1-x64.deb b/python/bin/gwinwrap-0-0-1-x64.deb index 77e583b..2a1d5ec 100644 Binary files a/python/bin/gwinwrap-0-0-1-x64.deb and b/python/bin/gwinwrap-0-0-1-x64.deb differ diff --git a/python/src/debs/build.sh b/python/src/debs/build.sh index 4487624..2568d44 100644 --- a/python/src/debs/build.sh +++ b/python/src/debs/build.sh @@ -10,7 +10,7 @@ function main() { sudo chmod 755 "${i}" done - # Set fxwinwrap permissions + # Set gwinwrap permissions for i in `find . -name gwinwrap`; do sudo chmod 755 "${i}" done @@ -20,8 +20,6 @@ function main() { sudo chmod 755 "${i}" done - sudo chmod 755 gwinwrap*/opt/GWinWrap/resources/bin/* - sudo chown -R root:root ./*/ builder; } diff --git a/python/src/debs/gwinwrap-0-0-1-x64/bin/gwinwrap b/python/src/debs/gwinwrap-0-0-1-x64/bin/gwinwrap index eeb78ae..fe880e0 100755 Binary files a/python/src/debs/gwinwrap-0-0-1-x64/bin/gwinwrap and b/python/src/debs/gwinwrap-0-0-1-x64/bin/gwinwrap differ diff --git a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/GWinWrap.py b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/GWinWrap.py old mode 100644 new mode 100755 index 64d548e..00d553f --- a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/GWinWrap.py +++ b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/GWinWrap.py @@ -46,9 +46,22 @@ class GWinWrap: self.gridLabel = self.builder.get_object("gridLabel") self.stateSaver = SaveState() + self.focusedImg = gtk.Image() + self.usrHome = os.path.expanduser('~') self.xScreenVal = None self.toSavePath = None # Global file path and type for saving to file - self.applyType = 1 # 1 is XWinWrap and 2 is Nitrogen + self.applyType = 1 # 1 is XWinWrap and 2 is Nitrogen + + self.loadProgress = self.builder.get_object("loadProgress") + self.helpLabel = self.builder.get_object("helpLabel") + self.defaultLabel = "Note: Double click an image to view the video or image." + self.savedLabel = "Saved settings..." + self.appliedLabel = "Running xwinwrap..." + self.stoppedLabel = "Stopped xwinwrap..." + # foreground=\"#ffa800\" + # foreground=\"#88cc27\" + # foreground=\"#ff0000\" + # foreground=\"#ff0000\" self.window.show() @@ -66,72 +79,91 @@ class GWinWrap: Thread(target=self.newDir, args=(dir,)).start() def newDir(self, dir): - self.clear() - imageGrid = self.builder.get_object("imageGrid") - path = dir - files = [] - list = [f for f in listdir(path) if isfile(join(path, f))] - row = 0 - col = 0 + imageGrid = self.builder.get_object("imageGrid") + dirPath = dir + list = [f for f in listdir(dirPath) if isfile(join(dirPath, f))] + files = [] + row = 0 + col = 0 for file in list: if file.lower().endswith(('.mkv', '.avi', '.flv', '.mov', '.m4v', '.mpg', '.wmv', '.mpeg', '.mp4', '.webm', '.png', '.jpg', '.jpeg', '.gif')): files.append(file) + + fractionTick = 1.0 / len(files) + tickCount = 0.0 + self.clear() imageGrid.remove_column(0) + self.loadProgress.set_text("Loading...") + self.loadProgress.set_fraction(0.0) + self.helpLabel.set_markup("" + dirPath.strip(self.usrHome) + "") for file in files: - fullPathFile = path + "/" + file + fullPathFile = dirPath + "/" + file eveBox = gtk.EventBox() thumbnl = gtk.Image() if file.lower().endswith(('.mkv', '.avi', '.flv', '.mov', '.m4v', '.mpg', '.wmv', '.mpeg', '.mp4', '.webm')): - subprocess.call(["ffmpegthumbnailer", "-t", "65%", "-s", "300", "-c", "jpg", "-i", fullPathFile, "-o", "/tmp/image.png"]) - thumbnl = self.createImage("/tmp/image.png") - eveBox.connect("button_press_event", self.runMplayerProcess, fullPathFile) + self.generateThumbnail(fullPathFile) + thumbnl = self.createGtkImage("/tmp/image.png", [310, 310]) + eveBox.connect("button_press_event", self.runMplayerProcess, (fullPathFile, file,)) elif file.lower().endswith(('.png', '.jpg', '.jpeg', '.gif')): - thumbnl = self.createImage(fullPathFile) - eveBox.connect("button_press_event", self.runImageViewerProcess, fullPathFile) + thumbnl = self.createGtkImage(fullPathFile, [310, 310]) + eveBox.connect("button_press_event", self.runImageViewerProcess, (fullPathFile, file)) else: print("Not a video or image file.") return gobject.idle_add(self.preGridSetup, (eveBox, thumbnl, )) gobject.idle_add(self.addToGrid, (imageGrid, eveBox, col, row,)) + tickCount = tickCount + fractionTick + self.loadProgress.set_fraction(tickCount) col += 1 if col == 2: col = 0 row += 1 + self.loadProgress.set_text("Finished...") + def preGridSetup(self, args): args[0].show() args[1].show() args[0].add(args[1]) - def createImage(self, arg): - pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( - filename = arg, - width = 310, - height = 310, - preserve_aspect_ratio = True) - return gtk.Image.new_from_pixbuf(pixbuf) - def addToGrid(self, args): args[0].attach(args[1], args[2], args[3], 1, 1) - def runMplayerProcess(self, widget, eve, fullPathFile): + def generateThumbnail(self, fullPathFile): + subprocess.call(["ffmpegthumbnailer", "-t", "65%", "-s", "300", "-c", "jpg", "-i", fullPathFile, "-o", "/tmp/image.png"]) + + def createGtkImage(self, path, wxh): + try: + pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale( + filename = path, + width = wxh[0], + height = wxh[1], + preserve_aspect_ratio = True) + return gtk.Image.new_from_pixbuf(pixbuf) + except Exception as e: + print(e) + return gtk.Image() + + def runMplayerProcess(self, widget, eve, params): if eve.type == gdk.EventType.DOUBLE_BUTTON_PRESS: - subprocess.call(["mplayer", "-really-quiet", "-ao", "null", "-loop", "0", fullPathFile]) + subprocess.call(["mplayer", "-really-quiet", "-ao", "null", "-loop", "0", params[0]]) - self.toSavePath = fullPathFile - self.applyType = 1 # Set to XWinWrap + self.toSavePath = params[0] + self.applyType = 1 + self.helpLabel.set_markup("" + params[1] + "") - def runImageViewerProcess(self, widget, eve, fullPathFile): + def runImageViewerProcess(self, widget, eve, params): if eve.type == gdk.EventType.DOUBLE_BUTTON_PRESS: - subprocess.call(["xdg-open", fullPathFile]) + subprocess.call(["xdg-open", params[0]]) - self.toSavePath = fullPathFile - self.applyType = 2 # Set to Nitrogen + self.toSavePath = params[0] + self.applyType = 2 + self.helpLabel.set_markup("" + params[1] + "") def toggleXscreenUsageField(self, widget, data=None): useXscreenSaver = self.builder.get_object("useXScrnList") @@ -148,6 +180,7 @@ class GWinWrap: resolution = plyBckRes.get_active_text() + offset4Res.get_active_text() self.applyType = self.stateSaver.saveToFile(self.toSavePath, resolution, saveLoc, useXscreenSaver, self.xScreenVal) + self.helpLabel.set_markup(self.savedLabel) def applySttngs(self, widget, data=None): os.system("killall xwinwrap &") @@ -158,10 +191,11 @@ class GWinWrap: os.system("nitrogen --restore &") else: os.system("nitrogen --restore &") - + self.helpLabel.set_markup(self.appliedLabel) def killXWinWrp(self, widget, data=None): os.system("killall xwinwrap &") + self.helpLabel.set_markup(self.stoppedLabel) def passXScreenVal(self, widget): xSvrListStore = self.builder.get_object("XScreensaver List") @@ -183,6 +217,9 @@ class GWinWrap: break imageGrid.attach(self.gridLabel, 0, 0, 1, 1) + self.helpLabel.set_markup(self.defaultLabel) + self.loadProgress.set_text("") + self.loadProgress.set_fraction(0.0) self.toSavePath = None self.applyType = 1 # Default to XWinWrap diff --git a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/resources/GWinWrap.glade b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/resources/GWinWrap.glade index 23c5eb7..1212a5c 100644 --- a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/resources/GWinWrap.glade +++ b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/resources/GWinWrap.glade @@ -244,9 +244,10 @@ False 5 - + True False + 15 Note: Double click an image to view the video or image. @@ -340,6 +341,18 @@ 1 + + + True + False + True + + + False + True + 2 + + True diff --git a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/SaveState.py b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/SaveState.py new file mode 100644 index 0000000..0eac2af --- /dev/null +++ b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/SaveState.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +import os + +class SaveState: + def __init__(self): + self.fileWriter = None + self.filePath = None + self.useXSvrn = None + self.xScreenVal = None + self.sveFileLoc = None + self.resolution = None + + def saveToFile(self, filePath, resolution, + saveLoc, useXSvrn, xScreenVal): + + self.filePath = filePath + self.useXSvrn = useXSvrn + self.xScreenVal = xScreenVal + self.resolution = resolution + userPth = os.path.expanduser('~') + + # Saves to file with selected and needed settings + if filePath: + if filePath.lower().endswith(('.png', '.jpg', '.jpeg', '.gif')): + self.sveFileLoc = userPth + "/" + ".config/nitrogen/bg-saved.cfg" + else: + self.sveFileLoc = userPth + "/" + saveLoc + else: + self.filePath = '' + if self.sveFileLoc: + self.fileWriter = open(self.sveFileLoc, "w") + + return self.startSave() + + def startSave(self): + applyType = 1 + output = None + + # XSCREENSAVER + if self.useXSvrn: + output = "xwinwrap -ov -g " + self.resolution + " -st -sp -b -nf -s -ni -- /usr/lib/xscreensaver/" + self.xScreenVal + " -window-id WID -root"; + # GIF + elif self.filePath.lower().endswith(('.gif')): + output = "xwinwrap -ov -g " + self.resolution + " -st -sp -b -nf -s -ni -- gifview -a -w WID " + self.filePath; + # Standard images using nitrogen + elif self.filePath.lower().endswith(('.png', 'jpg', '.jpeg')): + output = "[xin_0] \n file=" + self.filePath + "\nmode=0 \nbgcolor=#000000\n[xin_1] \nfile=" + self.filePath + "\nmode=0 \nbgcolor=#000000"; + applyType = 2; + # VIDEO + else: + output = "xwinwrap -ov -g " + self.resolution + " -st -sp -b -nf -s -ni -- mplayer -wid WID -really-quiet -ao null -loop 0 " + self.filePath; + pass + + if self.fileWriter: + self.fileWriter.write(output) + self.fileWriter.close() + + return applyType; diff --git a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/SaveState.pyc b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/SaveState.pyc deleted file mode 100644 index 0aa7323..0000000 Binary files a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/SaveState.pyc and /dev/null differ diff --git a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/__init__.py b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/__init__.py new file mode 100644 index 0000000..e0242e1 --- /dev/null +++ b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/__init__.py @@ -0,0 +1 @@ +from utils.SaveState import SaveState diff --git a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/__init__.pyc b/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/__init__.pyc deleted file mode 100644 index ba4d3be..0000000 Binary files a/python/src/debs/gwinwrap-0-0-1-x64/opt/GWinWrap/utils/__init__.pyc and /dev/null differ diff --git a/python/src/versions/0.0.1/gwinwrap_exec_bin.cpp b/python/src/versions/0.0.1/gwinwrap_exec_bin.cpp index 8022fbf..16c77a7 100644 --- a/python/src/versions/0.0.1/gwinwrap_exec_bin.cpp +++ b/python/src/versions/0.0.1/gwinwrap_exec_bin.cpp @@ -5,6 +5,6 @@ using namespace std; int main() { chdir("/opt/GWinWrap/"); - system("python GWinWrap.py"); + system("python3 GWinWrap.py"); return 0; }