Permalink
Browse files

Improved search behaviour and design. Got rid of toolbar for the cont…

…rols.
  • Loading branch information...
aruiz committed Apr 14, 2011
1 parent e79d0a0 commit 1cc6a98c9857f79f4e16a421280e149e74407c4b
Showing with 40 additions and 53 deletions.
  1. +19 −11 fontselector.py
  2. +21 −42 fontselector.ui
View
@@ -40,8 +40,11 @@ def __init__ (self):
self.font_size_scale.connect ("value-changed", size_changed_cb, self)
#self.font_size_scale.connect ("value-changed", scale_tooltip_cb, self)
self.font_face.connect ("changed", face_changed_cb, self)
- self.font_search.connect ("key-press-event", key_pressed_cb, self)
- self.font_search.connect ("backspace", backspace_cb, self)
+
+ text_buffer = self.font_search.get_buffer()
+ text_buffer.connect ("inserted-text", inserted_text_cb, self)
+ text_buffer.connect ("deleted-text", deleted_text_cb, self)
+
self.font_search.connect ("icon-press", icon_press_cb, self)
self.scale_adjustment = gtk.Adjustment (DEFAULT_SIZE, SIZES[0], SIZES[-1], 0.5, 0., 0.)
@@ -206,21 +209,26 @@ def preview_scrolled_cb (widget, event, ui):
adj.set_value (adj.get_value () - adj.get_step_increment ())
def icon_press_cb (font_search, position, event, ui):
- font_search.set_text ("")
- key_pressed_cb (font_search, None, ui)
+ font_search.get_buffer().set_text ("", 0)
#Workaround for the lack of gtk.EntryBuffer
-def key_pressed_cb (font_search, event, ui):
- text = font_search.get_text ()
+def inserted_text_cb (text_buffer, pos, chars, nchars, ui):
+ if text_buffer.get_length () > 0:
+ ui.font_search.set_icon_from_stock(gtk.EntryIconPosition(1), gtk.STOCK_CLEAR)
+ filter_list (ui)
+
+def deleted_text_cb(text_buffer, position, n_chars, ui):
+ if text_buffer.get_length () == 0:
+ ui.font_search.set_icon_from_stock(gtk.EntryIconPosition(1), gtk.STOCK_FIND)
+ filter_list (ui)
+
+def filter_list (ui):
+ text = ui.font_search.get_text ()
if text == ui.last_search:
return
ui.last_search = text
- ui.font_filter.refilter ()
-
-def backspace_cb(font_search, ui):
- key_pressed_cb(font_search, None, ui)
-
+ ui.font_filter.refilter ()
#Family sorting fuction
def compare_family_names (f1, f2):
View
@@ -75,71 +75,50 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="toolbar1">
+ <object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<child>
- <object class="GtkToolItem" id="toolbutton2">
+ <object class="GtkComboBox" id="fontface">
+ <property name="width_request">150</property>
<property name="visible">True</property>
- <property name="related_action">style_change</property>
- <property name="is_important">True</property>
+ <property name="button_sensitivity">on</property>
<child>
- <object class="GtkComboBox" id="fontface">
- <property name="width_request">150</property>
- <property name="visible">True</property>
- <property name="button_sensitivity">on</property>
- <child>
- <object class="GtkCellRendererText" id="cellrenderertext1"/>
- <attributes>
- <attribute name="markup">0</attribute>
- </attributes>
- </child>
- </object>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="markup">0</attribute>
+ </attributes>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkToolItem" id="toolbutton3">
+ <object class="GtkHScale" id="sizescale">
+ <property name="width_request">150</property>
<property name="visible">True</property>
- <child>
- <object class="GtkHScale" id="sizescale">
- <property name="width_request">150</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="draw_value">False</property>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="draw_value">False</property>
</object>
<packing>
- <property name="expand">True</property>
- <property name="homogeneous">True</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
- <object class="GtkToolItem" id="toolbutton4">
+ <object class="GtkSpinButton" id="fontsize">
<property name="visible">True</property>
- <child>
- <object class="GtkSpinButton" id="fontsize">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">&#x25CF;</property>
- <property name="digits">1</property>
- <property name="numeric">True</property>
- <property name="wrap">True</property>
- </object>
- </child>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">&#x25CF;</property>
+ <property name="digits">1</property>
+ <property name="numeric">True</property>
+ <property name="wrap">True</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
+ <property name="position">2</property>
</packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>

0 comments on commit 1cc6a98

Please sign in to comment.