Tweak watched status
This commit is contained in:
parent
6d09b7d1e7
commit
2472f80111
2 changed files with 29 additions and 19 deletions
lazy_player
|
@ -153,6 +153,10 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||||
return
|
return
|
||||||
|
|
||||||
position = file_item.load_attribute("position", 0)
|
position = file_item.load_attribute("position", 0)
|
||||||
|
duration = file_item.load_attribute("duration", 1) or 1
|
||||||
|
|
||||||
|
if (position / duration) >= 0.99:
|
||||||
|
position = 0
|
||||||
|
|
||||||
# Start playing the video
|
# Start playing the video
|
||||||
full_path = os.path.abspath(file_item.full_path)
|
full_path = os.path.abspath(file_item.full_path)
|
||||||
|
@ -235,26 +239,27 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||||
label = cast(Gtk.Label, box.get_last_child())
|
label = cast(Gtk.Label, box.get_last_child())
|
||||||
item = cast(FileItem, list_item.get_item())
|
item = cast(FileItem, list_item.get_item())
|
||||||
|
|
||||||
# Set appropriate icon
|
def update_icon(*args: object) -> None:
|
||||||
icon.set_opacity(1.0)
|
if item.file_type == FileType.DIRECTORY:
|
||||||
if item.file_type == FileType.DIRECTORY:
|
icon.set_from_icon_name("folder-symbolic")
|
||||||
icon.set_from_icon_name("folder-symbolic")
|
icon.set_css_classes(["file-icon"])
|
||||||
icon.set_css_classes(["file-icon"])
|
|
||||||
else:
|
|
||||||
position = item.load_attribute("position", 0)
|
|
||||||
duration = item.load_attribute("duration", 1) or 1
|
|
||||||
|
|
||||||
if position == 0:
|
|
||||||
icon.set_from_icon_name("checkbox-symbolic")
|
|
||||||
icon.set_css_classes(["file-icon", "unwatched"])
|
|
||||||
elif (position / duration) >= 0.9:
|
|
||||||
icon.set_from_icon_name("object-select-symbolic")
|
|
||||||
icon.set_css_classes(["file-icon", "completed"])
|
|
||||||
else:
|
else:
|
||||||
icon.set_from_icon_name("media-playback-pause-symbolic")
|
position = item.load_attribute("position", 0)
|
||||||
icon.set_css_classes(["file-icon", "in-progress"])
|
duration = item.load_attribute("duration", 1) or 1
|
||||||
|
|
||||||
|
if position == 0:
|
||||||
|
icon.set_from_icon_name("media-playback-start-symbolic")
|
||||||
|
icon.set_css_classes(["file-icon", "unwatched"])
|
||||||
|
elif (position / duration) >= 0.99:
|
||||||
|
icon.set_from_icon_name("object-select-symbolic")
|
||||||
|
icon.set_css_classes(["file-icon", "completed"])
|
||||||
|
else:
|
||||||
|
icon.set_from_icon_name("media-playback-pause-symbolic")
|
||||||
|
icon.set_css_classes(["file-icon", "in-progress"])
|
||||||
|
|
||||||
label.set_text(item.name)
|
label.set_text(item.name)
|
||||||
|
item.connect("notify::attrs-changed", update_icon)
|
||||||
|
update_icon()
|
||||||
|
|
||||||
def _on_selection_changed(
|
def _on_selection_changed(
|
||||||
self,
|
self,
|
||||||
|
@ -340,8 +345,8 @@ class MainWindow(Gtk.ApplicationWindow):
|
||||||
position = file_item.load_attribute("position", 0)
|
position = file_item.load_attribute("position", 0)
|
||||||
duration = file_item.load_attribute("duration", 1) or 1
|
duration = file_item.load_attribute("duration", 1) or 1
|
||||||
|
|
||||||
# If position exists and is >= 90% through, clear it
|
# If position exists and is >= 99% through, clear it
|
||||||
if position > 0 and (position / duration) >= 0.9:
|
if position > 0 and (position / duration) >= 0.99:
|
||||||
file_item.save_attribute("position", None)
|
file_item.save_attribute("position", None)
|
||||||
else:
|
else:
|
||||||
# Otherwise mark as complete
|
# Otherwise mark as complete
|
||||||
|
|
|
@ -21,8 +21,11 @@ class FileItem(GObject.Object):
|
||||||
|
|
||||||
__gtype_name__ = "FileItem"
|
__gtype_name__ = "FileItem"
|
||||||
|
|
||||||
|
attrs_changed = GObject.Property(type=int, default=0)
|
||||||
|
|
||||||
def __init__(self, name: str, file_type: FileType, full_path: str):
|
def __init__(self, name: str, file_type: FileType, full_path: str):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.attrs_changed = 0
|
||||||
self.name = name
|
self.name = name
|
||||||
self.file_type = file_type
|
self.file_type = file_type
|
||||||
self.full_path = full_path
|
self.full_path = full_path
|
||||||
|
@ -62,3 +65,5 @@ class FileItem(GObject.Object):
|
||||||
os.setxattr(self.full_path, f"user.lazy_player.{name}", str(value).encode("utf8"))
|
os.setxattr(self.full_path, f"user.lazy_player.{name}", str(value).encode("utf8"))
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
self.notify("attrs-changed")
|
||||||
|
|
Loading…
Reference in a new issue