Check-in [655dd9f19c]
Overview
Comment: | Add TreePath() abstractions for app_state/restore. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
655dd9f19c6de6ecf42932c4d59a12a2 |
User & Date: | mario on 2015-04-23 01:08:42 |
Other Links: | manifest | tags |
Context
2015-04-23
| ||
01:09 | Remove some print statements, and switch to log.FUNC where necessary. check-in: ecc88e5d3e user: mario tags: trunk | |
01:08 | Add TreePath() abstractions for app_state/restore. check-in: 655dd9f19c user: mario tags: trunk | |
2015-04-22
| ||
21:17 | Update online manual to current help page set. check-in: 2b95379373 user: mario tags: trunk | |
Changes
Modified st2.py from [0608c8f1cb] to [8c09094d97].
︙ | ︙ | |||
160 161 162 163 164 165 166 | "config_play_list_edit_col0": lambda w,path,txt: (self.configwin.list_edit(self.config_play, path, 0, txt)), "config_play_list_edit_col1": lambda w,path,txt: (self.configwin.list_edit(self.config_play, path, 1, txt)), "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, | | | 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | "config_play_list_edit_col0": lambda w,path,txt: (self.configwin.list_edit(self.config_play, path, 0, txt)), "config_play_list_edit_col1": lambda w,path,txt: (self.configwin.list_edit(self.config_play, path, 1, txt)), "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.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"), "menu_fossilwiki": lambda w: action.browser("http://fossil.include-once.org/streamtuner2/"), "menu_projhomepage": lambda w: action.browser("http://milki.include-once.org/streamtuner2/"), |
︙ | ︙ | |||
417 418 419 420 421 422 423 | # load application state (widget sizes, selections, etc.) def init_app_state(self): winlayout = conf.load("window") if (winlayout): try: uikit.app_restore(self, winlayout) | | | | | | | | 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | # load application state (widget sizes, selections, etc.) def init_app_state(self): winlayout = conf.load("window") if (winlayout): try: uikit.app_restore(self, winlayout) 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 Exception as e: log.APPSTATE(e) # store window/widget states (sizes, selections, etc.) 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) # object vars channelopts = {} #dict([(id, {"current":self.channels[id].current}) for id in self.channel_names]) for id in self.channels.keys(): if (self.channels[id]): channelopts[id] = {"current":self.channels[id].current} conf.save("state", channelopts, nice=1) # 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.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): if treeview and event and event.button >= 3: path = treeview.get_path_at_pos(int(event.x), int(event.y)) |
︙ | ︙ |
Modified uikit.py from [14781849fd] to [025a11079e].
︙ | ︙ | |||
281 282 283 284 285 286 287 | if t == gtk.TreeView: r[wn]["columns:width"] = [] 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): | | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | if t == gtk.TreeView: r[wn]["columns:width"] = [] 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(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"] = 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 if t == gtk.Notebook: r[wn]["tab_pos"] = int(w.get_tab_pos()) |
︙ | ︙ | |||
326 327 328 329 330 331 332 | for i,col in enumerate(w.get_columns()): if (i < len(args)): col.set_fixed_width(args[i]) # - Rows if method == "rows:expanded": w.collapse_all() for i in args: | | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | for i,col in enumerate(w.get_columns()): if (i < len(args)): col.set_fixed_width(args[i]) # - Rows if method == "rows:expanded": w.collapse_all() for i in args: w.expand_row(treepath(i), False) # - selected if method == "row:selected": 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) # gtk.Notebook if method == "tab_pos": |
︙ | ︙ | |||
511 512 513 514 515 516 517 518 519 520 521 522 523 524 | # Transparent png empty_pixbuf = uikit.pixbuf( """iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAA B6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUU H3wQLEAE6zgxuGAAAABFJREFUOBFjGAWjYBSMAigAAAQQAAFWMn04AAAAAElFTkSuQmCC""" ) # Text-only dropdown list. # # Necessary because gtk.ComboBoxText binding is absent in debian packages # https://bugzilla.gnome.org/show_bug.cgi?id=660659 # # This one implements a convenience method `.set_default()` to define the active | > > > > > > > > > > > > > > > > > > > > > | 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 | # Transparent png empty_pixbuf = uikit.pixbuf( """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 # # This one implements a convenience method `.set_default()` to define the active |
︙ | ︙ |