[gnome-music] discbox: Use Gtk.Template
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] discbox: Use Gtk.Template
- Date: Sun, 17 Jun 2018 07:28:42 +0000 (UTC)
commit bf1a238ec1ee0170519f79723b038df14f6e1ce8
Author: Apostol Bakalov <apogza gmail com>
Date: Fri Jun 15 18:21:02 2018 +0300
discbox: Use Gtk.Template
data/ArtistAlbumWidget.ui | 39 ----------------------------
data/DiscBox.ui | 45 +++++++++++++++++++++++++++++++++
data/org.gnome.Music.gresource.xml | 1 +
gnomemusic/widgets/disclistboxwidget.py | 19 +++++---------
4 files changed, 53 insertions(+), 51 deletions(-)
---
diff --git a/data/ArtistAlbumWidget.ui b/data/ArtistAlbumWidget.ui
index 2540005b..f1958cf8 100644
--- a/data/ArtistAlbumWidget.ui
+++ b/data/ArtistAlbumWidget.ui
@@ -92,45 +92,6 @@
</packing>
</child>
</object>
- <object class="GtkBox" id="disc">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="margin_top">16</property>
- <child>
- <object class="GtkLabel" id="disclabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="margin_start">60</property>
- <property name="margin_bottom">4</property>
- <style>
- <class name="dim-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="DiscSongsFlowBox" id="discsongsflowbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="orientation">vertical</property>
- <property name="homogeneous">True</property>
- <property name="max_children_per_line">0</property>
- <property name="selection_mode">none</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name gchararray1 -->
diff --git a/data/DiscBox.ui b/data/DiscBox.ui
new file mode 100644
index 00000000..c869d46a
--- /dev/null
+++ b/data/DiscBox.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.20.0 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <template parent="GtkBox" class="DiscBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="margin_top">16</property>
+ <child>
+ <object class="GtkLabel" id="_disc_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="margin_start">60</property>
+ <property name="margin_bottom">4</property>
+ <property name="no_show_all">True</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="DiscSongsFlowBox" id="_disc_songs_flowbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="orientation">vertical</property>
+ <property name="homogeneous">True</property>
+ <property name="max_children_per_line">0</property>
+ <property name="selection_mode">none</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index 0643824c..b235de09 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -10,6 +10,7 @@
<file preprocess="xml-stripblanks">AlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ArtistAlbumsWidget.ui</file>
+ <file preprocess="xml-stripblanks">DiscBox.ui</file>
<file preprocess="xml-stripblanks">EmptyView.ui</file>
<file preprocess="xml-stripblanks">PlayerToolbar.ui</file>
<file preprocess="xml-stripblanks">SelectionBarMenuButton.ui</file>
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index 32d527fe..714c4c82 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -83,6 +83,7 @@ class DiscSongsFlowBox(Gtk.FlowBox):
self.set_min_children_per_line(max_per_line)
+@Gtk.Template(resource_path='/org/gnome/Music/DiscBox.ui')
class DiscBox(Gtk.Box):
"""A widget which compromises one disc
@@ -91,6 +92,9 @@ class DiscBox(Gtk.Box):
"""
__gtype_name__ = 'DiscBox'
+ _disc_label = Gtk.Template.Child()
+ _disc_songs_flowbox = Gtk.Template.Child()
+
__gsignals__ = {
'selection-changed': (GObject.SignalFlags.RUN_FIRST, None, ()),
'selection-toggle': (GObject.SignalFlags.RUN_FIRST, None, ()),
@@ -118,34 +122,25 @@ class DiscBox(Gtk.Box):
self._model = model
self._model.connect('row-changed', self._model_row_changed)
- builder = Gtk.Builder()
- builder.add_from_resource('/org/gnome/Music/ArtistAlbumWidget.ui')
-
- self._label = builder.get_object('disclabel')
- self._label.set_no_show_all(True)
- self._disc_songs_flowbox = builder.get_object('discsongsflowbox')
-
self.bind_property(
'columns', self._disc_songs_flowbox, 'columns',
GObject.BindingFlags.SYNC_CREATE)
self.bind_property(
- 'show-disc-label', self._label, 'visible',
+ 'show-disc-label', self._disc_label, 'visible',
GObject.BindingFlags.SYNC_CREATE)
self._selection_mode_allowed = True
self._selected_items = []
self._songs = []
- self.pack_start(builder.get_object('disc'), True, True, 0)
-
@log
def set_disc_number(self, disc_number):
"""Set the dics number to display
:param int disc_number: Disc number to display
"""
- self._label.set_label(_("Disc {}").format(disc_number))
- self._label.set_visible(True)
+ self._disc_label.props.label = _("Disc {}").format(disc_number)
+ self._disc_label.props.visible = True
@log
def set_songs(self, songs):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]