Commits

Anonymous committed c380c4e

Improvements to mountpoint selection UI

  • Participants
  • Parent commits fa718e1

Comments (0)

Files changed (3)

File vinstall/backend/mountpoints.py

 
 from vinstall.backend.media import Partition
 
-
 class MountPoints(object):
+    
+    DEFAULT_ROOT_FS = "ext3" # Default os to be used for /, unless changed by the user.
+    MINIMUM_ROOT_SIZE = 4 # Size in GB
 
     def __init__(self):
 
         self.mountpoints = set(["/", "home", "boot", "var", "tmp", "opt",
             "usr", "swap"])
         self.mapping = dict((i, [None, None]) for i in self.partitions)
-        self.default_filesystem = "ext4"
+        
+        self.default_filesystem = self.DEFAULT_ROOT_FS
+        #XX: ^^ For compatibility purposes only.
 
     def set_mount(self, partition, mountpoint):
         """Declare a mountpoint for a partition

File vinstall/controller/mountpoints.py

         """
         title = "Mountpoints"
         intro = "Setup mountpoints for your new system.\n"
-        return Render(title, intro, mountpoints.MountPoints())
+        self.render = Render(title, intro, mountpoints.MountPoints())
+        return self.render
+        #return Render(title, intro, mountpoints.MountPoints())
 
     def next(self):
         """Return next step
 
         """
+        print self.render.main_window
         from vinstall.controller import packages
         return packages.PackageSelection
 

File vinstall/ui/gtk.py

     """
     DNF = "Do not format"
     DNU = "Not use"
-    ROOT_FS = "ext3" # FIXME:  This should be defined somewhere else.
 
     def __init__(self, mountpoints):
 
     def show_partitions(self):
         for p in self.mountpoints.partitions:
             self.store.append([p, self.DNU, self.DNF])
-    
-    def warn(self, title="", message=""):
-        dia = gtk.MessageDialog(type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_OK)
-        dia.set_property('title', title)
-        dia.set_markup(message)
-        if dia.run():
-            dia.destroy()
-    def error(self, title="", message=""):
-        dia = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
-        dia.set_property('title', title)
-        dia.set_markup(message)
-        if dia.run():
-            dia.destroy()
 
     def on_click(self, treeview, event):
         """Answer to click on treeview
                 elif index == 2:
                     # Format column clicked
                     self.show_filesystem_menu(path[0], event)
-                    self.warn("Test2")
                 else:
                     pass
             return True
     
     def verify_mountpoint_selection(self, menu, row, event):
         """Processed after the mountpoint has been selected.
-        Provides methods select a default fs for /"""
+        Provides methods select a default fs for / and swap. """
         mpoint = menu.get_active().get_label()
         partition = self.store[row][0]
         if mpoint is "/":
-            # Check if the partition selected for / is big enough
-            ## /dev/sda1 (9.7 GB ext4)
-            psize = partition.split("(")[1].split()[0]
-            ppath = partition.split()[0]
-            if int(float(psize)) > 4:
-                # Add a default filesystem for /
-                self.filesystem_selected(row, partition, self.ROOT_FS) 
-            else:
-                msg = """%s is not big enough to be your / partition."""% ppath
-                self.error('Insuficient space', msg)
-                self.mountpoint_selected(row, partition, self.DNU)
+            self.filesystem_selected(row, partition, 
+                self.mountpoints.DEFAULT_ROOT_FS) 
         elif "swap" in mpoint:
             # automatically select 'swap' as the format for swap partitions
             self.filesystem_selected(row, partition, "swap")
         else:
             self.filesystem_selected(row, partition, self.DNF)
+            
+    def _read_partition_size(self, partition):
+        """Return strip the partition size from the provided string.
+        
+        partition should be a media.Partition object"""
+        size_gb, gb = partition.size().split()
+        return float(size_gb)
 
     def show_mountpoints_menu(self, row, event):
         """Show mountpoints menu
         menu = gtk.Menu()
         partition = self.store[row][0]
         dnu = gtk.MenuItem(self.DNU)
+        #print partition," size= ", self._read_partition_size(partition)
         dnu.connect_object("activate", self.mountpoint_selected, row,
                 partition, None)
         dnu.show()
         menu.append(dnu)
+        
+        psize = self._read_partition_size(self.str_to_partition_map[partition])
+        
         for i in self.mountpoints.available_mountpoints():
             item = gtk.MenuItem(i)
             item.connect_object("activate", self.mountpoint_selected,
                     row, partition, i)
+            if i == "/" and int(psize) < self.mountpoints.MINIMUM_ROOT_SIZE:
+                item.set_property('sensitive', False)
+                item.set_property('label', '/ (%sGB Min.)'% str(self.mountpoints.MINIMUM_ROOT_SIZE))
             item.show()
             menu.append(item)
         menu.connect("selection-done", self.verify_mountpoint_selection, row, event)