Ejemplo n.º 1
0
def newActionButton(iconPrefix, alignX, alignY,
                    subDir="cell", scaleX=False, 
                    buttonLabel=None, fontSize=None, labelColor=None,
                    paddingY=0, paddingX=0):
    '''New action button.'''
    button = utils.newButtonWithoutPadding()
    drawButton(button, iconPrefix, subDir, scaleX, buttonLabel, fontSize, labelColor)
    align = gtk.Alignment()
    align.set(alignX, alignY, 0.0, 0.0)
    align.set_padding(paddingY, paddingY, paddingX, paddingX)
    align.add(button)
    
    return (button, align)
def newActionButton(iconPrefix,
                    alignX,
                    alignY,
                    subDir="cell",
                    scaleX=False,
                    buttonLabel=None,
                    fontSize=None,
                    labelColor=None,
                    paddingY=0,
                    paddingX=0):
    '''New action button.'''
    button = utils.newButtonWithoutPadding()
    drawButton(button, iconPrefix, subDir, scaleX, buttonLabel, fontSize,
               labelColor)
    align = gtk.Alignment()
    align.set(alignX, alignY, 0.0, 0.0)
    align.set_padding(paddingY, paddingY, paddingX, paddingX)
    align.add(button)

    return (button, align)
    def __init__(self, widget, messageCallback):
        '''Init proxy setup.'''
        self.widget = widget
        self.messageCallback = messageCallback
        self.window = gtk.Window()
        self.window.set_decorated(False)
        self.window.set_resizable(False)
        self.window.set_transient_for(widget.get_toplevel())
        self.window.connect("size-allocate", lambda w, a: updateShape(w, a, RADIUS))
        self.window.set_size_request(self.WINDOW_WIDTH, self.WINDOW_HEIGHT)
        
        # Draw.
        drawThemeSelectWindow(
            self.window,
            appTheme.getDynamicPixbuf("skin/background.png"),
            appTheme.getDynamicAlphaColor("frameLigtht"),
            )
        
        self.mainBox = gtk.VBox()
        self.mainEventBox = gtk.EventBox()
        self.mainEventBox.set_visible_window(False)
        self.mainEventBox.add(self.mainBox)
        self.window.add(self.mainEventBox)
        self.mainEventBox.connect("button-press-event", lambda w, e: utils.moveWindow(w, e, self.window))
        
        self.titleBox = gtk.HBox()
        self.mainBox.pack_start(self.titleBox, False, False)
        
        self.titleAlign = gtk.Alignment()
        dLabel = DynamicSimpleLabel(
            self.titleAlign,
            __("Proxy Setup"),
            appTheme.getDynamicColor("themeSelectTitleText"),
            LABEL_FONT_LARGE_SIZE,
            )
        self.titleLabel = dLabel.getLabel()
        alignY = 4
        alignX = 20
        self.titleAlign.set(0.0, 0.0, 0.0, 0.0)
        self.titleAlign.set_padding(alignY, alignY, alignX, alignX)
        self.titleAlign.add(self.titleLabel)
        self.titleBox.pack_start(self.titleAlign, True, True)
        
        self.closeButton = gtk.Button()
        self.closeButton.connect("button-release-event", lambda w, e: self.hide())
        drawButton(self.closeButton, "close", "navigate")
        self.titleBox.pack_start(self.closeButton, False, False)
        
        self.setupBox = gtk.VBox()
        self.setupAlign = gtk.Alignment()
        self.setupAlign.set(0.0, 0.0, 1.0, 1.0)
        self.setupAlign.set_padding(self.ALIGN_Y, self.ALIGN_Y, self.ALIGN_X, self.ALIGN_X + 10)
        self.setupAlign.add(self.setupBox)
        self.mainBox.pack_start(self.setupAlign, False, False)
        
        self.itemLabelWidth = 8
        
        (self.addressBox, self.addressLabel, self.addressEntry) = self.createInputItem(__("Proxy Address"))
        (self.portBox, self.portLabel, self.portEntry) = self.createInputItem(__("Proxy Port"))
        (self.userBox, self.userLabel, self.userEntry) = self.createInputItem(__("Proxy User"))
        (self.passwordBox, self.passwordLabel, self.passwordEntry) = self.createInputItem(__("Proxy Password"), True)
        
        self.setupBox.pack_start(self.addressBox)
        self.setupBox.pack_start(self.portBox)
        self.setupBox.pack_start(self.userBox)
        self.setupBox.pack_start(self.passwordBox)
        
        self.actionBox = gtk.HBox()
        self.actionAlign = gtk.Alignment()
        self.actionAlign.set(1.0, 0.5, 0.0, 0.0)
        self.actionAlign.set_padding(self.ACTION_ALIGN_Y, self.ACTION_ALIGN_Y, 0, 0)
        self.actionAlign.add(self.actionBox)
        self.setupBox.pack_start(self.actionAlign, True, True)
        
        buttonPaddingX = 10
        self.setupButton = utils.newButtonWithoutPadding()
        self.setupButton.connect("button-press-event", lambda w, e: self.setProxy())
        drawButton(self.setupButton, "button", "proxySetup", True, __("Proxy OK"), BUTTON_FONT_SIZE_SMALL, "buttonFont")
        self.actionBox.pack_start(self.setupButton, False, False, buttonPaddingX)

        self.cancelButton = utils.newButtonWithoutPadding()
        self.cancelButton.connect("button-press-event", lambda w, e: self.cancelProxy())
        drawButton(self.cancelButton, "button", "proxySetup", True, __("Proxy Cancel"), BUTTON_FONT_SIZE_SMALL, "buttonFont")
        self.actionBox.pack_start(self.cancelButton, False, False)
        
        # Read proxy setup.
        self.readProxySetup()
            
        # Hide window if user click on main window.
        widget.connect("button-press-event", lambda w, e: self.hide())
    def createIndexbar(self):
        """Create bottom bar."""
        # Init.
        paddingX = 5
        paddingY = 10

        # Just render when application more than one page.
        if self.appNum > self.defaultRows * self.pageSize:
            # Create index box.
            box = gtk.HBox()
            align = gtk.Alignment()
            align.set(0.5, 1.0, 0.0, 0.0)
            align.set_padding(paddingY, paddingY, paddingX, paddingX)
            align.add(box)

            # Get start/end index.
            if self.pageIndex % self.pageSize == 0:
                (startIndex, endIndex) = (
                    max(1, (self.pageIndex - 1) / self.pageSize * self.pageSize + 1),
                    min(self.pageIndex + 1, self.maxPageIndex + 1),
                )
            else:
                (startIndex, endIndex) = (
                    int(self.pageIndex / self.pageSize) * self.pageSize + 1,
                    min((int(self.pageIndex / self.pageSize) + 1) * self.pageSize + 1, self.maxPageIndex + 1),
                )

            # Don't add first icon if at first *page*.
            if startIndex != 1:
                # Add previous icon.
                prevButton = setHoverButton(
                    appTheme.getDynamicPixbuf("index/backward_normal.png"),
                    appTheme.getDynamicPixbuf("index/backward_hover.png"),
                )
                prevButton.connect(
                    "button-press-event",
                    lambda widget, event: self.jumpPage(max(1, (self.pageIndex - 1) / self.pageSize * self.pageSize)),
                )
                prevAlign = gtk.Alignment()
                prevAlign.set(0.5, 0.5, 0.0, 0.0)
                prevAlign.add(prevButton)
                box.pack_start(prevAlign, False, False, paddingX)

                firstBox = self.createNumIcon(1)
                firstLabel = gtk.Label()
                firstLabel.set_markup(
                    "<span foreground='%s' size='%s'> ... </span>"
                    % (appTheme.getDynamicColor("index").getColor(), LABEL_FONT_MEDIUM_SIZE)
                )
                box.pack_start(firstBox)
                box.pack_start(firstLabel)

            # Add index number icon.
            for i in range(startIndex, endIndex):
                box.pack_start(self.createNumIcon(i), False, False, paddingX)

            # Don't add last icon if at last *page*.
            if endIndex - 1 != self.maxPageIndex:
                lastBox = self.createNumIcon(self.maxPageIndex)
                lastLabel = gtk.Label()
                lastLabel.set_markup(
                    "<span foreground='%s' size='%s'> ... </span>"
                    % (appTheme.getDynamicColor("index").getColor(), LABEL_FONT_MEDIUM_SIZE)
                )
                box.pack_start(lastLabel)
                box.pack_start(lastBox)

                # Add next icon.
                nextButton = setHoverButton(
                    appTheme.getDynamicPixbuf("index/forward_normal.png"),
                    appTheme.getDynamicPixbuf("index/forward_hover.png"),
                )
                nextButton.connect(
                    "button-press-event",
                    lambda widget, event: self.jumpPage(
                        min(self.maxPageIndex, ((self.pageIndex - 1) / self.pageSize + 1) * self.pageSize + 1)
                    ),
                )
                nextAlign = gtk.Alignment()
                nextAlign.set(0.5, 0.5, 0.0, 0.0)
                nextAlign.add(nextButton)
                box.pack_start(nextAlign, False, False, paddingX)

            # Add jump button.
            spinButton = gtk.SpinButton()
            spinButton.set_digits(0)
            spinButton.set_increments(1, self.defaultRows)
            spinButton.set_range(1, self.maxPageIndex)
            spinButton.set_value(self.pageIndex)
            self.jumpButton = spinButton

            # Add jump label.
            jumpBeforeLabel = gtk.Label()
            jumpBeforeLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_MEDIUM_SIZE, __("Jump To")))
            jumpAfterLabel = gtk.Label()
            jumpAfterLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_MEDIUM_SIZE, __("Page")))
            jumpButton = utils.newButtonWithoutPadding()
            jumpButton.connect(
                "button-release-event", lambda widget, event: self.jumpPage(int(self.jumpButton.get_text()))
            )
            drawButton(jumpButton, "confirm", "index", False, __("Jump"), BUTTON_FONT_SIZE_SMALL, "buttonFont")

            # Connect widget.
            box.pack_start(jumpBeforeLabel, False, False, paddingX)
            box.pack_start(spinButton, False, False, paddingX)
            box.pack_start(jumpAfterLabel, False, False, paddingX)
            box.pack_start(jumpButton, False, False, paddingX)

            return align
        elif self.appNum > self.defaultRows:
            # Init.
            box = gtk.HBox()
            align = gtk.Alignment()
            align.set(0.5, 1.0, 0.0, 0.0)
            align.set_padding(paddingY, paddingY, paddingX, paddingX)
            align.add(box)

            # Add index number icon.
            for i in range(1, self.maxPageIndex + 1):
                box.pack_start(self.createNumIcon(i), False, False, paddingX)

            return align
        else:
            return None
 def createIndexbar(self):
     '''Create bottom bar.'''
     # Init.
     paddingX = 5
     paddingY = 10
         
     # Just render when application more than one page.
     if self.appNum > self.defaultRows * self.pageSize:
         # Create index box.
         box = gtk.HBox()
         align = gtk.Alignment()
         align.set(0.5, 1.0, 0.0, 0.0)
         align.set_padding(paddingY, paddingY, paddingX, paddingX)
         align.add(box)
         
         # Get start/end index.
         if self.pageIndex % self.pageSize == 0:
             (startIndex, endIndex) = (max(1, (self.pageIndex - 1) / self.pageSize * self.pageSize + 1),
                                       min(self.pageIndex + 1,
                                           self.maxPageIndex + 1))
         else:
             (startIndex, endIndex) = (int(self.pageIndex / self.pageSize) * self.pageSize + 1, 
                                       min((int(self.pageIndex / self.pageSize) + 1) * self.pageSize + 1,
                                           self.maxPageIndex + 1))
         
         # Don't add first icon if at first *page*.
         if startIndex != 1:
             # Add previous icon.
             prevButton = setHoverButton(
                 appTheme.getDynamicPixbuf("index/backward_normal.png"),
                 appTheme.getDynamicPixbuf("index/backward_hover.png"),
                 )
             prevButton.connect("button-press-event", 
                             lambda widget, event: self.jumpPage(max(1, (self.pageIndex - 1) / self.pageSize * self.pageSize)))
             prevAlign = gtk.Alignment()
             prevAlign.set(0.5, 0.5, 0.0, 0.0)
             prevAlign.add(prevButton)
             box.pack_start(prevAlign, False, False, paddingX)
             
             firstBox = self.createNumIcon(1)
             firstLabel = gtk.Label()
             firstLabel.set_markup("<span foreground='%s' size='%s'> ... </span>" % (
                     appTheme.getDynamicColor("index").getColor(),
                     LABEL_FONT_MEDIUM_SIZE))
             box.pack_start(firstBox)
             box.pack_start(firstLabel)
         
         # Add index number icon.
         for i in range(startIndex, endIndex):
             box.pack_start(self.createNumIcon(i), False, False, paddingX)
         
         # Don't add last icon if at last *page*.
         if endIndex - 1 != self.maxPageIndex:
             lastBox = self.createNumIcon(self.maxPageIndex)
             lastLabel = gtk.Label()
             lastLabel.set_markup("<span foreground='%s' size='%s'> ... </span>" % (
                     appTheme.getDynamicColor("index").getColor(),
                     LABEL_FONT_MEDIUM_SIZE))
             box.pack_start(lastLabel)
             box.pack_start(lastBox)
             
             # Add next icon.
             nextButton = setHoverButton(
                 appTheme.getDynamicPixbuf("index/forward_normal.png"),
                 appTheme.getDynamicPixbuf("index/forward_hover.png"),
                 )
             nextButton.connect("button-press-event", 
                                lambda widget, event: self.jumpPage(min(self.maxPageIndex, ((self.pageIndex - 1) / self.pageSize + 1) * self.pageSize + 1)))
             nextAlign = gtk.Alignment()
             nextAlign.set(0.5, 0.5, 0.0, 0.0)
             nextAlign.add(nextButton)
             box.pack_start(nextAlign, False, False, paddingX)
         
         # Add jump button.
         spinButton = gtk.SpinButton()
         spinButton.set_digits(0)
         spinButton.set_increments(1, self.defaultRows)
         spinButton.set_range(1, self.maxPageIndex)
         spinButton.set_value(self.pageIndex)
         self.jumpButton = spinButton
         
         # Add jump label.
         jumpBeforeLabel = gtk.Label()
         jumpBeforeLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_MEDIUM_SIZE, __("Jump To")))
         jumpAfterLabel = gtk.Label()
         jumpAfterLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_MEDIUM_SIZE, __("Page")))
         jumpButton = utils.newButtonWithoutPadding()
         jumpButton.connect("button-release-event", lambda widget, event: self.jumpPage(int(self.jumpButton.get_text())))
         drawButton(jumpButton, "confirm", "index", False, __("Jump"), BUTTON_FONT_SIZE_SMALL, "buttonFont")
         
         # Connect widget.
         box.pack_start(jumpBeforeLabel, False, False, paddingX)
         box.pack_start(spinButton, False, False, paddingX)
         box.pack_start(jumpAfterLabel, False, False, paddingX)
         box.pack_start(jumpButton, False, False, paddingX)
         
         return align
     elif self.appNum > self.defaultRows:
         # Init.
         box = gtk.HBox()
         align = gtk.Alignment()
         align.set(0.5, 1.0, 0.0, 0.0)
         align.set_padding(paddingY, paddingY, paddingX, paddingX)
         align.add(box)
         
         # Add index number icon.
         for i in range(1, self.maxPageIndex + 1):
             box.pack_start(self.createNumIcon(i), False, False, paddingX)
         
         return align
     else:
         return None
Ejemplo n.º 6
0
 def createIndexbar(self):
     '''Create bottom bar.'''
     # Init.
     paddingX = 5
     paddingY = 5
         
     # Just render when application more than one page.
     if self.appNum > self.defaultRows * self.pageSize:
         # Create index box.
         box = gtk.HBox()
         align = gtk.Alignment()
         align.set(0.5, 1.0, 0.0, 0.0)
         align.set_padding(paddingY, paddingY, paddingX, paddingX)
         align.add(box)
         
         # Get start/end index.
         if self.pageIndex % self.pageSize == 0:
             (startIndex, endIndex) = (max(1, (self.pageIndex - 1) / self.pageSize * self.pageSize + 1),
                                       min(self.pageIndex + 1,
                                           self.maxPageIndex + 1))
         else:
             (startIndex, endIndex) = (int(self.pageIndex / self.pageSize) * self.pageSize + 1, 
                                       min((int(self.pageIndex / self.pageSize) + 1) * self.pageSize + 1,
                                           self.maxPageIndex + 1))
         
         # Add index box.
         iconSize = 24
             
         # Don't add first icon if at first *page*.
         if startIndex != 1:
             # Add previous icon.
             prev = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file("./icons/index/backward.png"))
             prevBox = gtk.EventBox()
             prevBox.add(prev)
             prevBox.connect("button-press-event", lambda widget, event: self.jumpPage(max(1, self.pageIndex - self.pageSize)))
             prevBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(prevBox, False, False, paddingX)
             utils.setClickableCursor(prevBox)
             
             first = gtk.Label()
             first.set_markup("<span foreground='#1A3E88' size='%s'>1 ... </span>" % (LABEL_FONT_SIZE))
             firstBox = gtk.EventBox()
             firstBox.add(first)
             firstBox.connect("button-press-event", lambda widget, event: self.jumpPage(1))
             firstBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(firstBox, False, False, paddingX)
             utils.setClickableCursor(firstBox)
         
         # Add index number icon.
         for i in range(startIndex, endIndex):
             box.pack_start(self.createNumIcon(i), False, False, paddingX)
         
         # Don't add last icon if at last *page*.
         if endIndex - 1 != self.maxPageIndex:
             last = gtk.Label()
             last.set_markup("<span foreground='#1A3E88' size='%s'> ... %s</span>" % (LABEL_FONT_SIZE, str(self.maxPageIndex)))
             lastBox = gtk.EventBox()
             lastBox.add(last)
             lastBox.connect("button-press-event", lambda widget, event: self.jumpPage(self.maxPageIndex))
             lastBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(lastBox, False, False, paddingX)
             utils.setClickableCursor(lastBox)
             
             # Add next icon.
             next = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file("./icons/index/forward.png"))
             nextBox = gtk.EventBox()
             nextBox.add(next)
             nextBox.connect("button-press-event", lambda widget, event: self.jumpPage(min(self.maxPageIndex, 
                                                                                           self.pageIndex + self.pageSize)))
             nextBox.connect("expose-event", lambda w, e: drawBackground(w, e, "#FFFFFF"))
             box.pack_start(nextBox, False, False, paddingX)
             utils.setClickableCursor(nextBox)
         
         # Add jump button.
         spinButton = gtk.SpinButton()
         spinButton.set_digits(0)
         spinButton.set_increments(1, self.defaultRows)
         spinButton.set_range(1, self.maxPageIndex)
         spinButton.set_value(self.pageIndex)
         self.jumpButton = spinButton
         
         # Add jump label.
         jumpBeforeLabel = gtk.Label()
         jumpBeforeLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, "跳到第"))
         jumpAfterLabel = gtk.Label()
         jumpAfterLabel.set_markup("<span size='%s'>%s</span>" % (LABEL_FONT_SIZE, "页"))
         jumpButton = utils.newButtonWithoutPadding()
         jumpButton.connect("button-release-event", lambda widget, event: self.jumpPage(int(self.jumpButton.get_text())))
         drawButton(jumpButton, "confirm", "index", False, "确定", BUTTON_FONT_SIZE_SMALL)
         
         # Connect widget.
         box.pack_start(jumpBeforeLabel, False, False, paddingX)
         box.pack_start(spinButton, False, False, paddingX)
         box.pack_start(jumpAfterLabel, False, False, paddingX)
         box.pack_start(jumpButton, False, False, paddingX)
         
         return align
     elif self.appNum > self.defaultRows:
         # Init.
         box = gtk.HBox()
         align = gtk.Alignment()
         align.set(0.5, 1.0, 0.0, 0.0)
         align.set_padding(paddingY, paddingY, paddingX, paddingX)
         align.add(box)
         
         # Add index number icon.
         for i in range(1, self.maxPageIndex + 1):
             box.pack_start(self.createNumIcon(i), False, False, paddingX)
         
         return align
     else:
         return None
    def __init__(self, widget, messageCallback):
        '''Init proxy setup.'''
        self.widget = widget
        self.messageCallback = messageCallback
        self.window = gtk.Window()
        self.window.set_decorated(False)
        self.window.set_resizable(False)
        self.window.set_transient_for(widget.get_toplevel())
        self.window.connect("size-allocate",
                            lambda w, a: updateShape(w, a, RADIUS))
        self.window.set_size_request(self.WINDOW_WIDTH, self.WINDOW_HEIGHT)

        # Draw.
        drawThemeSelectWindow(
            self.window,
            appTheme.getDynamicPixbuf("skin/background.png"),
            appTheme.getDynamicAlphaColor("frameLigtht"),
        )

        self.mainBox = gtk.VBox()
        self.mainEventBox = gtk.EventBox()
        self.mainEventBox.set_visible_window(False)
        self.mainEventBox.add(self.mainBox)
        self.window.add(self.mainEventBox)
        self.mainEventBox.connect(
            "button-press-event",
            lambda w, e: utils.moveWindow(w, e, self.window))

        self.titleBox = gtk.HBox()
        self.mainBox.pack_start(self.titleBox, False, False)

        self.titleAlign = gtk.Alignment()
        dLabel = DynamicSimpleLabel(
            self.titleAlign,
            __("Proxy Setup"),
            appTheme.getDynamicColor("themeSelectTitleText"),
            LABEL_FONT_LARGE_SIZE,
        )
        self.titleLabel = dLabel.getLabel()
        alignY = 4
        alignX = 20
        self.titleAlign.set(0.0, 0.0, 0.0, 0.0)
        self.titleAlign.set_padding(alignY, alignY, alignX, alignX)
        self.titleAlign.add(self.titleLabel)
        self.titleBox.pack_start(self.titleAlign, True, True)

        self.closeButton = gtk.Button()
        self.closeButton.connect("button-release-event",
                                 lambda w, e: self.hide())
        drawButton(self.closeButton, "close", "navigate")
        self.titleBox.pack_start(self.closeButton, False, False)

        self.setupBox = gtk.VBox()
        self.setupAlign = gtk.Alignment()
        self.setupAlign.set(0.0, 0.0, 1.0, 1.0)
        self.setupAlign.set_padding(self.ALIGN_Y, self.ALIGN_Y, self.ALIGN_X,
                                    self.ALIGN_X + 10)
        self.setupAlign.add(self.setupBox)
        self.mainBox.pack_start(self.setupAlign, False, False)

        self.itemLabelWidth = 8

        (self.addressBox, self.addressLabel,
         self.addressEntry) = self.createInputItem(__("Proxy Address"))
        (self.portBox, self.portLabel,
         self.portEntry) = self.createInputItem(__("Proxy Port"))
        (self.userBox, self.userLabel,
         self.userEntry) = self.createInputItem(__("Proxy User"))
        (self.passwordBox, self.passwordLabel,
         self.passwordEntry) = self.createInputItem(__("Proxy Password"), True)

        self.setupBox.pack_start(self.addressBox)
        self.setupBox.pack_start(self.portBox)
        self.setupBox.pack_start(self.userBox)
        self.setupBox.pack_start(self.passwordBox)

        self.actionBox = gtk.HBox()
        self.actionAlign = gtk.Alignment()
        self.actionAlign.set(1.0, 0.5, 0.0, 0.0)
        self.actionAlign.set_padding(self.ACTION_ALIGN_Y, self.ACTION_ALIGN_Y,
                                     0, 0)
        self.actionAlign.add(self.actionBox)
        self.setupBox.pack_start(self.actionAlign, True, True)

        buttonPaddingX = 10
        self.setupButton = utils.newButtonWithoutPadding()
        self.setupButton.connect("button-press-event",
                                 lambda w, e: self.setProxy())
        drawButton(self.setupButton, "button", "proxySetup", True,
                   __("Proxy OK"), BUTTON_FONT_SIZE_SMALL, "buttonFont")
        self.actionBox.pack_start(self.setupButton, False, False,
                                  buttonPaddingX)

        self.cancelButton = utils.newButtonWithoutPadding()
        self.cancelButton.connect("button-press-event",
                                  lambda w, e: self.cancelProxy())
        drawButton(self.cancelButton, "button", "proxySetup", True,
                   __("Proxy Cancel"), BUTTON_FONT_SIZE_SMALL, "buttonFont")
        self.actionBox.pack_start(self.cancelButton, False, False)

        # Read proxy setup.
        self.readProxySetup()

        # Hide window if user click on main window.
        widget.connect("button-press-event", lambda w, e: self.hide())