Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [fdc2e9e4c4]

Overview
Comment:Support file open dialog
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fdc2e9e4c4a871b62dbbea555fe65d23413303f1
User & Date: mario on 2016-12-11 19:16:52
Other Links: manifest | tags
Context
2016-12-14
15:57
new plugin: theme installer for Gtk2 and Windows; fixed for support of JSON format; gtk_reset_styles -- Oliver check-in: ec7df3c333 user: mario tags: trunk
2016-12-11
19:16
Support file open dialog check-in: fdc2e9e4c4 user: mario tags: trunk
19:16
Update manual .chm version check-in: 697f62158c user: mario tags: trunk
Changes

Modified contrib/prefstore.py from [744b6117ce] to [e5b03874ae].

1
2
3
4
5

6
7
8
9
10
11
12
13
14
15
16
17

18
19
20
21
22
23
24
1
2
3
4

5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
24




-
+











-
+







# encoding: UTF-8
# api: streamtuner2
# title: Config save/import/reset
# description: Allows to store, reimport or delete all preferences
# version: 0.1
# version: 0.2
# type: feature
# category: config
# priority: optional
#
# Adds a context menu "Staton > Extensions > Config ...", which allows
# to save or restore settings, or reset them to defaults.


from config import *
from channels import *
import ahttp
from uikit import uikit
from uikit import uikit, gtk
import action
import re
import json


# hooks three functions to the main extension menu
class prefstore():
33
34
35
36
37
38
39
40

41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50

51
52
53
54
55
56
57
58







-
+










-
+







        self.parent = parent
        uikit.add_menu([parent.extensions], "Config save", self.save)
        uikit.add_menu([parent.extensions], "Config restore", self.restore)
        uikit.add_menu([parent.extensions], "Config delete", self.reset)

    # Save conf.
    def save(self, *w):
        fn = uikit.save_file(title="Export streamtuner2 config",fn="streatuner2-config.json", formats=[("*.json", "*.json")])
        fn = uikit.save_file(title="Export streamtuner2 config", fn="streatuner2-config.json", formats=[("*.json", "*.json")])
        if not fn:
            return
        data = vars(conf)
        del data["args"]
        with open(fn, "w") as f:
            f.write(json.dumps(data, indent=4, sort_keys=True))
        self.parent.status("Settings saved to " + fn)

    # Save conf.
    def restore(self, *w):
        fn = uikit.save_file(title="Import streamtuner2 config",fn="streatuner2-config.json", formats=[("*.json", "*.json")])
        fn = uikit.save_file(title="Import streamtuner2 config", fn="streatuner2-config.json", formats=[("*.json", "*.json")], action=gtk.FILE_CHOOSER_ACTION_OPEN, action_btn=gtk.STOCK_OPEN)
        if not fn:
            return
        with open(fn, "r") as f:
            conf.update(json.load(f))
        conf.save()
        self.parent.status("Restart streamtuner2 for changes to take effect.")

Modified uikit.py from [bb85fd7f1b] to [bd76b93be8].

361
362
363
364
365
366
367

368
369

370
371

372

373
374
375
376
377
378
379
380

381
382
383
384
385
386
387
361
362
363
364
365
366
367
368
369

370
371
372
373

374

375
376
377
378
379
380

381
382
383
384
385
386
387
388







+

-
+


+
-
+
-






-
+







                                w.set_current_page(pos)
        pass



    #-- Save-As dialog
    #
    save_formats = [("*.pls", "*.pls"), ("*.xspf", "*.xpsf"), ("*.m3u", "*.m3u"), ("*.jspf", "*.jspf"), ("*.asx", "*.asx"), ("*.json", "*.json"), ("*.smil", "*.smil"), ("*.desktop", "*.desktop"), ("*","*")]
    @staticmethod
    def save_file(title="Save As", parent=None, fn="", formats=[("*.pls", "*.pls"), ("*.xspf", "*.xpsf"), ("*.m3u", "*.m3u"), ("*.jspf", "*.jspf"), ("*.asx", "*.asx"), ("*.json", "*.json"), ("*.smil", "*.smil"), ("*.desktop", "*.desktop"), ("*","*")]):
    def save_file(title="Save As", parent=None, fn="", formats=None, action=gtk.FILE_CHOOSER_ACTION_SAVE, action_btn=gtk.STOCK_SAVE):

        # With overwrite confirmation
        buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, action_btn, gtk.RESPONSE_OK)
        c = gtk.FileChooserDialog(title, parent, action=gtk.FILE_CHOOSER_ACTION_SAVE,
        c = gtk.FileChooserDialog(title, parent, action=action, buttons=buttons)
                buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_SAVE, gtk.RESPONSE_OK))
        c.set_do_overwrite_confirmation(True)

        # Params
        if fn:
            c.set_current_name(fn)
            fn = ""
        for fname,ftype in formats:
        for fname,ftype in (formats or self.save_formats):
            f = gtk.FileFilter()
            f.set_name(fname)
            f.add_pattern(ftype)
            c.add_filter(f)
        # Yes, that's how to retrieve signals for changed filter selections
        try:
            filterbox = c.get_children()[0].get_children()[0]