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"""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.