Commits

Moises Henriquez  committed 5b469ee

Adding patches box

  • Participants
  • Parent commits 3e63a42

Comments (0)

Files changed (1)

File src/vpackager/guitools.py

         self.ver = None
         self.release = 1
         self.install = False
+        self.patchesbox = self._patchesbox()
         self.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK)
         self.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
         self.set_has_separator(True)
         lb = gtk.Label('Application')
         self.appEntry = gtk.Entry()
         bapp = gtk.HBox()
-        body.pack_start(bapp, False, True, 8)
+        body.pack_start(bapp, False, True, 4)
         bapp.pack_start(lb, False, False, 2)
-        bapp.pack_start(self.appEntry, False, False, 2)
+        bapp.pack_start(self.appEntry,True, True, 2)
 
         lbv = gtk.Label('Version')
         self.verEntry = gtk.Entry()
         bapp.pack_start(lbv, False, False, 2)
-        bapp.pack_start(self.verEntry, False, False, 2)
+        bapp.pack_start(self.verEntry, True, True, 2)
 
         self.appEntry.connect('changed', self._appname_changed)
         self.verEntry.connect('changed', self._appver_changed)
         bbox.pack_start(lSrcType, False, False, 2)
         bbox.pack_start(cbsrcsel, False, False, 2)
         body.pack_start(bbox, False, True, 2)
+        # Patches box
+        #exPatches = gtk.expander_new_with_mnemonic('Patches')
+        exPatches = gtk.Expander('Patches')
+        exPatches.add(self.patchesbox)
+        exPatches.connect('notify::expanded', self._expander_event)
+        body.pack_start(exPatches, True, True, 4)
+
+        # Option to install package after building
         cbInstallPkg = gtk.CheckButton(
                 label='Install this package after it is compiled')
         cbInstallPkg.connect('toggled', self._cbInstallpkg_changed)
         self.body = body
         body.show_all()
 
+    def _patchesbox(self):
+        box = gtk.HBox()
+        rbox = gtk.VBox()
+        lst = gtk.ListStore(str)
+        cr = gtk.CellRendererText()
+        tree = gtk.TreeView(lst)
+        col = gtk.TreeViewColumn()
+        col.pack_start(cr)
+        col.add_attribute(cr, 'text', 0)
+        tree.append_column(col)
+        tree.set_headers_visible(False)
+        box.pack_start(tree, True, True, 2)
+        box.pack_start(rbox, False, False, 2)
+        btAddPatch = vButton(stock=gtk.STOCK_ADD,
+                label='Add')
+        btDelPatch = vButton(stock=gtk.STOCK_REMOVE,
+                label='Remove')
+        rbox.pack_start(btAddPatch, False ,False, 2)
+        rbox.pack_start(btDelPatch, False ,False, 2)
+        return box
+
+    def _expander_event(self, widget=None, user_data=None):
+        ''' Resize the dialog to display the newly added widgets'''
+        ht = self.patchesbox.get_allocation()[-2]
+        ht = int(max(ht, 495)*0.25)
+        wwid,whei =  self.get_size()
+        if widget.get_expanded():
+            self.patchesbox.show()
+            self.resize(wwid, whei + ht)
+        else:
+            self.patchesbox.hide()
+            self.resize(wwid, whei - ht)
+        return
+
     def _cbInstallpkg_changed(self, widget=None):
         self.install = widget.get_active()
 
 
 
     def _browse(self, widget=None):
+        """ Browse for source archive """
         dia = gtk.FileChooserDialog(buttons=(gtk.STOCK_OK,
             gtk.RESPONSE_OK, gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
         dia.set_title('Choose source archive')
         flt.add_pattern('*.[bgx]z*')
         flt.set_name('Compressed Files')
         dia.add_filter(flt)
+        dia.set_current_folder('/home')
         res = dia.run()
         dia.hide()
         if res == gtk.RESPONSE_OK:
             self.SrcURI = dia.get_filename()
-        dia.destroy()
-        if self.SrcURI.startswith('/'):
-            src = buildutils.Source(self.SrcURI)
-            if src.builder is not None:
-                self.appEntry.set_text(src.app)
-                self.verEntry.set_text(src.ver)
-                del src
-            else:
+            try:
+                s = buildutils.Source(self.SrcURI)
+                self.appEntry.set_text(s.app)
+                self.verEntry.set_text(s.ver)
+                del s
+            except:
                 dia = message.Error(parent = self,
-                        text='Invalid source type')
+                        text = 'Error creating source object')
                 if dia.run():
                     dia.destroy()
 
-
         self.srcentry.set_text(self.SrcURI)
         return