Changeset 27 for storage

Show
Ignore:
Timestamp:
07/08/06 13:02:05 (3 years ago)
Author:
ploum
Message:

First steps in the bookmarks store

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • storage/bookmarks_store.py

    r25 r27  
    33import sys 
    44import string 
    5 try: 
    6         import pygtk 
    7         pygtk.require("2.0") 
    8 except: 
    9         pass 
    105try: 
    116        import gtk 
     
    1611 
    1712class bookmarks_store : 
    18         def __init__(self) : 
     13        # bts_name is a string arg. It will be used to have 
     14        # differents bookmarks for differents protocols. 
     15        def __init__(self, bts_name) : 
    1916                #listing is : Title of the bookmarks, number of the search method, arguments of the search 
    2017                # search method : 
     
    3633        def get(self) : 
    3734                return self.listing 
     35 
     36        def add(self,title,searchMethod, args) : 
     37                #TODO : do not forget to also add the bookmarks to 
     38                #the stored bookmarks. (sync with storage) 
     39                self.listing.insert_before(None, [title, searchMethod, args]) 
     40 
     41        def delete(self, to_delete) : 
     42                #TODO : do not forget to also remove the bookmarks from 
     43                #the stored bookmarks. (sync with storage) 
     44                self.listing.remove(to_delete) 
     45 
     46        # this function returns two strings in a tuple : 
     47        # [0] is the "nice" title of the displayed bug. 
     48        # [1] is the hacky name with all needed informations 
     49        def makeTitle(self, search_type, args) : 
     50                zename='' 
     51                title='' 
     52                if search_type == 1 : 
     53                        title = "bug #%s"%args 
     54                        zename= "%s\n\n1\n\n%s" %(title,args) 
     55                elif search_type == 2 : 
     56                        title = "%s" %args 
     57                        zename = "%s\n\n2\n\n%s"%(title,args) 
     58                elif search_type == 3 : 
     59                        array= args.split("\n",1) 
     60                        title = "(%s) %s"%(array[0],array[1]) 
     61                        zename = "%s\n\n3\n\n%s"%(title,args) 
     62                return [title, zename]