#
# partition_text.py: allows the user to choose how to partition their disks
# in text mode
#
# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007  Red Hat, Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Author(s): Jeremy Katz <katzj@redhat.com>
#

import os, sys
import isys
import string
import copy
import network
import parted
import storage.iscsi
import storage.fcoe
import storage.zfcp
from partIntfHelpers import *
from snack import *
from constants_text import *
from constants import *
from add_drive_text import addDriveDialog

import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)

import logging
log = logging.getLogger("anaconda")

class PartitionTypeWindow:
    def typeboxChange(self, (typebox, drivelist)):
        flag = FLAGS_RESET
        if typebox.current() == CLEARPART_TYPE_NONE:
            flag = FLAGS_SET
        # XXX need a way to disable the checkbox tree

    def clearDrivelist(self):
        # XXX remove parted object refs
        #     need to put in clear() method for checkboxtree in snack
        self.drivelist.key2item = {}
        self.drivelist.item2key = {}

    def __call__(self, screen, anaconda):
        self.anaconda = anaconda
        anaconda.dispatch.skipStep("autopartitionexecute", skip = 0)
        anaconda.id.storage.doAutoPart = True
        anaconda.id.storage.clearPartType = CLEARPART_TYPE_ALL
        anaconda.id.storage.clearPartDisks = map(lambda s: s.name, anaconda.id.storage.partitioned)
        anaconda.dispatch.skipStep("partition", skip = 1)
        anaconda.dispatch.skipStep("bootloader", skip = 1)
        anaconda.dispatch.skipStep("bootloadersetup", skip = 0)
        anaconda.dispatch.skipStep("bootloaderadvanced", skip = 1)
        anaconda.dispatch.skipStep("instbootloader", skip = 0)
        anaconda.id.bootloader.doUpgradeOnly = 1
        anaconda.id.bootloader.useGrubVal = 1
        #anaconda.id.bootloader.setDevice(self.bootDev)

        return INSTALL_OK

