Source

vpackager / src / vpackager / viewcontrollers.py

Diff from to

src/vpackager/viewcontrollers.py

 
 
     def refresh_view(self):
+        """ Refreh the GUI representation of the history"""
         return self.model.RefreshHistory()
 
     def apply_filter(self, widget=None, filter=None):
+        """ Filter the job history"""
         return self.model.FilterHistory(filter)
 
     def connect_signals(self):
+        """ Connect signals to different widgets that are exposed from the
+        view object"""
         # Connect buttons
         self.view.connect_item('about_task', self._about_task_event)
         self.view.connect_item('wipe_history', self._wipe_history_event)
         self.view.rc_menu.connect_item('rebuild_job', self._rebuild_job_event)
         self.view.rc_menu.connect_item('view_build_log',
                                        self._view_build_log_event)
+        # Connect the searchbox.
+        box = self.view.exposed_widgets['searchbox']
+        box.connect('icon_press', self.searchbox_icon_press)
+        box.connect('changed', self.searchbox_text_changed)
+
+    def searchbox_icon_press(self, widget=None, icon=None, event=None):
+        """ Defines what happend when the buttons on the search box are
+        clicked"""
+        if icon == gtk.ENTRY_ICON_SECONDARY:
+            widget.set_text('')
+            self.apply_filter(filter='all')
+        else:
+            if widget.get_text() == '':
+                return self.apply_filter(filter='all')
+            return self.model.SearchHistoryByApp(widget.get_text())
+
+    def searchbox_text_changed(self, widget=None):
+        """ Filter the job history when text is entered in the searchbox"""
+        if widget.get_text() == '' :
+            return self.apply_filter(filter='all')
+        else:
+            return self.model.SearchHistoryByApp(widget.get_text())
 
     def _view_build_log_event(self, widget=None):
         """ Display the build log if it is still present"""