diff options
-rw-r--r-- | iw/autopart_type.py | 82 | ||||
-rw-r--r-- | ui/autopart.glade | 238 |
2 files changed, 320 insertions, 0 deletions
diff --git a/iw/autopart_type.py b/iw/autopart_type.py index 7c3d903c1..a75b888e1 100644 --- a/iw/autopart_type.py +++ b/iw/autopart_type.py @@ -21,6 +21,7 @@ import gtk import gobject +import math import autopart import rhpl @@ -36,6 +37,78 @@ import network import partitions import iscsi +def whichToResize(partitions, diskset, intf): + def getActive(combo): + act = combo.get_active_iter() + return combo.get_model().get_value(act, 1) + + def comboCB(combo, resizeSB): + # partition to resize changed, let's update our spinbutton + req = getActive(combo) + if req.targetSize is not None: + value = req.targetSize + else: + value = req.size + reqlower = req.getMinimumResizeMB(partitions) + requpper = req.getMaximumResizeMB(partitions) + + adj = resizeSB.get_adjustment() + adj.lower = reqlower + adj.upper = requpper + adj.value = value + adj.set_value(value) + + + (dxml, dialog) = gui.getGladeWidget("autopart.glade", "resizeDialog") + + store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT) + combo = dxml.get_widget("resizePartCombo") + combo.set_model(store) + crt = gtk.CellRendererText() + combo.pack_start(crt, True) + combo.set_attributes(crt, text = 0) + combo.connect("changed", comboCB, dxml.get_widget("resizeSB")) + + found = False + biggest = -1 + for req in partitions.requests: + if req.type != REQUEST_PREEXIST: + continue + if req.isResizable(partitions): + i = store.append(None) + store[i] = ("%s (%s, %d MB)" %(req.device, + req.fstype.getName(), + math.floor(req.size)), + req) + if req.targetSize is not None: + combo.set_active(i) + found = True + if biggest < 0 or req.size > getActive(combo).size: + biggest = i + if not found and biggest > 0: + combo.set_active_iter(biggest) + + if len(store) == 0: + dialog.destroy() + intf.messageWindow(_("Error"), + _("No partitions are available to resize. Only " + "physical partitions with specific filesystems " + "can be resized."), + type="warning", custom_icon="error") + return gtk.RESPONSE_CANCEL + + gui.addFrame(dialog) + dialog.show_all() + rc = dialog.run() + if rc == gtk.RESPONSE_CANCEL: + dialog.destroy() + return rc + + req = getActive(combo) + req.targetSize = dxml.get_widget("resizeSB").get_value_as_int() + dialog.destroy() + return rc + class PartitionTypeWindow(InstallWindow): def __init__(self, ics): InstallWindow.__init__(self, ics) @@ -54,6 +127,14 @@ class PartitionTypeWindow(InstallWindow): self.dispatch.skipStep("partition", skip = 0) self.dispatch.skipStep("bootloader", skip = 0) else: + if val == -2: + rc = whichToResize(self.partitions, self.diskset, self.intf) + if rc == gtk.RESPONSE_CANCEL: + raise gui.StayOnScreen + + # we're not going to delete any partitions in the resize case + val = CLEARPART_TYPE_NONE + self.dispatch.skipStep("autopartitionexecute", skip = 0) if self.xml.get_widget("encryptButton").get_active(): @@ -319,6 +400,7 @@ class PartitionTypeWindow(InstallWindow): self.combo.set_model(store) opts = ((_("Remove all partitions on selected drives and create default layout"), CLEARPART_TYPE_ALL), (_("Remove Linux partitions on selected drives and create default layout"), CLEARPART_TYPE_LINUX), + (_("Resize existing partition and create default layout in free space"), -2), (_("Use free space on selected drives and create default layout"), CLEARPART_TYPE_NONE), (_("Create custom layout"), -1)) for (txt, val) in opts: diff --git a/ui/autopart.glade b/ui/autopart.glade index 166922714..f607a433d 100644 --- a/ui/autopart.glade +++ b/ui/autopart.glade @@ -338,4 +338,242 @@ </child> </widget> +<widget class="GtkDialog" id="resizeDialog"> + <property name="border_width">12</property> + <property name="visible">True</property> + <property name="title" translatable="yes">Which Partition to resize</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">GTK_WIN_POS_NONE</property> + <property name="modal">False</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> + <property name="focus_on_map">True</property> + <property name="urgency_hint">False</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="button4"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-cancel</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-6</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="button5"> + <property name="visible">True</property> + <property name="can_default">True</property> + <property name="can_focus">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">-5</property> + + <child> + <widget class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xscale">0</property> + <property name="yscale">0</property> + <property name="top_padding">0</property> + <property name="bottom_padding">0</property> + <property name="left_padding">0</property> + <property name="right_padding">0</property> + + <child> + <widget class="GtkHBox" id="hbox5"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image3"> + <property name="visible">True</property> + <property name="stock">gtk-apply</property> + <property name="icon_size">4</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Resize</property> + <property name="use_underline">True</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + </child> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="vbox2"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="label" translatable="yes">Which partition would you like to resize to make room for your installation?</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkComboBox" id="resizePartCombo"> + <property name="visible">True</property> + <property name="add_tearoffs">False</property> + <property name="focus_on_click">True</property> + <signal name="changed" handler="on_resizePartCombo_changed" last_modification_time="Tue, 05 Feb 2008 18:27:52 GMT"/> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + </packing> + </child> + + <child> + <widget class="GtkHBox" id="hbox4"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">6</property> + + <child> + <widget class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="label" translatable="yes"><b>Resize _target:</b></property> + <property name="use_underline">True</property> + <property name="use_markup">True</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="mnemonic_widget">resizeSB</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkSpinButton" id="resizeSB"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="climb_rate">1</property> + <property name="digits">0</property> + <property name="numeric">True</property> + <property name="update_policy">GTK_UPDATE_ALWAYS</property> + <property name="snap_to_ticks">False</property> + <property name="wrap">False</property> + <property name="adjustment">1 0 100 1 10 10</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + </glade-interface> |