[gnome-music] artistalbumwidget: Use Gtk.Template
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] artistalbumwidget: Use Gtk.Template
- Date: Sun, 17 Jun 2018 07:28:47 +0000 (UTC)
commit 56df3e5270c31e22b029faeb0bd8aba886f31e90
Author: Apostol Bakalov <apogza gmail com>
Date: Fri Jun 15 18:49:00 2018 +0300
artistalbumwidget: Use Gtk.Template
data/ArtistAlbumWidget.ui | 16 +++++++-------
gnomemusic/widgets/artistalbumwidget.py | 37 ++++++++++++++++++---------------
2 files changed, 27 insertions(+), 26 deletions(-)
---
diff --git a/data/ArtistAlbumWidget.ui b/data/ArtistAlbumWidget.ui
index f1958cf8..0c81c591 100644
--- a/data/ArtistAlbumWidget.ui
+++ b/data/ArtistAlbumWidget.ui
@@ -2,11 +2,9 @@
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <object class="GtkBox" id="ArtistAlbumWidget">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <template parent="GtkBox" class="ArtistAlbumWidget">
<child>
- <object class="GtkStack" id="cover">
+ <object class="GtkStack" id="_cover">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
@@ -21,7 +19,7 @@
</packing>
</child>
<child>
- <object class="GtkBox" id="box1">
+ <object class="GtkBox" id="_album_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
@@ -30,7 +28,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="title">
+ <object class="GtkLabel" id="_title">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">6</property>
@@ -50,7 +48,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="year">
+ <object class="GtkLabel" id="_year">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -73,7 +71,7 @@
</packing>
</child>
<child>
- <object class="DiscListBox" id="disclistbox">
+ <object class="DiscListBox" id="_disc_list_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
@@ -91,7 +89,7 @@
<property name="position">1</property>
</packing>
</child>
- </object>
+ </template>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name gchararray1 -->
diff --git a/gnomemusic/widgets/artistalbumwidget.py b/gnomemusic/widgets/artistalbumwidget.py
index 1e3c70cb..d9a9ce12 100644
--- a/gnomemusic/widgets/artistalbumwidget.py
+++ b/gnomemusic/widgets/artistalbumwidget.py
@@ -33,8 +33,17 @@ from gnomemusic.widgets.disclistboxwidget import DiscBox
import gnomemusic.utils as utils
+@Gtk.Template(resource_path='/org/gnome/Music/ArtistAlbumWidget.ui')
class ArtistAlbumWidget(Gtk.Box):
+ __gtype_name__ = 'ArtistAlbumWidget'
+
+ _album_box = Gtk.Template.Child()
+ _cover = Gtk.Template.Child()
+ _disc_list_box = Gtk.Template.Child()
+ _title = Gtk.Template.Child()
+ _year = Gtk.Template.Child()
+
__gsignals__ = {
'songs-loaded': (GObject.SignalFlags.RUN_FIRST, None, ()),
}
@@ -66,31 +75,24 @@ class ArtistAlbumWidget(Gtk.Box):
self._header_bar._select_button.connect(
'toggled', self._on_header_select_button_toggled)
- ui = Gtk.Builder()
- ui.add_from_resource('/org/gnome/Music/ArtistAlbumWidget.ui')
-
- self.cover = ui.get_object('cover')
-
- self.cover_stack = CoverStack(self.cover, Art.Size.MEDIUM)
+ self.cover_stack = CoverStack(self._cover, Art.Size.MEDIUM)
self.cover_stack.update(self._media)
- self._disc_listbox = ui.get_object('disclistbox')
allowed = self._selection_mode_allowed
- self._disc_listbox.props.selection_mode_allowed = allowed
+ self._disc_list_box.props.selection_mode_allowed = allowed
- ui.get_object('title').set_label(self._album_title)
+ self._title.props.label = self._album_title
year = utils.get_media_year(self._media)
+
if year:
- ui.get_object('year').set_label(year)
+ self._year.props.label = year
if self._size_group:
- self._size_group.add_widget(ui.get_object('box1'))
+ self._size_group.add_widget(self._album_box)
if self._cover_size_group:
self._cover_size_group.add_widget(self.cover_stack._stack)
- self.pack_start(ui.get_object('ArtistAlbumWidget'), True, True, 0)
-
grilo.populate_album_songs(self._media, self._add_item)
def create_disc_box(self, disc_nr, disc_songs):
@@ -122,13 +124,14 @@ class ArtistAlbumWidget(Gtk.Box):
"""Selection mode button clicked callback."""
if button.get_active():
self._selection_mode = True
- self._disc_listbox.props.selection_mode = True
+ self._disc_list_box.props.selection_mode = True
self._header_bar.props.selection_mode = True
self._parent_view.set_player_visible(False)
else:
self._selection_mode = False
- self._disc_listbox.props.selection_mode = False
self._header_bar.props.selection_mode = False
+ self._disc_list_box.props.selection_mode = False
+
if self._player.get_playback_status() != Playback.STOPPED:
self._parent_view.set_player_visible(True)
@@ -148,7 +151,7 @@ class ArtistAlbumWidget(Gtk.Box):
for disc_nr in discs:
disc = self.create_disc_box(disc_nr, discs[disc_nr])
- self._disc_listbox.add(disc)
+ self._disc_list_box.add(disc)
if len(discs) == 1:
disc.props.show_disc_label = False
@@ -173,4 +176,4 @@ class ArtistAlbumWidget(Gtk.Box):
return
self._selection_mode = selection_mode
- self._disc_listbox.props.selection_mode = selection_mode
+ self._disc_list_box.props.selection_mode = selection_mode
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]