Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Private Member Functions
timedops.TimedOperation Class Reference
Inheritance diagram for timedops.TimedOperation:
Inheritance graph
[legend]
Collaboration diagram for timedops.TimedOperation:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def run
def cancel

Public Attributes

 wait_window
 parent
 show_dialog
 callback
 context
 thread
 use_callback
 timeout_source

Private Member Functions

def _check_thread
def _wait_window_response

Detailed Description

Definition at line 165 of file timedops.py.


Constructor & Destructor Documentation

def timedops.TimedOperation.__init__ (   self,
  target,
  args = (),
  kwargs = {},
  parent = None,
  show_dialog = False,
  callback = None,
  context = None 
)

Definition at line 167 of file timedops.py.

00167 
00168                   show_dialog=False, callback=None, context=None):
00169         self.wait_window = None
00170         self.parent = parent
00171         self.show_dialog = show_dialog
00172         self.callback = callback
00173         self.context = context
00174         self.thread = OperationThread (target=target,
00175                                        args=args,
00176                                        kwargs=kwargs)
00177         self.thread.start ()
00178 
00179         self.use_callback = callback != None
00180         if self.use_callback:
00181             self.timeout_source = gobject.timeout_add (50, self._check_thread)


Member Function Documentation

def timedops.TimedOperation._check_thread (   self) [private]

Definition at line 210 of file timedops.py.

00210 
00211     def _check_thread (self):
00212         if self.thread.isAlive ():
00213             # Thread still running.
00214             return True
00215 
00216         # Thread has finished.  Stop the sub-loop or trigger callback.
00217         if self.use_callback:
00218             if self.callback != None:
00219                 if self.context != None:
00220                     self.callback (self.thread.result, self.thread.exception,
00221                                    self.context)
00222                 else:
00223                     self.callback (self.thread.result, self.thread.exception)
00224         else:
00225             gtk.main_quit ()
00226 
00227         return False

Here is the caller graph for this function:

def timedops.TimedOperation._wait_window_response (   self,
  dialog,
  response 
) [private]

Definition at line 228 of file timedops.py.

00228 
00229     def _wait_window_response (self, dialog, response):
00230         if response == gtk.RESPONSE_CANCEL:
00231             self.cancel ()

Here is the call graph for this function:

Here is the caller graph for this function:

Reimplemented from timedops.Timed.

Definition at line 232 of file timedops.py.

00232 
00233     def cancel (self):
00234         debugprint ("Command canceled")
00235         if self.use_callback:
00236             self.callback = None
00237         else:
00238             gtk.main_quit ()
00239 
00240         return False

Reimplemented from timedops.Timed.

Definition at line 182 of file timedops.py.

00182 
00183     def run (self):
00184         if self.use_callback:
00185             raise RuntimeError
00186 
00187         if self.show_dialog:
00188             wait = gtk.MessageDialog (self.parent,
00189                                       gtk.DIALOG_MODAL |
00190                                       gtk.DIALOG_DESTROY_WITH_PARENT,
00191                                       gtk.MESSAGE_INFO,
00192                                       gtk.BUTTONS_CANCEL,
00193                                       _("Please wait"))
00194             wait.connect ("delete_event", lambda *args: False)
00195             wait.connect ("response", self._wait_window_response)
00196             if self.parent:
00197                 wait.set_transient_for (self.parent)
00198 
00199             wait.set_position (gtk.WIN_POS_CENTER_ON_PARENT)
00200             wait.format_secondary_text (_("Gathering information"))
00201             wait.show_all ()
00202 
00203         self.timeout_source = gobject.timeout_add (50, self._check_thread)
00204         gtk.main ()
00205         gobject.source_remove (self.timeout_source)
00206         if self.show_dialog:
00207             wait.destroy ()
00208 
00209         return self.thread.collect_result ()

Here is the call graph for this function:


Member Data Documentation

Definition at line 171 of file timedops.py.

Definition at line 172 of file timedops.py.

Definition at line 169 of file timedops.py.

Definition at line 170 of file timedops.py.

Definition at line 173 of file timedops.py.

Definition at line 180 of file timedops.py.

Definition at line 178 of file timedops.py.

Definition at line 168 of file timedops.py.


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