From d41b443a9d0f5efcd32ef1fa81e7eba350354524 Mon Sep 17 00:00:00 2001 From: bjschuma Date: Thu, 30 Jul 2009 01:08:46 +0000 Subject: [PATCH] Store column widths, apply when changing tabs git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@51 1daee41c-8060-4895-b1f0-2197c00d777a --- trunk/src/data.py | 3 ++- trunk/src/list.py | 24 ++++++++++++++++++++++-- trunk/src/ocarina.py | 1 + trunk/src/rightPane.py | 15 +++++++++++++-- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/trunk/src/data.py b/trunk/src/data.py index a3196bf6..2d1223aa 100644 --- a/trunk/src/data.py +++ b/trunk/src/data.py @@ -25,6 +25,7 @@ class Data: self.save(self.library,"library") self.library.libview = libview self.save([self.curList,self.curQ,self.curSong],"playlist") + print self.colSizes self.save([self.size,self.divider,self.colSizes,self.sortedCol,self.random],"preferences") self.save([self.lfm,self.lfmuser,self.lfmpass],"last.fm") @@ -59,7 +60,7 @@ class Data: if prefs == None: self.size = (800,600) self.divider = 150 - self.colSizes = [200,110,110,110,110] + self.colSizes = [0,0,0,0,0] self.sortedCol = 3 self.random = False else: diff --git a/trunk/src/list.py b/trunk/src/list.py index 87e412d1..4d22c76f 100644 --- a/trunk/src/list.py +++ b/trunk/src/list.py @@ -55,7 +55,6 @@ class List(gtk.ScrolledWindow): col.set_sort_indicator(False) if cols[i] != "Id": self.tree.append_column(col) - col.set_fixed_width(self.data.colSizes[i-1]) self.tree.set_rules_hint(True) self.tree.connect("row-activated",self.selectSong,"clicked",list) @@ -63,6 +62,8 @@ class List(gtk.ScrolledWindow): self.sel = self.tree.get_selection() self.sel.set_mode(gtk.SELECTION_MULTIPLE) self.list.set_sort_column_id(self.data.sortedCol,gtk.SORT_ASCENDING) + self.cols = self.tree.get_columns() + self.loadCols() #self.tree.show() self.add(self.tree) @@ -157,7 +158,6 @@ class List(gtk.ScrolledWindow): if self.hideRows(None,file,string) == True: self.count+=1 self.seconds+=file.duration - print self.count self.makeLabel() @@ -220,8 +220,28 @@ class List(gtk.ScrolledWindow): def visible(self,func): if func=="show": + self.loadCols() self.align.show() self.tree.show() else: + self.storeCols() self.align.hide() self.tree.hide() + + + def storeCols(self): + #cols = self.tree.get_columns() + for i in range(len(self.cols)): + self.data.colSizes[i] = self.cols[i].get_width() + + + def loadCols(self): + #cols = self.tree.get_columns() + for i in range(len(self.cols)): + width = self.data.colSizes[i] + if width <= 0: + if i==0: + width = 200 + else: + width = 110 + self.cols[i].set_fixed_width(width) diff --git a/trunk/src/ocarina.py b/trunk/src/ocarina.py index 37b71236..36d5e633 100644 --- a/trunk/src/ocarina.py +++ b/trunk/src/ocarina.py @@ -32,6 +32,7 @@ class main: #print self.window.get_size() self.data.size = self.window.get_size() self.data.divider = self.window.contentPane.divider.get_position() + self.window.contentPane.right.storeCols() #self.window.contentPane.plistview.saveCols() #self.data.clearSong() self.data.dump() diff --git a/trunk/src/rightPane.py b/trunk/src/rightPane.py index de1f6c72..5a2bdf2b 100644 --- a/trunk/src/rightPane.py +++ b/trunk/src/rightPane.py @@ -55,7 +55,7 @@ class RightPane(gtk.VBox): self.pack_start(hbox,False,False,0) hbox.show() - self.changedTab(None,None,0) + #self.changedTab(None,None,0) self.status = "" @@ -79,6 +79,7 @@ class RightPane(gtk.VBox): self.queue = Queue(self.data,self.next,self.setLabels,self.plause) self.playlist = Playlist(self.data,self.queue,self.next,self.setLabels,self.plause) + self.playlist.visible("show") self.library = LibList(self.data,self.playlist,self.queue,self.next,self.setLabels,self.plause) self.data.library.libview = self.library @@ -86,7 +87,7 @@ class RightPane(gtk.VBox): self.tabs.append_page(self.queue,self.queue.label) self.tabs.append_page(self.library,self.library.label) - self.curTab = -1 + self.curTab = 0 self.tabs.connect("switch-page",self.changedTab) #self.filter("") @@ -241,3 +242,13 @@ class RightPane(gtk.VBox): self.status = "pafter" else: print status + + + def storeCols(self): + print self.curTab + if self.curTab == 0: + self.playlist.storeCols() + elif self.curTab == 1: + self.queue.storeCols() + else: + self.library.storeCols()