Use GTK Composite Templates (close #62)
Use GTK Composite Templates for GUI elements to clean up and simplify the code for widgets and all UI elements. This includes splitting the large “gtk.glade” file into smaller .ui files and the large “widgets.py” file into smaller .py files.
This commit is contained in:
parent
f4b545369c
commit
ba373ddf4e
31 changed files with 4436 additions and 4305 deletions
35
mcg/albumheaderbar.py
Normal file
35
mcg/albumheaderbar.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
|
||||
from gi.repository import Gtk, GObject
|
||||
|
||||
|
||||
|
||||
|
||||
@Gtk.Template(resource_path='/de/coderkun/mcg/ui/album-headerbar.ui')
|
||||
class AlbumHeaderbar(Gtk.HeaderBar):
|
||||
__gtype_name__ = 'McgAlbumHeaderbar'
|
||||
__gsignals__ = {
|
||||
'close': (GObject.SIGNAL_RUN_FIRST, None, ())
|
||||
}
|
||||
|
||||
# Widgets
|
||||
standalone_title = Gtk.Template.Child()
|
||||
standalone_artist = Gtk.Template.Child()
|
||||
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
|
||||
@Gtk.Template.Callback()
|
||||
def on_close_clicked(self, widget):
|
||||
self.emit('close')
|
||||
|
||||
|
||||
def set_album(self, album):
|
||||
self.standalone_title.set_text(album.get_title())
|
||||
self.standalone_artist.set_text(", ".join(album.get_albumartists()))
|
Loading…
Add table
Add a link
Reference in a new issue