Skip to content

Commit

Permalink
Merge branch 'master' into new-book-card
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende authored Jun 1, 2024
2 parents 7a9899e + 477c0f6 commit 6007598
Show file tree
Hide file tree
Showing 13 changed files with 437 additions and 628 deletions.
8 changes: 3 additions & 5 deletions cozy/ui/chapter_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def __init__(self, chapter: Chapter):
self.title_label.set_text(self.chapter.name)
self.duration_label.set_text(seconds_to_str(self.chapter.length))

@GObject.Signal(arg_types=(object,))
def play_pause_clicked(self, *_): ...

def _on_button_press(self, *_):
self.emit("play-pause-clicked", self.chapter)

Expand Down Expand Up @@ -63,8 +66,3 @@ def set_playing(self, playing):
self.play_icon.set_from_icon_name("media-playback-pause-symbolic")
else:
self.play_icon.set_from_icon_name("media-playback-start-symbolic")


GObject.type_register(ChapterElement)
GObject.signal_new('play-pause-clicked', ChapterElement, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,))
6 changes: 3 additions & 3 deletions cozy/ui/delete_book_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class DeleteBookView(Adw.AlertDialog):

def __init__(self, callback, book: Book):
super().__init__(
heading=_("Delete Audiobook?"),
body=_("The audiobook will be removed from your disk and from Cozy's library."),
heading=_("Permanently Delete Audiobook?"),
body=_("The audiobook will be permanently deleted from your device and cannot be recovered"),
default_response="cancel",
close_response="cancel",
)

self.add_response("cancel", _("Cancel"))
self.add_response("delete", _("Remove Audiobook"))
self.add_response("delete", _("Delete"))
self.set_response_appearance("delete", Adw.ResponseAppearance.DESTRUCTIVE)

list_box = Gtk.ListBox(margin_top=12, css_classes=["boxed-list"])
Expand Down
2 changes: 1 addition & 1 deletion cozy/ui/file_not_found_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, chapter: Chapter):
self.missing_chapter = chapter

super().__init__(
heading=_("File not found"),
heading=_("File Not Found"),
body=_("This file could not be found. Do you want to locate it manually?"),
default_response="locate",
close_response="cancel",
Expand Down
18 changes: 3 additions & 15 deletions cozy/ui/widgets/album_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ def __init__(self, book: Book):
self.book_icon.set_from_icon_name("book-open-variant-symbolic")
self.stack.set_visible_child(self.book_icon)


self.play_button.connect("clicked", self._on_play_button_press)
self.progress_drawing_area.set_draw_func(self._draw_progress)

@GObject.Signal(arg_types=(object,))
def play_pause_clicked(self, *_): ...

def set_playing(self, playing: bool):
if playing:
self.play_button.set_icon_name("media-playback-pause-symbolic")
Expand All @@ -72,19 +74,5 @@ def _draw_progress(self, area: Gtk.DrawingArea, context: cairo.Context, *_):
context.set_line_width(STROKE_WIDTH)
context.stroke()

def draw_background(self, area: Gtk.DrawingArea, context: cairo.Context):
width = area.get_allocated_width()
height = area.get_allocated_height()

context.arc(width / 2.0, height / 2.0, self.radius, 0, math.pi * 2.0)
context.set_source_rgba(0, 0, 0, 1.0)
context.set_line_width(2)
context.stroke()

def update_progress(self):
self.progress_drawing_area.queue_draw()


GObject.type_register(AlbumElement)
GObject.signal_new('play-pause-clicked', AlbumElement, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,))
25 changes: 12 additions & 13 deletions cozy/ui/widgets/book_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ def _add_event_controllers(self):
key_event_controller.connect("key-pressed", self._on_key_press_event)
self.container_box.add_controller(key_event_controller)

@GObject.Signal(arg_types=(object,))
def play_pause_clicked(self, *_): ...

@GObject.Signal(arg_types=(object,))
def open_book_overview(self, *_): ...

@GObject.Signal(arg_types=(object,))
def book_removed(self, *_): ...

def set_playing(self, is_playing):
self.art.set_playing(is_playing)

Expand All @@ -62,13 +71,13 @@ def _create_context_menu(self):
menu_model = Gio.Menu()

self.install_action("book_element.mark_as_read", None, self._mark_as_read)
menu_model.append(_("Mark as read"), "book_element.mark_as_read")
menu_model.append(_("Mark as Read"), "book_element.mark_as_read")

self.install_action("book_element.jump_to_folder", None, self._jump_to_folder)
menu_model.append(_("Open in file browser"), "book_element.jump_to_folder")
menu_model.append(_("Open in File Browser"), "book_element.jump_to_folder")

self.install_action("book_element.remove_book", None, self._remove_book)
menu_model.append(_("Remove from library"), "book_element.remove_book")
menu_model.append(_("Permanently Delete…"), "book_element.remove_book")

menu = Gtk.PopoverMenu(menu_model=menu_model, has_arrow=False)
menu.set_parent(self.art)
Expand Down Expand Up @@ -116,13 +125,3 @@ def _on_key_press_event(self, keyval, *_):

def _on_album_art_press_event(self, *_):
self.emit("play-pause-clicked", self.book)


GObject.type_register(BookElement)
GObject.signal_new('play-pause-clicked', BookElement, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,))
GObject.signal_new('open-book-overview', BookElement, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,))
GObject.signal_new('book-removed', BookElement, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,))

16 changes: 9 additions & 7 deletions cozy/ui/widgets/seek_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ def __init__(self, **kwargs):
keyboard_controller.connect("key-pressed", self._on_progress_key_pressed)
self.progress_scale.add_controller(keyboard_controller)

@GObject.Signal(arg_types=(object,))
def position_changed(self, *_): ...

@GObject.Signal
def rewind(self): ...

@GObject.Signal
def forward(self): ...

@property
def position(self) -> float:
return self.progress_scale.get_value()
Expand Down Expand Up @@ -89,10 +98,3 @@ def _on_progress_key_pressed(self, _, event, *__):

def _on_progress_scale_press(self, *_):
self._progress_scale_pressed = True


GObject.signal_new('position-changed', SeekBar, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,))

GObject.signal_new('rewind', SeekBar, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, ())
GObject.signal_new('forward', SeekBar, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, ())
16 changes: 6 additions & 10 deletions cozy/ui/widgets/storages.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def __init__(self, model: Storage, menu_model: Gio.Menu) -> None:
self._set_default_icon()
self._set_drive_icon()

@GObject.Signal(arg_types=(object,))
def location_changed(self, *_): ...

@GObject.Signal
def menu_opened(self): ...

@property
def model(self) -> Storage:
return self._model
Expand All @@ -71,16 +77,6 @@ def _set_default_icon(self) -> None:
self.default_icon.set_visible(self._model.default)


GObject.signal_new(
"location-changed",
StorageRow,
GObject.SIGNAL_RUN_LAST,
GObject.TYPE_PYOBJECT,
(GObject.TYPE_PYOBJECT,),
)
GObject.signal_new("menu-opened", StorageRow, GObject.SIGNAL_RUN_LAST, GObject.TYPE_PYOBJECT, ())


@Gtk.Template.from_resource("/com/github/geigi/cozy/ui/storage_locations.ui")
class StorageLocations(Adw.PreferencesGroup):
__gtype_name__ = "StorageLocations"
Expand Down
2 changes: 1 addition & 1 deletion data/com.github.geigi.cozy.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<component type="desktop">
<id>com.github.geigi.cozy</id>
<name translate="no">Cozy</name>
<metadata_license>CC0</metadata_license>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0+</project_license>
<launchable type="desktop-id">com.github.geigi.cozy.desktop</launchable>
<translation type="gettext">com.github.geigi.cozy</translation>
Expand Down
2 changes: 1 addition & 1 deletion data/ui/main_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Adw.ApplicationWindow app_window {
}

Adw.NavigationPage {
title: _("Book title");
title: _("Book Title");
tag: 'book_overview';

child: Adw.ToolbarView book_details_container {};
Expand Down
2 changes: 1 addition & 1 deletion data/ui/preferences.blp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ template $PreferencesWindow: Adw.PreferencesDialog {
title: _("Feedback");

Adw.PreferencesGroup user_feedback_preference_group {
title: _("User feedback");
title: _("User Feedback");
}
}
}
4 changes: 2 additions & 2 deletions data/ui/search_page.blp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ using Adw 1;
template $SearchView: Adw.Bin {
Stack stack {
Adw.StatusPage start_searching_page {
title: _("Search in your library");
title: _("Search in Your Library");
icon-name: 'library-symbolic';
}

Adw.StatusPage nothing_found_page {
title: _("No results found");
title: _("No Results Found");
icon-name: 'edit-find-symbolic';
}

Expand Down
2 changes: 1 addition & 1 deletion data/ui/storage_locations.blp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Gtk 4.0;
using Adw 1;

template $StorageLocations: Adw.PreferencesGroup {
title: _("Storage locations");
title: _("Storage Locations");

ListBox storage_locations_list {
margin-bottom: 18;
Expand Down
Loading

0 comments on commit 6007598

Please sign in to comment.