Back to index

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

List of all members.

Public Member Functions

def __init__
def show_special_choice
def hide_special_choice
def reinit
def reset
def changed
def get_default
def set_default
def set_widget_value
def get_widget_value
def get_current_value
def is_changed

Public Attributes

 special_choice
 special_choice_shown
 name
 widget
 button
 ipp_type
 combobox_map
 combobox_dict
 use_supported
 system_default
 original_value
 state

Static Public Attributes

int STATE_UNCHANGED = 0
int STATE_RESET = 1
int STATE_ADJUSTED = 2

Detailed Description

Definition at line 306 of file options.py.


Constructor & Destructor Documentation

def options.OptionAlwaysShownSpecial.__init__ (   self,
  name,
  ipp_type,
  system_default,
  widget,
  button,
  combobox_map = None,
  use_supported = False,
  special_choice = "System default" 
)

Definition at line 309 of file options.py.

00309 
00310                  special_choice = "System default"):
00311         self.special_choice = special_choice
00312         self.special_choice_shown = False
00313         OptionAlwaysShown.__init__ (self, name, ipp_type, system_default,
00314                                     widget, button,
00315                                     combobox_map=combobox_map,
00316                                     use_supported=use_supported)


Member Function Documentation

Reimplemented from options.OptionAlwaysShown.

Definition at line 349 of file options.py.

00349 
00350     def changed(self):
00351         OptionAlwaysShown.changed (self)
00352         if self.widget.get_active () > 0:
00353             self.hide_special_choice ()

Here is the call graph for this function:

def options.OptionAlwaysShown.get_current_value (   self) [inherited]

Reimplemented from options.OptionInterface.

Definition at line 272 of file options.py.

00272 
00273     def get_current_value(self):
00274         return self.get_widget_value ()

Here is the call graph for this function:

Here is the caller graph for this function:

def options.OptionAlwaysShown.get_default (   self) [inherited]

Reimplemented from options.OptionInterface.

Definition at line 161 of file options.py.

00161 
00162     def get_default(self):
00163         return self.system_default

def options.OptionAlwaysShown.get_widget_value (   self) [inherited]

Definition at line 246 of file options.py.

00246 
00247     def get_widget_value(self):
00248         t = type(self.widget)
00249         if t == gtk.SpinButton:
00250             # Ideally we would use self.widget.get_value() here, but
00251             # it doesn't work if the value has been typed in and then
00252             # the Apply button immediately clicked.  To handle this,
00253             # we use self.widget.get_text() and fall back to
00254             # get_value() if the result cannot be interpreted as the
00255             # type we expect.
00256             try:
00257                 return self.ipp_type (self.widget.get_text ())
00258             except ValueError:
00259                 # Can't convert result of get_text() to ipp_type.
00260                 return self.ipp_type (self.widget.get_value ())
00261         elif t == gtk.ComboBox:
00262             if self.combobox_map:
00263                 return self.combobox_map[self.widget.get_active()]
00264             if self.ipp_type == str or self.ipp_type == IPPResolution:
00265                 return self.widget.get_active_text ()
00266             return self.ipp_type (self.widget.get_active ())
00267         elif t == gtk.CheckButton:
00268             return self.ipp_type (self.widget.get_active ())
00269 
00270         print t
00271         raise NotImplemented

Here is the caller graph for this function:

Definition at line 328 of file options.py.

00328 
00329     def hide_special_choice (self):
00330         if not self.special_choice_shown:
00331             return
00332 
00333         self.special_choice_shown = False
00334         # Only works for ComboBox widgets
00335         model = self.widget.get_model ()
00336         model.remove (model.get_iter_first ())

Here is the caller graph for this function:

def options.OptionAlwaysShown.is_changed (   self) [inherited]

Reimplemented from options.OptionInterface.

Definition at line 275 of file options.py.

00275 
00276     def is_changed(self):
00277         if self.original_value != None:
00278             # There was a value set previously.
00279             if self.state == self.STATE_RESET:
00280                 # It's been removed.
00281                 return True
00282             if self.state == self.STATE_ADJUSTED:
00283                 if self.get_current_value () != self.original_value:
00284                     return True
00285                 return False
00286 
00287             # The value is the same as before, and not reset.
00288             return False
00289 
00290         # There was no original value set.
00291         if self.state == self.STATE_ADJUSTED:
00292             # It's been adjusted.
00293             return True
00294 
00295         # It's been left alone, or possible adjusted and then reset.
00296         return False

Here is the call graph for this function:

def options.OptionAlwaysShownSpecial.reinit (   self,
  original_value,
  supported = None 
)
Set the original value of the option and the supported choices.
The special value None for original_value resets the option to the
system default.

Reimplemented from options.OptionAlwaysShown.

Definition at line 337 of file options.py.

00337 
00338     def reinit(self, original_value, supported=None):
00339         if original_value != None:
00340             self.hide_special_choice ()
00341         else:
00342             self.show_special_choice ()
00343 
00344         OptionAlwaysShown.reinit (self, original_value, supported=supported)

Here is the call graph for this function:

Reimplemented from options.OptionAlwaysShown.

Definition at line 345 of file options.py.

00345 
00346     def reset(self):
00347         self.show_special_choice ()
00348         OptionAlwaysShown.reset (self)

Here is the call graph for this function:

def options.OptionAlwaysShown.set_default (   self,
  system_default 
) [inherited]

Definition at line 164 of file options.py.

00164 
00165     def set_default(self, system_default):
00166         # For the media option, the system default depends on the printer's
00167         # PageSize setting.  This method allows the main module to tell us
00168         # what that is.
00169         self.system_default = self.ipp_type (system_default)

def options.OptionAlwaysShown.set_widget_value (   self,
  ipp_value 
) [inherited]

Definition at line 220 of file options.py.

00220 
00221     def set_widget_value(self, ipp_value):
00222         t = type(self.widget)
00223         if t == gtk.SpinButton:
00224             return self.widget.set_value (ipp_value)
00225         elif t == gtk.ComboBox:
00226             if ((self.ipp_type == str or self.ipp_type == IPPResolution)
00227                 and self.combobox_map == None):
00228                 model = self.widget.get_model ()
00229                 iter = model.get_iter_first ()
00230                 while (iter != None and
00231                        self.ipp_type (model.get_value (iter, 0)) != ipp_value):
00232                     iter = model.iter_next (iter)
00233                 if iter:
00234                     self.widget.set_active_iter (iter)
00235             else:
00236                 # It's an int.
00237                 if self.combobox_map:
00238                     index = self.combobox_map.index (ipp_value)
00239                 else:
00240                     index = ipp_value
00241                 return self.widget.set_active (index)
00242         elif t == gtk.CheckButton:
00243             return self.widget.set_active (ipp_value)
00244         else:
00245             raise NotImplemented

Here is the caller graph for this function:

Definition at line 317 of file options.py.

00317 
00318     def show_special_choice (self):
00319         if self.special_choice_shown:
00320             return
00321 
00322         self.special_choice_shown = True
00323         # Only works for ComboBox widgets
00324         model = self.widget.get_model ()
00325         iter = model.insert (0)
00326         model.set_value (iter, 0, self.special_choice)
00327         self.widget.set_active_iter (model.get_iter_first ())

Here is the caller graph for this function:


Member Data Documentation

Definition at line 128 of file options.py.

Definition at line 157 of file options.py.

Definition at line 140 of file options.py.

Definition at line 138 of file options.py.

Definition at line 126 of file options.py.

Definition at line 211 of file options.py.

Definition at line 310 of file options.py.

Definition at line 311 of file options.py.

Definition at line 218 of file options.py.

int options.OptionAlwaysShown.STATE_ADJUSTED = 2 [static, inherited]

Definition at line 122 of file options.py.

int options.OptionAlwaysShown.STATE_RESET = 1 [static, inherited]

Definition at line 121 of file options.py.

int options.OptionAlwaysShown.STATE_UNCHANGED = 0 [static, inherited]

Definition at line 120 of file options.py.

Definition at line 168 of file options.py.

Definition at line 158 of file options.py.

Definition at line 127 of file options.py.


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