develop #1
@@ -62,5 +62,5 @@ class Builtins(DBusControllerMixin):
 | 
			
		||||
# NOTE: Just reminding myself we can add to builtins two different ways...
 | 
			
		||||
# __builtins__.update({"event_system": Builtins()})
 | 
			
		||||
builtins.event_system      = Builtins()
 | 
			
		||||
builtins.event_sleep_time  = 0.5
 | 
			
		||||
builtins.event_sleep_time  = 0.2
 | 
			
		||||
builtins.debug             = False
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ from __builtins__ import Builtins
 | 
			
		||||
class Main(Builtins):
 | 
			
		||||
    def __init__(self, args, unknownargs):
 | 
			
		||||
        event_system.create_ipc_server()
 | 
			
		||||
        time.sleep(0.5)
 | 
			
		||||
        time.sleep(0.2)
 | 
			
		||||
        if not event_system.is_ipc_alive:
 | 
			
		||||
            if unknownargs:
 | 
			
		||||
                for arg in unknownargs:
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ def threaded(fn):
 | 
			
		||||
 | 
			
		||||
class Icon(DesktopIconMixin, VideoIconMixin):
 | 
			
		||||
    def create_icon(self, dir, file):
 | 
			
		||||
        full_path = dir + "/" + file
 | 
			
		||||
        full_path = f"{dir}/{file}"
 | 
			
		||||
        return self.get_icon_image(dir, file, full_path)
 | 
			
		||||
 | 
			
		||||
    def get_icon_image(self, dir, file, full_path):
 | 
			
		||||
@@ -36,29 +36,27 @@ class Icon(DesktopIconMixin, VideoIconMixin):
 | 
			
		||||
            return None
 | 
			
		||||
 | 
			
		||||
    def create_thumbnail(self, dir, file):
 | 
			
		||||
        full_path = dir + "/" + file
 | 
			
		||||
        full_path = f"{dir}/{file}"
 | 
			
		||||
        try:
 | 
			
		||||
            file_hash    = hashlib.sha256(str.encode(full_path)).hexdigest()
 | 
			
		||||
            hash_img_pth = self.ABS_THUMBS_PTH + "/" + file_hash + ".jpg"
 | 
			
		||||
            hash_img_pth = f"{self.ABS_THUMBS_PTH}/{file_hash}.jpg"
 | 
			
		||||
            if isfile(hash_img_pth) == False:
 | 
			
		||||
                self.generate_video_thumbnail(full_path, hash_img_pth)
 | 
			
		||||
 | 
			
		||||
            thumbnl = self.create_scaled_image(hash_img_pth, self.VIDEO_ICON_WH)
 | 
			
		||||
            if thumbnl == None: # If no icon whatsoever, return internal default
 | 
			
		||||
                thumbnl = GdkPixbuf.Pixbuf.new_from_file(self.DEFAULT_ICONS + "/video.png")
 | 
			
		||||
                thumbnl = GdkPixbuf.Pixbuf.new_from_file(f"{self.DEFAULT_ICONS}/video.png")
 | 
			
		||||
 | 
			
		||||
            return thumbnl
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            print("Thumbnail generation issue:")
 | 
			
		||||
            print( repr(e) )
 | 
			
		||||
            return GdkPixbuf.Pixbuf.new_from_file(self.DEFAULT_ICONS + "/video.png")
 | 
			
		||||
            return GdkPixbuf.Pixbuf.new_from_file(f"{self.DEFAULT_ICONS}/video.png")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def create_scaled_image(self, path, wxh):
 | 
			
		||||
        try:
 | 
			
		||||
            pixbuf        = GdkPixbuf.Pixbuf.new_from_file(path)
 | 
			
		||||
            scaled_pixbuf = pixbuf.scale_simple(wxh[0], wxh[1], 2)  # 2 = BILINEAR and is best by default
 | 
			
		||||
            return scaled_pixbuf
 | 
			
		||||
             return GdkPixbuf.Pixbuf.new_from_file_at_scale(path, wxh[0], wxh[1], True)
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            print("Image Scaling Issue:")
 | 
			
		||||
            print( repr(e) )
 | 
			
		||||
 
 | 
			
		||||
@@ -107,7 +107,7 @@ class WidgetFileActionMixin:
 | 
			
		||||
    def open_with_files(self, appchooser_widget):
 | 
			
		||||
        wid, tid, view, iconview, store = self.get_current_state()
 | 
			
		||||
        app_info  = appchooser_widget.get_app_info()
 | 
			
		||||
        uris      = self.format_to_uris(store, wid, tid, self.selected_files, True)
 | 
			
		||||
        uris      = self.format_to_uris(store, wid, tid, self.selected_files)
 | 
			
		||||
 | 
			
		||||
        view.app_chooser_exec(app_info, uris)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,5 +1,5 @@
 | 
			
		||||
# Python imports
 | 
			
		||||
import os, threading, subprocess
 | 
			
		||||
import os, threading, subprocess, time
 | 
			
		||||
 | 
			
		||||
# Lib imports
 | 
			
		||||
import gi
 | 
			
		||||
@@ -20,15 +20,13 @@ def threaded(fn):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class WidgetMixin:
 | 
			
		||||
 | 
			
		||||
    def load_store(self, view, store, save_state=False):
 | 
			
		||||
        store.clear()
 | 
			
		||||
        dir   = view.get_current_directory()
 | 
			
		||||
        files = view.get_files()
 | 
			
		||||
 | 
			
		||||
        icon = GdkPixbuf.Pixbuf.new_from_file(view.DEFAULT_ICON)
 | 
			
		||||
        for i, file in enumerate(files):
 | 
			
		||||
            store.append([icon, file[0]])
 | 
			
		||||
            store.append([None, file[0]])
 | 
			
		||||
            self.create_icon(i, view, store, dir, file[0])
 | 
			
		||||
 | 
			
		||||
        # NOTE: Not likely called often from here but it could be useful
 | 
			
		||||
@@ -49,6 +47,10 @@ class WidgetMixin:
 | 
			
		||||
 | 
			
		||||
        try:
 | 
			
		||||
            itr = store.get_iter(i)
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            try:
 | 
			
		||||
                time.sleep(0.2)
 | 
			
		||||
                itr = store.get_iter(i)
 | 
			
		||||
            except Exception as e:
 | 
			
		||||
                print(":Invalid Itr detected: (Potential race condition...)")
 | 
			
		||||
                print(f"Index Requested:  {i}")
 | 
			
		||||
@@ -113,7 +115,7 @@ class WidgetMixin:
 | 
			
		||||
    def create_grid_iconview_widget(self, view, wid):
 | 
			
		||||
        scroll = Gtk.ScrolledWindow()
 | 
			
		||||
        grid   = Gtk.IconView()
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf or None, str)
 | 
			
		||||
 | 
			
		||||
        grid.set_model(store)
 | 
			
		||||
        grid.set_pixbuf_column(0)
 | 
			
		||||
@@ -154,8 +156,8 @@ class WidgetMixin:
 | 
			
		||||
    def create_grid_treeview_widget(self, view, wid):
 | 
			
		||||
        scroll = Gtk.ScrolledWindow()
 | 
			
		||||
        grid   = Gtk.TreeView()
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
 | 
			
		||||
        # store  = Gtk.TreeStore(GdkPixbuf.Pixbuf, str)
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf or None, str)
 | 
			
		||||
        # store  = Gtk.TreeStore(GdkPixbuf.Pixbuf or None, str)
 | 
			
		||||
        column = Gtk.TreeViewColumn("Icons")
 | 
			
		||||
        icon   = Gtk.CellRendererPixbuf()
 | 
			
		||||
        name   = Gtk.CellRendererText()
 | 
			
		||||
 
 | 
			
		||||
@@ -62,5 +62,5 @@ class Builtins(DBusControllerMixin):
 | 
			
		||||
# NOTE: Just reminding myself we can add to builtins two different ways...
 | 
			
		||||
# __builtins__.update({"event_system": Builtins()})
 | 
			
		||||
builtins.event_system      = Builtins()
 | 
			
		||||
builtins.event_sleep_time  = 0.5
 | 
			
		||||
builtins.event_sleep_time  = 0.2
 | 
			
		||||
builtins.debug             = False
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ from __builtins__ import Builtins
 | 
			
		||||
class Main(Builtins):
 | 
			
		||||
    def __init__(self, args, unknownargs):
 | 
			
		||||
        event_system.create_ipc_server()
 | 
			
		||||
        time.sleep(0.5)
 | 
			
		||||
        time.sleep(0.2)
 | 
			
		||||
        if not event_system.is_ipc_alive:
 | 
			
		||||
            if unknownargs:
 | 
			
		||||
                for arg in unknownargs:
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ def threaded(fn):
 | 
			
		||||
 | 
			
		||||
class Icon(DesktopIconMixin, VideoIconMixin):
 | 
			
		||||
    def create_icon(self, dir, file):
 | 
			
		||||
        full_path = dir + "/" + file
 | 
			
		||||
        full_path = f"{dir}/{file}"
 | 
			
		||||
        return self.get_icon_image(dir, file, full_path)
 | 
			
		||||
 | 
			
		||||
    def get_icon_image(self, dir, file, full_path):
 | 
			
		||||
@@ -36,22 +36,22 @@ class Icon(DesktopIconMixin, VideoIconMixin):
 | 
			
		||||
            return None
 | 
			
		||||
 | 
			
		||||
    def create_thumbnail(self, dir, file):
 | 
			
		||||
        full_path = dir + "/" + file
 | 
			
		||||
        full_path = f"{dir}/{file}"
 | 
			
		||||
        try:
 | 
			
		||||
            file_hash    = hashlib.sha256(str.encode(full_path)).hexdigest()
 | 
			
		||||
            hash_img_pth = self.ABS_THUMBS_PTH + "/" + file_hash + ".jpg"
 | 
			
		||||
            hash_img_pth = f"{self.ABS_THUMBS_PTH}/{file_hash}.jpg"
 | 
			
		||||
            if isfile(hash_img_pth) == False:
 | 
			
		||||
                self.generate_video_thumbnail(full_path, hash_img_pth)
 | 
			
		||||
 | 
			
		||||
            thumbnl = self.create_scaled_image(hash_img_pth, self.VIDEO_ICON_WH)
 | 
			
		||||
            if thumbnl == None: # If no icon whatsoever, return internal default
 | 
			
		||||
                thumbnl = GdkPixbuf.Pixbuf.new_from_file(self.DEFAULT_ICONS + "/video.png")
 | 
			
		||||
                thumbnl = GdkPixbuf.Pixbuf.new_from_file(f"{self.DEFAULT_ICONS}/video.png")
 | 
			
		||||
 | 
			
		||||
            return thumbnl
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            print("Thumbnail generation issue:")
 | 
			
		||||
            print( repr(e) )
 | 
			
		||||
            return GdkPixbuf.Pixbuf.new_from_file(self.DEFAULT_ICONS + "/video.png")
 | 
			
		||||
            return GdkPixbuf.Pixbuf.new_from_file(f"{self.DEFAULT_ICONS}/video.png")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def create_scaled_image(self, path, wxh):
 | 
			
		||||
 
 | 
			
		||||
@@ -20,15 +20,13 @@ def threaded(fn):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class WidgetMixin:
 | 
			
		||||
 | 
			
		||||
    def load_store(self, view, store, save_state=False):
 | 
			
		||||
        store.clear()
 | 
			
		||||
        dir   = view.get_current_directory()
 | 
			
		||||
        files = view.get_files()
 | 
			
		||||
 | 
			
		||||
        icon = GdkPixbuf.Pixbuf()
 | 
			
		||||
        for i, file in enumerate(files):
 | 
			
		||||
            store.append([icon, file[0]])
 | 
			
		||||
            store.append([None, file[0]])
 | 
			
		||||
            self.create_icon(i, view, store, dir, file[0])
 | 
			
		||||
 | 
			
		||||
        # NOTE: Not likely called often from here but it could be useful
 | 
			
		||||
@@ -117,7 +115,7 @@ class WidgetMixin:
 | 
			
		||||
    def create_grid_iconview_widget(self, view, wid):
 | 
			
		||||
        scroll = Gtk.ScrolledWindow()
 | 
			
		||||
        grid   = Gtk.IconView()
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf or None, str)
 | 
			
		||||
 | 
			
		||||
        grid.set_model(store)
 | 
			
		||||
        grid.set_pixbuf_column(0)
 | 
			
		||||
@@ -158,8 +156,8 @@ class WidgetMixin:
 | 
			
		||||
    def create_grid_treeview_widget(self, view, wid):
 | 
			
		||||
        scroll = Gtk.ScrolledWindow()
 | 
			
		||||
        grid   = Gtk.TreeView()
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf, str)
 | 
			
		||||
        # store  = Gtk.TreeStore(GdkPixbuf.Pixbuf, str)
 | 
			
		||||
        store  = Gtk.ListStore(GdkPixbuf.Pixbuf or None, str)
 | 
			
		||||
        # store  = Gtk.TreeStore(GdkPixbuf.Pixbuf or None, str)
 | 
			
		||||
        column = Gtk.TreeViewColumn("Icons")
 | 
			
		||||
        icon   = Gtk.CellRendererPixbuf()
 | 
			
		||||
        name   = Gtk.CellRendererText()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user