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 | # gtk modules
from uikit import pygtk, gtk, gobject, uikit, ui_xml, gui_startup, AboutStreamtuner2
# custom modules
import ahttp
import action
import logo
import favicon
import channels
import channels.bookmarks
import channels.configwin
import channels.streamedit
import channels.search
# This represents the main window, dispatches Gtk events,
# and shares most application behaviour with the channel modules.
class StreamTunerTwo(gtk.Builder):
# object containers
widgets = {} # non-glade widgets (any manually instantiated ones)
channels = {} # channel modules
features = {} # non-channel plugins
working = [] # threads
hooks = {
"play": [favicon.download_playing], # observers queue here
"record": [],
"init": [],
"quit": [action.cleanup_tmp_files],
"config_load": [],
"config_save": [],
}
meta = plugin_meta() |
<
|
| 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 | # gtk modules
from uikit import pygtk, gtk, gobject, uikit, ui_xml, gui_startup, AboutStreamtuner2
# custom modules
import ahttp
import action
import logo
import channels
import channels.bookmarks
import channels.configwin
import channels.streamedit
import channels.search
# This represents the main window, dispatches Gtk events,
# and shares most application behaviour with the channel modules.
class StreamTunerTwo(gtk.Builder):
# object containers
widgets = {} # non-glade widgets (any manually instantiated ones)
channels = {} # channel modules
features = {} # non-channel plugins
working = [] # threads
hooks = {
"play": [], # observers queue here
"record": [],
"init": [],
"quit": [action.cleanup_tmp_files],
"config_load": [],
"config_save": [],
}
meta = plugin_meta() |
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133 | self.init_app_state()
# and late plugin initializations
[callback(self) for callback in self.hooks["init"]]
# display current open channel/notebook tab
gui_startup(18/20.0)
self.current_channel = self.current_channel_gtk()
try: self.channel().first_show()
except: log.INIT("main.__init__: current_channel.first_show() initialization error")
# bind gtk/glade event names to functions
gui_startup(19.75/20.0)
self.connect_signals({
"gtk_main_quit" : self.gtk_main_quit, # close window
# treeviews / notebook |
>
|
>
|
| 117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134 | self.init_app_state()
# and late plugin initializations
[callback(self) for callback in self.hooks["init"]]
# display current open channel/notebook tab
gui_startup(18/20.0)
self.current_channel = self.current_channel_gtk()
try:
self.channel().first_show()
except Exception as e:
log.INIT("main.__init__: current_channel.first_show() initialization error:", e)
# bind gtk/glade event names to functions
gui_startup(19.75/20.0)
self.connect_signals({
"gtk_main_quit" : self.gtk_main_quit, # close window
# treeviews / notebook |
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310 | category = self.channel().current
self.thread(
#@TODO: should get a wrapper, for HTTP errors, and optionalize bookamrks
lambda: ( self.channel().load(category,reload), reload and self.bookmarks.heuristic_update(self.current_channel,category) )
)
# Thread a function, add to worker pool (for utilizing stop button)
def thread(self, target, *args):
if conf.nothreads:
return target(*args)
thread = Thread(target=target, args=args)
thread.start()
self.working.append(thread)
# Click in category list
def on_category_clicked(self, widget, event, *more):
category = self.channel().currentcat() |
|
|
|
| 294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311 | category = self.channel().current
self.thread(
#@TODO: should get a wrapper, for HTTP errors, and optionalize bookamrks
lambda: ( self.channel().load(category,reload), reload and self.bookmarks.heuristic_update(self.current_channel,category) )
)
# Thread a function, add to worker pool (for utilizing stop button)
def thread(self, target, *args, **kwargs):
if conf.nothreads:
return target(*args, **kwargs)
thread = Thread(target=target, args=args, kwargs=kwargs)
thread.start()
self.working.append(thread)
# Click in category list
def on_category_clicked(self, widget, event, *more):
category = self.channel().currentcat() |
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336 |
# Reload category tree
def update_categories(self, widget):
Thread(target=self.channel().reload_categories).start()
# Menu invocation: refresh favicons for all stations in current streams category
def update_favicons(self, widget):
ch = self.channel()
favicon.download_all(entries=ch.stations(), pixstore=[ch._ls, ch._pix_entry, None])
# Save stream to file (.m3u)
def save_as(self, widget):
row = self.row()
default_fn = row["title"] + ".m3u"
fn = uikit.save_file("Save Stream", None, default_fn, [(".m3u","*m3u"),(".pls","*pls"),(".xspf","*xspf"),(".jspf","*jspf"),(".smil","*smil"),(".asx","*asx"),("all files","*")])
if fn: |
>
|
|
| 322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338 |
# Reload category tree
def update_categories(self, widget):
Thread(target=self.channel().reload_categories).start()
# Menu invocation: refresh favicons for all stations in current streams category
def update_favicons(self, widget):
if "favicon" in self.features:
ch = self.channel()
self.features["favicon"].update_all(entries=ch.stations(), pixstore=[ch._ls, ch._pix_entry, None])
# Save stream to file (.m3u)
def save_as(self, widget):
row = self.row()
default_fn = row["title"] + ".m3u"
fn = uikit.save_file("Save Stream", None, default_fn, [(".m3u","*m3u"),(".pls","*pls"),(".xspf","*xspf"),(".jspf","*jspf"),(".smil","*smil"),(".asx","*asx"),("all files","*")])
if fn: |