Beispiel #1
0
 def __init__(self, items=None):
     ScrolledWindow.__init__(self, 0, 0)
     self.file_iconview = IconView()
     self.file_iconview.draw_mask = self.draw_mask
     if items != None:
         self.file_iconview.add_items(items)
     self.file_scrolledwindow = ScrolledWindow()
     self.file_scrolledwindow.add_child(self.file_iconview)
     self.add_child(self.file_scrolledwindow)
Beispiel #2
0
    def __init__(
        self,
        init_color="#FFFFFF",
        confirm_callback=None,
        cancel_callback=None,
        cancel_first=True,
    ):
        '''
        Initialize ColorSelectDialog class.

        @param init_color: Initialize color of dialog.
        @param confirm_callback: Callback when user click OK, this callback accept one argument, color string.
        @param cancel_callback: Callback when user click cancel, this callback don't accept any argument.
        @param cancel_first: Set as True if to make cancel button before confirm button, default is True.
        '''
        DialogBox.__init__(self,
                           _("Select color"),
                           mask_type=DIALOG_MASK_SINGLE_PAGE)
        self.confirm_callback = confirm_callback
        self.cancel_callback = cancel_callback
        self.cancel_first = cancel_first

        self.color_box = gtk.HBox()
        self.color_align = gtk.Alignment()
        self.color_align.set(0.5, 0.5, 0.0, 0.0)
        self.color_align.set_padding(10, 0, 8, 8)
        self.color_align.add(self.color_box)
        self.color_hsv = HSV()
        self.color_string = init_color
        (self.color_r, self.color_g,
         self.color_b) = self.color_hsv.get_rgb_color()
        self.color_hsv.get_hsv_widget().connect(
            "button-release-event", lambda w, e: self.update_color_info(
                self.color_hsv.get_color_string()))
        self.color_box.pack_start(self.color_hsv, False, False)

        self.color_right_box = gtk.VBox()
        self.color_right_align = gtk.Alignment()
        self.color_right_align.set(0.5, 0.5, 0.0, 0.0)
        self.color_right_align.set_padding(8, 0, 0, 0)
        self.color_right_align.add(self.color_right_box)
        self.color_box.pack_start(self.color_right_align)

        self.color_info_box = gtk.HBox()
        self.color_right_box.pack_start(self.color_info_box, False, False)

        self.color_display_box = gtk.VBox()
        self.color_display_button = gtk.Button()
        self.color_display_button.connect("expose-event",
                                          self.expose_display_button)
        self.color_display_button.set_size_request(70, 58)
        self.color_display_align = gtk.Alignment()
        self.color_display_align.set(0.5, 0.5, 1.0, 1.0)
        self.color_display_align.set_padding(5, 5, 5, 5)
        self.color_display_align.add(self.color_display_button)
        self.color_display_box.pack_start(self.color_display_align, False,
                                          False, 5)

        self.color_hex_box = gtk.HBox()
        self.color_hex_label = Label(_("Color value"))
        self.color_hex_box.pack_start(self.color_hex_label, False, False, 5)
        self.color_hex_entry = InputEntry(self.color_string)
        self.color_hex_entry.entry.check_text = is_hex_color
        self.color_hex_entry.entry.connect("press-return",
                                           self.press_return_color_entry)
        self.color_hex_entry.set_size(70, 24)
        self.color_hex_box.pack_start(self.color_hex_entry, False, False, 5)
        self.color_display_box.pack_start(self.color_hex_box, False, False, 5)

        self.color_info_box.pack_start(self.color_display_box, False, False, 5)

        self.color_rgb_box = gtk.VBox()
        self.color_r_box = gtk.HBox()
        self.color_r_label = Label(_("Red: "))
        self.color_r_spin = SpinBox(self.color_r,
                                    0,
                                    255,
                                    1,
                                    check_text=self.is_color_value)
        self.color_r_spin.connect("value-changed",
                                  lambda s, v: self.click_rgb_spin())
        self.color_r_box.pack_start(self.color_r_label, False, False)
        self.color_r_box.pack_start(self.color_r_spin, False, False)
        self.color_g_box = gtk.HBox()
        self.color_g_label = Label(_("Green: "))
        self.color_g_spin = SpinBox(self.color_g,
                                    0,
                                    255,
                                    1,
                                    check_text=self.is_color_value)
        self.color_g_spin.connect("value-changed",
                                  lambda s, v: self.click_rgb_spin())
        self.color_g_box.pack_start(self.color_g_label, False, False)
        self.color_g_box.pack_start(self.color_g_spin, False, False)
        self.color_b_box = gtk.HBox()
        self.color_b_label = Label(_("Blue: "))
        self.color_b_spin = SpinBox(self.color_b,
                                    0,
                                    255,
                                    1,
                                    check_text=self.is_color_value)
        self.color_b_spin.connect("value-changed",
                                  lambda s, v: self.click_rgb_spin())
        self.color_b_box.pack_start(self.color_b_label, False, False)
        self.color_b_box.pack_start(self.color_b_spin, False, False)

        self.color_rgb_box.pack_start(self.color_r_box, False, False, 8)
        self.color_rgb_box.pack_start(self.color_g_box, False, False, 8)
        self.color_rgb_box.pack_start(self.color_b_box, False, False, 8)
        self.color_info_box.pack_start(self.color_rgb_box, False, False, 5)

        self.color_select_view = IconView()
        self.color_select_view.set_size_request(250, 60)
        self.color_select_view.connect(
            "button-press-item",
            lambda view, item, x, y: self.update_color_info(item.color, False))
        self.color_select_view.draw_mask = self.get_mask_func(
            self.color_select_view)
        self.color_select_scrolled_window = ScrolledWindow()
        for color in self.DEFAULT_COLOR_LIST:
            self.color_select_view.add_items([ColorItem(color)])

        self.color_select_align = gtk.Alignment()
        self.color_select_align.set(0.5, 0.5, 1.0, 1.0)
        self.color_select_align.set_padding(10, 5, 6, 5)

        self.color_select_scrolled_window.add_child(self.color_select_view)
        self.color_select_scrolled_window.set_size_request(-1, 60)
        self.color_select_align.add(self.color_select_scrolled_window)
        self.color_right_box.pack_start(self.color_select_align, True, True)

        self.confirm_button = Button(_("OK"))
        self.cancel_button = Button(_("Cancel"))

        self.confirm_button.connect("clicked",
                                    lambda w: self.click_confirm_button())
        self.cancel_button.connect("clicked",
                                   lambda w: self.click_cancel_button())

        if self.cancel_first:
            self.right_button_box.set_buttons(
                [self.cancel_button, self.confirm_button])
        else:
            self.right_button_box.set_buttons(
                [self.confirm_button, self.cancel_button])
        self.body_box.pack_start(self.color_align, True, True)

        self.update_color_info(self.color_string)
Beispiel #3
0
    def __init__(self,
                 crumb,
                 arrow_right=ui_theme.get_pixbuf("treeview/arrow_right.png"),
                 arrow_down=ui_theme.get_pixbuf("treeview/arrow_down.png"),
                 show_others=False,
                 show_entry=False,
                 show_left_right_box=True):
        '''
        Initialize Bread class.

        @param crumb: Crumb instance or a list of crumb instances
        @param arrow_right: Dynamic pixbuf for right arrow, default is \"treeview/arrow_right.png\" from ui theme.
        @param arrow_down: Dynamic pixbuf for down arrow, default is \"treeview/arrow_down.png\" from ui theme.
        @param show_others: If True, crumbs will not be destroyed, otherwise all crumbs on the right side will be destroyed.
        @param show_entry: If True, an entry will pop up when click space area in Bread.
        '''
        # Init.
        super(Bread, self).__init__(spacing=0)
        self.arrow_right = arrow_right
        self.arrow_down = arrow_down
        self.item_list = list()
        self.show_others = show_others
        self.show_entry = show_entry
        self.crumb = self.create_crumb(crumb)
        self.button_width = ARROW_BUTTON_WIDTH  # for left & right buttons
        self.in_event_box = False

        # Init left button and right button.
        self.show_left_right_box = show_left_right_box
        left_box = gtk.HBox(spacing=0)
        right_box = gtk.HBox(spacing=0)

        # FIXME: left && right box static setting size
        #        it is better to consider whether or not shown left && right box
        #        at runtime
        if self.show_left_right_box:
            left_box.set_size_request(self.button_width, -1)
            right_box.set_size_request(self.button_width, -1)
        self.left_btn = Button("<")
        self.right_btn = Button(">")
        self.left_btn.set_no_show_all(True)
        self.right_btn.set_no_show_all(True)
        self.right_btn.connect("clicked", self.move_right)
        self.left_btn.connect("clicked", self.move_left)
        self.left_btn.set_size_request(self.button_width, -1)
        self.right_btn.set_size_request(self.button_width, -1)
        left_box.pack_start(self.left_btn, False, False)
        right_box.pack_start(self.right_btn, False, False)

        # Init Hbox
        self.hbox = gtk.HBox(False, 0)
        self.hbox.show()
        self.eventbox = gtk.EventBox()
        self.eventbox.set_visible_window(False)

        if self.show_entry:
            self.eventbox.connect("enter-notify-event", self.enter_notify)
            self.eventbox.connect("leave-notify-event", self.leave_notify)
            self.eventbox.connect("button-press-event", self.event_box_press)

        self.hbox.pack_end(self.eventbox, True, True)
        self.scroll_win = ScrolledWindow()
        self.pack_start(left_box, False, True)
        self.pack_start(self.hbox, True, True)

        # Add Bread Items
        self.adj = self.scroll_win.get_hadjustment()

        self.add(self.crumb)