Commits

Moises Henriquez committed 0767f7c

Replaced history filter buttons for a search box

Comments (0)

Files changed (6)

src/vpackager/bot.py

         self.tabstrip.append_page(self.queue_view,
                                   guitools.TabIcon(
                                     label = 'Job Queue',
-                                    stock=gtk.STOCK_INDEX))
+                                    icon=os.path.join(datadir, 'queue.png')))
         self.tabstrip.append_page(self.history_view,
                                   guitools.TabIcon(
                                     label = 'Job History',
-                                    stock=gtk.STOCK_JUSTIFY_FILL))
+                                    stock=gtk.STOCK_INDEX))
         self.tabstrip.append_page(self.bot_tab,
                                   guitools.TabIcon(
                                     label='Terminal\nOutput',
Add a comment to this file

src/vpackager/data/queue.png

Added
New image

src/vpackager/dbutils.py

         self.close()
         return self.notify(ret, group='history')
 
+    def SearchHistoryByApp(self, appname=''):
+        """ Search the job history for app named appname"""
+        db, cursor = self._open()
+        sql = '''SELECT id, app, ver, release, buildstart, buildend, result
+        FROM history WHERE app LIKE "''' + appname + '%"'
+        cursor.execute(sql)
+        ret = cursor.fetchall()
+        self.close()
+        return self.notify(ret, group='history')
 
     def WipeHistory(self):
         """ Deletes the entire job history. Only use after confirming with the

src/vpackager/dbviews.py

                 return
             self.rc_menu.popup(None, None, None, event.button, event.time)
 
-
     def Refresh_Toolbar_Status(self):
         self.exposed_widgets['about_task'].set_property(
             'sensitive', self._selectedjob is not None)
             group = self.exposed_widgets['filter_all'], label='Successful')
         self.exposed_widgets['filter_failed'] = gtk.RadioButton(
             group = self.exposed_widgets['filter_all'], label='Failed')
-        lb = gtk.Label('Filter: ')
+        lb = gtk.Label('Search history: ')
+        self.exposed_widgets['searchbox'] = guitools.SearchBox()
 
         box.pack_start(self.exposed_widgets['wipe_history'], False, False, 2)
-        box.pack_end(self.exposed_widgets['filter_failed'], False, False, 2)
-        box.pack_end(self.exposed_widgets['filter_successful'], False, False, 2)
-        box.pack_end(self.exposed_widgets['filter_all'], False, False, 2)
-        box.pack_end(lb, False, False, False)
+        #box.pack_end(self.exposed_widgets['filter_failed'], False, False, 2)
+        #box.pack_end(self.exposed_widgets['filter_successful'], False, False, 2)
+        #box.pack_end(self.exposed_widgets['filter_all'], False, False, 2)
+        box.pack_start(lb, False, False, 8)
+        searchbox = guitools.SearchBox()
+        box.pack_start(self.exposed_widgets['searchbox'], True, True, 2)
 
         return box
 

src/vpackager/guitools.py

 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
 __version__ = '0.1'
 
+class SearchBox(gtk.Entry):
+    """ Search box packed into the history viewer to filter the history.
+    This is useful to search for a certain application in the job history"""
+    def __init__(self):
+        gtk.Entry.__init__(self)
+        # Add the find button
+
+        self.set_icon_from_stock(gtk.ENTRY_ICON_PRIMARY,
+                                 gtk.STOCK_FIND)
+        self.set_icon_from_stock(gtk.ENTRY_ICON_SECONDARY,
+                                 gtk.STOCK_CLEAR)
+
 class PrefsDialog(gtk.Dialog):
     """vpackager preferences dialog."""
     def __init__(self, parent=None):
 class TabIcon(gtk.VBox):
     """ Custom widget composed of a gtk.VBox that shows an image and label
     and is used for the tabstrip label widgets"""
-    def __init__(self, label='', stock=None):
+    def __init__(self, label='', stock=None, icon=None):
         gtk.VBox.__init__(self)
         lb = gtk.Label()
         lb.set_use_markup(True)
         lb.set_markup(label)
         lb.set_property('xalign', 0.5)
-        img = gtk.Image()
-        img.set_from_stock(stock, gtk.ICON_SIZE_BUTTON)
+        if stock:
+            img = gtk.Image()
+            #pb = gtk.gdk.pixbuf_new_from_file_at_size(
+            #    icon, 24, 24)
+            #img.set_from_pixbuf(pb)
+            img.set_from_stock(stock, gtk.ICON_SIZE_BUTTON)
+        elif icon:
+            img = gtk.Image()
+            pb = gtk.gdk.pixbuf_new_from_file_at_size(
+                icon, 24, 24)
+            img.set_from_pixbuf(pb)
+            #img.set_from_file(icon)
         self.pack_start(lb, False, False, 2)
         self.pack_start(img, False, False, 2)
         self.show_all()

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.