Back to index

apport  2.3
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
apport.ui.HookUI Class Reference

List of all members.

Public Member Functions

def __init__
def information
def yesno
def choice
def file
def process_event

Public Attributes

 ui

Private Member Functions

def _trigger_ui_request

Private Attributes

 _request_event
 _response_event
 _request_fn
 _request_args
 _response

Detailed Description

Interactive functions which can be used in package hooks.

This provides an interface for package hooks which need to ask interactive
questions. Directly passing the UserInterface instance to the hooks needs
to be avoided, since we need to call the UI methods in a different thread,
and also don't want hooks to be able to poke in the UI.

Definition at line 1394 of file ui.py.


Constructor & Destructor Documentation

def apport.ui.HookUI.__init__ (   self,
  ui 
)
Create a HookUI object.

ui is the UserInterface instance to wrap.

Definition at line 1402 of file ui.py.

01402 
01403     def __init__(self, ui):
01404         '''Create a HookUI object.
01405 
01406         ui is the UserInterface instance to wrap.
01407         '''
01408         self.ui = ui
01409 
01410         # variables for communicating with the UI thread
01411         self._request_event = threading.Event()
01412         self._response_event = threading.Event()
01413         self._request_fn = None
01414         self._request_args = None
01415         self._response = None


Member Function Documentation

def apport.ui.HookUI._trigger_ui_request (   self,
  fn,
  args 
) [private]
Called by HookUi functions in info collection thread.

Definition at line 1459 of file ui.py.

01459 
01460     def _trigger_ui_request(self, fn, *args):
01461         '''Called by HookUi functions in info collection thread.'''
01462 
01463         # only one at a time
01464         assert not self._request_event.is_set()
01465         assert not self._response_event.is_set()
01466         assert self._request_fn is None
01467 
01468         self._response = None
01469         self._request_fn = fn
01470         self._request_args = args
01471         self._request_event.set()
01472         self._response_event.wait()
01473 
01474         self._request_fn = None
01475         self._response_event.clear()
01476 
01477         return self._response

Here is the caller graph for this function:

def apport.ui.HookUI.choice (   self,
  text,
  options,
  multiple = False 
)
Show an question with predefined choices.

options is a list of strings to present. If multiple is True, they
should be check boxes, if multiple is False they should be radio
buttons.

Return list of selected option indexes, or None if the user cancelled.
If multiple == False, the list will always have one element.

Definition at line 1436 of file ui.py.

01436 
01437     def choice(self, text, options, multiple=False):
01438         '''Show an question with predefined choices.
01439 
01440         options is a list of strings to present. If multiple is True, they
01441         should be check boxes, if multiple is False they should be radio
01442         buttons.
01443 
01444         Return list of selected option indexes, or None if the user cancelled.
01445         If multiple == False, the list will always have one element.
01446         '''
01447         return self._trigger_ui_request('ui_question_choice', text, options, multiple)

Here is the call graph for this function:

def apport.ui.HookUI.file (   self,
  text 
)
Show a file selector dialog.

Return path if the user selected a file, or None if cancelled.

Definition at line 1448 of file ui.py.

01448 
01449     def file(self, text):
01450         '''Show a file selector dialog.
01451 
01452         Return path if the user selected a file, or None if cancelled.
01453         '''
01454         return self._trigger_ui_request('ui_question_file', text)

Here is the call graph for this function:

def apport.ui.HookUI.information (   self,
  text 
)
Show an information with OK/Cancel buttons.

This can be used for asking the user to perform a particular action,
such as plugging in a device which does not work.

Definition at line 1420 of file ui.py.

01420 
01421     def information(self, text):
01422         '''Show an information with OK/Cancel buttons.
01423 
01424         This can be used for asking the user to perform a particular action,
01425         such as plugging in a device which does not work.
01426         '''
01427         return self._trigger_ui_request('ui_info_message', '', text)

Here is the call graph for this function:

Called by GUI thread to check and process hook UI requests.

Definition at line 1478 of file ui.py.

01478 
01479     def process_event(self):
01480         '''Called by GUI thread to check and process hook UI requests.'''
01481 
01482         # sleep for 0.1 seconds to wait for events
01483         self._request_event.wait(0.1)
01484         if not self._request_event.is_set():
01485             return
01486 
01487         assert not self._response_event.is_set()
01488         self._request_event.clear()
01489         self._response = getattr(self.ui, self._request_fn)(*self._request_args)
01490         self._response_event.set()
def apport.ui.HookUI.yesno (   self,
  text 
)
Show a yes/no question.

Return True if the user selected "Yes", False if selected "No" or
"None" on cancel/dialog closing.

Definition at line 1428 of file ui.py.

01428 
01429     def yesno(self, text):
01430         '''Show a yes/no question.
01431 
01432         Return True if the user selected "Yes", False if selected "No" or
01433         "None" on cancel/dialog closing.
01434         '''
01435         return self._trigger_ui_request('ui_question_yesno', text)

Here is the call graph for this function:


Member Data Documentation

Definition at line 1413 of file ui.py.

Definition at line 1410 of file ui.py.

Definition at line 1412 of file ui.py.

Definition at line 1414 of file ui.py.

Definition at line 1411 of file ui.py.

Definition at line 1407 of file ui.py.


The documentation for this class was generated from the following file: