Changeset 34 for storage

Show
Ignore:
Timestamp:
07/09/06 18:13:24 (2 years ago)
Author:
ploum
Message:

#9 Window size
#15 tab size must be limited
#39 order of bookmarks is not stored
+ bookmarks file for each protocol

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • storage/bookmarks_store.py

    r33 r34  
    88        sys.exit(1) 
    99 
    10 bmark_file="bookmarks.xml" 
    11  
    1210# this class represent the whole bookmarks list 
    1311class bookmarks_store : 
    14  
     12         
    1513        # bts_name is a string arg. It will be used to have 
    1614        # differents bookmarks for differents protocols. 
    1715        def __init__(self, bts_name) : 
     16                self.bmark_file ="bookmarks_%s.xml" %(bts_name) 
    1817                #listing is : Title of the bookmarks, description of the search 
    1918                # search method : 
     
    2322                # 4- advanced search 
    2423                self.listing = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING) 
    25                 def reorder_callback(treemodel, path, iter, new_order): 
     24                # rows-reordered signal not sent 
     25                # but I let this code here, don't know why. 
     26                def reorder_callback(treemodel, path, itera, new_order): 
    2627                        print "reordering" 
    2728                        self.sync_file() 
     29                # Funny ! rows-reordered is not sent but we can 
     30                # use the rows-deleted signal as well. 
     31                def deleted_callback(treemodel, path): 
     32                        self.sync_file() 
    2833                self.listing.connect("rows-reordered", reorder_callback) 
    29                 if os.path.exists(bmark_file) : 
    30                         f = open(bmark_file,mode='r') 
     34                self.listing.connect("row-deleted", deleted_callback) 
     35                if os.path.exists(self.bmark_file) : 
     36                        f = open(self.bmark_file,mode='r') 
    3137                        # sanitize the pretty XML 
    3238                        stringed = f.read().replace('\n','').replace('\t','') 
     
    4248                        # 
    4349                        #then we create the file 
    44                         f = open(bmark_file, mode='a+') 
     50                        f = open(self.bmark_file, mode='a+') 
    4551                        f.write(doc.toxml().encode("utf-8")) 
    4652                        f.close() 
     
    8187                # but I'm not sure that those operations are so frequent 
    8288                # might be changed in the future. 
    83                 f = open(bmark_file, mode='w+') 
     89                f = open(self.bmark_file, mode='w+') 
    8490                f.write(doc.toprettyxml().encode("utf-8")) 
    8591                f.close()