Commit 888645cf authored by Tijder's avatar Tijder

Show track and disc number in album view

parent 91ee81aa
Pipeline #183527 canceled with stage
in 3 minutes and 18 seconds
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="album_item" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel" id="_index_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="width_chars">4</property>
<attributes>
<attribute name="weight" value="ultralight"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="_title_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">10</property>
<property name="label" translatable="yes">label</property>
<property name="label">label</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
<child>
......@@ -27,7 +42,7 @@
<property name="halign">start</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="label" translatable="yes">label</property>
<property name="label">label</property>
<property name="ellipsize">end</property>
<attributes>
<attribute name="weight" value="light"/>
......@@ -36,7 +51,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
......@@ -87,7 +102,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</template>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<requires lib="libhandy" version="0.0"/>
......@@ -162,7 +162,7 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkBox" id="_item_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">20</property>
......@@ -248,17 +248,24 @@
</packing>
</child>
<child>
<object class="GtkListBox" id="_item_box">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">10</property>
<property name="selection_mode">none</property>
<property name="activate_on_single_click">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
</object>
......
......@@ -26,6 +26,7 @@ class AlbumItem(Gtk.Box):
_title_label = GtkTemplate.Child()
_time_label = GtkTemplate.Child()
_index_label = GtkTemplate.Child()
_play_button = GtkTemplate.Child()
_music_clip_button = GtkTemplate.Child()
......@@ -38,7 +39,7 @@ class AlbumItem(Gtk.Box):
self._plex = plex
self._item = item
if item.viewCount == 0:
style = self._time_label.get_style_context()
style = self._index_label.get_style_context()
style.add_class("unplayed")
if item.primaryExtraKey != None:
......@@ -46,6 +47,8 @@ class AlbumItem(Gtk.Box):
self._music_clip_button.connect("clicked", self.__on_music_clip_button_clicked)
self._title_label.set_text(self._item.title)
if self._item.index is not None:
self._index_label.set_text(self._item.index)
con_sec, con_min, con_hour = self.__convertMillis(int(self._item.duration))
self._time_label.set_text(str("{0}:{1}".format(int(con_min), format(int(con_sec), '02'))))
......
......@@ -47,6 +47,8 @@ class AlbumView(Handy.Column):
_cover2_box = GtkTemplate.Child()
_left_box = GtkTemplate.Child()
_discs = {}
_download_key = None
_key = None
......@@ -75,6 +77,8 @@ class AlbumView(Handy.Column):
for item in self._item_box.get_children():
self._item_box.remove(item)
self._discs = {}
self._connection_album_retrieved = self._plex.connect("album-retrieved", self.__album_retrieved)
thread = threading.Thread(target=self._plex.get_album, args=(key,))
......@@ -101,8 +105,8 @@ class AlbumView(Handy.Column):
self._tracks = tracks
self.__start_add_items_timout()
def __add_track(self, track):
self._item_box.add(AlbumItem(self._plex, track))
def __add_track(self, track, itemBox):
itemBox.add(AlbumItem(self._plex, track))
self._tracks.remove(track)
def __show_more_items(self):
......@@ -110,7 +114,21 @@ class AlbumView(Handy.Column):
if len(self._tracks) > 0:
i = 10
while len(self._tracks) > 0:
self.__add_track(self._tracks[0])
parentindex = '1'
if self._tracks[0].parentIndex is not None:
parentindex = self._tracks[0].parentIndex
if parentindex not in self._discs:
listBox = Gtk.ListBox()
self._discs[parentindex] = listBox
listBox.set_margin_bottom(10)
listBox.set_visible(True)
label = Gtk.Label(_('Disc ') + str(parentindex))
label.set_margin_bottom(10)
label.set_visible(True)
self._item_box.add(label)
self._item_box.add(listBox)
self.__add_track(self._tracks[0], self._discs[parentindex])
i -= 1
if (i == 0):
break
......
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