def update_parsed_ok(self, data): self.last_parsed = data self.last_error = None if len(data) > 0: SharedData().panel.model.update(data[0]) else: SharedData().panel.model.update(None) SharedData().panel.treeview.expand_all()
def update_parsed_error(self, data): self.last_parsed = [] self.last_error = data message = data.message lstart = data.line_start lend = data.line_end cstart = data.column_start cend = data.column_end doc = self.view.get_buffer() piter = doc.get_iter_at_line(max(0, lstart - 1)) if piter: pend = piter.copy() piter.forward_chars(max(cstart - 1, 0)) if lend > lstart: pend.forward_lines(lend - lstart) pend.forward_chars(max(cend, 0)) doc.apply_tag(self.error_tag, piter, pend) SharedData().panel.model.update(None)
def do_deactivate(self): if self.timeout_update_id != 0: GObject.source_remove(self.timeout_update_id) self.timeout_update_id = 0 del self.update_placeholders[:] del self.jump_placeholders[:] # Always release the reference to the global snippets Library().unref(None) self.active_placeholder = None self.disconnect_signals(self.view) self.disconnect_signals(self.view.get_buffer()) # Remove all active snippets for snippet in list(self.active_snippets): self.deactivate_snippet(snippet, True) completion = self.view.get_completion() if completion: completion.remove_provider(self.provider) completion.remove_provider(self.defaults_provider) if self.language_id != 0: Library().unref(self.language_id) SharedData().unregister_controller(self.view, self)
def __init__(self): super(PollingThread, self).__init__() self.expires = 0 self.last_refresh = time.time() self.player = MyPlayer() self.shared_data = SharedData()
def play_live(): live = TV.get_live() if live is not None: shared_data = SharedData() shared_data.set('playing', { 'what': 'nba_tv_live', }) common.play(live)
def accelerator_activated(self, group, obj, keyval, mod): if obj == self.window: controller = SharedData().get_active_controller(self.window) if controller: return controller.accelerator_activate(keyval, mod) else: return False
def play_serieepisode(): episode = TV.get_serie_episode() if episode is not None: shared_data = SharedData() shared_data.set('playing', { 'what': 'episode_nba_tv', }) common.play(episode)
def playLive(): video_url = LiveTV.getLiveUrl() if video_url: shared_data = SharedData() shared_data.set("playing", { "what": "nba_tv_live", }) item = xbmcgui.ListItem(path=video_url) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
def do_activate(self): self.panel = Panel() self.panel.show() side = self.window.get_side_panel() side.add_item_with_stock_icon(self.panel, "cdncontext", "CDN Context", Gtk.STOCK_INDEX) SharedData().panel = self.panel
def play_live(): video_url = TV.get_live_url() if video_url is not None: shared_data = SharedData() shared_data.set('playing', { 'what': 'nba_tv_live', }) item = common.getPlayableItem(video_url) if item is not None: xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
def play_episode(): start_timestamp = vars.params.get('start_timestamp') duration = vars.params.get('duration') episode = TV.get_episode(start_timestamp, duration) if episode is not None: shared_data = SharedData() shared_data.set('playing', { 'what': 'nba_tv_episode', 'data': { 'start_timestamp': start_timestamp, 'duration': duration, }, }) common.play(episode)
def do_deactivate(self): if self.accel_group: self.window.remove_accel_group(self.accel_group) self.accel_group = None self.remove_menu() self.unregister_messages() library = Library() library.remove_accelerator_callback(self.accelerator_activated) self.disconnect_signals(self.window) SharedData().unregister_window(self)
def do_activate(self): self.insert_menu() self.register_messages() library = Library() library.add_accelerator_callback(self.accelerator_activated) self.accel_group = Library().get_accel_group(None) if self.accel_group: self.window.add_accel_group(self.accel_group) self.connect_signal(self.window, 'active-tab-changed', self.on_active_tab_changed) self.do_update_state() SharedData().register_window(self)
def on_message_parse_and_activate(self, bus, message, userdata): view = message.props.view if not view: view = self.window.get_active_view() controller = SharedData().get_controller(view) if not controller: return iter = message.props.iter if not iter: iter = view.get_buffer().get_iter_at_mark( view.get_buffer().get_insert()) controller.parse_and_run_snippet(message.props.snippet, iter)
def run_parser_at_cursor(self): if self.parser != None: self.parser.cancel() self.parser = None buf = self.view.get_buffer() self.parser = parser.Parser(buf, self.on_parser_finished) if SharedData().panel.get_mapped(): ins = buf.get_iter_at_mark(buf.get_insert()) l = ins.get_line() + 1 c = ins.get_line_offset() + 1 else: l = -1 c = -1 self.parser.run(l, c)
def play_episode(): start_timestamp = vars.params.get('start_timestamp') duration = vars.params.get('duration') video_url = TV.get_episode_url(start_timestamp, duration) if video_url is not None: shared_data = SharedData() shared_data.set( 'playing', { 'what': 'nba_tv_episode', 'data': { 'start_timestamp': start_timestamp, 'duration': duration, }, }) item = common.getPlayableItem(video_url) if item is not None: xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
def main(): utils.log("starting service...") #Reset currently playing video shared_data = SharedData() shared_data.set("playing", {}) polling_thread = PollingThread() polling_thread.start() if xbmc.__version__ >= '2.19.0': monitor = xbmc.Monitor() while not monitor.abortRequested(): if monitor.waitForAbort(100): break else: while not xbmc.abortRequested: xbmc.sleep(100) utils.log("stopping service..") polling_thread.stop()
def update_language(self): lang = self.view.get_buffer().get_language() if lang == None and self.language_id == None: return elif lang and lang.get_id() == self.language_id: return langid = self.language_id if lang: self.language_id = lang.get_id() else: self.language_id = None if langid != 0: Library().unref(langid) Library().ref(self.language_id) self.provider.language_id = self.language_id SharedData().update_state(self.view.get_toplevel())
def do_activate(self): # Always have a reference to the global snippets Library().ref(None) buf = self.view.get_buffer() self.connect_signal(self.view, 'key-press-event', self.on_view_key_press) self.connect_signal(buf, 'notify::language', self.on_notify_language) self.connect_signal(self.view, 'drag-data-received', self.on_drag_data_received) self.connect_signal_after(self.view, 'draw', self.on_draw) self.update_language() completion = self.view.get_completion() completion.add_provider(self.provider) completion.add_provider(self.defaults_provider) self.connect_signal(completion, 'hide', self.on_completion_hide) SharedData().register_controller(self.view, self)
def on_active_tab_changed(self, window, tab): self.update_language(SharedData().get_controller(tab.get_view()))
def create_configure_dialog(self): SharedData().show_manager(self.window, self.plugin_info.get_data_dir())
def do_update_state(self): controller = SharedData().get_active_controller(self.window) self.update_language(controller)
def onPlayBackEnded(self): utils.log("Playback ENDED...") shared_data = SharedData() shared_data.set("playing", {})
def onPlayBackStopped(self): utils.log("Playback STOPPED...") shared_data = SharedData() shared_data.set("playing", {})