From 3125ab0b815bd1d8917be1b8e7a719c17431b152 Mon Sep 17 00:00:00 2001 From: oscfdezdz Date: Tue, 9 Aug 2022 16:40:25 +0200 Subject: [PATCH 1/2] build: Add latest libadwaita version as a module Can be removed when GNOME SDK and Runtime update to version 43. --- com.github.lachhebo.Gabtag.Devel.json | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/com.github.lachhebo.Gabtag.Devel.json b/com.github.lachhebo.Gabtag.Devel.json index 28a03be..2a8629d 100644 --- a/com.github.lachhebo.Gabtag.Devel.json +++ b/com.github.lachhebo.Gabtag.Devel.json @@ -65,6 +65,53 @@ } ] }, + { + "name": "libsass", + "sources": [ + { + "type" : "archive", + "url" : "https://github.com/sass/libsass/archive/3.6.5.tar.gz", + "sha256": "89d8f2c46ae2b1b826b58ce7dde966a176bac41975b82e84ad46b01a55080582" + }, + { + "type" : "script", + "dest-filename" : "autogen.sh", + "commands" : [ "autoreconf -si" ] + } + ] + }, + { + "name": "sassc", + "sources": [ + { + "type" : "archive", + "url" : "https://github.com/sass/sassc/archive/3.6.2.tar.gz", + "sha256": "608dc9002b45a91d11ed59e352469ecc05e4f58fc1259fc9a9f5b8f0f8348a03" + }, + { + "type" : "script", + "dest-filename" : "autogen.sh", + "commands" : [ "autoreconf -si" ] + } + ] + }, + { + "name" : "libadwaita", + "buildsystem": "meson", + "config-opts" : [ + "-Dvapi=true", + "-Dgtk_doc=false", + "-Dexamples=false", + "-Dtests=false" + ], + "sources" : [ + { + "type" : "git", + "url" : "https://gitlab.gnome.org/GNOME/libadwaita.git", + "branch" : "main" + } + ] + }, { "name": "gabtag", "buildsystem": "meson", From 24a8a4e844075140f62bfe9d0226b92d387a5634 Mon Sep 17 00:00:00 2001 From: oscfdezdz Date: Sat, 6 Aug 2022 01:47:30 +0200 Subject: [PATCH 2/2] app: Port to GTK4 + libadwaita --- com.github.lachhebo.Gabtag.Devel.json | 1 + src/audio_ogg_file_handler.py | 1 - src/controller.py | 2 +- src/event_machine.py | 76 +-- src/main.py | 11 +- src/tools.py | 2 +- src/treeview.py | 6 +- src/view.py | 10 +- src/window.ui | 738 +++++++++----------------- src/window_gtk.py | 36 +- tests/test_controller.py | 2 +- 11 files changed, 330 insertions(+), 555 deletions(-) diff --git a/com.github.lachhebo.Gabtag.Devel.json b/com.github.lachhebo.Gabtag.Devel.json index 2a8629d..0e39536 100644 --- a/com.github.lachhebo.Gabtag.Devel.json +++ b/com.github.lachhebo.Gabtag.Devel.json @@ -6,6 +6,7 @@ "command": "gabtag", "finish-args": [ "--filesystem=home", + "--device=dri", "--share=network", "--share=ipc", "--socket=fallback-x11", diff --git a/src/audio_ogg_file_handler.py b/src/audio_ogg_file_handler.py index dd0147a..605175c 100644 --- a/src/audio_ogg_file_handler.py +++ b/src/audio_ogg_file_handler.py @@ -22,7 +22,6 @@ class OggFileHandler(AudioExtensionHandler): - @staticmethod def get_extension(): return ".ogg" diff --git a/src/controller.py b/src/controller.py index 3ec0338..4aabcfe 100644 --- a/src/controller.py +++ b/src/controller.py @@ -14,7 +14,7 @@ from .view import VIEW -gi.require_version("Gtk", "3.0") +gi.require_version("Gtk", "4.0") class Controller: diff --git a/src/event_machine.py b/src/event_machine.py index e14bbec..e71d82b 100644 --- a/src/event_machine.py +++ b/src/event_machine.py @@ -4,12 +4,12 @@ from .controller import Controller from .tools import add_filters, get_filenames_from_selection -from gi.repository import Gtk +from gi.repository import Gio, Gtk import gi import gettext -gi.require_version("Gtk", "3.0") +gi.require_version("Gtk", "4.0") _ = gettext.gettext @@ -31,37 +31,43 @@ def on_clicked_save_one(self, widget): def on_reset_one_clicked(self, widget): if self.is_real_selection == 1: self.is_real_selection = 0 - Controller.reset_some_files() + # Controller.reset_some_files() + Controller.reset_all() self.is_real_selection = 1 - def on_reset_all_clicked(self, widget): + def on_reset_all_clicked(self, widget, action: Gio.Action): if self.is_real_selection == 1: self.is_real_selection = 0 Controller.reset_all() self.is_real_selection = 1 - def on_about_clicked(self, widget): - self.window.id_about_window.run() - self.window.id_about_window.hide() + def on_about_clicked(self, widget, action: Gio.Action): + if self.window is not None: + self.window.id_about_window.show() def on_open_clicked(self, widget): self.is_real_selection = 0 dialog = Gtk.FileChooserDialog( - _("Select Folder"), - self.window, - Gtk.FileChooserAction.SELECT_FOLDER, - (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, _("Select"), Gtk.ResponseType.OK), + title=_("Select a Folder"), + transient_for=self.window, + action=Gtk.FileChooserAction.SELECT_FOLDER, ) - dialog.set_default_size(800, 400) + dialog.add_buttons(_("_Open"), Gtk.ResponseType.OK) + dialog.add_buttons(_("_Cancel"), Gtk.ResponseType.CANCEL) + dialog.set_default_response(Gtk.ResponseType.OK) + dialog.set_modal(True) - response = dialog.run() + dialog.connect("response", self.on_open_folder_chooser) - if response == Gtk.ResponseType.OK: - Controller.change_directory(dialog.get_filename()) + dialog.show() + + self.is_real_selection = 1 + def on_open_folder_chooser(self, dialog, response): dialog.destroy() - self.is_real_selection = 1 + if response == Gtk.ResponseType.OK: + Controller.change_directory(dialog.get_file().get_path()) def on_menu_but_toggled(self, widget): pass @@ -107,29 +113,33 @@ def on_load_cover_clicked(self, widget): self.is_real_selection = 0 dialog = Gtk.FileChooserDialog( - _("Open File"), - self.window, - Gtk.FileChooserAction.OPEN, - ( - Gtk.STOCK_CANCEL, - Gtk.ResponseType.CANCEL, - Gtk.STOCK_OPEN, - Gtk.ResponseType.OK, - ), + title=_("Open a File"), + transient_for=self.window, + action=Gtk.FileChooserAction.OPEN, ) + dialog.add_buttons(_("_Open"), Gtk.ResponseType.OK) + dialog.add_buttons(_("_Cancel"), Gtk.ResponseType.CANCEL) + dialog.set_default_response(Gtk.ResponseType.OK) + dialog.set_modal(True) add_filters(dialog) - response = dialog.run() - if response == Gtk.ResponseType.OK: - file_cover = dialog.get_filename() - name_files = get_filenames_from_selection(SELECTION.selection) - MODEL.update_modifications(name_files, "cover", file_cover) - Controller.update_view(name_files) + dialog.connect("response", self.on_open_image_chooser) + + dialog.show() - dialog.destroy() self.is_real_selection = 1 + def on_open_image_chooser(self, dialog, response): + dialog.destroy() + + if response == Gtk.ResponseType.OK: + file_cover = dialog.get_file().get_path() + + name_files = get_filenames_from_selection(SELECTION.selection) + MODEL.update_modifications(name_files, "cover", file_cover) + Controller.update_view(name_files) + def on_selected_changed(self, selection): if self.is_real_selection == 1: self.is_real_selection = 0 @@ -149,7 +159,7 @@ def on_set_mbz(self, widget): Controller.update_view(name_files) self.is_real_selection = 1 - def on_set_online_tags(self, widget): + def on_set_online_tags(self, widget, action: Gio.Action): if DIR_MANAGER.is_open_directory and self.is_real_selection == 1: self.is_real_selection = 0 name_files = get_filenames_from_selection(SELECTION.selection) diff --git a/src/main.py b/src/main.py index 16ac60f..248d46b 100644 --- a/src/main.py +++ b/src/main.py @@ -20,13 +20,12 @@ from .window_gtk import GabtagWindow -gi.require_version("Gtk", "3.0") -gi.require_version("Handy", "1") +gi.require_version("Adw", "1") -from gi.repository import Gtk, Gio, GLib, GObject, Handy # noqa: E402 +from gi.repository import Adw, Gio, GLib, GObject # noqa: E402 -class Application(Gtk.Application): +class Application(Adw.Application): app_id = GObject.Property(type=str) version = GObject.Property(type=str) @@ -43,10 +42,8 @@ def __init__(self, app_id: str, version: str, devel: bool, *args, **kwargs): self.version = version self.devel = devel - GLib.set_application_name(("GabTag")) + GLib.set_application_name("GabTag") GLib.set_prgname(self.app_id) - Handy.init() - Handy.StyleManager.get_default().set_color_scheme(Handy.ColorScheme.PREFER_LIGHT) def do_activate(self): win = self.props.active_window diff --git a/src/tools.py b/src/tools.py index 20dfbf1..4a3395a 100644 --- a/src/tools.py +++ b/src/tools.py @@ -9,7 +9,7 @@ from .extension_manager import is_extension_managed from .selection_handler import SELECTION -gi.require_version("Gtk", "3.0") +gi.require_version("Gtk", "4.0") from gi.repository import Gtk # noqa: E402 diff --git a/src/treeview.py b/src/treeview.py index 0c25e03..585e17e 100644 --- a/src/treeview.py +++ b/src/treeview.py @@ -5,7 +5,7 @@ import gettext -gi.require_version("Gtk", "3.0") +gi.require_version("Gtk", "4.0") _ = gettext.gettext @@ -21,12 +21,12 @@ def add_columns(self): renderer_filename = Gtk.CellRendererText() column_filename = Gtk.TreeViewColumn( - _("Name"), renderer_filename, text=0, weight=2, weight_set=True + _("Name"), renderer_filename, text=0, weight=2 ) renderer_data = Gtk.CellRendererText() column_data_gathered = Gtk.TreeViewColumn( - _("Data"), renderer_data, text=1, weight=2, weight_set=True + _("Data"), renderer_data, text=1, weight=2 ) self.view.append_column(column_data_gathered) diff --git a/src/view.py b/src/view.py index b4dc572..d5dd8e0 100644 --- a/src/view.py +++ b/src/view.py @@ -7,7 +7,7 @@ from .tools import set_text_widget_permission, set_label -gi.require_version("Gtk", "3.0") +gi.require_version("Gtk", "4.0") verrou_tags = RLock() @@ -76,9 +76,9 @@ def show_mbz(self, data_scrapped): self.cover_mbz.set_from_pixbuf(pixbuf) except TypeError: - self.cover_mbz.set_from_icon_name("emblem-music-symbolic", 6) + self.cover_mbz.set_from_icon_name("emblem-music-symbolic") else: - self.cover_mbz.set_from_icon_name("emblem-music-symbolic", 6) + self.cover_mbz.set_from_icon_name("emblem-music-symbolic") def erase(self): """ @@ -90,7 +90,7 @@ def erase(self): self.artist.set_text("") self.year.set_text("") self.track.set_text("") - self.cover.set_from_icon_name("emblem-music-symbolic", 6) + self.cover.set_from_icon_name("emblem-music-symbolic") self.last_cover = "" self.show_mbz( { @@ -180,7 +180,7 @@ def show_tags(self, tags_dict, multiple_rows): pass else: - self.cover.set_from_icon_name("emblem-music-symbolic", 6) + self.cover.set_from_icon_name("emblem-music-symbolic") self.last_cover = "" diff --git a/src/window.ui b/src/window.ui index b3f1f3d..f365925 100644 --- a/src/window.ui +++ b/src/window.ui @@ -1,52 +1,36 @@ - + +
+ + Reset Files + win.reset-all + + + Set Online Tags + win.set-online-tags + +
+
+ + About GabTag + win.about + +
+
+ True - com.github.lachhebo.Gabtag - GabTag - GabTag is an open-source audio tagging tool written in GTK3. - gpl-3-0 - Ismaël Lachheb + True + GabTag + gpl-3-0 + Audio tagging tool. + Ismaël Lachheb + Tobias Bernard translator-credits - Tobias Bernard - - - False - - - True - vertical - 6 - - - True - Reset Files - - - - - - True - Set Online Tags - - - - - - True - horizontal - - - - - True - About GabTag - - - - - + + + @@ -58,507 +42,285 @@ -