class TimezoneWindow(InstallWindow):
    def __init__(self, ics):
        InstallWindow.__init__(self, ics)

        # Need to set the custom handler before loading the glade file or
        # this won't work.
        gtk.glade.set_custom_handler(self.custom_widget_handler)

        # Set the default now.  We'll fix it for real in upon the first render.
        self.default = "America/New York"

        self.zonetab = zonetab.ZoneTab()

        # Pull in a bunch of widgets.
        self.xml = gtk.glade.XML(
            "/usr/share/system-config-date/system-config-date.glade",
            domain="system-config-date")
        self.vbox = self.xml.get_widget("tz_vbox")
        self.utcCheckbox = self.xml.get_widget("utc_check")
        self.notebook = self.xml.get_widget("notebook")

        ics.setTitle(_("Time Zone Selection"))
        ics.setNextEnabled(1)

    def custom_widget_handler(self, xml, function_name, widget_name, str1,
                              str2, int1, int2):
        if hasattr(self, function_name):
            handler = getattr(self, function_name)
            return handler(str1, str2, int1, int2)
        else:
            # Lame.
            return gtk.Label()

    def timezone_widget_create(self, str1, str2, int1, int2):
        mappath = "/usr/share/system-config-date/pixmaps/map1440.png"

        self.tz = TimezoneMap(self.zonetab,
                              self.default,
                              map=mappath,
                              viewportWidth=480)
        self.tz.show_all()
        return self.tz

    def getNext(self):
        newzone = self.tz.getCurrent().tz
        self.timezone.setTimezoneInfo(newzone.replace(" ", "_"),
                                      self.utcCheckbox.get_active())
        return None

    # TimezoneWindow tag="timezone"
    def getScreen(self, anaconda):
        self.intf = anaconda.intf
        self.timezone = anaconda.timezone
        (self.default, asUTC) = self.timezone.getTimezoneInfo()

        if not self.default:
            self.default = anaconda.instLanguage.getDefaultTimeZone(
                anaconda.rootPath)
            asUTC = 0

        if (string.find(self.default, "UTC") != -1):
            self.default = "America/New_York"

        self.default = self.default.replace("_", " ")

        self.utcCheckbox.set_active(asUTC)

        if not anaconda.ksdata:
            self.utcCheckbox.set_active(not hasWindows(anaconda.bootloader))

        self.notebook.remove(self.vbox)
        return self.vbox

    def renderCallback(self):
        # Now fix the default we set when we made the timezone map widget. Due
        # to a GTK weirdness, this would not do what we desire if put in
        # getScreen(): the element would get selected but stay outside of the
        # visible part of the TreeView.
        self.tz.setCurrent(self.zonetab.findEntryByTZ(self.default))
class TimezoneWindow(InstallWindow):
    def __init__(self, ics):
        InstallWindow.__init__(self, ics)

        # Need to set the custom handler before loading the glade file or
        # this won't work.
        gtk.glade.set_custom_handler(self.custom_widget_handler)

        # Set the default now.  We'll fix it for real in upon the first render.
        self.default = "America/New York"

        self.zonetab = zonetab.ZoneTab()

        # Pull in a bunch of widgets.
        self.xml = gtk.glade.XML("/usr/share/system-config-date/system-config-date.glade", domain="system-config-date")
        self.vbox = self.xml.get_widget("tz_vbox")
        self.utcCheckbox = self.xml.get_widget("utc_check")
        self.notebook = self.xml.get_widget("notebook")

        ics.setTitle(_("Time Zone Selection"))
        ics.setNextEnabled(1)

    def custom_widget_handler(self, xml, function_name, widget_name, str1, str2,
                              int1, int2):
        if hasattr(self, function_name):
            handler = getattr(self, function_name)
            return handler(str1, str2, int1, int2)
        else:
            # Lame.
            return gtk.Label()

    def timezone_widget_create (self, str1, str2, int1, int2):
        mappath = "/usr/share/system-config-date/pixmaps/map1440.png"

        self.tz = TimezoneMap(self.zonetab, self.default, map=mappath,
                              viewportWidth=480)
        self.tz.show_all()
        return self.tz

    def getNext(self):
        newzone = self.tz.getCurrent().tz
        self.timezone.setTimezoneInfo(newzone.replace(" ", "_"), self.utcCheckbox.get_active())
        return None

    # TimezoneWindow tag="timezone"
    def getScreen(self, anaconda):
	self.intf = anaconda.intf        
        self.timezone = anaconda.timezone
        (self.default, asUTC) = self.timezone.getTimezoneInfo()

        if not self.default:
            self.default = anaconda.instLanguage.getDefaultTimeZone(anaconda.rootPath)
            asUTC = 0

        if (string.find(self.default, "UTC") != -1):
            self.default = "America/New_York"

        self.default = self.default.replace("_", " ")

        self.utcCheckbox.set_active(asUTC)

        if not anaconda.ksdata:
            self.utcCheckbox.set_active(not hasWindows(anaconda.bootloader))

        self.notebook.remove(self.vbox)
        return self.vbox

    def renderCallback(self):
        # Now fix the default we set when we made the timezone map widget. Due
        # to a GTK weirdness, this would not do what we desire if put in
        # getScreen(): the element would get selected but stay outside of the
        # visible part of the TreeView.
        self.tz.setCurrent(self.zonetab.findEntryByTZ(self.default))
Exemplo n.º 3
0
class TimezoneWindow(InstallWindow):
    def __init__(self, ics):
        InstallWindow.__init__(self, ics)

        ics.setTitle(_("Time Zone Selection"))
        ics.setNextEnabled(1)
        ics.readHTML("timezone")

    def getNext(self):
        newzone = self.tz.getCurrent().tz
        self.timezone.setTimezoneInfo(newzone, self.systemUTC.get_active())
        return None

    # TimezoneWindow tag="timezone"
    def getScreen(self, instLang, timezone):
        self.timezone = timezone

        try:
            f = open("/usr/share/anaconda/pixmaps/map480.png")
            f.close()
        except:
            path = "pixmaps/map480.png"
        else:
            path = "/usr/share/anaconda/pixmaps/map480.png"

        mainBox = gtk.VBox(gtk.FALSE, 5)

        zonetab = ZoneTab()
        self.tz = TimezoneMap(zonetab=zonetab, map=path)

        (self.default, asUTC, asArc) = self.timezone.getTimezoneInfo()

        self.langDefault = instLang.getDefaultTimeZone()

        if not self.default:
            self.default = self.langDefault
            asUTC = 0

        if (string.find(self.default, "UTC") != -1):
            self.default = "America/New_York"

        self.tz.setCurrent(zonetab.findEntryByTZ(self.default))

        self.systemUTC = gtk.CheckButton(_("System clock uses _UTC"))
        self.systemUTC.set_active(asUTC)

        hbox = gtk.HBox(gtk.FALSE, 5)
        pix = self.ics.readPixmap("timezone.png")
        if pix:
            hbox.pack_start(pix, gtk.FALSE)

        hbox.pack_start(
            gtk.Label(_("Please select the nearest city in your timezone:")),
            gtk.FALSE)
        mainBox.pack_start(hbox, gtk.FALSE)
        mainBox.pack_start(self.tz, gtk.TRUE, gtk.TRUE)
        mainBox.pack_start(self.systemUTC, gtk.FALSE)
        mainBox.set_border_width(5)

        box = gtk.VBox(gtk.FALSE, 5)
        box.pack_start(mainBox)
        box.set_border_width(5)

        return box