home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / lib / python2.4 / site-packages / deskbar / Match.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-08-31  |  4.7 KB  |  160 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import deskbar.Utils as deskbar
  5.  
  6. class Match:
  7.     
  8.     def __init__(self, handler, **args):
  9.         self._priority = 0
  10.         self._handler = handler
  11.         self._icon = None
  12.         self.name = None
  13.         self.icon = None
  14.         if 'name' in args:
  15.             self.name = args['name']
  16.         
  17.         if 'icon' in args:
  18.             self.icon = args['icon']
  19.         
  20.  
  21.     
  22.     def get_handler(self):
  23.         '''
  24. \t\tReturns the handler owning this match.
  25. \t\t'''
  26.         return self._handler
  27.  
  28.     
  29.     def get_name(self, text = None):
  30.         '''
  31. \t\tReturns a dictionary whose entries will be used in the Action
  32. \t\tstring returned by get_verb.
  33. \t\t
  34. \t\tThe passed string is the complete query string.
  35. \t\t
  36. \t\tThe resulting action text will be
  37. \t\tmatch.get_verb() % match.get_name(query)
  38. \t\t
  39. \t\tRemember to escape pango markup if needed.
  40. \t\t'''
  41.         return {
  42.             'name': self.name }
  43.  
  44.     
  45.     def get_verb(self):
  46.         '''
  47. \t\tReturns the action string associated to this handler.
  48. \t\t
  49. \t\tThe string must contain one or more "%(name)s" that will
  50. \t\tbe replaced by the match get_name().
  51. \t\t
  52. \t\tThe %(text)s will be replaced by the typed text.
  53. \t\tBy default the %(name)s will be replaced by the self._name
  54. \t\t
  55. \t\tThe string can also contain pango markup.
  56. \t\t
  57. \t\tExamples:
  58. \t\t Send mail to %(address)s
  59. \t\t Search <b>%s</b> for %(text)s
  60. \t\t Execute %(prog)s
  61. \t\t'''
  62.         raise NotImplementedError
  63.  
  64.     
  65.     def get_priority(self):
  66.         """
  67. \t\tReturns the priority of the given match as a tuple (int,int).
  68. \t\tThis number can be used to compare the match from the
  69. \t\tsame handler.
  70. \t\tThe first number in the tuple is the match's handler prio, the second
  71. \t\tis the prio relative to other matces from the hander
  72. \t\t"""
  73.         return (self._handler.get_priority(), self._priority)
  74.  
  75.     
  76.     def get_hash(self, text = None):
  77.         '''
  78. \t\tReturns a hash used to verify if a query has one or more duplicates.
  79. \t\tMatches that have same hash will be selected based on the handler priority.
  80. \t\ttext is the entered query string.
  81. \t\tBy default, if the handler does not override this, it will return None.
  82. \t\tReturning None means no duplication check will be performed.
  83. \t\t'''
  84.         pass
  85.  
  86.     
  87.     def get_icon(self):
  88.         '''
  89. \t\tReturns a GdkPixbuf hat represents this match.
  90. \t\tReturns None if there is no associated icon.
  91. \t\t'''
  92.         if self._icon == None:
  93.             if self.icon != None:
  94.                 self._icon = deskbar.Utils.load_icon(self.icon)
  95.             
  96.             if self._icon == None:
  97.                 self._icon = False
  98.             
  99.         
  100.         if self._icon == False:
  101.             return self.get_handler().get_icon()
  102.         else:
  103.             return self._icon
  104.  
  105.     
  106.     def get_category(self):
  107.         '''
  108. \t\tReturns a string corresponding to a key in the Categories.py file, indicating
  109. \t\tin which category this match should be put in.
  110. \t\t
  111. \t\tReturning None, uses the default category
  112. \t\t'''
  113.         pass
  114.  
  115.     
  116.     def action(self, text = None):
  117.         '''
  118. \t\tTell the match to do the associated action.
  119. \t\tThis method should not block.
  120. \t\tThe optional text is the additional argument entered in the entry
  121. \t\t'''
  122.         raise NotImplementedError
  123.  
  124.     
  125.     def is_valid(self, text = None):
  126.         """
  127. \t\tTests wether the match is still valid, by default it's True.
  128. \t\tFor example if a file has moved, the file match is invalid
  129. \t\tThe optional text is the additional argument entered in the entry
  130. \t\t"""
  131.         return True
  132.  
  133.     
  134.     def serialize(self):
  135.         serialized = { }
  136.         for prop in dir(self):
  137.             if not prop.startswith('_') and not callable(getattr(self, prop)):
  138.                 continue
  139.             _[1][(prop, getattr(self, prop))]
  140.         
  141.         return serialized
  142.  
  143.     
  144.     def skip_history(self):
  145.         '''
  146. \t\tWether the match should appear or not in the history dropdown (and thus be saved as history is saved)
  147. \t\t'''
  148.         return False
  149.  
  150.     
  151.     def copy(self):
  152.         
  153.         try:
  154.             return self._handler.deserialize(str(self.__class__)[str(self.__class__).rfind('.') + 1:], self.serialize())
  155.         except:
  156.             return None
  157.  
  158.  
  159.  
  160.