Commit 10ed52ea authored by Bruce Cowan's avatar Bruce Cowan

widgets: Use CSS instead of markup

Instead of using embedded markup in the labels, use style classes.
Add two new style classes for this purpose.

Fixes #163
parent ee168700
......@@ -58,9 +58,9 @@
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<attributes>
<attribute name="foreground" value="#bababdbdb6b6"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......@@ -107,6 +107,9 @@
<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>
......
......@@ -53,6 +53,9 @@
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="justify">right</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -78,3 +78,8 @@ flowbox, treeview, widget {
.grey-image {
color: alpha(@theme_fg_color, 0.3);
}
/* Used in AlbumWidget and ArtistAlbumsWidget */
.playing-song-label {
font-weight: bold;
}
......@@ -305,21 +305,21 @@ class AlbumWidget(Gtk.EventBox):
song = playlist[_iter][player.Field.SONG]
song_widget = song.song_widget
self._duration += song.get_duration()
escaped_title = GLib.markup_escape_text(
utils.get_media_title(song))
context = song_widget.title.get_style_context()
if (song == current_song):
song_widget.now_playing_sign.show()
song_widget.title.set_markup("<b>{}</b>".format(escaped_title))
context.remove_class('dim-label')
context.add_class('playing-song-label')
song_passed = True
elif (song_passed):
song_widget.now_playing_sign.hide()
song_widget.title.set_markup(
"<span>{}</span>".format(escaped_title))
context.remove_class('dim-label')
context.remove_class('playing-song-label')
else:
song_widget.now_playing_sign.hide()
song_widget.title.set_markup(
"<span color=\'grey\'>{}</span>".format(escaped_title))
context.remove_class('playing-song-label')
context.add_class('dim-label')
_iter = playlist.iter_next(_iter)
......
......@@ -25,11 +25,10 @@
import logging
from gettext import gettext as _, ngettext
from gi.repository import GLib, GObject, Gtk
from gi.repository import GObject, Gtk
from gnomemusic import log
from gnomemusic.widgets.artistalbumwidget import ArtistAlbumWidget
import gnomemusic.utils as utils
logger = logging.getLogger(__name__)
......@@ -150,20 +149,21 @@ class ArtistAlbumsWidget(Gtk.Box):
itr = playlist.iter_next(itr)
continue
escaped_title = GLib.markup_escape_text(
utils.get_media_title(song))
context = song_widget.title.get_style_context()
if (song == current_song):
song_widget.now_playing_sign.show()
song_widget.title.set_markup('<b>%s</b>' % escaped_title)
context.remove_class('dim-label')
context.add_class('playing-song-label')
song_passed = True
elif (song_passed):
song_widget.now_playing_sign.hide()
song_widget.title.set_markup('<span>%s</span>' % escaped_title)
context.remove_class('dim-label')
context.remove_class('playing-song-label')
else:
song_widget.now_playing_sign.hide()
song_widget.title.set_markup(
'<span color=\'grey\'>%s</span>' % escaped_title)
context.remove_class('playing-song-label')
context.add_class('dim-label')
itr = playlist.iter_next(itr)
return False
......@@ -175,11 +175,11 @@ class ArtistAlbumsWidget(Gtk.Box):
while itr:
song = self._model[itr][5]
song_widget = song.song_widget
escaped_title = GLib.markup_escape_text(
utils.get_media_title(song))
if song_widget.can_be_played:
song_widget.now_playing_sign.hide()
song_widget.title.set_markup('<span>%s</span>' % escaped_title)
context = song_widget.title.get_style_context()
context.remove_class('playing-song-label')
context.remove_class('dim-label')
itr = self._model.iter_next(itr)
return False
......
......@@ -80,8 +80,7 @@ class ArtistAlbumWidget(Gtk.Box):
ui.get_object('title').set_label(self._album_title)
year = utils.get_media_year(self._media)
if year:
ui.get_object('year').set_markup(
'<span color=\'grey\'>{}</span>'.format(year))
ui.get_object('year').set_label(year)
if self._size_group:
self._size_group.add_widget(ui.get_object('box1'))
......
......@@ -189,8 +189,7 @@ class DiscBox(Gtk.Box):
:param int disc_number: Disc number to display
"""
self._label.set_markup(_("Disc {}").format(disc_number))
self._label.get_style_context().add_class('dim-label')
self._label.set_label(_("Disc {}").format(disc_number))
self._label.set_visible(True)
@log
......@@ -324,8 +323,7 @@ class DiscBox(Gtk.Box):
if song_number == 0:
song_number = ""
song_widget.number = builder.get_object('num')
song_widget.number.set_markup(
'<span color=\'grey\'>{}</span>'.format(song_number))
song_widget.number.set_label(str(song_number))
song_widget.number.set_no_show_all(True)
song_widget.title = builder.get_object('title')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment