Back to index

system-config-printer  1.3.9+20120706
Public Member Functions | Public Attributes | Static Private Attributes
ToolbarSearchEntry.ToolbarSearchEntry Class Reference

List of all members.

Public Member Functions

def __init__
def do_get_property
def do_set_property
def clear
def get_text
def set_text
def check_style
def on_changed
def on_search_timeout
def on_focus_out_event
def searching
def on_activate
def grab_focus
def set_drop_down_menu
def on_icon_press

Public Attributes

 entry
 timeout
 is_a11y_theme
 search_timeout
 menu

Static Private Attributes

dictionary __gproperties__
dictionary __gsignals__

Detailed Description

Definition at line 33 of file ToolbarSearchEntry.py.


Constructor & Destructor Documentation

Definition at line 53 of file ToolbarSearchEntry.py.

00053 
00054     def __init__ (self):
00055         self.entry = None
00056         self.timeout = 0
00057         self.is_a11y_theme = False
00058         self.search_timeout = 300
00059         self.menu = None
00060 
00061         gtk.HBox.__gobject_init__ (self)
00062         self.set_spacing (HIG.PAD_NORMAL)
00063         self.set_border_width (HIG.PAD_NORMAL)
00064 
00065         settings = gtk.settings_get_for_screen (self.get_screen ())
00066         theme = settings.get_property ('gtk-theme-name')
00067         self.is_a11y_theme = theme == 'HighContrast' or theme == 'LowContrast'
00068 
00069         label = gtk.Label ()
00070         label.set_text_with_mnemonic (_("_Filter:"))
00071         label.set_justify (gtk.JUSTIFY_RIGHT)
00072         self.pack_start (label, False, True, 0)
00073 
00074         self.entry = gtk.Entry()
00075         if gtk.__dict__.has_key ('ENTRY_ICON_PRIMARY'):
00076             # We have primary/secondary icon support.
00077             self.entry.set_icon_from_stock (gtk.ENTRY_ICON_PRIMARY,
00078                                             gtk.STOCK_FIND)
00079             self.entry.set_icon_from_stock (gtk.ENTRY_ICON_SECONDARY,
00080                                             gtk.STOCK_CLEAR)
00081 
00082             self.entry.set_icon_sensitive (gtk.ENTRY_ICON_SECONDARY, False)
00083             self.entry.set_icon_activatable (gtk.ENTRY_ICON_SECONDARY, False)
00084             self.entry.connect ('icon-press', self.on_icon_press)
00085 
00086         label.set_mnemonic_widget (self.entry)
00087 
00088         self.pack_start (self.entry, True, True, 0)
00089 
00090         self.entry.connect ('changed', self.on_changed)
00091         self.entry.connect ('focus_out_event', self.on_focus_out_event)
00092         self.entry.connect ('activate', self.on_activate)


Member Function Documentation

Definition at line 118 of file ToolbarSearchEntry.py.

00118 
00119     def check_style (self):
00120         if self.is_a11y_theme:
00121             return
00122 
00123         bg_colour = gtk.gdk.color_parse ('#f7f7be') # yellow-ish
00124         fg_colour = gtk.gdk.color_parse ('#000000') # black
00125 
00126         text = self.entry.get_text ()
00127         if len (text) > 0:
00128             self.entry.modify_text (gtk.STATE_NORMAL, fg_colour)
00129             self.entry.modify_base (gtk.STATE_NORMAL, bg_colour)
00130         else:
00131             self.entry.modify_text (gtk.STATE_NORMAL, None)
00132             self.entry.modify_base (gtk.STATE_NORMAL, None)
00133 
00134         self.queue_draw ()

Here is the caller graph for this function:

Definition at line 105 of file ToolbarSearchEntry.py.

00105 
00106     def clear (self):
00107         if self.timeout != 0:
00108             gobject.source_remove (self.timeout)
00109             self.timeout = 0
00110 
00111         self.entry.set_text ("")

Definition at line 93 of file ToolbarSearchEntry.py.

00093 
00094     def do_get_property (self, property):
00095         if property.name == 'search_timeout':
00096             return self.search_timeout
00097         else:
00098             raise AttributeError, 'unknown property %s' % property.name

def ToolbarSearchEntry.ToolbarSearchEntry.do_set_property (   self,
  property,
  value 
)

Definition at line 99 of file ToolbarSearchEntry.py.

00099 
00100     def do_set_property (self, property, value):
00101         if property.name == 'search_timeout':
00102             self.search_timeout = value
00103         else:
00104             raise AttributeError, 'unknown property %s' % property.name

Definition at line 112 of file ToolbarSearchEntry.py.

00112 
00113     def get_text (self):
00114         return self.entry.get_text ()

Definition at line 177 of file ToolbarSearchEntry.py.

00177 
00178     def grab_focus (self):
00179         self.entry.grab_focus ()

def ToolbarSearchEntry.ToolbarSearchEntry.on_activate (   self,
  UNUSED_entry 
)

Definition at line 174 of file ToolbarSearchEntry.py.

00174 
00175     def on_activate (self, UNUSED_entry):
00176         self.emit ('search', self.entry.get_text ())

Definition at line 135 of file ToolbarSearchEntry.py.

00135 
00136     def on_changed (self, UNUSED):
00137         self.check_style ()
00138 
00139         if self.timeout != 0:
00140             gobject.source_remove (self.timeout)
00141             self.timeout = 0
00142 
00143               # emit it now if we have no more text
00144         has_text = self.entry.get_text_length () > 0
00145         if has_text:
00146             self.timeout = gobject.timeout_add (self.search_timeout,
00147                                                 self.on_search_timeout)
00148         else:
00149             self.on_search_timeout ()
00150 
00151         if gtk.__dict__.has_key ("ENTRY_ICON_PRIMARY"):
00152             self.entry.set_icon_sensitive (gtk.ENTRY_ICON_SECONDARY, has_text)
00153             self.entry.set_icon_activatable (gtk.ENTRY_ICON_SECONDARY, has_text)

Here is the call graph for this function:

def ToolbarSearchEntry.ToolbarSearchEntry.on_focus_out_event (   self,
  UNUSED_widget,
  UNUSED_event 
)

Definition at line 160 of file ToolbarSearchEntry.py.

00160 
00161     def on_focus_out_event (self, UNUSED_widget, UNUSED_event):
00162         if self.timeout == 0:
00163             return False
00164 
00165         gobject.source_remove (self.timeout)
00166         self.timeout = 0
00167 
00168         self.emit ('search', self.entry.get_text ())
00169 
00170         return False

def ToolbarSearchEntry.ToolbarSearchEntry.on_icon_press (   self,
  UNUSED,
  icon_position,
  event 
)

Definition at line 193 of file ToolbarSearchEntry.py.

00193 
00194     def on_icon_press (self, UNUSED, icon_position, event):
00195         if icon_position == gtk.ENTRY_ICON_SECONDARY:
00196             self.set_text ("")
00197             return
00198 
00199         if icon_position == gtk.ENTRY_ICON_PRIMARY:
00200             if not self.menu:
00201                 return
00202 
00203             self.menu.popup (None, None, None, event.button, event.time)
00204 
00205 gobject.type_register (ToolbarSearchEntry)

Here is the call graph for this function:

Definition at line 154 of file ToolbarSearchEntry.py.

00154 
00155     def on_search_timeout (self):
00156         self.emit ('search', self.entry.get_text ())
00157         self.timeout = 0
00158 
00159         return False

Here is the caller graph for this function:

Definition at line 171 of file ToolbarSearchEntry.py.

00171 
00172     def searching (self):
00173         return self.entry.get_text () != ''

Definition at line 180 of file ToolbarSearchEntry.py.

00180 
00181     def set_drop_down_menu (self, menu):
00182         if not gtk.__dict__.has_key ("ENTRY_ICON_PRIMARY"):
00183             return
00184 
00185         if menu:
00186             self.entry.set_icon_sensitive (gtk.ENTRY_ICON_PRIMARY, True)
00187             self.entry.set_icon_activatable (gtk.ENTRY_ICON_PRIMARY, True)
00188             self.menu = menu
00189         else:
00190             self.entry.set_icon_sensitive (gtk.ENTRY_ICON_PRIMARY, False)
00191             self.entry.set_icon_activatable (gtk.ENTRY_ICON_PRIMARY, False)
00192             self.menu = None

Definition at line 115 of file ToolbarSearchEntry.py.

00115 
00116     def set_text (self, text):
00117         self.entry.set_text (text)

Here is the caller graph for this function:


Member Data Documentation

Initial value:
{
        'search_timeout' : (gobject.TYPE_UINT,
                            'search timeout',
                            'search signal rate limiter (in ms)',
                            0,
                            5000,
                            300,
                            gobject.PARAM_READWRITE)
        }

Definition at line 34 of file ToolbarSearchEntry.py.

Initial value:
{
        'search' : (gobject.SIGNAL_RUN_LAST,
                    gobject.TYPE_NONE,
                    [ gobject.TYPE_STRING ]),
        'activate' : (gobject.SIGNAL_RUN_LAST,
                      gobject.TYPE_NONE,
                      [])
        }

Definition at line 44 of file ToolbarSearchEntry.py.

Definition at line 54 of file ToolbarSearchEntry.py.

Definition at line 56 of file ToolbarSearchEntry.py.

Definition at line 58 of file ToolbarSearchEntry.py.

Definition at line 57 of file ToolbarSearchEntry.py.

Definition at line 55 of file ToolbarSearchEntry.py.


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