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

⌈⌋ branch:  streamtuner2


Check-in [b9cadd6925]

Overview
Comment:Rename `mygtk` to `uikit`. Move AuxiliaryWindow and About dialog from main.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b9cadd6925d5891c6b8ed813d638a3a298fe5dfe
User & Date: mario on 2015-03-29 14:43:28
Other Links: manifest | tags
Context
2015-03-29
14:44
Move search and streamedit dialogs into plugins. Less indentation. check-in: 99f122b391 user: mario tags: trunk
14:43
Rename `mygtk` to `uikit`. Move AuxiliaryWindow and About dialog from main. check-in: b9cadd6925 user: mario tags: trunk
14:41
Less indentation, update pack: list. check-in: 3c07d74bb6 user: mario tags: trunk
Changes

Modified uikit.py from [dec662c44d] to [9c82dd0573].

1
2
3
4
5
6
7
8
9
10
11
12
#
# encoding: UTF-8
# api: python
# type: functions
# title: mygtk helper functions
# description: simplify usage of some gtk widgets
# version: 1.8
# author: mario
# license: public domain
#
#
# Wrappers around gtk methods. The TreeView method .columns() allows




|







1
2
3
4
5
6
7
8
9
10
11
12
#
# encoding: UTF-8
# api: python
# type: functions
# title: uikit helper functions
# description: simplify usage of some gtk widgets
# version: 1.8
# author: mario
# license: public domain
#
#
# Wrappers around gtk methods. The TreeView method .columns() allows
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
#




# debug
from config import __print__, dbg

# filesystem
import os.path
import copy
import sys

from compat2and3 import unicode, xrange, PY3


# gtk version (2=gtk2, 3=gtk3)
ver = 2
# if running on Python3 or with commandline flag
if PY3 or "--gtk3" in sys.argv:







|





|







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
#




# debug
from config import __print__, dbg, plugin_meta

# filesystem
import os.path
import copy
import sys
import inspect
from compat2and3 import unicode, xrange, PY3


# gtk version (2=gtk2, 3=gtk3)
ver = 2
# if running on Python3 or with commandline flag
if PY3 or "--gtk3" in sys.argv:
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    ui_file = "gtk2.xml"
    empty_pixbuf = gtk.gdk.pixbuf_new_from_data(b"\0\0\0\0",gtk.gdk.COLORSPACE_RGB,True,8,1,1,4)




# simplified gtk constructors               ---------------------------------------------
class mygtk:


             
        #-- fill a treeview
        #
        # Adds treeviewcolumns/cellrenderers and liststore from a data dictionary.
        # Its datamap and the table contents can be supplied in one or two steps.







|







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
    ui_file = "gtk2.xml"
    empty_pixbuf = gtk.gdk.pixbuf_new_from_data(b"\0\0\0\0",gtk.gdk.COLORSPACE_RGB,True,8,1,1,4)




# simplified gtk constructors               ---------------------------------------------
class uikit:


             
        #-- fill a treeview
        #
        # Adds treeviewcolumns/cellrenderers and liststore from a data dictionary.
        # Its datamap and the table contents can be supplied in one or two steps.
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274




        #-- save window size and widget properties
        #
        # needs a list of widgetnames
        # e.g. pickle.dump(mygtk.app_state(...), open(os.environ["HOME"]+"/.config/app_winstate", "w"))
        #
        @staticmethod
        def app_state(wTree, widgetnames=["window1", "treeview2", "vbox17"]):
            r = {} # restore array
            for wn in widgetnames:
                r[wn] = {}
                w = wTree.get_widget(wn)







|







260
261
262
263
264
265
266
267
268
269
270
271
272
273
274




        #-- save window size and widget properties
        #
        # needs a list of widgetnames
        # e.g. pickle.dump(uikit.app_state(...), open(os.environ["HOME"]+"/.config/app_winstate", "w"))
        #
        @staticmethod
        def app_state(wTree, widgetnames=["window1", "treeview2", "vbox17"]):
            r = {} # restore array
            for wn in widgetnames:
                r[wn] = {}
                w = wTree.get_widget(wn)
540
541
542
543
544
545
546







































        progressbar.set_property("text", msg)
        while gtk.events_pending(): gtk.main_iteration(False)
      else:
        progresswin.hide()
    except: return
















































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
        progressbar.set_property("text", msg)
        while gtk.events_pending(): gtk.main_iteration(False)
      else:
        progresswin.hide()
    except: return




# Encapsulates references to gtk objects AND properties in main window,
# which allows to use self. and main. almost interchangably.
#
# This is a kludge to keep gtkBuilder widgets accessible; so just one
# instance has to be built. Also ties main.channels{} or .features{}
# dicts together for feature windows. Used by search, config, streamedit.
#
class AuxiliaryWindow(object):

    def __init__(self, parent):
        self.main = parent
        self.meta = plugin_meta(None, inspect.getcomments(inspect.getmodule(self)))
        
    def __getattr__(self, name):
        if name in self.main.__dict__:
            return self.main.__dict__[name]
        elif name in self.main.__class__.__dict__:
            return self.main.__class__.__dict__[name]
        else:
            return self.main.get_widget(name)




# Auxiliary window: about dialog
#
class AboutStreamtuner2(AuxiliaryWindow):
    def __init__(self, parent):
        a = gtk.AboutDialog()
        a.set_version(parent.__version__)
        a.set_name("streamtuner2")
        a.set_license("Public Domain\n\nNo Strings Attached.\nUnrestricted distribution,\nmodification, use.")
        a.set_authors(["Mario Salzer <http://mario.include-once.org/>\n\nConcept based on streamtuner 0."+"99."+"99 from\nJean-Yves Lefort, of which some code remains\nin the Google stations plugin.\n<http://www.nongnu.org/streamtuner/>\n\nMyOggRadio plugin based on cooperation\nwith Christian Ehm. <http://ehm-edv.de/>"])
        a.set_website("http://milki.include-once.org/streamtuner2/")
        a.connect("response", lambda a, ok: ( a.hide(), a.destroy() ) )
        a.show()