home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- import deskbar.Utils as deskbar
-
- class Match:
-
- def __init__(self, handler, **args):
- self._priority = 0
- self._handler = handler
- self._icon = None
- self.name = None
- self.icon = None
- if 'name' in args:
- self.name = args['name']
-
- if 'icon' in args:
- self.icon = args['icon']
-
-
-
- def get_handler(self):
- '''
- \t\tReturns the handler owning this match.
- \t\t'''
- return self._handler
-
-
- def get_name(self, text = None):
- '''
- \t\tReturns a dictionary whose entries will be used in the Action
- \t\tstring returned by get_verb.
- \t\t
- \t\tThe passed string is the complete query string.
- \t\t
- \t\tThe resulting action text will be
- \t\tmatch.get_verb() % match.get_name(query)
- \t\t
- \t\tRemember to escape pango markup if needed.
- \t\t'''
- return {
- 'name': self.name }
-
-
- def get_verb(self):
- '''
- \t\tReturns the action string associated to this handler.
- \t\t
- \t\tThe string must contain one or more "%(name)s" that will
- \t\tbe replaced by the match get_name().
- \t\t
- \t\tThe %(text)s will be replaced by the typed text.
- \t\tBy default the %(name)s will be replaced by the self._name
- \t\t
- \t\tThe string can also contain pango markup.
- \t\t
- \t\tExamples:
- \t\t Send mail to %(address)s
- \t\t Search <b>%s</b> for %(text)s
- \t\t Execute %(prog)s
- \t\t'''
- raise NotImplementedError
-
-
- def get_priority(self):
- """
- \t\tReturns the priority of the given match as a tuple (int,int).
- \t\tThis number can be used to compare the match from the
- \t\tsame handler.
- \t\tThe first number in the tuple is the match's handler prio, the second
- \t\tis the prio relative to other matces from the hander
- \t\t"""
- return (self._handler.get_priority(), self._priority)
-
-
- def get_hash(self, text = None):
- '''
- \t\tReturns a hash used to verify if a query has one or more duplicates.
- \t\tMatches that have same hash will be selected based on the handler priority.
- \t\ttext is the entered query string.
- \t\tBy default, if the handler does not override this, it will return None.
- \t\tReturning None means no duplication check will be performed.
- \t\t'''
- pass
-
-
- def get_icon(self):
- '''
- \t\tReturns a GdkPixbuf hat represents this match.
- \t\tReturns None if there is no associated icon.
- \t\t'''
- if self._icon == None:
- if self.icon != None:
- self._icon = deskbar.Utils.load_icon(self.icon)
-
- if self._icon == None:
- self._icon = False
-
-
- if self._icon == False:
- return self.get_handler().get_icon()
- else:
- return self._icon
-
-
- def get_category(self):
- '''
- \t\tReturns a string corresponding to a key in the Categories.py file, indicating
- \t\tin which category this match should be put in.
- \t\t
- \t\tReturning None, uses the default category
- \t\t'''
- pass
-
-
- def action(self, text = None):
- '''
- \t\tTell the match to do the associated action.
- \t\tThis method should not block.
- \t\tThe optional text is the additional argument entered in the entry
- \t\t'''
- raise NotImplementedError
-
-
- def is_valid(self, text = None):
- """
- \t\tTests wether the match is still valid, by default it's True.
- \t\tFor example if a file has moved, the file match is invalid
- \t\tThe optional text is the additional argument entered in the entry
- \t\t"""
- return True
-
-
- def serialize(self):
- serialized = { }
- for prop in dir(self):
- if not prop.startswith('_') and not callable(getattr(self, prop)):
- continue
- _[1][(prop, getattr(self, prop))]
-
- return serialized
-
-
- def skip_history(self):
- '''
- \t\tWether the match should appear or not in the history dropdown (and thus be saved as history is saved)
- \t\t'''
- return False
-
-
- def copy(self):
-
- try:
- return self._handler.deserialize(str(self.__class__)[str(self.__class__).rfind('.') + 1:], self.serialize())
- except:
- return None
-
-
-
-