Index: compat2and3.py ================================================================== --- compat2and3.py +++ compat2and3.py @@ -21,10 +21,11 @@ PY3 = 0 # basic functions xrange = xrange range = xrange + unicode = unicode # urllib modules import urllib import urllib2 from urllib import urlencode @@ -42,10 +43,11 @@ PY2 = 0 PY3 = 1 # basic functions xrange = range + unicode = str # urllib modules import urllib.request as urllib import urllib.request as urllib2 from urllib.parse import urlencode Index: help/streamtuner2.1 ================================================================== --- help/streamtuner2.1 +++ help/streamtuner2.1 @@ -1,6 +1,5 @@ -.\" this is one of the nanoweb man pages .\" (many thanks to the manpage howto!) .\" .TH streamtuner2 "January 2014" "BSD/Linux" "User Manuals" .SH NAME streamtuner2 \- Browser for internet radio stations @@ -58,14 +57,23 @@ returns all info about the first match as JSON output. .TP .BI streamtuner2 " play frequence3" Looks for the first occourence, and starts the audio player for FREQUENCE3. + +.SH GRAPHICAL MODE + +There's only one option for the graphical UI mode: +.TP +.BI --gtk3 +Loads Gtk3 via PyGI instead of Gtk2. This is implicit when running on Python3 +anyway. + .SH FILES .IR /home/ $USER /.config/streamtuner2/settings.json .SH "SEE ALSO" .BR streamripper (1) .BR audacious (1) .BR json (5) .BR m3u (5) .BR pls (5) Index: mygtk.py ================================================================== --- mygtk.py +++ mygtk.py @@ -32,19 +32,17 @@ # filesystem import os.path import copy import sys -if sys.version_info[0] >= 3: - unicode = str +from compat2and3 import unicode, xrange, PY3 -# gtk version -ver = 2 # 2=gtk2, 3=gtk3 -if "--gtk3" in sys.argv: - ver = 3 -if sys.version_info >= (3, 0): +# gtk version (2=gtk2, 3=gtk3) +ver = 2 +# if running on Python3 or with commandline flag +if PY3 or "--gtk3" in sys.argv: ver = 3 # load gtk modules if ver==3: from gi import pygtkcompat as pygtk pygtk.enable() @@ -51,24 +49,21 @@ pygtk.enable_gtk(version='3.0') from gi.repository import Gtk as gtk from gi.repository import GObject as gobject from gi.repository import GdkPixbuf ui_file = "gtk3.xml" + empty_pixbuf = GdkPixbuf.Pixbuf.new_from_data(b"\0\0\0\0", GdkPixbuf.Colorspace.RGB, True, 8, 1, 1, 4, None, None) __print__(dbg.PROC, gtk) __print__(dbg.PROC, gobject) else: import pygtk import gtk import gobject 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) -try: - empty_pixbuf = gtk.gdk.pixbuf_new_from_data(b"\0\0\0\0",gtk.gdk.COLORSPACE_RGB,True,8,1,1,4) -except: - empty_pixbuf = GdkPixbuf.Pixbuf.new_from_data(b"\0\0\0\0", GdkPixbuf.Colorspace.RGB, True, 8, 1, 1, 4, None, None) - # simplified gtk constructors --------------------------------------------- class mygtk: @@ -114,11 +109,11 @@ if (desc[1] > 0): col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_fixed_width(desc[1]) # loop through cells - for var in range(2, len(desc)): + for var in xrange(2, len(desc)): cell = desc[var] # cell renderer if (cell[2] == "pixbuf"): rend = gtk.CellRendererPixbuf() # img cell if (cell[1] == str): @@ -156,11 +151,11 @@ #- expand datamap vartypes = [] #(str, str, bool, str, int, int, gtk.gdk.Pixbuf, str, int) rowmap = [] #["title", "desc", "bookmarked", "name", "count", "max", "img", ...] if (not rowmap): for desc in datamap: - for var in range(2, len(desc)): + for var in xrange(2, len(desc)): vartypes.append(desc[var][1]) # content types rowmap.append(desc[var][0]) # dict{} column keys in entries[] list # create gtk array storage ls = gtk.ListStore(*vartypes) # could be a TreeStore, too __print__(vartypes) Index: pson.py ================================================================== --- pson.py +++ pson.py @@ -20,13 +20,11 @@ #-- reading and writing json (for the config module) ---------------------------------- import sys -if sys.version_info > (2, 9): - unicode = str - #dict.iteritems = dict.items +from compat2and3 import unicode # try to load the system module first try: from json import dump as json_dump, load as json_load except: