Example #1
0
 def _add_progress_text(self, progress_text, view):
     prog = NSTextField.createLabelWithText_(progress_text)
     prog.setFrameOrigin_(NSPoint(self.BOX_LEFT, self._window_y_offset))
     view.addSubview_(prog)
     prog.alignBottomInSuperview()
     offset = -2
     prog.setFrameOrigin_(NSPoint(prog.frame().origin.x, prog.frame().origin.y - offset))
     return prog
Example #2
0
 def initWithDropboxApp_takeAction_hideText_width_(self, dropbox_app, take_action, hide_text, width):
     self = super(SelectiveSyncLauncher, self).initWithFrame_(NSZeroRect)
     if self is None:
         return
     self._dropbox_app = dropbox_app
     self._action = None
     self._take_action = take_action
     self.current_ignore_list = None
     self._width = width
     self.listingProgress = None
     if not hide_text:
         self.info_label = NSTextField.createLabelWithText_(selsync_strings.prefs_launch_label)
         self.addSubview_(self.info_label)
     else:
         self.info_label = None
     self.launch_button = self.addNormalRoundButtonWithTitle_action_(selsync_strings.prefs_launch_button, self.launch_)
     self.setEnabled_(self._dropbox_app.ui_kit.post_link)
     self.sizeToFit()
     return self
Example #3
0
    def layout(self):
        view = self.contentView()
        buttons = []
        right_button = view.addNormalRoundButtonWithTitle_action_(self.right_button_text, self.handleRightButton_)
        right_button.setKeyEquivalent_(ENTER_KEY if not self.right_button_key else self.right_button_key)
        offset = (self.BOTTOM_BORDER - (NSHeight(right_button.frame()) + NSHeight(right_button.insetRect()))) / 2
        right_button.alignRightInSuperview()
        right_button.alignBottomInSuperview(offset)
        buttons.append(right_button)
        self.left_button = None
        if self.left_button_text:
            left_button = view.addNormalRoundButtonWithTitle_action_(self.left_button_text, self.handleLeftButton_)
            left_button.alignLeftInSuperview()
            left_button.alignBottomInSuperview(offset)
            if self.left_button_key:
                left_button.setKeyEquivalent_(self.left_button_key)
            self.left_button = left_button
            buttons.append(left_button)
        elif self.left_label:
            left_label = NSTextField.createLabelWithText_(self.left_label)
            view.addSubview_(left_label)
            left_label.alignLeftInSuperview()
            left_label.alignBottomInSuperview(offset)
        if self.lefter_right_button_text:
            lefter_right_button = view.addNormalRoundButtonWithTitle_action_(self.lefter_right_button_text, self.handleLefterRightButton_)
            if self.lefter_right_button_key:
                lefter_right_button.setKeyEquivalent_(self.lefter_right_button_key)
            lefter_right_button.placeLeftOfButton_(right_button)
            buttons.append(lefter_right_button)
        for button in buttons:
            button.setTarget_(self)

        bg_image = BackgroundImageView(NSRect((0, self.BOTTOM_BORDER), (NSWidth(self.frame()), NSHeight(self.frame()) - self.BOTTOM_BORDER)), self.background, bottom_align=True)
        if (self.background.size().width, self.background.size().height) != self.WINDOW_SIZE:
            bg_image.setImageSize_(NSSize(self.WINDOW_SIZE[0], self.WINDOW_SIZE[1]))
        view.addSubview_(bg_image)
        view.addSubview_(self.inner)
        self.inner.alignBottomInSuperview(self.BOTTOM_BORDER)
Example #4
0
 def layout(self):
     height = self.BORDER + self.IMAGE_PADDING
     width = self.VIEW_SIZE[0] - self.BORDER * 2
     image = NonBlurryImageView.alloc().initWithFrame_(NSZeroRect)
     image.setImage_(self.image)
     image.setFrameSize_(self.image.size())
     self.addSubview_(image)
     image.setFrameOrigin_((0, height))
     image.centerHorizontallyInSuperview()
     height += NSHeight(image.frame()) + self.HEADER_PADDING
     label1 = NSTextField.createLabelWithText_font_maxWidth_origin_(self.header, NSFont.boldSystemFontOfSize_(self.HEADER_SIZE) if self.BOLD_HEADER else NSFont.systemFontOfSize_(self.HEADER_SIZE), width, NSPoint(0, height))
     self.addSubview_(label1)
     label1.centerHorizontallyInSuperview()
     label1.setTextColor_(self.HEADER_COLOR)
     height += NSHeight(label1.frame()) + self.SUBHEADER_PADDING
     label2 = NSTextField.createLabelWithText_font_maxWidth_origin_(NSAttributedString.boldify(self.subheader, font=NSFont.systemFontOfSize_(self.SUBHEADER_SIZE), bold_font=NSFont.boldSystemFontOfSize_(self.SUBHEADER_SIZE), center=True, line_height=self.SUBHEADER_LINE_HEIGHT), NSFont.systemFontOfSize_(self.SUBHEADER_SIZE), width, NSPoint(0, height))
     self.addSubview_(label2)
     label2.setAlignment_(NSCenterTextAlignment)
     label2.setTextColor_(self.SUBHEADER_COLOR)
     label2.balancedWrapToWidth_(width)
     label2.centerHorizontallyInSuperview()
     if self.checkbox_text:
         checkbox = NSButton.alloc().initWithFrame_(NSZeroRect)
         self.addSubview_(checkbox)
         checkbox.setButtonType_(NSSwitchButton)
         checkbox.setAttributedTitle_(NSAttributedString.boldify(self.checkbox_text, font=NSFont.systemFontOfSize_(self.CHECKBOX_SIZE), bold_font=NSFont.boldSystemFontOfSize_(self.CHECKBOX_SIZE)))
         checkbox.setTextColor_(Colors.camera_font)
         checkbox.sizeToFit()
         if NSWidth(checkbox.frame()) > width:
             checkbox.setAttributedTitle_(CameraStrings.splash_always_import_no_name)
             checkbox.setTextColor_(Colors.camera_font)
             checkbox.sizeToFit()
         checkbox.setState_(True)
         checkbox.centerHorizontallyInSuperview()
         checkbox.alignBottomInSuperview(self.BORDER - checkbox.flippedBaselineOffset())
         self.checkbox = checkbox
     else:
         self.checkbox = None
     height += NSHeight(label2.frame()) + self.FINE_PRINT_PADDING
     if self.fine_print:
         fine_print = NSTextField.createLabelWithText_font_maxWidth_origin_(self.fine_print, NSFont.systemFontOfSize_(self.FINE_PRINT_SIZE), width, NSPoint(0, height))
         self.addSubview_(fine_print)
         fine_print.setAlignment_(NSCenterTextAlignment)
         fine_print.setTextColor_(Colors.fine_print)
         fine_print.balancedWrapToWidth_(width)
         fine_print.centerHorizontallyInSuperview()
         self.fine_print_label = fine_print
     else:
         self.fine_print_label = None
     self.combo = None
     if self.choice_selector:
         subview = NSView.alloc().initWithFrame_(NSZeroRect)
         combo_descriptor = NSTextField.createLabelWithText_(NSAttributedString.boldify(self.choice_selector.text, font=NSFont.systemFontOfSize_(NSRegularControlSize), bold_font=NSFont.boldSystemFontOfSize_(NSRegularControlSize)))
         combo_descriptor.setTextColor_(self.SUBHEADER_COLOR)
         subview.addSubview_(combo_descriptor)
         combo = NSPopUpButton.createNormalPopUpButtonWithChoices_default_(self.choice_selector.selections, self.choice_selector.default_index)
         combo.sizeToFit()
         subview.addSubview_(combo)
         descriptor_frame = combo_descriptor.frame()
         half = combo.frame().size.height / 2.0
         descriptor_half = descriptor_frame.size.height / 2.0
         combo_descriptor.setFrameOrigin_(NSPoint(descriptor_frame.origin.x, half - descriptor_half + 2.0))
         combo.setFrameOrigin_(NSPoint(descriptor_frame.origin.x + descriptor_frame.size.width, 0))
         subview.setFrameSize_((combo.frame().size.width + descriptor_frame.size.width, combo.frame().size.height))
         self.addSubview_(subview)
         subview.centerHorizontallyInSuperview()
         subview.alignBottomInSuperview(CONTENT_BORDER + self.CHOICE_SELECTOR_PADDING)
         self.combo = combo