[gnome-music/wip/mschraal/core: 187/190] Add ArtistTile.
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/core: 187/190] Add ArtistTile.
- Date: Sun, 7 Jul 2019 21:49:09 +0000 (UTC)
commit 81fe781a200294d0294e30b48004346526207db0
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Jul 5 11:40:34 2019 +0200
Add ArtistTile.
data/org.gnome.Music.gresource.xml | 1 +
data/ui/ArtistTile.ui | 40 ++++++++++++++++++++++
gnomemusic/views/artistsview.py | 17 ++++++----
gnomemusic/views/searchview.py | 24 +++++--------
gnomemusic/widgets/artisttile.py | 69 ++++++++++++++++++++++++++++++++++++++
5 files changed, 129 insertions(+), 22 deletions(-)
---
diff --git a/data/org.gnome.Music.gresource.xml b/data/org.gnome.Music.gresource.xml
index 3992ffa4..e84ee34c 100644
--- a/data/org.gnome.Music.gresource.xml
+++ b/data/org.gnome.Music.gresource.xml
@@ -10,6 +10,7 @@
<file preprocess="xml-stripblanks">ui/AppMenu.ui</file>
<file preprocess="xml-stripblanks">ui/ArtistAlbumWidget.ui</file>
<file preprocess="xml-stripblanks">ui/ArtistAlbumsWidget.ui</file>
+ <file preprocess="xml-stripblanks">ui/ArtistTile.ui</file>
<file preprocess="xml-stripblanks">ui/DiscBox.ui</file>
<file preprocess="xml-stripblanks">ui/DropDown.ui</file>
<file preprocess="xml-stripblanks">ui/EmptyView.ui</file>
diff --git a/data/ui/ArtistTile.ui b/data/ui/ArtistTile.ui
new file mode 100644
index 00000000..6c75c483
--- /dev/null
+++ b/data/ui/ArtistTile.ui
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="ArtistTile" parent="GtkEventBox">
+ <property name="can_focus">False</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="orientation">horizontal</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkRevealer" id="_revealer">
+ <property name="halign">fill</property>
+ <property name="hexpand">False</property>
+ <property name="reveal-child">False</property>
+ <property name="transition-type">slide-right</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkCheckButton" id="_check">
+ <property name="margin-start">12</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="_label">
+ <property name="can_focus">False</property>
+ <property name="ellipsize">end</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ <property name="margin">16</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/gnomemusic/views/artistsview.py b/gnomemusic/views/artistsview.py
index 92b8e65a..584621c0 100644
--- a/gnomemusic/views/artistsview.py
+++ b/gnomemusic/views/artistsview.py
@@ -30,7 +30,7 @@ from gnomemusic import log
from gnomemusic.grilo import grilo
from gnomemusic.views.baseview import BaseView
from gnomemusic.widgets.artistalbumswidget import ArtistAlbumsWidget
-from gnomemusic.widgets.sidebarrow import SidebarRow
+from gnomemusic.widgets.artisttile import ArtistTile
logger = logging.getLogger(__name__)
@@ -78,7 +78,7 @@ class ArtistsView(BaseView):
self.show_all()
def _create_widget(self, coreartist):
- row = SidebarRow(coreartist)
+ row = ArtistTile(coreartist)
row.props.text = coreartist.props.artist
self.bind_property("selection-mode", row, "selection-mode")
@@ -111,12 +111,13 @@ class ArtistsView(BaseView):
@log
def _on_artist_activated(self, sidebar, row, data=None):
"""Initializes new artist album widgets"""
+ artist_tile = row.get_child()
if self.props.selection_mode:
- row.props.selected = not row.props.selected
+ artist_tile.props.selected = not artist_tile.props.selected
return
# Prepare a new artist_albums_widget here
- coreartist = row.props.coreartist
+ coreartist = artist_tile.props.coreartist
new_artist_albums_widget = Gtk.Frame(
shadow_type=Gtk.ShadowType.NONE, hexpand=True)
@@ -162,8 +163,12 @@ class ArtistsView(BaseView):
@log
def _toggle_all_selection(self, selected):
- for row in self._sidebar:
- row.props.selected = selected
+
+ def toggle_selection(child):
+ tile = child.get_child()
+ tile.props.selected = selected
+
+ self._sidebar.foreach(toggle_selection)
@log
def select_all(self):
diff --git a/gnomemusic/views/searchview.py b/gnomemusic/views/searchview.py
index e4e95e97..ac724a4c 100644
--- a/gnomemusic/views/searchview.py
+++ b/gnomemusic/views/searchview.py
@@ -33,6 +33,7 @@ from gnomemusic.widgets.albumcover import AlbumCover
from gnomemusic.widgets.albumwidget import AlbumWidget
from gnomemusic.widgets.headerbar import HeaderBar
from gnomemusic.widgets.artistalbumswidget import ArtistAlbumsWidget
+from gnomemusic.widgets.artisttile import ArtistTile
from gnomemusic.widgets.songwidget import SongWidget
@@ -135,25 +136,16 @@ class SearchView(BaseView):
return album_widget
def _create_artist_widget(self, coreartist):
- return
- # FIXME: Hacky quick 'artist' widget. Needs its own tile.
- song_widget = SongWidget(coreartist)
- song_widget._title_label.props.label = coreartist.props.artist
- song_widget.props.show_duration = False
- song_widget.props.show_favorite = False
- song_widget.props.show_song_number = False
- song_widget.coreartist = coreartist
+ artist_tile = ArtistTile(coreartist)
+ artist_tile.props.text = coreartist.props.artist
+ artist_tile.connect('button-release-event', self._artist_activated)
self.bind_property(
- "selection-mode", song_widget, "selection-mode",
- GObject.BindingFlags.BIDIRECTIONAL
- | GObject.BindingFlags.SYNC_CREATE)
-
- song_widget.connect('button-release-event', self._artist_activated)
-
- song_widget.show_all()
+ "selection-mode", artist_tile, "selection-mode",
+ GObject.BindingFlags.SYNC_CREATE
+ | GObject.BindingFlags.BIDIRECTIONAL)
- return song_widget
+ return artist_tile
def _song_activated(self, widget, event):
mod_mask = Gtk.accelerator_get_default_mod_mask()
diff --git a/gnomemusic/widgets/artisttile.py b/gnomemusic/widgets/artisttile.py
new file mode 100644
index 00000000..859ea779
--- /dev/null
+++ b/gnomemusic/widgets/artisttile.py
@@ -0,0 +1,69 @@
+# Copyright 2018 The GNOME Music developers
+#
+# GNOME Music is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# GNOME Music is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with GNOME Music; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# The GNOME Music authors hereby grant permission for non-GPL compatible
+# GStreamer plugins to be used and distributed together with GStreamer
+# and GNOME Music. This permission is above and beyond the permissions
+# granted by the GPL license by which GNOME Music is covered. If you
+# modify this code, you may extend this exception to your version of the
+# code, but you are not obligated to do so. If you do not wish to do so,
+# delete this exception statement from your version.
+
+from gi.repository import GObject, Gtk
+
+from gnomemusic import log
+from gnomemusic.coreartist import CoreArtist
+
+
+@Gtk.Template(resource_path='/org/gnome/Music/ui/ArtistTile.ui')
+class ArtistTile(Gtk.EventBox):
+ """Row for sidebars
+
+ Contains a label and an optional checkbox.
+ """
+
+ __gtype_name__ = 'ArtistTile'
+
+ _check = Gtk.Template.Child()
+ _label = Gtk.Template.Child()
+ _revealer = Gtk.Template.Child()
+
+ coreartist = GObject.Property(type=CoreArtist, default=None)
+ selected = GObject.Property(type=bool, default=False)
+ selection_mode = GObject.Property(type=bool, default=False)
+ text = GObject.Property(type=str, default='')
+
+ def __repr__(self):
+ return '<ArtistTile>'
+
+ @log
+ def __init__(self, coreartist=None):
+ super().__init__()
+
+ self.props.coreartist = coreartist
+
+ self.bind_property(
+ 'selected', self._check, 'active',
+ GObject.BindingFlags.BIDIRECTIONAL)
+ if coreartist:
+ self.bind_property(
+ "selected", coreartist, "selected",
+ GObject.BindingFlags.BIDIRECTIONAL)
+ self.bind_property('selection-mode', self._revealer, 'reveal-child')
+ self.bind_property('text', self._label, 'label')
+ self.bind_property('text', self._label, 'tooltip-text')
+
+ self.show()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]