Index: channels/__init__.py ================================================================== --- channels/__init__.py +++ channels/__init__.py @@ -74,17 +74,18 @@ gtk_cat = None # Gtk widget for category columns ls = None # ListStore for station treeview rowmap = None # Preserve streams-datamap pix_entry = None # ListStore entry that contains favicon img_resize = None # Rescale `img` references to icon size + fixed_size = [24,24] # Default height+width for favicons # mapping of stream{} data into gtk treeview/treestore representation datamap = [ # coltitle width [ datasrc key, type, renderer, attrs ] [cellrenderer2], ... ["", 20, ["state", str, "pixbuf", {}], ], ["Genre", 65, ['genre', str, "t", {}], ], - ["Station Title",275, ["title", str, "text", {"strikethrough":11, "cell-background":12, "cell-background-set":13}], ["favicon", gtk.gdk.Pixbuf, "pixbuf", {}], ], + ["Station Title",275, ["title", str, "text", {"strikethrough":11, "cell-background":12, "cell-background-set":13}], ["favicon", gtk.gdk.Pixbuf, "pixbuf", {"expand":False}], ], ["Now Playing", 185, ["playing", str, "text", {"strikethrough":11}], ], #{"width":20} ["Listeners", 45, ["listeners", int, "t", {"strikethrough":11}], ], #["Max", 45, ["max", int, "t", {}], ], ["Bitrate", 35, ["bitrate", int, "t", {}], ], ["Homepage", 160, ["homepage", str, "t", {"underline":10}], ], @@ -185,11 +186,12 @@ # Just wraps uikit.columns() to retain liststore, rowmap and pix_entry def columns(self, entries=None): self.ls, self.rowmap, self.pix_entry = uikit.columns( - self.gtk_list, self.datamap, entries, show_favicons=True + self.gtk_list, self.datamap, entries, + show_favicons=True, fixed_size=self.fixed_size ) # no longer using `conf.show_favicons` # Statusbar stub (defers to parent/main window, if in GUI mode) Index: contrib/reddit.py ================================================================== --- contrib/reddit.py +++ contrib/reddit.py @@ -48,11 +48,14 @@ # control attributes has_search = False listformat = "srv" audioformat = "video/youtube" titles = dict(playing="submitter", listeners="votes", bitrate=False) - img_resize = 24 # scale down reddit preview `img` artwork + + # favicon scaling (from reddit preview `img`) + img_resize = 32 + fixed_size = [32,26] # just subreddit names to extract from categories = [ # static radio list "radioreddit 📟", @@ -294,11 +297,10 @@ state = "gtk-page-setup" format = "url/http" else: log.DATA_SKIP(format, row["url"]) continue - #log.DATA(format, row["url"]) # repack into streams list r.append(dict( title = row["title"], url = row["url"], Index: uikit.py ================================================================== --- uikit.py +++ uikit.py @@ -84,20 +84,20 @@ # entries = [ {"titlerow":"first", "interndat":123}, {"titlerow":"..."}, ] # Keys not mentioned in the datamap get ignored, and defaults are applied # for missing cols. All values must already be in the correct type however. # @staticmethod - def columns(widget, datamap=[], entries=None, show_favicons=True, pix_entry=False): + def columns(widget, datamap=[], entries=None, show_favicons=True, pix_entry=False, fixed_size=24): # create treeviewcolumns? - if (not widget.get_column(0)): + if not widget.get_column(0): # loop through titles datapos = 0 - for n_col,desc in enumerate(datamap): - + for n_col, desc in enumerate(datamap): + # check for title - if (type(desc[0]) != str): + if not isinstance(desc[0], str): datapos += 1 # if there is none, this is just an undisplayed data column continue # new tvcolumn col = gtk.TreeViewColumn(desc[0]) # title col.set_resizable(True) @@ -105,22 +105,27 @@ if (desc[1] > 0): col.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) col.set_fixed_width(desc[1]) # loop through cells - for var in xrange(2, len(desc)): + for var in range(2, len(desc)): cell = desc[var] # cell renderer if (cell[2] == "pixbuf"): rend = gtk.CellRendererPixbuf() # img cell - rend.set_fixed_size(24, 24) - if (cell[1] == str): - cell[3]["stock_id"] = datapos # for stock icons + # stock icons + if cell[1] == str: # only match for literal `str` + cell[3]["stock_id"] = datapos expand = False + # pixbufs else: pix_entry = datapos cell[3]["pixbuf"] = datapos + if fixed_size: + if not isinstance(fixed_size, list): + fixed_size = [fixed_size, fixed_size] + rend.set_fixed_size(*fixed_size) else: rend = gtk.CellRendererText() # text cell cell[3]["text"] = datapos #col.set_sort_column_id(datapos) # only on textual cells @@ -133,17 +138,10 @@ datapos += 1 #log.INFO(cell, len(cell)) # add column to treeview widget.append_column(col) - # finalize widget - widget.set_search_column(5) #?? - widget.set_search_column(4) #?? - widget.set_search_column(3) #?? - widget.set_search_column(2) #?? - widget.set_search_column(1) #?? - #widget.set_reorderable(True) # add data? if (entries is not None): #- expand datamap vartypes = [] #(str, str, bool, str, int, int, gtk.gdk.Pixbuf, str, int)