Browse the code

 

Differences between 216 and 217 on /.
Number of edited files: 5 (0 added, 0 deleted and 5 modified)
Revision 217

About 2 months and 19 days ago.

* Restored configuration window (in a popover button)
Added file(s) Deleted file(s) Modified file(s)

 

Old New Code
127
127
                tree = self.get_xml(url)
128
128

                                        
129
129
                artist = tree.find('artist')
 
130
                if artist is None:
 
131
                    return
 
132

                                    
130
133
                images = artist.getiterator('image')
131
134
                for img in images:
132
135
                    if img.attrib['size'] == 'large':
133
136

                                        

 

Old New Code
68
68
        # Add the about button
69
69
        about_button = Button(relief=2)
70
70
        about_button.add(Image.new_from_gicon(ThemedIcon(
71
 
                              name='help-about-symbolic'), IconSize.BUTTON))
 
71
                         name='help-about-symbolic'), IconSize.BUTTON))
72
72
        box.pack_end(about_button)
73
73

                                        
74
74
        # Add the reload button
75
75
        refresh_button = Button(relief=2)
76
76
        refresh_button.add(Image.new_from_gicon(ThemedIcon(
77
 
                              name='view-refresh-symbolic'), IconSize.BUTTON))
 
77
                           name='view-refresh-symbolic'), IconSize.BUTTON))
78
78
        box.pack_end(refresh_button)
79
79

                                        
 
80
        # Add the configuration button
 
81
        config_button = Button(relief=2)
 
82
        config_button.add(Image.new_from_gicon(ThemedIcon(
 
83
                          name='preferences-system-symbolic'), IconSize.BUTTON))
 
84
        box.pack_end(config_button)
 
85

                                    
80
86
        # Add PREVIOUS/STOP/PLAYPAUSE/NEXT buttons
81
87
        player_box = Box(orientation=Orientation.HORIZONTAL)
82
88
        StyleContext.add_class(player_box.get_style_context(), 'linked')
124
130
            dialog.set_authors(['Erwan Briand <erwan@codingteam.net>'])
125
131
            dialog.set_translator_credits()
126
132

                                        
127
 
            dialog.set_copyright('Copyright © 2007-2017 Erwan Briand ' +
 
133
            dialog.set_copyright('Copyright © 2007-2019 Erwan Briand ' +
128
134
                                 '<erwan@codingteam.net>')
129
135

                                        
130
136
            dialog.set_comments(_('Ergonomic and modern music player ' +
151
157
        # Start main handler
152
158
        headerbar_wdg = [box, None, about_button, refresh_button,
153
159
                         player_box, previous_b, stop_b, playpause_b, next_b,
154
 
                         None, win.get_object('box1'), self.main_window]
 
160
                         None, win.get_object('box1'), self.main_window,
 
161
                         config_button]
155
162
        self.wdg = [headerbar_wdg, win]
156
163

                                        
157
164
    def start_thread(self):
158
165

                                        

 

Old New Code
129
129
            idle_add(self.widgets[0][6].set_sensitive, False)
130
130
            idle_add(self.widgets[0][7].set_sensitive, False)
131
131
            idle_add(self.widgets[0][8].set_sensitive, False)
 
132
            idle_add(self.widgets[0][12].set_sensitive, False)
132
133

                                        
133
134
            idle_add(self.widgets[1].get_object('box1').add, box_content)
134
135

                                        
197
198
            # Show original GUI
198
199
            idle_add(self.widgets[0][2].set_sensitive, True)
199
200
            idle_add(self.widgets[0][3].set_sensitive, True)
 
201
            idle_add(self.widgets[0][12].set_sensitive, True)
200
202
            idle_add(box_content.hide)
201
203
            idle_add(self.widgets[1].get_object('box2').show_all)
202
204
            idle_add(self.create_view)
203
205

                                        

 

Old New Code
18
18
from gettext import gettext as _
19
19
from gi.repository.Gtk import (Label, Switch, ListBoxRow, Box, Orientation,
20
20
                               ComboBox, CellRendererText, Frame, ListStore,
21
 
                               Settings)
 
21
                               Settings, Popover, ScrolledWindow, ShadowType)
22
22
from gi.repository.Pango import WrapMode
23
23

                                        
24
24
from common.config import ConfigLoader
26
26

                                        
27
27
class Configuration:
28
28
    def __init__(self, widgets, scrolledwindow, contentbox):
 
29
        self.config_button = widgets[0][12]
 
30
        self.config_button.connect('clicked', self.on_open_config)
 
31

                                    
 
32
    def on_open_config(self, widget):
 
33
        popup = Popover.new(self.config_button)
 
34
        popup.set_size_request(400, 350)
 
35
        contentbox = Box.new(Orientation.VERTICAL, 5)
 
36
        config_wdw = ScrolledWindow(expand=False)
 
37
        config_wdw.add(contentbox)
 
38
        config_wdw.set_size_request(380, -1)
 
39
        config_wdw.set_hexpand(False)
 
40
        config_wdw.set_vexpand(True)
 
41
        config_wdw.set_property('margin_start', 10)
 
42
        config_wdw.set_property('margin_end', 10)
 
43

                                    
 
44
        popup.add(config_wdw)
 
45

                                    
29
46
        # Widgets for user interface
30
 
        frame = Frame(label=_('User interface'))
 
47
        frame = Frame(label='')
 
48
        frame.get_label_widget().set_markup('<b>' + _('User interface') + '</b>')
 
49
        frame.set_shadow_type(ShadowType.NONE)
31
50
        contentbox.add(frame)
32
51

                                        
33
52
        framebox = Box(orientation=Orientation.VERTICAL, spacing=5)
55
74
        hbox.pack_start(switch, False, False, 0)
56
75

                                        
57
76
        # Widgets for random mode
58
 
        frame = Frame(label=_('Drunk mode'))
 
77
        frame = Frame(label='')
 
78
        frame.get_label_widget().set_markup('<b>' + _('Drunk mode') + '</b>')
 
79
        frame.set_shadow_type(ShadowType.NONE)
59
80
        frame.set_margin_top(10)
60
81
        contentbox.add(frame)
61
82

                                        
67
88
        frame.add(framebox)
68
89

                                        
69
90
        lbl = Label(xalign=0)
70
 
        lbl.set_markup('<small><b>' + _('Automatic playback when playlist is empty and nothing queued. We choose music for you.') + '</b></small>')
 
91
        lbl.set_markup('<small>' + _('Automatic playback when playlist is empty and nothing queued. We choose music for you.') + '</small>')
71
92
        lbl.set_line_wrap_mode(WrapMode.WORD)
72
93
        lbl.set_line_wrap(True)
73
94
        framebox.add(lbl)
75
96
        hbox = Box(orientation=Orientation.HORIZONTAL, spacing=5)
76
97
        framebox.add(hbox)
77
98
        lbl = Label(xalign=0)
78
 
        lbl.set_markup('<small>' + _('Mode:') + '</small>')
 
99
        lbl.set_markup('<small>' + _('Activate:') + '</small>')
79
100
        lbl.set_line_wrap_mode(WrapMode.WORD)
80
101
        lbl.set_line_wrap(True)
81
102
        hbox.pack_start(lbl, True, True, 0)
82
103

                                        
83
104
        switch = Switch()
84
105
        switch.set_vexpand(False)
 
106
        switch.connect('notify::active', self.on_switch, 'Player', 'drunk_mode')
85
107

                                        
86
108
        useroption = bool(int(config.config['Player']['drunk_mode']))
87
109
        switch.set_active(useroption)
99
121
        framebox.add(mode_combo)
100
122

                                        
101
123
        useroption = config.config['Player']['drunk_mode_type']
102
 
        #mode_combo.set_active(mode_store[useroption].get_path()[0])
 
124
        if useroption == 'similar':
 
125
            mode_combo.set_active(0)
 
126
        else:
 
127
            mode_combo.set_active(1)
103
128

                                        
 
129
        mode_combo.connect('changed', self.on_combo, 'Player', 'drunk_mode_type')
 
130

                                    
104
131
        # Widgets for replaygain
105
 
        frame = Frame(label=_('ReplayGain'))
 
132
        frame = Frame(label='')
 
133
        frame.get_label_widget().set_markup('<b>' + _('ReplayGain') + '</b>')
 
134
        frame.set_shadow_type(ShadowType.NONE)
106
135
        frame.set_margin_top(10)
107
136
        contentbox.add(frame)
108
137

                                        
114
143
        frame.add(framebox)
115
144

                                        
116
145
        lbl = Label(xalign=0)
117
 
        lbl.set_markup('<small><b>' + _('Normalize loudness (avoids the common problem of having to manually adjust volume levels between tracks).') + '</b></small>')
 
146
        lbl.set_markup('<small>' + _('Normalize loudness (avoids the common problem of having to manually adjust volume levels between tracks).') + '</small>')
118
147
        lbl.set_line_wrap_mode(WrapMode.WORD)
119
148
        lbl.set_line_wrap(True)
120
149
        framebox.add(lbl)
122
151
        hbox = Box(orientation=Orientation.HORIZONTAL, spacing=5)
123
152
        framebox.add(hbox)
124
153
        lbl = Label(xalign=0)
125
 
        lbl.set_markup('<small>' + _('Mode:') + '</small>')
 
154
        lbl.set_markup('<small>' + _('Activate:') + '</small>')
126
155
        lbl.set_line_wrap_mode(WrapMode.WORD)
127
156
        lbl.set_line_wrap(True)
128
157
        hbox.pack_start(lbl, True, True, 0)
129
158

                                        
130
159
        switch = Switch()
131
160
        switch.set_vexpand(False)
 
161
        switch.connect('notify::active', self.on_switch, 'Player', 'replaygain')
 
162

                                    
 
163
        useroption = bool(int(config.config['Player']['replaygain']))
 
164
        switch.set_active(useroption)
 
165

                                    
132
166
        hbox.pack_start(switch, False, False, 0)
133
167

                                        
134
168
        mode_store = ListStore(str, str)
142
176
        mode_combo.add_attribute(renderer_text, 'text', 1)
143
177
        framebox.add(mode_combo)
144
178

                                        
 
179
        useroption = config.config['Player']['replaygain_mode']
 
180
        if useroption == 'auto':
 
181
            mode_combo.set_active(0)
 
182
        elif useroption == 'album':
 
183
            mode_combo.set_active(1)
 
184
        else:
 
185
            mode_combo.set_active(2)
145
186

                                        
 
187
        mode_combo.connect('changed', self.on_combo, 'Player', 'replaygain_mode')
146
188

                                        
 
189
        popup.show_all()
 
190

                                    
 
191

                                    
147
192
    def on_darkmode_activate(self, widget, event):
148
193
        state = widget.get_active()
149
194

                                        
154
199
        # Save option
155
200
        config.update_key('Window', 'dark_theme', str(int(state)))
156
201

                                        
 
202

                                    
 
203
    def on_switch(self, widget, event, group, key):
 
204
        state = widget.get_active()
 
205

                                    
 
206
        # Change key value
 
207
        config.update_key(group, key, str(int(state)))
 
208

                                    
 
209

                                    
 
210
    def on_combo(self, widget, group, key):
 
211
        id_item = widget.get_active()
 
212
        value = None
 
213

                                    
 
214
        if group == 'Player' and key == 'drunk_mode_type':
 
215
            if id_item == 0:
 
216
                value = 'similar'
 
217
            else:
 
218
                value = 'random'
 
219
        elif group == 'Player' and key == 'replaygain_mode':
 
220
            if id_item == 0:
 
221
                value = 'auto'
 
222
            elif id_item == 1:
 
223
                value = 'album'
 
224
            else:
 
225
                value = 'track'
 
226

                                    
 
227
        if value is None:
 
228
            try:
 
229
                raise ValueError('['+group+'] '+key+': '+str(id_item))
 
230
            except:
 
231
                print ('Unknown configuration key. Aborting.')
 
232
                raise
 
233

                                    
 
234
            return
 
235

                                    
 
236
        # Change key value
 
237
        config.update_key(group, key, value)
157
238

                                        

 

Old New Code
213
213
                if sng.track == self.current_song.track:
214
214
                   item_in_album = a
215
215

                                        
 
216
            print (item_in_album, album_items)
 
217

                                    
216
218
            if item_in_album < album_items:
217
219
                self.on_play_new_song(self.current_album.tracks[item_in_album + 1])
218
220
            else:
219
221