Commits

Moises Henriquez committed 0e4c6ba

Added job information dialog for queued jobs

Comments (0)

Files changed (3)

File contents unchanged.

src/vpackager/guitools.py

 import os
 import buildutils
 import message
+import dbutils
 
 __author__ = 'M0E-lnx'
 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
 __version__ = '0.1'
 
+class AboutJob(gtk.Dialog):
+    '''Dialog used to display detailed information about a build job. The user
+    interface will not display every detail about the job, but this dialog
+    will.'''
+    def __init__(self, jobid=None, title='Job Details', parent=None):
+        gtk.Dialog.__init__(self, parent=parent)
+        self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
+        self.body = self.get_content_area()
+        lbtop = gtk.Label()
+        topbox = gtk.HBox()
+        img = gtk.Image()
+        img.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
+        #img = gtk.image.new_from_stock(gtk.STOCK_INFO,
+        #        gtk.ICON_SIZE_DIALOG)
+        topbox.pack_start(img, False, False, 2)
+        lbtop.set_markup('<b>Job Details</b>')
+        lbtop.set_property('xalign', 0.0)
+        topbox.pack_start(lbtop, True, True, 2)
+        self.body.pack_start(topbox, False, True, 4)
+        # Read the job details
+        self._jobid = jobid
+        self.set_title(title)
+        self.set_size_request(500, 300)
+        self.body.pack_start(self._pack_tree(), True, True, 2)
+        self.show_all()
+
+    def _pack_tree(self):
+        sw = gtk.ScrolledWindow()
+        sw.set_policy(gtk.POLICY_AUTOMATIC,
+                gtk.POLICY_AUTOMATIC)
+
+        mod = gtk.ListStore(str, str)
+        tree = gtk.TreeView(model=mod)
+        col0 = gtk.TreeViewColumn()
+        cr0 = gtk.CellRendererText()
+        col0.pack_start(cr0)
+        col0.add_attribute(cr0, 'markup', 0)
+        col1 = gtk.TreeViewColumn()
+        cr1 = gtk.CellRendererText()
+        col1.pack_start(cr1)
+        col1.add_attribute(cr1, 'text', 1)
+        tree.append_column(col0)
+        tree.append_column(col1)
+        sw.add(tree)
+
+        # Fill in the informmation:
+        info = self._get_job_details(self._jobid)
+        patches = info['patches'].split(',')
+        mod.append(['<b>Job ID</b>', info['id']])
+        mod.append(['<b>Application</b>', info['app']])
+        mod.append(['<b>Version</b>', info['ver']])
+        mod.append(['<b>Source URI</b>', info['src']])
+        mod.append(['<b>Description URI</b>', info['desc']])
+        mod.append(['<b>Package Release</b>', info['release']])
+        mod.append(['<b>Source Type</b>', info['type']])
+        mod.append(['<b>Install after build</b>', info['install']==1])
+        mod.append(['<b>Patches to be applied</b>', patches[0]])
+        for x in range(1,len(patches)):
+            mod.append(['',patches[x]])
+
+
+
+        return sw
+
+    def _get_job_details(self, jobid, fromtable='queue'):
+        ''' Retreive details from the database '''
+        info = {}
+        info['id'] = dbutils.GetJobProp(jobid, 'id')
+        info['app'] = dbutils.GetJobProp(jobid, 'app')
+        info['ver'] = dbutils.GetJobProp(jobid, 'ver')
+        info['src'] = dbutils.GetJobProp(jobid, 'srcURI')
+        info['desc'] = dbutils.GetJobProp(jobid, 'descURI')
+        info['release'] = dbutils.GetJobProp(jobid, 'release')
+        info['type'] = dbutils.GetJobProp(jobid, 'type')
+        info['install'] = dbutils.GetJobProp(jobid, 'install')
+        info['patches'] = dbutils.GetJobProp(jobid, 'patches')
+        return info
+
 class About(gtk.AboutDialog):
     """ About dialog for vpackager"""
     def __init__(self):

src/vpackager/jobmanage.py

         self.pack_start(hbtop, False, True, 4)
         lbtop = gtk.Label('Manage job queue')
         hbtop.pack_start(lbtop, True, True, 2)
-
         scrl = gtk.ScrolledWindow()
         scrl.set_policy(gtk.POLICY_AUTOMATIC,
                 gtk.POLICY_AUTOMATIC)
         self._fill_tree_with_queue()
         self.pack_start(scrl, True, True, 8)
         hbbot = gtk.HBox()
+        self._selected_jobid = None
         self.pack_start(hbbot, False, True, 4)
         self.btAdd = gtk.Button(stock=gtk.STOCK_ADD)
         self.btRem = gtk.Button(stock=gtk.STOCK_REMOVE)
         self.btRem.connect('clicked', self._btDeleteClick)
         self.btAdd.connect('clicked', self._btAddClick)
+        btJobDetails = guitools.vButton(stock=gtk.STOCK_INFO,
+                label='Details')
+        self.btJobDetails = btJobDetails
+        btJobDetails.connect('clicked', self._job_details_event)
         frmJobCtrl = gtk.Frame('Job Control')
         jobsvbox = gtk.HBox()
         frmJobCtrl.add(jobsvbox)
         jobsvbox.pack_start(self.btAdd, False, False, 2)
         jobsvbox.pack_start(self.btRem, False, False, 2)
+        jobsvbox.pack_start(btJobDetails, False, False, 2)
         hbbot.pack_start(frmJobCtrl, True, True , 4)
+        self.btJobDetails.set_sensitive(
+                self._selected_jobid != None)
+        self.btRem.set_sensitive(
+                self._selected_jobid != None)
+
+
+    def _job_details_event(self, widget=None):
+        ''' Pop-up the job info dialog'''
+        dia = guitools.AboutJob(jobid = self._selected_jobid)
+        if dia.run():
+            dia.destroy()
 
     def _btAddClick(self, widget=None):
+        ''' Launch a dialog to select the tarball for this job'''
         dia = guitools.JobAddDialog(parent=self)
         res = dia.run()
         dia.hide()
             return self._update_queue()
 
     def _btDeleteClick(self, widget=None):
+        '''Delete the selected job from the job queue'''
         if self._selected_jobid:
             dbutils.RemoveJob(self._selected_jobid)
             self._update_queue()
 
     def _update_queue(self):
+        '''Refresh the GUI displaying the job queue'''
         self.tree.set_model(gtk.ListStore(int,str, str, str))
         lst = dbutils.GetQueue()
         for entry in lst:
         sel = tree.get_selection()
         (model, iter) = sel.get_selected()
         selrow = tree.get_model()[iter][0]
-
         self._selected_jobid = selrow
+        self.btJobDetails.set_property('sensitive',
+                self._selected_jobid != None)
+        self.btRem.set_property('sensitive',
+                self._selected_jobid != None)
 
 
     def _fill_tree_with_queue(self):
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.