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

⌈⌋ ⎇ branch:  streamtuner2


Check-in [1786e24701]

Overview
Comment:Remove gtk/visibility setting in favour of show_all(). Fix pixbuf creation, b64decode ignoring non-base64 data.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 1786e247011f53ad0d15f4545d5271e00e137190
User & Date: mario on 2015-04-01 11:15:30
Other Links: manifest | tags
Context
2015-04-01
11:16
Slim down initialization (wrapper script for /usr/bin and pyzip will be used). Move module coupling into ST2 window constructor. check-in: b973f0e385 user: mario tags: trunk
11:15
Remove gtk/visibility setting in favour of show_all(). Fix pixbuf creation, b64decode ignoring non-base64 data. check-in: 1786e24701 user: mario tags: trunk
2015-03-31
19:26
Add basic menu_label= manually (GtkBuilder option seems to have no effect, only populates tab_label= with child widget.) check-in: 193527df2c user: mario tags: trunk
Changes

Modified uikit.py from [cbea8fe804] to [048bd8afa3].

23
24
25
26
27
28
29

30

31
32
33
34
35
36
37
# debug
from config import __print__, dbg, plugin_meta

# system
import os.path
import copy
import sys

import base64

import inspect
from compat2and3 import unicode, xrange, PY3
import pkgutil


# gtk version (2=gtk2, 3=gtk3, 7=tk;)
ver = 2







>

>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# debug
from config import __print__, dbg, plugin_meta

# system
import os.path
import copy
import sys
import re
import base64
import zlib
import inspect
from compat2and3 import unicode, xrange, PY3
import pkgutil


# gtk version (2=gtk2, 3=gtk3, 7=tk;)
ver = 2
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
    def bg(w, color="", where=["bg"]):
        """ this method should be called after widget creation, and before .add()ing it to container """
        if color:
            # wrap unstylable widgets into EventBox
            if not isinstance(w, gtk.Window):
                wrap = gtk.EventBox()
                wrap.add(w)
                wrap.set_property("visible", True)
                w = wrap
            # copy style object, modify settings
            s = w.get_style().copy()
            c = w.get_colormap().alloc_color(color)
            for state in (gtk.STATE_NORMAL, gtk.STATE_SELECTED):
                s.bg[state] = c
            w.set_style(s)
            # probably redundant, but better safe than sorry:
            w.modify_bg(gtk.STATE_NORMAL, c)
        # return modified or wrapped widget
        return w


    # Create GtkLabel
    @staticmethod
    def label(text, size=400, markup=0):
        label = gtk.Label(text)
        if markup:
            label.set_markup(text)
        label.set_property("visible", True)
        label.set_line_wrap(True) 
        label.set_size_request(size, -1)
        return label

    # Wrap two widgets in horizontal box
    @staticmethod
    def hbox(w1, w2):
        b = gtk.HBox(homogeneous=False, spacing=10)
        b.set_property("visible", True)
        b.pack_start(w1, expand=False, fill=False)
        b.pack_start(w2, expand=True, fill=True)
        return b


    # Attach textual menu entry and callback
    @staticmethod







|



















|








|







387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
    def bg(w, color="", where=["bg"]):
        """ this method should be called after widget creation, and before .add()ing it to container """
        if color:
            # wrap unstylable widgets into EventBox
            if not isinstance(w, gtk.Window):
                wrap = gtk.EventBox()
                wrap.add(w)
                ##########wrap.set_property("visible", True)
                w = wrap
            # copy style object, modify settings
            s = w.get_style().copy()
            c = w.get_colormap().alloc_color(color)
            for state in (gtk.STATE_NORMAL, gtk.STATE_SELECTED):
                s.bg[state] = c
            w.set_style(s)
            # probably redundant, but better safe than sorry:
            w.modify_bg(gtk.STATE_NORMAL, c)
        # return modified or wrapped widget
        return w


    # Create GtkLabel
    @staticmethod
    def label(text, size=400, markup=0):
        label = gtk.Label(text)
        if markup:
            label.set_markup(text)
        #######label.set_property("visible", True)
        label.set_line_wrap(True) 
        label.set_size_request(size, -1)
        return label

    # Wrap two widgets in horizontal box
    @staticmethod
    def hbox(w1, w2):
        b = gtk.HBox(homogeneous=False, spacing=10)
        ######b.set_property("visible", True)
        b.pack_start(w1, expand=False, fill=False)
        b.pack_start(w2, expand=True, fill=True)
        return b


    # Attach textual menu entry and callback
    @staticmethod
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
                if os.path.exists(f):
                    gtk.rc_parse(f)
            pass

        
    # Pixbug loader (from inline string, as in `logo.png`)
    @staticmethod
    def pixbuf(buf, fmt="png"):
        p = GdkPixbuf.PixbufLoader(fmt)
        try: # inline encoding
            buf = base64.b64decode(buf)
        except:
            None
        #print "PNG: %s" % len(buf)
        p.write(buf, len(buf))
        #print "FMT: %s" % p.get_format()
        pix = p.get_pixbuf()
        p.close()
        #print "PIX: %s" % pix
        return pix
            
            


# Text-only dropdown list.
#







|
|
|
|
|
<
|

<


<







452
453
454
455
456
457
458
459
460
461
462
463

464
465

466
467

468
469
470
471
472
473
474
                if os.path.exists(f):
                    gtk.rc_parse(f)
            pass

        
    # Pixbug loader (from inline string, as in `logo.png`)
    @staticmethod
    def pixbuf(buf, fmt="png", decode=True, gzip=False):
        p = GdkPixbuf.PixbufLoader(*[fmt] if fmt else [])
        if decode and re.match("^[\w+/=\s]+$", buf):
            buf = base64.b64decode(buf)  # inline encoding
        if gzip:

            buf = zlib.decompress(buf)
        p.write(buf, len(buf))

        pix = p.get_pixbuf()
        p.close()

        return pix
            
            


# Text-only dropdown list.
#
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500

    ls = None

    def __init__(self, entries, no_scroll=1):

        # prepare widget
        gtk.ComboBox.__init__(self)
        self.set_property("visible", True)
        cell = gtk.CellRendererText()
        self.pack_start(cell, True)
        self.add_attribute(cell, "text", 1)
        if no_scroll:
            self.connect("scroll_event", self.no_scroll)

        # collect entries







|







485
486
487
488
489
490
491
492
493
494
495
496
497
498
499

    ls = None

    def __init__(self, entries, no_scroll=1):

        # prepare widget
        gtk.ComboBox.__init__(self)
        ########self.set_property("visible", True)
        cell = gtk.CellRendererText()
        self.pack_start(cell, True)
        self.add_attribute(cell, "text", 1)
        if no_scroll:
            self.connect("scroll_event", self.no_scroll)

        # collect entries
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
        progresswin.set_property("title", "streamtuner2")
        progresswin.set_property("default_width", 300)
        progresswin.set_property("width_request", 300)
        progresswin.set_property("default_height", 30)
        progresswin.set_property("height_request", 30)
        #progresswin.set_property("window_position", "center")
        progresswin.set_property("decorated", False)
        progresswin.set_property("visible", True)

        # GtkProgressBar "progressbar"
        progressbar = gtk.ProgressBar()
        progressbar.set_property("visible", True)
        progressbar.set_property("show_text", True)
        progressbar.set_property("text", msg)
        progresswin.add(progressbar)
        progresswin.show_all()

    try:
      if p<1:







|



|







548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
        progresswin.set_property("title", "streamtuner2")
        progresswin.set_property("default_width", 300)
        progresswin.set_property("width_request", 300)
        progresswin.set_property("default_height", 30)
        progresswin.set_property("height_request", 30)
        #progresswin.set_property("window_position", "center")
        progresswin.set_property("decorated", False)
        #######progresswin.set_property("visible", True)

        # GtkProgressBar "progressbar"
        progressbar = gtk.ProgressBar()
        #########progressbar.set_property("visible", True)
        progressbar.set_property("show_text", True)
        progressbar.set_property("text", msg)
        progresswin.add(progressbar)
        progresswin.show_all()

    try:
      if p<1:
603
604
605
606
607
608
609
610
611
612
613
614
#
class AboutStreamtuner2(AuxiliaryWindow):
    def __init__(self, parent):
        a = gtk.AboutDialog()
        a.set_name(parent.meta["id"])
        a.set_version(parent.meta["version"])
        a.set_license(parent.meta["license"])
        a.set_authors(parent.meta["author"].split(","))
        a.set_website(parent.meta["url"])
        a.connect("response", lambda a, ok: ( a.hide(), a.destroy() ) )
        a.show()
            







|


|

602
603
604
605
606
607
608
609
610
611
612
613
#
class AboutStreamtuner2(AuxiliaryWindow):
    def __init__(self, parent):
        a = gtk.AboutDialog()
        a.set_name(parent.meta["id"])
        a.set_version(parent.meta["version"])
        a.set_license(parent.meta["license"])
        a.set_authors((pkgutil.get_data("config", "CREDITS") or parent.meta["author"]).split("\n"))
        a.set_website(parent.meta["url"])
        a.connect("response", lambda a, ok: ( a.hide(), a.destroy() ) )
        a.show_all()