Commits

Moises Henriquez  committed 80cec80

Moved bot control / status bar out of the tabstrip for independent control

  • Participants
  • Parent commits 6970cb7

Comments (0)

Files changed (4)

+VPACKAGER TO-DO LIST
+
+* Move start/stop buttons out of the notebook and make them visible from
+  any tab. Dedicate the first tab to the job queue and move the output tab
+  to be the last.
+      ==== OR ====
+  Remove the status tab entirely?
+
+* Add a configuration dialog that allows the following settings to be set
+  + packager name
+  + database path
+  + default source location.

File src/vpackager/bot.py

 
     def run(self):
         """ Actual build sequence"""
-        while self.view.RUN_BOT:
+        while self.view._parentView.RUN_BOT:
             time.sleep(1)
             job_id = self.model.GetNextJob()
             if job_id is None:
     """ Content of the status tab packed in a vbox that can be
     appended as a page to the tabstrip"""
 
-    def __init__(self, model):
+    def __init__(self, model, _parentView=None):
         gtk.VBox.__init__(self)
         self.model = model
-        self.bot_state_indicators = {}
-        self.bot_control_buttons = {}
-        self.bot_state_indicators['state'] = gtk.Label()
-        self.bot_state_indicators['running_job'] = gtk.Label()
-        for label in self.bot_state_indicators.values():
-            label.set_property('xalign', 0.0)
-        self.bot_control_buttons['start'] = guitools.vButton(
-            stock=gtk.STOCK_YES, label='Start')
-        self.bot_control_buttons['stop'] = guitools.vButton(
-            stock=gtk.STOCK_NO, label='Stop')
-        for lb  in self.bot_state_indicators.values():
-            lb.set_use_markup(True)
-        self.pack_start(self._get_top_frames(), False, True, 4)
+        self._parentView = _parentView
+        #self.bot_state_indicators = {}
+        #self.bot_control_buttons = {}
+        #self.bot_state_indicators['state'] = gtk.Label()
+        #self.bot_state_indicators['running_job'] = gtk.Label()
+        #for label in self.bot_state_indicators.values():
+        #    label.set_property('xalign', 0.0)
+        #self.bot_control_buttons['start'] = guitools.vButton(
+        #    stock=gtk.STOCK_YES, label='Start')
+        #self.bot_control_buttons['stop'] = guitools.vButton(
+        #    stock=gtk.STOCK_NO, label='Stop')
+        #for lb  in self.bot_state_indicators.values():
+        #    lb.set_use_markup(True)
+        #self.pack_start(self._get_top_frames(), False, True, 4)
         self.pack_start(self._get_output_display(), True, True, 4)
-        self.RUN_BOT = False
-        self.bot_control_buttons['start'].connect(
-            'clicked', self.StartBot)
-        self.bot_control_buttons['stop'].connect(
-            'clicked', self.StopBot)
-        self.StopBot(self.bot_control_buttons['stop'])
-        self.dispatcher = Dispatcher(model = self.model, view = self)
+        #self.RUN_BOT = False
+        #self.bot_control_buttons['start'].connect(
+        #    'clicked', self.StartBot)
+        #self.bot_control_buttons['stop'].connect(
+        #    'clicked', self.StopBot)
+        #self.StopBot(self.bot_control_buttons['stop'])
+        #self.dispatcher = Dispatcher(model = self.model, view = self)
 
     def IndicateBotRunning(self, app, ver):
-        self.bot_state_indicators['state'].set_label(
-            'Running')
-        self.bot_state_indicators['running_job'].set_label(
-            '%s-%s'% (app, ver))
+        return self._parentView.IndicateBotRunning(app, ver)
+        #self.bot_state_indicators['state'].set_label(
+        #    'Running')
+        #self.bot_state_indicators['running_job'].set_label(
+        #    '%s-%s'% (app, ver))
 
     def IndicateBotStopped(self):
-        self.bot_state_indicators['state'].set_label('Idle')
-        self.bot_state_indicators['running_job'].set_label('None')
-        self.bot_control_buttons['stop'].set_sensitive(False)
-        self.bot_control_buttons['start'].set_sensitive(True)
+        return self._parentView.IndicateBotStopped()
+        #self.bot_state_indicators['state'].set_label('Idle')
+        #self.bot_state_indicators['running_job'].set_label('None')
+        #self.bot_control_buttons['stop'].set_sensitive(False)
+        #self.bot_control_buttons['start'].set_sensitive(True)
 
     def StopBot(self, widget=None):
-        self.RUN_BOT = False
-        return self.IndicateBotStopped()
+        return self._parentView.StopBot()
+        #self.RUN_BOT = False
+        #return self.IndicateBotStopped()
 
     def StartBot(self, widget=None):
         self.RUN_BOT = True
     def __init__(self, dbase_model):
         gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
         self.dbase_model = dbase_model
+        self.RUN_BOT = False
         self.CheckDatabase()
         self.body = gtk.VBox()
         datadir = os.path.dirname(os.path.abspath(__file__))
         self.body.pack_start(self._get_menubar(), False, True, 2)
         self.tabstrip = guitools.TabStrip()
         self.bot_tab = StatusTab(model = self.dbase_model)
+
+        # Bot control and status bar.
+        bot_controlbar = gtk.HBox()
+        btStatuslb = gtk.Label('Bot Status:')
+        bot_controlbar.pack_start(btStatuslb, False, False, 2)
+        self.bot_state_label = gtk.Label()
+        self.bot_state_label.set_property('use-markup', True)
+        self.bot_state_label.set_property('xalign', 0.0)
+        bot_controlbar.pack_start(self.bot_state_label, True, True, 2)
+        self.bt_bot_start = guitools.vButton(stock=gtk.STOCK_YES,
+                                             label = 'Start')
+        self.bt_bot_stop = guitools.vButton(stock=gtk.STOCK_NO,
+                                            label = 'Stop')
+        bot_controlbar.pack_start(self.bt_bot_start, False, False, 2)
+        bot_controlbar.pack_start(self.bt_bot_stop, False, False, 2)
+
+        self.body.pack_start(bot_controlbar, False, True, 4)
+
         #self.bot_tab = StatusTab()
         self.queue_view = dbviews.QueueView()
         self.history_view = dbviews.HistoryView()
         history_controller = viewcontrollers.HistoryController(
             model = self.dbase_model, view = self.history_view)
 
-        self.tabstrip.append_page(self.bot_tab,
-                                  guitools.TabIcon(
-                                    label='Bot Status',
-                                    stock=gtk.STOCK_PREFERENCES))
         self.tabstrip.append_page(self.queue_view,
                                   guitools.TabIcon(
                                     label = 'Job Queue',
                                   guitools.TabIcon(
                                     label = 'Job History',
                                     stock=gtk.STOCK_JUSTIFY_FILL))
+        self.tabstrip.append_page(self.bot_tab,
+                                  guitools.TabIcon(
+                                    label='Terminal\nOutput',
+                                    stock=gtk.STOCK_EXECUTE))
+
+
 
         self.body.pack_start(self.tabstrip, True, True, 2)
         self.add(self.body)
         # Force initial display of the queue and history
         self.dbase_model.RefreshQueue()
         self.dbase_model.RefreshHistory()
+        self.StopBot(self.bt_bot_stop)
+
+    def StartBot(self, widget=None):
+        """ Start the bot"""
+        self.RUN_BOT = True
+        if widget:
+            widget.set_sensitive(False)
+        self.bt_bot_stop.set_sentivie(True)
+
+        try:
+            self.dispatcher.start()
+        except:
+            del self.dispatcher
+            self.dispatcher = Dispatcher(model = self.dbase_model,
+                                         view = self.bot_tab)
+            self.dispatcher.start()
+
+    def StopBot(self, widget=None):
+        self.RUN_BOT = False
+        return self.IndicateBotStopped()
+
+    def IndicateBotStopped(self):
+        """ Update the GUI to indicate the bot is not running"""
+        self.bot_state_label.set_text('Stopped')
+        self.bt_bot_start.set_sensitive(True)
+        self.bt_bot_stop.set_sensitive(False)
+
+    def IndicateBotRunning(self, app, ver):
+        """ UPdate the GUI to indicate the bot is running and
+        show the current job being built"""
+        self.bot_state_label.set_text(
+            "Building %s-%s"%(app, ver))
+        self.bt_bot_start.set_sensitive(False)
+        self.bt_bot_start.set_sensitive(True)
 
     def CheckDatabase(self):
         """ Run a sanity check and make sure the databse tables exist"""
         return mb
 
     def ShowPrefsWindow(self, widget=None):
-        dia = guitools.message.Error(
-            text = "No preferences available yet",
-            parent = self)
+        #dia = guitools.message.Error(
+        #    text = "No preferences available yet",
+        #    parent = self)
+        dia = guitools.PrefsDialog(parent = self)
         if dia.run():
             return dia.destroy()
 

File src/vpackager/dbviews.py

             'Job Details', 'Delete Job', 'Edit Job'])
         self.exposed_widgets = {}
         self.banner_area = gtk.HBox()
-        self.pack_start(self.banner_area, False, True, 4)
+        #self.pack_start(self.banner_area, False, True, 4)
         self.banner_label = gtk.Label('Manage job queue')
         self.banner_area.pack_start(self.banner_label, True, True, 2)
         scrl = gtk.ScrolledWindow()
     """ History manager tree view """
     def __init__(self):
         QueueView.__init__(self)
-        self.banner_label.set_label('Manager job history')
+        self.banner_label.set_label('Job History')
         self.rc_menu = RCMenu(items=['About Job', 'Rebuild Job',
                                      'View Build Log'])
 

File src/vpackager/guitools.py

 import buildutils
 import message
 import dbutils
+import ConfigParser
 
 __author__ = 'M0E-lnx'
 __author_email__ = 'moc.liamg@xnl.E0M'[::-1]
     """vpackager preferences dialog."""
     def __init__(self, parent=None):
         gtk.Dialog.__init__(self, parent=parent)
+        datadir = os.path.dirname(os.path.abspath(__file__))
+        datadir = os.path.join(datadir, 'data')
         self.body = self.get_content_area()
         self.set_has_separator(True)
         self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
         self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CANCEL)
-        
+        self.config = ConfigParser.ConfigParser()
+        self.PACKAGER_NAME = "vpackager"
+        self.DEFAULT_SOURCES_PATH = "/home"
+        self.DATABASE_HOME = "/tmp"
+        # banner
+        bannerbox = gtk.HBox()
+        img = gtk.Image()
+        pixbuf = gtk.gdk.pixbuf_new_from_file(
+            os.path.join(datadir, 'vpackager_logo.png'))
+        scaled_buf = pixbuf.scale_simple(150, 50, gtk.gdk.INTERP_BILINEAR)
+        img.set_from_pixbuf(scaled_buf)
+        bannerbox.pack_start(img, False, False, 8)
+        banner = BoldLabel("Preferences")
+        bannerbox.pack_start(banner, False, True, 2)
+        self.body.pack_start(bannerbox, False, True, 2)
+        self.set_title('vpackager preferences')
+        self.set_size_request(550, 250)
+
+        frame = gtk.Frame('Global Configuration')
+        self.body.pack_start(frame, True, True, 4)
+        confbox = gtk.VBox()
+        frame.add(confbox)
+        # packager line
+        line_packager = gtk.HBox()
+        confbox.pack_start(line_packager, False, True, 4)
+        lb_packager = gtk.Label('Packager Name:')
+        en_packager = gtk.Entry()
+        line_packager.pack_start(lb_packager, False, False, 2)
+        line_packager.pack_start(en_packager, True, True, 2)
+
+        # default sources path
+        line_srcs = gtk.HBox()
+        confbox.pack_start(line_srcs, False, True, 4)
+        lb_srcs = gtk.Label('Local sources Dir:')
+        en_srcs = gtk.Entry()
+        bt_srcs = vButton(stock=gtk.STOCK_OPEN, label='Select')
+        line_srcs.pack_start(lb_srcs, False, False, 2)
+        line_srcs.pack_start(en_srcs, True, True, 2)
+        line_srcs.pack_start(bt_srcs, False, False, 2)
+
+        # Database location
+        line_dbase_loc = gtk.HBox()
+        confbox.pack_start(line_dbase_loc, False, True, 4)
+        lb_dbase = gtk.Label("Database Location:")
+        en_dbase = gtk.Entry()
+        bt_dbase = vButton(stock=gtk.STOCK_OPEN, label='Select')
+        line_dbase_loc.pack_start(lb_dbase, False, False, 2)
+        line_dbase_loc.pack_start(en_dbase, True, True, 2)
+        line_dbase_loc.pack_start(bt_dbase, False, False, 2)
+
+
+        self.show_all()
+
+class BoldLabel(gtk.Label):
+    """ Preset label that displays text in bigger larger fonts """
+    def __init__(self, text):
+        gtk.Label.__init__(self)
+        self.set_use_markup(True)
+        self.set_markup(
+        "<span size='xx-large'>%s</span>"% text)
 
 class LogDisplay(gtk.Dialog):
     """ Dialog used to display the build log"""
         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)
         self.pack_start(lb, False, False, 2)
             self.dbase = dbutils.dbase()
         self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
         self.body = self.get_content_area()
-        lbtop = gtk.Label()
+        lbtop = BoldLabel('Job Details')
         topbox = gtk.HBox()
         img = gtk.Image()
         self.set_has_separator(True)
         img.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
         topbox.pack_start(img, False, False, 2)
-        lbtop.set_markup('<b>Job Details</b>')
+        #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)
         topbox = gtk.HBox()
         img = gtk.Image()
         img.set_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON)
-        lbl = gtk.Label()
-        lbl.set_markup('<b>Build task details</b>')
+        lbl = BoldLabel("Build Task Details")
         lbl.set_property('xalign', 0.0)
         topbox.pack_start(img, False, False, 2)
         topbox.pack_start(lbl, True, True, 2)