Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,14 @@ jobs:
manifest-path: flatpak/com.github.geigi.cozy.json
cache-key: flatpak-builder-${{ matrix.arch }}-${{ github.sha }}
arch: ${{ matrix.arch }}

- name: Create tarball
run: |
mv Cozy.flatpak Cozy-${{ matrix.arch }}.flatpak
tar -czvf Cozy-${{ matrix.arch }}.tar.gz Cozy-${{ matrix.arch }}.flatpak

- name: Upload tarball artifact
uses: actions/upload-artifact@v4
with:
name: Cozy-${{ matrix.arch }}.tar.gz
path: Cozy-${{ matrix.arch }}.tar.gz
1 change: 1 addition & 0 deletions cozy/ui/book_detail_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from cozy.model.chapter import Chapter
from cozy.report import reporter
from cozy.ui.chapter_element import ChapterElement
from cozy.ui.delete_book_view import DeleteBookView
from cozy.ui.toaster import ToastNotifier
from cozy.view_model.book_detail_view_model import BookDetailViewModel

Expand Down
7 changes: 2 additions & 5 deletions cozy/ui/library_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,7 @@ def _jump_to_folder(self, _, book):
FileNotFoundDialog(book.chapters[0]).present()

def _on_remove_book(self, _, book):
if self._view_model.book_files_exist(book):
DeleteBookView(self._on_remove_book_response, book).present()
else:
self._view_model.remove_book(book)
DeleteBookView(self._on_remove_book_response, book).present()

def _on_remove_book_response(self, _, response, book):
if response != "delete":
Expand All @@ -202,7 +199,7 @@ def _on_remove_book_response(self, _, response, book):
delete_from_library = True
delete_files = True # TODO: maybe an option to not delete the files

if delete_files:
if delete_files and self._view_model.book_files_exist(book):
self._view_model.delete_book_files(book)

if delete_from_library:
Expand Down
12 changes: 7 additions & 5 deletions cozy/ui/widgets/book_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class BookCard(Gtk.FlowBoxChild):
artwork: Gtk.Picture = Gtk.Template.Child()
fallback_icon: Gtk.Image = Gtk.Template.Child()
stack: Gtk.Stack = Gtk.Template.Child()
button: Gtk.Stack = Gtk.Template.Child()
button: Gtk.Button = Gtk.Template.Child()
menu_button: Gtk.MenuButton = Gtk.Template.Child()
play_revealer: Gtk.Revealer = Gtk.Template.Child()
menu_revealer: Gtk.Revealer = Gtk.Template.Child()
Expand Down Expand Up @@ -105,9 +105,10 @@ def _install_event_controllers(self):

long_press_gesture = Gtk.GestureLongPress()
long_press_gesture.connect("pressed", self._on_long_tap)
long_press_gesture.set_propagation_phase(Gtk.PropagationPhase.CAPTURE)

self.add_controller(hover_controller)
self.add_controller(long_press_gesture)
self.button.add_controller(long_press_gesture)

def set_playing(self, is_playing):
self.play_button.set_playing(is_playing)
Expand Down Expand Up @@ -150,7 +151,8 @@ def _on_leave(self, *_) -> None:

def _on_long_tap(self, gesture: Gtk.Gesture, *_):
gesture.set_state(Gtk.EventSequenceState.CLAIMED)
self.menu_button.emit("activate")
self.play_revealer.set_reveal_child(True)
self.menu_revealer.set_reveal_child(True)

device = gesture.get_device()
if device and device.get_source() == Gdk.InputSource.TOUCHSCREEN:
self.menu_button.emit("activate")
inject.instance("GtkApp").selected_book = self
28 changes: 21 additions & 7 deletions cozy/view_model/sleep_timer_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_remaining_from_chapter(self) -> float | None:
return 0

position = book.current_chapter.length - (
book.current_chapter.position - book.current_chapter.start_position
book.current_chapter.position - book.current_chapter.start_position
)
return int(position / Gst.SECOND / book.playback_speed)

Expand All @@ -92,12 +92,27 @@ def _start_timer(self):
log.info("Start Sleep Timer")
self._notify("timer_enabled")

# Start a GLib timeout to tick every second
if not hasattr(self, '_glib_timer_id') or self._glib_timer_id is None:
self._glib_timer_id = GLib.timeout_add_seconds(1, self._glib_timer_tick)

def _stop_timer(self):
self._timer_running = False

log.info("Stop Sleep Timer")
self._notify("timer_enabled")

# Remove the GLib timeout if running
if hasattr(self, '_glib_timer_id') and self._glib_timer_id is not None:
GLib.source_remove(self._glib_timer_id)
self._glib_timer_id = None

def _glib_timer_tick(self):
if not self._timer_running:
return False # Stop the timeout
self._on_timer_tick()
return self._timer_running and self._remaining_seconds > 0

def _on_timer_tick(self):
self._remaining_seconds -= 1
self._notify("remaining_seconds")
Expand All @@ -112,10 +127,7 @@ def _on_timer_tick(self):
self._handle_system_power_event()

def _on_player_changed(self, event, _):
if event == "position":
if self._timer_running:
self._on_timer_tick()
elif event == "chapter-changed":
if event == "chapter-changed":
self.stop_after_chapter = False
elif event == "fadeout-finished":
self._handle_system_power_event()
Expand All @@ -129,7 +141,8 @@ def _handle_system_power_event(self):
case _:
return

def _shutdown(self):
@staticmethod
def _shutdown():
inject.instance("MainWindow").quit() # Exit gracefully
if os.getenv("XDG_CURRENT_DESKTOP") == "GNOME":
Gio.bus_get_sync(Gio.BusType.SESSION, None).call_sync(
Expand All @@ -156,7 +169,8 @@ def _shutdown(self):
None,
)

def _suspend(self):
@staticmethod
def _suspend():
Gio.bus_get_sync(Gio.BusType.SYSTEM, None).call_sync(
"org.freedesktop.login1",
"/org/freedesktop/login1",
Expand Down
2 changes: 1 addition & 1 deletion data/ui/book_detail.blp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ menu book_menu_model {

section {
item {
action: 'app.remove_book';
action: 'book_overview.remove_book';
label: _("Delete Permanently…");
}
}
Expand Down
11 changes: 11 additions & 0 deletions peewee-python313.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/playhouse/_sqlite_ext.pyx
+++ b/playhouse/_sqlite_ext.pyx
@@ -326,7 +326,7 @@
cdef python_to_sqlite(sqlite3_context *context, value):
if value is None:
sqlite3_result_null(context)
- elif isinstance(value, (int, long)):
+ elif isinstance(value, int):
sqlite3_result_int64(context, value)
elif isinstance(value, float):
sqlite3_result_double(context, value)