Check-in [43b36ed35b]
Overview
| Comment: | new plugin: specbuttons allows to define mini
toolbar buttons to control applications (audio settings, mute/volume,
start/kill players or other apps).
Has been externalized as plugin. The UI features are built into gtk3.xml
|
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
43b36ed35b1488d5d625c0463e9fc4e1 |
| User & Date: | mario on 2016-10-22 19:07:55 |
| Other Links: | manifest | tags |
Context
|
2016-10-23
| ||
| 16:28 | action: Allow %url %title placeholders also with $ prefix. Also reuse interpolate() function for specbuttons and without default %pls. check-in: 27c88c7dcd user: mario tags: trunk | |
|
2016-10-22
| ||
| 19:07 |
new plugin: specbuttons allows to define mini
toolbar buttons to control applications (audio settings, mute/volume,
start/kill players or other apps).
Has been externalized as plugin. The UI features are built into gtk3.xml
| |
| 19:01 | Minor text fixes check-in: e421c1af60 user: mario tags: trunk | |
Changes
Added channels/specbuttons.py version [bddc19b064].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# encoding: utf-8
# title: Extra buttons for apps
# description: Adds configurable mini toolbar buttons
# version: 0.5
# depends: streamtuner2 >= 2.2.0
# type: feature
# category: ui
# config:
# { name: specbutton_rows, value: 2, type: int, description: "Number of rows to arrange buttons in (default 2, looks ok with up to 3 rows)" }
#
# Shows the mini extra buttons in the toolbar, which allow to control your
# audio player or run other system commands. The configuration list is in
# the Settings → Options tab.
#
# Icons can either be gtk-xyz icon names, or load /usr/share/icon/*.png
# pixmaps.
import os.path
import subprocess
import math
import re
from config import conf, log
import action
from uikit import gtk
# Channel Homepage in Toolbar
class specbuttons(object):
module = __name__
# Hook toolbar label
def __init__(self, parent):
self.parent = parent
self.specbuttons = parent.get_widget("specbuttons")
parent.hooks["init"].append(self.update_buttons)
parent.hooks["config_save"].append(self.update_paths)
parent.specbuttons.show()
parent.tv_config_specbuttons.show()
# Extra buttons
def update_buttons(self, parent):
# define table width (2 rows default)
y = min(int(conf.specbutton_rows), 4)
self.specbuttons.resize(y, int(math.ceil(len(conf.specbuttons) / y)))
# clean up
for widget in self.specbuttons.get_children():
widget.destroy()
xy = 0
# add icon buttons
for btn, cmd in conf.specbuttons.items():
#log.IN(btn, cmd)
w_btn = gtk.Button()
w_btn.set_image(self.icon(btn))
w_btn.connect("clicked", lambda x0, cmd=cmd, *x: action.run(cmd) )
self.specbuttons.attach(
w_btn,
int(xy / y), int(xy / y) + 1, xy % y, (xy % y) + 1,
gtk.EXPAND, gtk.EXPAND, 1, 1
)
xy = xy + 1
self.specbuttons.show_all()
# Instantiate Image from gtk-* string or path
def icon(self, btn):
wi = gtk.Image()
if (btn.find("gtk-") == 0):
wi.set_from_stock(btn, gtk.ICON_SIZE_SMALL_TOOLBAR)
else:
if not os.path.exists(btn):
btn = self.locate(btn)
log.DATA(btn)
if btn:
wi.set_from_file(btn)
else:
wi.set_from_stock("gtk-image-missing", gtk.ICON_SIZE_SMALL_TOOLBAR)
return wi
# Look for image basename "play" in /usr/share/icons/*.*
def locate(self, btn):
f = subprocess.Popen(["locate", "/usr/share/[pi]*s/*%s*.*" % btn], stdout=subprocess.PIPE)
path, err = f.communicate()
if not err:
return path.split("\n")[0]
# Update paths when saving config dialog
def update_paths(self):
r = {}
for btn, cmd in conf.specbuttons.items():
# replace "gtk." to "gtk-"
if re.match("^gtk\.\w+", btn, re.I):
btn = re.sub("[._]+", "-", btn).lower()
# not /path or gtk-
elif not re.match("^/|\./|gtk-", btn):
path = self.locate(btn)
if path:
btn = path
else:
log.WARN("Extra button icon '%s' could not be found" % btn)
r[btn] = cmd
conf.specbuttons = r
self.update_buttons(self.parent)
|
Modified gtk3.xml.gz from [8289f3469a] to [9e4c8a0b5c].
cannot compute difference between binary files
Modified st2.py from [af3c3860ce] to [6db22b65ab].
| ︙ | ︙ | |||
30 31 32 33 34 35 36 | # # Primarily radio stations are displayed, some channels however are music # collections. Commercial and sign-up services are not an objective. # standard modules import sys | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # # Primarily radio stations are displayed, some channels however are music # collections. Commercial and sign-up services are not an objective. # standard modules import sys import os import re from copy import copy import inspect import traceback from threading import Thread import time from compat2and3 import * |
| ︙ | ︙ | |||
195 196 197 198 199 200 201 |
})
# actually display main window
if conf.window_title:
self.update_title()
self.win_streamtuner2.show_all()
gui_startup(100.0)
| < | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
})
# actually display main window
if conf.window_title:
self.update_title()
self.win_streamtuner2.show_all()
gui_startup(100.0)
#-- Shortcut for glade.get_widget()
# Allows access to widgets as direct attributes instead of using .get_widget()
# Also looks in self.channels[] for the named channel plugins
def __getattr__(self, name):
if name in self.channels:
|
| ︙ | ︙ | |||
444 445 446 447 448 449 450 |
pix = uikit.pixbuf(logo.png, decode=1, fmt="png")
if map and map in (2,5,0): # gtk.ICON_SIZE_SMALL_TOOLBAR / _DND / _DIALOG
r = { 2: 0.45, 5: 0.75, 0: 1.0 }[map]
if r != 1.0:
pix = pix.scale_simple(int(321*r), int(115*r), gtk.gdk.INTERP_BILINEAR)
self.img_logo.set_from_pixbuf(pix)
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
pix = uikit.pixbuf(logo.png, decode=1, fmt="png")
if map and map in (2,5,0): # gtk.ICON_SIZE_SMALL_TOOLBAR / _DND / _DIALOG
r = { 2: 0.45, 5: 0.75, 0: 1.0 }[map]
if r != 1.0:
pix = pix.scale_simple(int(321*r), int(115*r), gtk.gdk.INTERP_BILINEAR)
self.img_logo.set_from_pixbuf(pix)
# load application state (widget sizes, selections, etc.)
def init_app_state(self):
winlayout = conf.load("window")
if (winlayout):
try:
uikit.app_restore(self, winlayout)
self.logo_scale(map=winlayout["toolbar"]["icon_size"])
|
| ︙ | ︙ |