Skip to content

Commit

Permalink
Merge branch 'master' into new-book-overview
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende authored Jun 1, 2024
2 parents fe055a7 + 5189bbe commit 0edaf27
Show file tree
Hide file tree
Showing 7 changed files with 428 additions and 631 deletions.
15 changes: 4 additions & 11 deletions cozy/ui/chapter_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __init__(self, chapter: Chapter):
self.duration_label.set_label(seconds_to_str(self.chapter.length))
self.number_label.set_text(str(self.chapter.number))

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

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

Expand All @@ -37,14 +40,4 @@ def set_playing(self, playing):
if 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,),
)
self.play_icon.set_from_icon_name("media-playback-start-symbolic")
29 changes: 5 additions & 24 deletions cozy/ui/widgets/album_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ def __init__(self, book: Book):

self.play_button.connect("clicked", self._on_play_button_press)

# TODO: Just use CSS
#self.progress_drawing_area.connect("realize", lambda w: w.get_window().set_pass_through(True))
# TODO: Use CSS for hover
self.progress_drawing_area.set_draw_func(self._draw_progress)
#self.album_art_drawing_area.set_draw_func(self._draw_album_hover)

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

def set_playing(self, playing: bool):
if playing:
Expand All @@ -61,11 +62,6 @@ def set_hover(self, hover: bool):
def _on_play_button_press(self, _):
self.emit("play-pause-clicked", self._book)

def _draw_album_hover(self, area: Gtk.DrawingArea, context: cairo.Context, *_):
context.rectangle(0, 0, area.get_allocated_width(), area.get_allocated_height())
context.set_source_rgba(1, 1, 1, 0.15)
context.fill()

def _draw_progress(self, area: Gtk.DrawingArea, context: cairo.Context, *_):
width = area.get_allocated_width()
height = area.get_allocated_height()
Expand All @@ -83,20 +79,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,))

self.progress_drawing_area.queue_draw()
19 changes: 9 additions & 10 deletions cozy/ui/widgets/book_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ def _add_event_controllers(self):
motion_event_controller.connect("leave", self._on_cover_leave_notify)
self.container_box.add_controller(motion_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 Down Expand Up @@ -127,13 +136,3 @@ def _on_cover_leave_notify(self, *_):

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
Loading

0 comments on commit 0edaf27

Please sign in to comment.