Index: st2.py ================================================================== --- st2.py +++ st2.py @@ -162,11 +162,11 @@ "config_record_list_edit_col0": lambda w,path,txt: (self.configwin.list_edit(self.config_record, path, 0, txt)), "config_record_list_edit_col1": lambda w,path,txt: (self.configwin.list_edit(self.config_record, path, 1, txt)), # else "update_categories": self.update_categories, "update_favicons": self.update_favicons, - "app_state": self.app_state, + "app_state": self.save_app_state, "bookmark": self.bookmark, "save_as": self.save_as, "menu_about": lambda w: AboutStreamtuner2(self), "menu_help": action.help, "menu_onlineforum": lambda w: action.browser("http://sourceforge.net/projects/streamtuner2/forums/forum/1173108"), @@ -419,20 +419,20 @@ def init_app_state(self): winlayout = conf.load("window") if (winlayout): try: uikit.app_restore(self, winlayout) - except: pass # may fail for disabled/reordered plugin channels + except Exception as e: log.APPRESTORE(e) # may fail for disabled/reordered plugin channels winstate = conf.load("state") if (winstate): for id,prev in winstate.items(): try: self.channels[id].current = prev["current"] - except: pass + except Exception as e: log.APPSTATE(e) # store window/widget states (sizes, selections, etc.) - def app_state(self, widget): + def save_app_state(self, widget): # gtk widget states widgetnames = ["win_streamtuner2", "toolbar", "notebook_channels", ] \ + [id+"_list" for id in self.channel_names] \ + [id+"_cat" for id in self.channel_names] conf.save("window", uikit.app_state(wTree=self, widgetnames=widgetnames), nice=1) @@ -446,13 +446,13 @@ # end application and gtk+ main loop def gtk_main_quit(self, widget, *x): if conf.auto_save_appstate: try: # doesn't work with gtk3 yet (probably just hooking at the wrong time) - self.app_state(widget) - except: - None + self.save_app_state(widget) + except Exception as e: + log.ERR(e) gtk.main_quit() # Right clicking a stream/station in the treeview to make context menu pop out. def station_context_menu(self, treeview, event): Index: uikit.py ================================================================== --- uikit.py +++ uikit.py @@ -283,16 +283,16 @@ for col in w.get_columns(): r[wn]["columns:width"].append( col.get_width() ) # - Rows r[wn]["rows:expanded"] = [] for i in xrange(0,50): - if w.row_expanded(str(i)): + if w.row_expanded(treepath(i)): # Gtk.TreePath for Gtk3 r[wn]["rows:expanded"].append(i) # - selected (model, paths) = w.get_selection().get_selected_rows() if paths: - r[wn]["row:selected"] = paths[0] + r[wn]["row:selected"] = treepath_to_str(paths[0]) # gtk.Toolbar if t == gtk.Toolbar: r[wn]["icon_size"] = int(w.get_icon_size()) r[wn]["style"] = int(w.get_style()) # gtk.Notebook @@ -328,14 +328,14 @@ col.set_fixed_width(args[i]) # - Rows if method == "rows:expanded": w.collapse_all() for i in args: - w.expand_row(str(i), False) + w.expand_row(treepath(i), False) # - selected if method == "row:selected": - w.get_selection().select_path(tuple(args)) + w.get_selection().select_path(treepath(args)) # gtk.Toolbar if method == "icon_size": w.set_icon_size(args) if method == "style": w.set_style(args) @@ -513,10 +513,31 @@ """iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAA B6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUU H3wQLEAE6zgxuGAAAABFJREFUOBFjGAWjYBSMAigAAAQQAAFWMn04AAAAAElFTkSuQmCC""" ) + + +#-- Gtk3 wrappers + +# Use a str of "1:2:3" as treepath, +# literally in Gtk2, TreePath-wrapped for Gtk3 +def treepath(ls): + if isinstance(ls, (list,tuple)): + ls = ls[0] + if ver==2: + return str(ls) + else: + return gtk.TreePath.new_from_string(str(ls)) +# +def treepath_to_str(tp): + if ver==2: + return tp + else: + return tp.to_string() + + # Text-only dropdown list. # # Necessary because gtk.ComboBoxText binding is absent in debian packages # https://bugzilla.gnome.org/show_bug.cgi?id=660659