Browse the code

 

Differences between 213 and 214 on /.
Number of edited files: 5 (1 added, 0 deleted and 4 modified)
Revision 214

About 15 days and 10 hours ago.

* Added the ability to order the album lists by Artists names, Albums names or Release date
Added file(s) Deleted file(s) Modified file(s)

 

Old New Code
1
1
<?xml version="1.0" encoding="UTF-8"?>
2
 
<!-- Generated with glade 3.20.0 -->
 
2
<!-- Generated with glade 3.20.1 -->
3
3
<interface>
4
4
  <requires lib="gtk+" version="3.12"/>
5
5
  <object class="GtkBox" id="box1">
213
213
                            <property name="homogeneous">True</property>
214
214
                          </packing>
215
215
                        </child>
 
216
                        <child>
 
217
                          <object class="GtkToolItem" id="toolbutton3">
 
218
                            <property name="visible">True</property>
 
219
                            <property name="can_focus">False</property>
 
220
                            <child>
 
221
                              <object class="GtkButton" id="sortbutton">
 
222
                                <property name="visible">True</property>
 
223
                                <property name="can_focus">True</property>
 
224
                                <property name="receives_default">True</property>
 
225
                                <child>
 
226
                                  <object class="GtkImage">
 
227
                                    <property name="visible">True</property>
 
228
                                    <property name="can_focus">False</property>
 
229
                                    <property name="icon_name">emblem-documents-symbolic</property>
 
230
                                  </object>
 
231
                                </child>
 
232
                              </object>
 
233
                            </child>
 
234
                          </object>
 
235
                          <packing>
 
236
                            <property name="expand">False</property>
 
237
                            <property name="homogeneous">True</property>
 
238
                          </packing>
 
239
                        </child>
216
240
                      </object>
217
241
                      <packing>
218
242
                        <property name="expand">True</property>
219
243

                                        

 

Old New Code
59
59
                                    filename=sng[8]
60
60
                              ))
61
61

                                        
 
62
        self.year = sng[5]
 
63

                                    
62
64
    def __get_statistics(self):
63
65
        if self.__is_loaded:
64
66
            sql = SQLite()
98
100

                                        
99
101
            sql.close()
100
102
        else:
101
 
            raise Exception('[Album] object was not loaded.')
 
103
            raise Exception('[Album] object was not loaded.')
102
104

                                        

 

Old New Code
45
45

                                        
46
46
        # Create the IconView
47
47
        self.albumview = self.widgets[1].get_object('albumview')
48
 
        self.albummodel = ListStore(Pixbuf, str, str, str, int, str, str)
 
48
        self.albummodel = ListStore(Pixbuf, str, str, str, int, str, str, str)
49
49

                                        
50
50
        self.albumview.set_pixbuf_column(0)
51
51
        self.albumview.set_markup_column(1)
166
166
                                        '</b>\n<span foreground="grey">' +
167
167
                                        self.functions.view_encode(artist) +
168
168
                                        '</span>',
169
 
                                        artist, album, album_id, '', ''])
 
169
                                        artist, album, album_id, '', '',
 
170
                                        self.albums[album_id].year])
170
171

                                        
171
172
            album_id += 1
172
173

                                        
173
174

                                        

 

Old New Code
17
17

                                        
18
18
from gettext import gettext as _
19
19
from gi.repository.Gtk import (ListStore, EntryCompletion, CellRendererPixbuf,
20
 
                               CellRendererText, Builder as gtk_builder)
 
20
                               CellRendererText, Builder as gtk_builder,
 
21
                               Popover, SortType)
21
22
from gi.repository.GdkPixbuf import Pixbuf
22
23
from gi.repository.GLib import Error as GLIBError
 
24
from gi.repository.Pango import EllipsizeMode
23
25
from threading import Thread
24
26
from os.path import join, isfile, exists
25
27

                                        
109
111
        searchentry.set_completion(ecomplet)
110
112
        searchentry.grab_focus()
111
113

                                        
 
114
        # Sort button/popover window
 
115
        sortbutton = self.widgets[1].get_object('sortbutton')
 
116

                                    
 
117
        gtkpla = join(self.functions.datadir, 'glade', 'sortingpopover.ui')
 
118
        sortwin = gtk_builder()
 
119
        sortwin.add_from_file(gtkpla)
 
120
        hbox = sortwin.get_object('box-sorting')
 
121

                                    
 
122
        sortwin.get_object('label1').set_text(_('Order by:'))
 
123
        sortwin.get_object('label1').set_xalign(0)
 
124

                                    
 
125
        items = ListStore(int, str)
 
126
        items.append([0, _('Artists')])
 
127
        items.append([1, _('Albums')])
 
128
        items.append([2, _('Year')])
 
129

                                    
 
130
        combobox = sortwin.get_object('combo1')
 
131
        combobox.set_model(items)
 
132
        renderer_text = CellRendererText()
 
133
        renderer_text.props.ellipsize = EllipsizeMode.END
 
134
        combobox.pack_start(renderer_text, True)
 
135
        combobox.set_entry_text_column(1)
 
136
        combobox.add_attribute(renderer_text, 'text', 1)
 
137

                                    
 
138
        def on_combo_changed(widget):
 
139
            item_id = widget.get_model()[widget.get_active_iter()][0]
 
140

                                    
 
141
            albummodel = self.albumview.get_model().get_model()
 
142

                                    
 
143
            if item_id == 0:
 
144
                # Order by artists (by default)
 
145
                albummodel.set_sort_column_id(2, SortType.ASCENDING)
 
146
            elif item_id == 1:
 
147
                # Order by albums
 
148
                albummodel.set_sort_column_id(3, SortType.ASCENDING)
 
149
            else:
 
150
                # Order by years
 
151
                albummodel.set_sort_column_id(7, SortType.ASCENDING)
 
152

                                    
 
153
            sorting_pop.hide()
 
154

                                    
 
155
        combobox.set_active(0)
 
156
        combobox.connect('changed', on_combo_changed)
 
157

                                    
 
158
        sorting_pop = Popover.new(sortbutton)
 
159
        sorting_pop.set_size_request(200, 50)
 
160
        sorting_pop.add(hbox)
 
161

                                    
 
162
        def show_sortwindow(widget):
 
163
            sorting_pop.show_all()
 
164

                                    
 
165
        sortbutton.connect('clicked', show_sortwindow)
 
166

                                    
112
167
        def do_filter(widget):
113
168
            self.albumfilter.refilter()
114
169
            self.aview.matched = False
115
170