Skip to content

Commit

Permalink
Merge pull request #41 from oscfdezdz/gtk4
Browse files Browse the repository at this point in the history
app: Port to GTK4 + libadwaita
  • Loading branch information
oscfdezdz authored Aug 17, 2022
2 parents 4a44de1 + 24a8a4e commit 42d84b9
Show file tree
Hide file tree
Showing 11 changed files with 377 additions and 555 deletions.
48 changes: 48 additions & 0 deletions com.github.lachhebo.Gabtag.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"command": "gabtag",
"finish-args": [
"--filesystem=home",
"--device=dri",
"--share=network",
"--share=ipc",
"--socket=fallback-x11",
Expand Down Expand Up @@ -65,6 +66,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",
Expand Down
1 change: 0 additions & 1 deletion src/audio_ogg_file_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@


class OggFileHandler(AudioExtensionHandler):

@staticmethod
def get_extension():
return ".ogg"
Expand Down
2 changes: 1 addition & 1 deletion src/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from .view import VIEW

gi.require_version("Gtk", "3.0")
gi.require_version("Gtk", "4.0")


class Controller:
Expand Down
76 changes: 43 additions & 33 deletions src/event_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
11 changes: 4 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/treeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import gettext

gi.require_version("Gtk", "3.0")
gi.require_version("Gtk", "4.0")

_ = gettext.gettext

Expand All @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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(
{
Expand Down Expand Up @@ -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 = ""


Expand Down
Loading

0 comments on commit 42d84b9

Please sign in to comment.