Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -76,10 +76,11 @@ working = [] # threads hooks = { "play": [favicon.download_playing], # observers queue here "record": [], "init": [], + "quit": [action.cleanup_tmp_files], "config_load": [], "config_save": [], } meta = plugin_meta() @@ -109,30 +110,15 @@ # early module coupling action.main = self # action (play/record) module needs a reference to main window for gtk interaction and some URL/URI callbacks ahttp.feedback = self.status # http module gives status feedbacks too - # append other channel modules and plugins + # load plugins self.load_plugin_channels() - - - # load application state (widget sizes, selections, etc.) - try: - winlayout = conf.load("window") - if (winlayout): - uikit.app_restore(self, winlayout) - # selection values - winstate = conf.load("state") - if (winstate): - for id in winstate.keys(): - self.channels[id].current = winstate[id]["current"] - self.channels[id].shown = winlayout[id+"_list"].get("row:selected", 0) # actually just used as boolean flag (for late loading of stream list), selection bar has been positioned before already - except: - pass # fails for disabled/reordered plugin channels - - # late plugin initializations - gui_startup(17/20.0) + # restore app/widget states + 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() @@ -429,10 +415,24 @@ except Exception as e: __print__(dbg.INIT, "load_plugin_channels: error initializing:", name, ", exception:") traceback.print_exc() + # load application state (widget sizes, selections, etc.) + def init_app_state(self): + try: + winlayout = conf.load("window") + if (winlayout): + uikit.app_restore(self, winlayout) + # selection values + winstate = conf.load("state") + if (winstate): + for id in winstate.keys(): + self.channels[id].current = winstate[id]["current"] + self.channels[id].shown = winlayout[id+"_list"].get("row:selected", 0) # actually just used as boolean flag (for late loading of stream list), selection bar has been positioned before already + except: + pass # fails for disabled/reordered plugin channels # store window/widget states (sizes, selections, etc.) def app_state(self, widget): # gtk widget states widgetnames = ["win_streamtuner2", "toolbar", "notebook_channels", ] \ @@ -494,10 +494,11 @@ main.configwin.open(None) del conf.firstrun # run gtk.main() + [callback() for callback in main.hooks["quit"]] __print__(dbg.PROC, r" gtk_main_quit ") # invoke command-line interface else: import cli Index: uikit.py ================================================================== --- uikit.py +++ uikit.py @@ -353,11 +353,11 @@ w_tab = w.get_nth_page(i) w_label = w.get_menu_label_text(w_tab) if w_label == ord_tabname: w.reorder_child(w_tab, pos) if tab_current == ord_tabname: - w_set_current_page(pos) + w.set_current_page(pos) pass #-- Save-As dialog