Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to GTK 4 #799

Merged
merged 104 commits into from
Dec 3, 2023
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
4bb6f82
wip: port to gtk4
geigi Apr 24, 2022
3623313
wip: port to gtk4
geigi Apr 24, 2022
2a8f215
fix chapter and disk elements
geigi Apr 24, 2022
a4b2f7f
wip
geigi May 1, 2022
9c28f3f
wip
geigi May 1, 2022
c6933f0
wip
geigi Aug 9, 2022
d8df91a
fix: filter navigation
geigi Aug 21, 2022
88e5cdb
Update runtime version to 45
rdbende Nov 11, 2023
2d238ac
Update to AdwAboutWindow
rdbende Nov 11, 2023
614cd04
Remove help menu item
rdbende Nov 11, 2023
d1506ed
Add icon directly to the titlebar buttons
rdbende Nov 11, 2023
9b80847
Update whats_new.ui to GTK4
rdbende Nov 11, 2023
bb94142
Progress with porting to libadwaita 1.4 widgets
rdbende Nov 11, 2023
6aea48e
Let's remove libdazzle and libhandy
rdbende Nov 11, 2023
a411c35
I said remove libdazzle
rdbende Nov 12, 2023
b3a923a
Get rid of AdwLeaflet, make navigation actually work
rdbende Nov 12, 2023
1dd93c9
Cleanup stacks
rdbende Nov 12, 2023
81ee4fe
Add sidebar toggle button and breakpoint
rdbende Nov 12, 2023
01c83ab
Switch to AdwStatusPage in most places
rdbende Nov 12, 2023
da8e440
Maybe this way?
rdbende Nov 12, 2023
3a0efdf
Fix filedialog issue
rdbende Nov 12, 2023
b99e212
Update enum name
rdbende Nov 12, 2023
9fbe8e8
Remove newlines and indentation from strings
rdbende Nov 12, 2023
4afc7a0
Modernize book element
rdbende Nov 12, 2023
f7770df
Work on preferences
rdbende Nov 12, 2023
bd73281
Partially fix seek bar
rdbende Nov 12, 2023
8f84e5d
Remove context menu for now
rdbende Nov 14, 2023
82b4344
Add HeaderBar to the Stay tuned page
rdbende Nov 14, 2023
accce25
Make search partially work
rdbende Nov 14, 2023
b570c62
Fix right click menu and deletion confirmation dialog
rdbende Nov 14, 2023
fed89df
Then all this is unnecessary
rdbende Nov 14, 2023
f903c34
Fix a bug and a warning, remove some redundant code
rdbende Nov 15, 2023
f55f187
Fix/rewrite database migration dialog
rdbende Nov 15, 2023
597e501
No duplicated pages in navigation
rdbende Nov 18, 2023
311a92b
Use AdwStatusPage in yet another place
rdbende Nov 18, 2023
85dcbca
Use AdwBreakpoints instead of AdwSqueezer
rdbende Nov 18, 2023
559d0c7
Fix dark mode
rdbende Nov 18, 2023
fc26c88
Fix search popover
rdbende Nov 18, 2023
eb063b8
Modernize a couple of UI files, delete Glade catalog files
rdbende Nov 18, 2023
df90494
Further improve the UI files
rdbende Nov 18, 2023
61d5e56
Rework back navigation
rdbende Nov 18, 2023
4054eed
Some improvements around imports
rdbende Nov 18, 2023
6cec4e5
Clean up navigation logic
rdbende Nov 18, 2023
a3475c2
Added longpress support so that touchscreens can get context menu
Nov 12, 2023
199a686
Disable selecting a boot_element for now, it causes lots of things to
Aug 13, 2023
c69056f
Use a GtkSpinner as progress indicator for now
Oct 29, 2023
ce7c44d
Use flat button style for scan progress button
rdbende Nov 18, 2023
652f073
Use GtkFileDialog for storage selector
rdbende Nov 18, 2023
ae1861c
Delete obsolete ScrollWrapper widget
rdbende Nov 18, 2023
a9c6ff2
Let's get rid of unwanted dependencies and side effects
rdbende Nov 19, 2023
2dc879e
Merge headerbar and primary menu UI files and remove corresponding ob…
rdbende Nov 19, 2023
4b79241
Remove obsolete back navigation code
rdbende Nov 19, 2023
617350c
Remove Gtk version checks, fix dynamic popover size
rdbende Nov 19, 2023
ef3fe01
Remove more obsolete code
rdbende Nov 19, 2023
0489cff
Fix album art border radius, plus other nice things
rdbende Nov 19, 2023
a6fe0cc
Use libadwaita stles for mini player
rdbende Nov 19, 2023
16b659a
Fix list not displaying when error reporting is loaded
rdbende Nov 19, 2023
fd34682
Bit bigger media controller elements, and icons
rdbende Nov 19, 2023
73f0c33
Set window title for book overview page
rdbende Nov 19, 2023
13561ea
Properly switch between desktop and mobile view switchers
rdbende Nov 19, 2023
f10cdce
Fix little view model sync bug
rdbende Nov 19, 2023
26fc2e1
Hide sidebar button on recents page
rdbende Nov 19, 2023
bf00a17
Reduce huge margins on filter listbox rows
rdbende Nov 19, 2023
bd15443
This is already fixed
rdbende Nov 19, 2023
29d37c5
Simplify DiekElement implementation
rdbende Nov 19, 2023
867af76
GtkStyleContext is deprecated
rdbende Nov 20, 2023
56fb023
Use a GdkPaintable for artworks
rdbende Nov 20, 2023
bb58fdb
GtkVolumeButton is deprecated
rdbende Nov 20, 2023
f664076
Some more GTK 4 modernizations in UI files
rdbende Nov 20, 2023
8aef99e
Modernize file not found dialog
rdbende Nov 20, 2023
a3bebec
i would like to refactor this dialog to use a listbox instead, becaus…
rdbende Nov 20, 2023
ac20102
Merge master
rdbende Nov 20, 2023
d687d91
Fix problems reported by codeclimate and fix a bug
rdbende Nov 20, 2023
9767d9d
I know, bandit
rdbende Nov 20, 2023
82c93eb
Fixd
rdbende Nov 20, 2023
9e04eb3
Work things around :)
rdbende Nov 20, 2023
628aafd
make it clear which book is going to be deleted
rdbende Nov 20, 2023
a1b25db
Fix a bug introduced by caching the menu
rdbende Nov 20, 2023
73ff165
Fix attribute error when book_element is None
rdbende Nov 22, 2023
04ae65b
Add window title on mobile
rdbende Nov 22, 2023
4363bdb
Fix mouse click on book element play button
rdbende Nov 23, 2023
038fe25
Use newer playback icons, that don't differ in size
rdbende Nov 24, 2023
9df9c9d
Though the icon was too big and misaligned
rdbende Nov 24, 2023
1b2b6e8
Fix right click menu for now
rdbende Nov 24, 2023
228c839
Update package versions here and there
rdbende Nov 25, 2023
daf5aa0
Make dropping files work
rdbende Nov 26, 2023
2f8d1ac
Use AdwToast instead of infobanner
rdbende Nov 26, 2023
9133e2c
Forgot to add this new icon
rdbende Nov 26, 2023
53b18e8
Fix two bugs with external storage
rdbende Nov 26, 2023
a0762dd
Simplify this a little bit
rdbende Nov 27, 2023
812d20e
Fix mistake with gettext
rdbende Nov 27, 2023
2ee7c9c
No, it looks like it's not needed
rdbende Nov 27, 2023
5c4f42b
Update comment
rdbende Nov 27, 2023
b235607
Remove unneded code
rdbende Nov 27, 2023
d4a6061
Add myself to about dialog
rdbende Nov 27, 2023
f52e743
AdwApplication can load style.css automatically
rdbende Nov 29, 2023
9f8d640
Remove unnecessary require_version calls
rdbende Nov 29, 2023
577fe24
Remove unused warning popover
rdbende Nov 29, 2023
609ab8e
I guess with this I fixed one of Codeclimate's problem
rdbende Nov 29, 2023
6915ed2
Fix warnings in tests
rdbende Nov 29, 2023
ba78a05
readme: Update support link
rdbende Nov 29, 2023
70de1ee
Merge branch 'master' into gtk4
rdbende Dec 3, 2023
0ac1939
Merge branch 'gtk4' of github.com:rdbende/cozy into gtk4
rdbende Dec 3, 2023
1e6d0b6
Fix type annotations
rdbende Dec 3, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ venv/
*.log
*.prof
*.pyc

.DS_Store
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ See [DEVELOPMENT.md](DEVELOPMENT.md) for detailed instructions and developing Co
## Requirements
- `python3`
- `meson >= 0.40.0` as build system
- `gtk3 >= 3.22`
- `libhandy >= 1.0.0`
- `libdazzle >= 3.34.0`
- `gtk4 >= 4.10`
- `libadwaita >= 1.4.0`
- `peewee >= 3.9.6` as object relation mapper
- `mutagen` for meta tag management
- `distro`
Expand Down Expand Up @@ -165,6 +164,7 @@ To the contributors on GitHub:
- paper42
- phpwutz
- rapenne-s
- rdbende
rdbende marked this conversation as resolved.
Show resolved Hide resolved
- thibaultamartin
- umeboshi2
- worldofpeace
Expand Down Expand Up @@ -277,9 +277,9 @@ The translators:
To nedrichards for the Flatpak.

## Help me translate cozy!
Cozy is on <a href="https://www.transifex.com/geigi/cozy/"> Transifex</a>, where anyone can contribute and translate. Can't find your language in the list? Let me know!
Cozy is on <a href="https://www.transifex.com/geigi/cozy/">Transifex</a>, where anyone can contribute and translate. Can't find your language in the list? Let me know!

If you like this project, consider supporting me on <a href="https://www.patreon.com/bePatron?u=8147127"> Patreon</a> :)
If you like this project, consider supporting me on <a href="https://www.patreon.com/bePatron?u=8147127">Patreon</a> :)
rdbende marked this conversation as resolved.
Show resolved Hide resolved

----
[![Maintainability](https://api.codeclimate.com/v1/badges/fde8cbdff23033adaca2/maintainability)](https://codeclimate.com/github/geigi/cozy/maintainability)
35 changes: 2 additions & 33 deletions com.github.geigi.cozy.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.github.geigi.cozy",
"runtime": "org.gnome.Platform",
"runtime-version": "42",
"runtime-version": "45",
"sdk": "org.gnome.Sdk",
"command": "com.github.geigi.cozy",
"finish-args": [
Expand Down Expand Up @@ -130,37 +130,6 @@
}
]
},
{
"name": "libhandy",
"buildsystem": "meson",
"config-opts": [
"-Dprofiling=false",
"-Dintrospection=enabled",
"-Dgtk_doc=false",
"-Dtests=false",
"-Dexamples=false",
"-Dvapi=false",
"-Dglade_catalog=disabled"
],
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libhandy",
"tag": "1.7.90"
}
]
},
{
"name": "libdazzle",
"buildsystem": "meson",
"sources": [
{
"type": "git",
"url": "https://gitlab.gnome.org/GNOME/libdazzle.git",
"tag": "3.44.0"
}
]
},
{
"name": "cozy",
"buildsystem": "meson",
Expand All @@ -172,4 +141,4 @@
]
}
]
}
}
4 changes: 2 additions & 2 deletions cozy.doap
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<shortdesc xml:lang="en">Listen to audio books</shortdesc>

<programming-language>Python</programming-language>
<platform>GTK 3</platform>
<platform>Libhandy</platform>
<platform>GTK 4</platform>
<platform>Libadwaita</platform>

<maintainer>
<foaf:Person>
Expand Down
9 changes: 2 additions & 7 deletions cozy/app_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from cozy.ui.app_view import AppView
from cozy.ui.book_detail_view import BookDetailView
from cozy.ui.headerbar import Headerbar
from cozy.ui.info_banner import InfoBanner
from cozy.ui.toaster import ToastNotifier
from cozy.ui.library_view import LibraryView
from cozy.ui.main_view import CozyUI
from cozy.ui.media_controller import MediaController
Expand Down Expand Up @@ -105,7 +105,7 @@ def configure_inject(self, binder):
binder.bind_to_constructor(SleepTimerViewModel, lambda: SleepTimerViewModel())
binder.bind_to_constructor(GstPlayer, lambda: GstPlayer())
binder.bind_to_constructor(PowerManager, lambda: PowerManager())
binder.bind_to_constructor(InfoBanner, lambda: InfoBanner())
binder.bind_to_constructor(ToastNotifier, lambda: ToastNotifier())
binder.bind_to_constructor(AppViewModel, lambda: AppViewModel())
binder.bind_to_constructor(SettingsViewModel, lambda: SettingsViewModel())

Expand All @@ -125,9 +125,6 @@ def open_library(self):
self.library_view_model.open_library()
self.app_view_model.view = View.LIBRARY_FILTER

def navigate_back(self):
self.app_view_model.navigate_back()

def _connect_popovers(self):
self.headerbar.search_button.set_popover(self.search_view.popover)

Expand All @@ -140,8 +137,6 @@ def _on_open_view(self, event, data):
self.open_book(data)
elif event == OpenView.LIBRARY:
self.open_library()
elif event == OpenView.BACK:
self.navigate_back()

def _on_library_view_event(self, event: str, _):
if event == "work-done":
Expand Down
25 changes: 11 additions & 14 deletions cozy/application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import locale
import logging
import os
import platform
import sys
import threading
from pathlib import Path
Expand All @@ -14,9 +15,9 @@
from cozy.ui.widgets.filter_list_box import FilterListBox
from cozy.ui.widgets.seek_bar import SeekBar

gi.require_version('Handy', '1')
gi.require_version('Adw', '1')

from gi.repository import Gtk, GLib, Handy
from gi.repository import Gtk, GLib, Adw

from cozy.app_controller import AppController
from cozy.control.db import init_db
Expand Down Expand Up @@ -85,13 +86,8 @@ def do_startup(self):
self.ui = CozyUI(self.pkgdatadir, self, __version__)
init_db()
Gtk.Application.do_startup(self)
Handy.init()
try:
manager = Handy.StyleManager.get_default()
manager.set_color_scheme(Handy.ColorScheme.PREFER_LIGHT)
except:
log.info("Not setting libhandy style manager, version is too old.")
log.info("libhandy version: {}".format(Handy._version))
Adw.init()
log.info("libadwaita version: {}".format(Adw._version))
self.ui.startup()

def do_activate(self):
Expand All @@ -109,23 +105,24 @@ def do_activate(self):
os.makedirs(path, exist_ok=True)

self.add_window(self.ui.window)
mpris = MPRIS(self)
mpris._on_current_changed()

if platform.system().lower() == "linux":
mpris = MPRIS(self)
mpris._on_current_changed()

def handle_exception(self, exc_type, exc_value, exc_traceback):
print("handle exception")
try:
reporter.exception("uncaught", exc_value, "\n".join(format_exception(exc_type, exc_value, exc_traceback)))
except:
pass
except Exception:
None

self.old_except_hook(exc_type, exc_value, exc_traceback)

def quit(self):
self.app_controller.quit()
super(Application, self).quit()


@staticmethod
def init_custom_widgets():
FilterListBox()
2 changes: 1 addition & 1 deletion cozy/application_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def dark_mode(self) -> bool:

@dark_mode.setter
def dark_mode(self, new_value: bool):
self._settings.set_boolean("dark_mode", new_value)
self._settings.set_boolean("dark-mode", new_value)

@property
def window_width(self) -> int:
Expand Down
12 changes: 4 additions & 8 deletions cozy/architecture/event_sender.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from typing import List, Callable

import gi

gi.require_version('Gdk', '3.0')

from gi.repository import Gdk, GLib
from gi.repository import GLib


class EventSender:
Expand All @@ -14,15 +11,14 @@ def __init__(self):
self._listeners = []

def emit_event(self, event, message=None):
if type(event) is tuple and not message:
message = event[1]
event = event[0]
if isinstance(event, tuple) and message is None:
event, message = event

for function in self._listeners:
function(event, message)

def emit_event_main_thread(self, event: str, message=None):
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self.emit_event, (event, message))
GLib.MainContext.default().invoke_full(GLib.PRIORITY_DEFAULT_IDLE, self.emit_event, (event, message))

def add_listener(self, function: Callable[[str, object], None]):
self._listeners.append(function)
Expand Down
4 changes: 2 additions & 2 deletions cozy/architecture/observable.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Callable

from gi.repository import Gdk, GLib
from gi.repository import GLib

from cozy.report import reporter
import logging
Expand Down Expand Up @@ -47,7 +47,7 @@ def _notify(self, prop: str):
reporter.exception("observable", e)

def _notify_main_thread(self, prop: str):
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT_IDLE, self._notify, (prop))
GLib.MainContext.default().invoke_full(GLib.PRIORITY_DEFAULT_IDLE, self._notify, (prop))

def _destroy_observers(self):
self._observers = {}
29 changes: 12 additions & 17 deletions cozy/control/artwork_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import uuid
import logging

from gi.repository import GdkPixbuf
from gi.repository import Gdk, GdkPixbuf

from cozy.application_settings import ApplicationSettings
from cozy.control.application_directories import get_cache_dir
Expand All @@ -21,31 +21,25 @@ def __init__(self):
_app_settings = inject.instance(ApplicationSettings)
_app_settings.add_listener(self._on_app_setting_changed)

def get_cover_pixbuf(self, book, scale, size=0):
def get_cover_paintable(self, book, scale, size=0) -> Gdk.Texture | None:
pixbuf = None
size *= scale

if size > 0:
# first try the cache
# First try the cache
pixbuf = self._load_pixbuf_from_cache(book, size)

if pixbuf:
return pixbuf
else:
# then try the db or file
if not pixbuf:
# Then try the db or file
pixbuf = self._load_cover_pixbuf(book)

if pixbuf:
# return original size if it is not greater than 0
if not size > 0:
return pixbuf

# create cached version
pixbuf = self._create_artwork_cache(book, pixbuf, size)
else:
pixbuf = None
if not pixbuf:
return None
elif size > 0:
# Resize and cache artwork if size is greater than 0
pixbuf = self._create_artwork_cache(book, pixbuf, size)

return pixbuf
return Gdk.Texture.new_for_pixbuf(pixbuf)

def delete_artwork_cache(self):
"""
Expand Down Expand Up @@ -240,3 +234,4 @@ def _load_pixbuf_from_file(self, book):
def _on_app_setting_changed(self, event: str, data):
if event == "prefer-external-cover":
self.delete_artwork_cache()

7 changes: 3 additions & 4 deletions cozy/control/db_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,7 @@ def update_db():
_restore_db(backup_dir_name)

from cozy.ui.db_migration_failed_view import DBMigrationFailedView
dialog = DBMigrationFailedView()
dialog.show()
DBMigrationFailedView().present()
exit(1)

if version < 10:
Expand All @@ -298,8 +297,7 @@ def update_db():
_restore_db(backup_dir_name)

from cozy.ui.db_migration_failed_view import DBMigrationFailedView
dialog = DBMigrationFailedView()
dialog.show()
DBMigrationFailedView().present()
exit(1)


Expand Down Expand Up @@ -354,3 +352,4 @@ def _restore_db(backup_dir_name: str):
if os.path.exists(wal_path_backup):
log.info("Copying wal file")
shutil.copyfile(wal_path_backup, wal_path)

15 changes: 6 additions & 9 deletions cozy/control/filesystem_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ def init_offline_mode(self):
# go through all audiobook locations and test if they can be found in the mounts list

for storage in self._settings.external_storage_locations:
online = False
if any(mount.get_root().get_path() in storage.path for mount in mounts):
online = True
online = any(
mount.get_root().get_path() and mount.get_root().get_path() in storage.path
for mount in mounts
)
self.external_storage.append(ExternalStorage(storage=storage, online=online))

def close(self):
Expand All @@ -62,18 +63,14 @@ def close(self):

def get_book_online(self, book: Book):
try:
result = next(
return next(
(storage.online for storage in self.external_storage if storage.storage.path in book.chapters[0].file),
True)
return result
except IndexError:
return True

def is_track_online(self, track):
"""
"""
result = next((storage.online for storage in self.external_storage if storage.storage.path in track.file), True)
return (result)
return next((storage.online for storage in self.external_storage if storage.storage.path in track.file), True)

def get_offline_storages(self):
return [i.storage.path for i in self.external_storage if not i.online]
Expand Down
16 changes: 0 additions & 16 deletions cozy/extensions/gtk_widget.py

This file was deleted.

Loading