Ejemplo n.º 1
0
    def __init__(self,
                 width=180,
                 height=180):
        '''
        Initialize DateTime class.

        @param width: Width of widget, default is 180 pixels.
        @param height: Height of widget, default is 180 pixels.
        '''
        gtk.VBox.__init__(self)

        self.hour_value = time.localtime().tm_hour
        self.minute_value = time.localtime().tm_min
        self.second_value = time.localtime().tm_sec

        self.width = width
        self.height = height
        self.set_size_request(self.width, self.height)

        self.clockface = ui_theme.get_pixbuf("datetime/clockface.png")
        self.clockface_width = self.clockface.get_pixbuf().get_width()
        self.clockface_height = self.clockface.get_pixbuf().get_height()
        self.hourhand = ui_theme.get_pixbuf("datetime/hourhand.png")
        self.hourhand_width = self.hourhand.get_pixbuf().get_width()
        self.hourhand_height = self.hourhand.get_pixbuf().get_height()
        self.minhand = ui_theme.get_pixbuf("datetime/minhand.png")
        self.minhand_width = self.minhand.get_pixbuf().get_width()
        self.minhand_height = self.minhand.get_pixbuf().get_height()
        self.sechand = ui_theme.get_pixbuf("datetime/sechand.png")
        self.sechand_width = self.sechand.get_pixbuf().get_width()
        self.sechand_height = self.sechand.get_pixbuf().get_height()

        self.connect("expose-event", self.__expose)

        SecondThread(self).start()
Ejemplo n.º 2
0
    def __init__(self, 
                 width=180, 
                 height=180):
        '''
        Initialize DateTime class.
        
        @param width: Width of widget, default is 180 pixels.
        @param height: Height of widget, default is 180 pixels.
        '''
        gtk.VBox.__init__(self)
        
        self.hour_value = time.localtime().tm_hour                               
        self.minute_value = time.localtime().tm_min                              
        self.second_value = time.localtime().tm_sec

        self.width = width
        self.height = height
        self.set_size_request(self.width, self.height)

        self.clockface = ui_theme.get_pixbuf("datetime/clockface.png")
        self.clockface_width = self.clockface.get_pixbuf().get_width()
        self.clockface_height = self.clockface.get_pixbuf().get_height()
        self.hourhand = ui_theme.get_pixbuf("datetime/hourhand.png")
        self.hourhand_width = self.hourhand.get_pixbuf().get_width()
        self.hourhand_height = self.hourhand.get_pixbuf().get_height()
        self.minhand = ui_theme.get_pixbuf("datetime/minhand.png")
        self.minhand_width = self.minhand.get_pixbuf().get_width()
        self.minhand_height = self.minhand.get_pixbuf().get_height()
        self.sechand = ui_theme.get_pixbuf("datetime/sechand.png")
        self.sechand_width = self.sechand.get_pixbuf().get_width()
        self.sechand_height = self.sechand.get_pixbuf().get_height()

        self.connect("expose-event", self.__expose)

        SecondThread(self).start()
Ejemplo n.º 3
0
 def expose_button(self, widget, event):
     '''Expose button.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     x, y, w, h = rect.x, rect.y, rect.width, rect.height
     
     # Get color info.
     if widget.state == gtk.STATE_NORMAL:
         text_color = ui_theme.get_color("button_font").get_color()
         border_color = ui_theme.get_color("button_border_normal").get_color()
         background_color = ui_theme.get_shadow_color("button_background_normal").get_color_info()
     elif widget.state == gtk.STATE_PRELIGHT:
         text_color = ui_theme.get_color("button_font").get_color()
         border_color = ui_theme.get_color("button_border_prelight").get_color()
         background_color = ui_theme.get_shadow_color("button_background_prelight").get_color_info()
     elif widget.state == gtk.STATE_ACTIVE:
         text_color = ui_theme.get_color("button_font").get_color()
         border_color = ui_theme.get_color("button_border_active").get_color()
         background_color = ui_theme.get_shadow_color("button_background_active").get_color_info()
     elif widget.state == gtk.STATE_INSENSITIVE:
         text_color = ui_theme.get_color("disable_text").get_color()
         border_color = ui_theme.get_color("disable_frame").get_color()
         disable_background_color = ui_theme.get_color("disable_background").get_color()
         background_color = [(0, (disable_background_color, 1.0)),
                             (1, (disable_background_color, 1.0))]
         
     # Draw background.
     draw_vlinear(
         cr,
         x + 1, y + 1, w - 2, h - 2,
         background_color)
     
     # Draw border.
     cr.set_source_rgb(*color_hex_to_cairo(border_color))
     draw_line(cr, x + 2, y + 1, x + w - 2, y + 1) # top
     draw_line(cr, x + 2, y + h, x + w - 2, y + h) # bottom
     draw_line(cr, x + 1, y + 2, x + 1, y + h - 2) # left
     draw_line(cr, x + w, y + 2, x + w, y + h - 2) # right
     
     # Draw four point.
     if widget.state == gtk.STATE_INSENSITIVE:
         top_left_point = ui_theme.get_pixbuf("button/disable_corner.png").get_pixbuf()
     else:
         top_left_point = ui_theme.get_pixbuf("button/corner.png").get_pixbuf()
     top_right_point = top_left_point.rotate_simple(270)
     bottom_right_point = top_left_point.rotate_simple(180)
     bottom_left_point = top_left_point.rotate_simple(90)
     
     draw_pixbuf(cr, top_left_point, x, y)
     draw_pixbuf(cr, top_right_point, x + w - top_left_point.get_width(), y)
     draw_pixbuf(cr, bottom_left_point, x, y + h - top_left_point.get_height())
     draw_pixbuf(cr, bottom_right_point, x + w - top_left_point.get_width(), y + h - top_left_point.get_height())
     
     # Draw font.
     draw_text(cr, self.label, x, y, w, h, self.font_size, text_color,
                 alignment=pango.ALIGN_CENTER)
     
     return True
Ejemplo n.º 4
0
    def __init__(
        self,
        items,
        add_separator=False,
        font_size=DEFAULT_FONT_SIZE,
        padding_x=10,
        padding_y=10,
        vertical=True,
        item_hover_pixbuf=ui_theme.get_pixbuf(
            "navigatebar/nav_item_hover.png"),
        item_press_pixbuf=ui_theme.get_pixbuf(
            "navigatebar/nav_item_press.png"),
    ):
        '''
        Initialize Navigatebar class.

        @param items: A list of navigate item, item format: (item_icon_dpixbuf, item_content, clicked_callback)
        @param add_separator: Whether add separator between navigatebar and body, default is False.
        @param font_size: Font size, default is DEFAULT_FONT_SIZE.
        @param padding_x: Padding value horizontal.
        @param padding_y: Padding value vertical.
        @param vertical: Draw direction, default is vertical.
        @param item_hover_pixbuf: Item hover dpixbuf.
        @param item_press_pixbuf: Item press dpixbuf.
        '''
        # Init event box.
        EventBox.__init__(self)
        self.nav_index = 0
        self.item_hover_pixbuf = item_hover_pixbuf
        self.item_press_pixbuf = item_press_pixbuf
        self.nav_items = []

        # Init nav box.
        self.nav_box = gtk.VBox()
        self.add(self.nav_box)

        # Init item box.
        self.nav_item_box = gtk.HBox()
        self.nav_box.pack_start(self.nav_item_box, False, False)

        # Add navigate item.
        if items:
            for (index, item) in enumerate(items):
                nav_item = NavItem(item, index, font_size, padding_x,
                                   padding_y, vertical, self.set_index,
                                   self.get_index, self.item_hover_pixbuf,
                                   self.item_press_pixbuf)
                self.nav_items.append(nav_item)
                self.nav_item_box.pack_start(nav_item.item_box, False, False)

        # Add separator.
        if add_separator:
            self.separator = gtk.HBox()
            self.separator.set_size_request(-1, 2)
            self.separator.connect("expose-event", self.expose_nav_separator)
            self.nav_box.pack_start(self.separator, False, False)

        # Show.
        self.show_all()
Ejemplo n.º 5
0
 def expose_menu_item(self, widget, event):
     '''Expose menu item.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     font_color = ui_theme.get_color("menu_font").get_color()
     (item_icons, item_content, item_node) = self.item[0:3]
     
     # Draw select effect.
     if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
         # Draw background.
         draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height, 
                      ui_theme.get_shadow_color("menu_item_select").get_color_info(),
                      MENU_ITEM_RADIUS)
         
         # Set font color.
         font_color = ui_theme.get_color("menu_select_font").get_color()
         
     # Draw item icon.
     pixbuf = None
     pixbuf_width = 0
     if item_icons:
         (item_normal_dpixbuf, item_hover_dpixbuf) = item_icons
         if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
             if item_hover_dpixbuf == None:
                 pixbuf = item_normal_dpixbuf.get_pixbuf()
             else:
                 pixbuf = item_hover_dpixbuf.get_pixbuf()
         else:
             pixbuf = item_normal_dpixbuf.get_pixbuf()
         pixbuf_width += pixbuf.get_width()
         draw_pixbuf(cr, pixbuf, rect.x + self.item_padding_x, rect.y + (rect.height - pixbuf.get_height()) / 2)
         
     # Draw item content.
     draw_text(cr, item_content, 
                 rect.x + self.item_padding_x * 2 + self.icon_width,
                 rect.y,
                 rect.width,
                 rect.height,
                 self.font_size, font_color,
                 )
     
     # Draw submenu arrow.
     if isinstance(item_node, Menu):
         if self.submenu_active or widget.state in [gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE]:
             submenu_pixbuf = ui_theme.get_pixbuf("menu/arrow_hover.png").get_pixbuf()
         else:
             submenu_pixbuf = ui_theme.get_pixbuf("menu/arrow_normal.png").get_pixbuf()
         draw_pixbuf(cr, submenu_pixbuf,
                     rect.x + rect.width - self.item_padding_x - submenu_pixbuf.get_width() - self.arrow_padding_x,
                     rect.y + (rect.height - submenu_pixbuf.get_height()) / 2)
     
     # Propagate expose to children.
     propagate_expose(widget, event)
 
     return True
Ejemplo n.º 6
0
    def __init__(self,
                 items,
                 add_separator=False,
                 font_size=DEFAULT_FONT_SIZE,
                 padding_x=10,
                 padding_y=10,
                 vertical=True,
                 item_hover_pixbuf=ui_theme.get_pixbuf("navigatebar/nav_item_hover.png"),
                 item_press_pixbuf=ui_theme.get_pixbuf("navigatebar/nav_item_press.png"),
                 ):
        '''
        Initialize Navigatebar class.

        @param items: A list of navigate item, item format: (item_icon_dpixbuf, item_content, clicked_callback)
        @param add_separator: Whether add separator between navigatebar and body, default is False.
        @param font_size: Font size, default is DEFAULT_FONT_SIZE.
        @param padding_x: Padding value horizontal.
        @param padding_y: Padding value vertical.
        @param vertical: Draw direction, default is vertical.
        @param item_hover_pixbuf: Item hover dpixbuf.
        @param item_press_pixbuf: Item press dpixbuf.
        '''
        # Init event box.
        EventBox.__init__(self)
        self.nav_index = 0
        self.item_hover_pixbuf = item_hover_pixbuf
        self.item_press_pixbuf = item_press_pixbuf
        self.nav_items = []

        # Init nav box.
        self.nav_box = gtk.VBox()
        self.add(self.nav_box)

        # Init item box.
        self.nav_item_box = gtk.HBox()
        self.nav_box.pack_start(self.nav_item_box, False, False)

        # Add navigate item.
        if items:
            for (index, item) in enumerate(items):
                nav_item = NavItem(item, index, font_size, padding_x, padding_y, vertical,
                                   self.set_index, self.get_index,
                                   self.item_hover_pixbuf,
                                   self.item_press_pixbuf)
                self.nav_items.append(nav_item)
                self.nav_item_box.pack_start(nav_item.item_box, False, False)

        # Add separator.
        if add_separator:
            self.separator = gtk.HBox()
            self.separator.set_size_request(-1, 2)
            self.separator.connect("expose-event", self.expose_nav_separator)
            self.nav_box.pack_start(self.separator, False, False)

        # Show.
        self.show_all()
Ejemplo n.º 7
0
 def __init__(self, width=20, height = 30,
              font_size = 10, font_x_padding=5, font_width=120, font_height = 0,
              font_align=pango.ALIGN_LEFT,
              arrow_x_padding = 10, 
              normal_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right.png"), 
              press_pixbuf = ui_theme.get_pixbuf("treeview/arrow_down.png"),
              normal_hover_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right_hover.png"), 
              press_hover_pixbuf = ui_theme.get_pixbuf("treeview/arrow_down_hover.png")):        
     gtk.DrawingArea.__init__(self)
     self.root = Tree()
     self.tree_list = []
     self.tree_all_node_list = [] # Save all node.
     
     self.tree_id_list = []        
     self.tree_id_num = 0
     self.scan_save_item = None
     
     self.set_can_focus(True)
     # Init DrawingArea event.
     self.add_events(gtk.gdk.ALL_EVENTS_MASK)
     self.connect("button-press-event", self.tree_view_press_event)
     self.connect("motion-notify-event", self.tree_view_motion_event)
     self.connect("expose-event", self.tree_view_expose_event)
     self.connect("key-press-event", self.tree_view_key_press_event)
     self.connect("leave-notify-event", self.tree_view_leave_notify_event)
     self.connect("realize", lambda w: self.grab_focus()) # focus key after realize
     
     self.width = width
     self.height = height
     # Draw icon.
     self.normal_pixbuf = normal_pixbuf
     self.press_pixbuf = press_pixbuf
     self.normal_hover_pixbuf = normal_hover_pixbuf
     self.press_hover_pixbuf = press_hover_pixbuf
     self.arrow_x_padding = arrow_x_padding
     # Draw move background. 
     self.move_height = -1
     self.move_draw_bool = False
     self.move_index_num = None
     # Draw press background.
     self.press_height = -1
     self.press_draw_bool = False
     # Draw font.
     self.font_x_padding = font_x_padding
     self.font_width = font_width
     self.font_height = font_height
     self.font_align = font_align
     self.font_size = font_size
     
     self.highlight_index = None
     
     if not self.font_size:
         self.font_size = self.height/2 - 4
         
     if self.font_size > self.height - 15:    
         self.font_size = self.height - 15
Ejemplo n.º 8
0
 def __init__(self):
     '''Init close button.'''
     gtk.Button.__init__(self)
     self.cache_pixbuf = CachePixbuf()
     draw_button(
         self, 
         self.cache_pixbuf,
         ui_theme.get_pixbuf("button/window_close_normal.png"),
         ui_theme.get_pixbuf("button/window_close_hover.png"),
         ui_theme.get_pixbuf("button/window_close_press.png"))
Ejemplo n.º 9
0
 def __init__(self, dir=HOME_DIR, view_mode=ICONVIEW):
     HPaned.__init__(self)
     self.categorybar = Categorybar([
         (ui_theme.get_pixbuf("filemanager/computer.png"), _("Computer"),
          None),
         (ui_theme.get_pixbuf("filemanager/user-home.png"), _("Home"),
          lambda: self.open_dir(self.HOME_DIR)),
         (ui_theme.get_pixbuf("filemanager/user-desktop.png"), _("Desktop"),
          lambda: self.open_dir(self.HOME_DIR + "Desktop/")),
         (ui_theme.get_pixbuf("filemanager/folder-documents.png"),
          _("Documents"),
          lambda: self.open_dir(self.HOME_DIR + "Documents/")),
         (ui_theme.get_pixbuf("filemanager/folder-download.png"),
          _("Downloads"),
          lambda: self.open_dir(self.HOME_DIR + "Downloads/")),
         (ui_theme.get_pixbuf("filemanager/folder-music.png"), _("Music"),
          lambda: self.open_dir(self.HOME_DIR + "Music/")),
         (ui_theme.get_pixbuf("filemanager/folder-pictures.png"),
          _("Pictures"),
          lambda: self.open_dir(self.HOME_DIR + "Pictures/")),
         (ui_theme.get_pixbuf("filemanager/folder-videos.png"), _("Videos"),
          lambda: self.open_dir(self.HOME_DIR + "Videos/")),
         (ui_theme.get_pixbuf("filemanager/user-trash.png"), _("Trash"),
          lambda: self.open_dir("trash:///"))
     ])
     self.icon_size = 48
     self.iconview = FileIconView()
     self.iconview.add_items(iconview_get_dir_items(dir, self.icon_size))
     self.treeview = TreeView(get_dir_items(dir))
     self.add1(self.categorybar)
     if view_mode == self.ICONVIEW:
         self.add2(self.iconview)
     else:
         self.add2(self.treeview)
Ejemplo n.º 10
0
 def __init__(self,
              dir=HOME_DIR,
              view_mode=ICONVIEW
             ):
     HPaned.__init__(self)
     self.categorybar = Categorybar([
         (ui_theme.get_pixbuf("filemanager/computer.png"), _("Computer"), None),
         (ui_theme.get_pixbuf("filemanager/user-home.png"), _("Home"), lambda : self.open_dir(self.HOME_DIR)),
         (ui_theme.get_pixbuf("filemanager/user-desktop.png"), _("Desktop"), lambda : self.open_dir(self.HOME_DIR + "Desktop/")),
         (ui_theme.get_pixbuf("filemanager/folder-documents.png"), _("Documents"), lambda : self.open_dir(self.HOME_DIR + "Documents/")),
         (ui_theme.get_pixbuf("filemanager/folder-download.png"), _("Downloads"), lambda : self.open_dir(self.HOME_DIR + "Downloads/")),
         (ui_theme.get_pixbuf("filemanager/folder-music.png"), _("Music"), lambda : self.open_dir(self.HOME_DIR + "Music/")),
         (ui_theme.get_pixbuf("filemanager/folder-pictures.png"), _("Pictures"), lambda : self.open_dir(self.HOME_DIR + "Pictures/")),
         (ui_theme.get_pixbuf("filemanager/folder-videos.png"), _("Videos"), lambda : self.open_dir(self.HOME_DIR + "Videos/")),
         (ui_theme.get_pixbuf("filemanager/user-trash.png"), _("Trash"), lambda : self.open_dir("trash:///"))
         ])
     self.icon_size = 48
     self.iconview = FileIconView()
     self.iconview.add_items(iconview_get_dir_items(dir, self.icon_size))
     self.treeview = TreeView(get_dir_items(dir))
     self.add1(self.categorybar)
     if view_mode == self.ICONVIEW:
         self.add2(self.iconview)
     else:
         self.add2(self.treeview)
Ejemplo n.º 11
0
 def init_button(self, status):
     if self.get_orientation() == gtk.ORIENTATION_HORIZONTAL:
         if self.shrink_first:
             self.button_pixbuf = ui_theme.get_pixbuf("paned/paned_left_%s.png" % status).get_pixbuf()
         else:
             self.button_pixbuf = ui_theme.get_pixbuf("paned/paned_right_%s.png" % status).get_pixbuf()
     else:
         if self.shrink_first:
             self.button_pixbuf = ui_theme.get_pixbuf("paned/paned_up_%s.png" % status).get_pixbuf()
         else:
             self.button_pixbuf = ui_theme.get_pixbuf("paned/paned_down_%s.png" % status).get_pixbuf()
Ejemplo n.º 12
0
 def __init__(self, items, droplist_height=None, select_index=0, max_width=None):
     '''Init combo box.'''
     # Init.
     gtk.VBox.__init__(self)
     self.set_can_focus(True)
     self.items = items
     self.droplist_height = droplist_height
     self.select_index = select_index
     self.focus_flag = False
     
     self.droplist = Droplist(self.items, max_width=max_width)
     if self.droplist_height:
         self.droplist.set_size_request(-1, self.droplist_height)
     self.width = self.droplist.get_droplist_width() 
     self.height = 22
     self.label_padding_left = 6
     self.box = gtk.HBox()
     self.dropbutton_width = ui_theme.get_pixbuf("combo/dropbutton_normal.png").get_pixbuf().get_width()
     self.label = Label(self.items[select_index][0], 
                        label_width=self.width - self.dropbutton_width - 1 - self.label_padding_left,
                        enable_select=False,
                        enable_double_click=False)
     self.label.text_color = ui_theme.get_color("menu_font")
     self.dropbutton = DisableButton(
         (ui_theme.get_pixbuf("combo/dropbutton_normal.png"),
          ui_theme.get_pixbuf("combo/dropbutton_hover.png"),
          ui_theme.get_pixbuf("combo/dropbutton_press.png"),
          ui_theme.get_pixbuf("combo/dropbutton_disable.png")),
         )
             
     self.align = gtk.Alignment()
     self.align.set(0.5, 0.5, 0.0, 0.0)
     self.align.set_padding(1, 1, 1 + self.label_padding_left, 1)
     
     self.pack_start(self.align, False, False)
     self.align.add(self.box)
     self.box.pack_start(self.label, False, False)
     self.box.pack_start(self.dropbutton, False, False)
     
     self.align.connect("expose-event", self.expose_combobox_frame)
     self.label.connect("button-press-event", self.click_drop_button)
     self.dropbutton.connect("button-press-event", self.click_drop_button)
     self.droplist.connect("item-selected", self.update_select_content)
     self.droplist.connect("key-release", lambda dl, s, o, i: self.emit("key-release", s, o, i))
     self.connect("key-press-event", self.key_press_combo)
     self.connect("key-release-event", self.key_release_combo)
     self.connect("focus-in-event", self.focus_in_combo)
     self.connect("focus-out-event", self.focus_out_combo)
     
     self.keymap = {
         "Home" : self.select_first_item,
         "End" : self.select_last_item,
         "Up" : self.select_prev_item,
         "Down" : self.select_next_item}
Ejemplo n.º 13
0
 def create_simple_button(self, name, callback=None):
     button = DisableButton(
         (
             ui_theme.get_pixbuf("spin/spin_arrow_%s_normal.png" % name),
             ui_theme.get_pixbuf("spin/spin_arrow_%s_hover.png" % name),
             ui_theme.get_pixbuf("spin/spin_arrow_%s_press.png" % name),
             ui_theme.get_pixbuf("spin/spin_arrow_%s_disable.png" % name),
         )
     )
     if callback:
         button.connect("button-press-event", callback)
         button.connect("button-release-event", self.handle_key_release)
     return button
Ejemplo n.º 14
0
 def create_simple_button(self, name, callback=None):
     '''
     Internal function to create simple button.
     '''
     button = DisableButton(
         (ui_theme.get_pixbuf("spin/spin_arrow_%s_normal.png" % name),
          ui_theme.get_pixbuf("spin/spin_arrow_%s_hover.png" % name),
          ui_theme.get_pixbuf("spin/spin_arrow_%s_press.png" % name),
          ui_theme.get_pixbuf("spin/spin_arrow_%s_disable.png" % name)), )
     if callback:
         button.connect("button-press-event", callback)
         button.connect("button-release-event", self.handle_key_release)
     return button
Ejemplo n.º 15
0
    def draw_handle(self, e):
        '''
        Draw the cusom handle apperance.
        '''
        handle = self.get_handle_window()
        line_width = 1
        cr = handle.cairo_create()
        cr.set_source_rgb(*color_hex_to_cairo(self.handle_color.get_color()))
        (width, height) = handle.get_size()
        if self.get_orientation() == gtk.ORIENTATION_HORIZONTAL:
            if self.shrink_first:
                if self.get_position() != 0:
                    cr.rectangle(0, 0, line_width, height)
                    cr.fill()

                if self.always_show_button or self.show_button:
                    if self.get_position() == 0:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_right_normal.png").get_pixbuf()
                    else:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_left_normal.png").get_pixbuf()
                    draw_pixbuf(cr, pixbuf, 0, (height - self.bheight) / 2)
            else:
                cr.rectangle(width - line_width, 0, line_width, height)
                cr.fill()

                if self.always_show_button or self.show_button:
                    if self.get_position() == 0:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_left_normal.png").get_pixbuf()
                    else:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_right_normal.png").get_pixbuf()
                    draw_pixbuf(cr, pixbuf, 0, (height - self.bheight) / 2)
        else:
            if self.shrink_first:
                cr.rectangle(0, 0, width, line_width)
                cr.fill()

                if self.always_show_button or self.show_button:
                    if self.get_position() == 0:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_down_normal.png").get_pixbuf()
                    else:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_up_normal.png").get_pixbuf()
                    draw_pixbuf(cr, pixbuf, (width - self.bheight) / 2, 0)
            else:
                cr.rectangle(0, height - line_width, width, line_width)
                cr.fill()

                if self.always_show_button or self.show_button:
                    if self.get_position() == 0:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_up_normal.png").get_pixbuf()
                    else:
                        pixbuf = ui_theme.get_pixbuf(
                            "paned/paned_down_normal.png").get_pixbuf()
                    draw_pixbuf(cr, pixbuf, (width - self.bheight) / 2, 0)
Ejemplo n.º 16
0
 def expose_nav_item(self, widget, event):
     '''Expose navigate item.'''
     # Init.
     cr = widget.window.cairo_create()
     rect = widget.allocation
     select_index = self.get_index()
     hover_pixbuf = ui_theme.get_pixbuf("navigatebar/nav_item_hover.png").get_pixbuf()
     press_pixbuf = ui_theme.get_pixbuf("navigatebar/nav_item_press.png").get_pixbuf()
     
     # Draw background.
     if widget.state == gtk.STATE_NORMAL:
         if select_index == self.index:
             select_pixbuf = press_pixbuf
         else:
             select_pixbuf = None
     elif widget.state == gtk.STATE_PRELIGHT:
         if select_index == self.index:
             select_pixbuf = press_pixbuf
         else:
             select_pixbuf = hover_pixbuf
     elif widget.state == gtk.STATE_ACTIVE:
         select_pixbuf = press_pixbuf
         
     if select_pixbuf:
         draw_pixbuf(cr, select_pixbuf, rect.x, rect.y)
     
     # Draw navigate item.
     nav_item_pixbuf = self.icon_dpixbuf.get_pixbuf()
     draw_pixbuf(
         cr, nav_item_pixbuf, 
         rect.x + (rect.width - nav_item_pixbuf.get_width()) / 2,
         rect.y)
     
     # Draw font.
     draw_text(cr, 
               self.content, 
               rect.x, 
               rect.y + nav_item_pixbuf.get_height() - 3, 
               rect.width, 
               rect.height - nav_item_pixbuf.get_height(),
               text_color="#FFFFFF",
               alignment=pango.ALIGN_CENTER,
               gaussian_radious=2, gaussian_color="#000000",
               border_radious=1, border_color="#000000", 
               )
     
     # Propagate expose to children.
     propagate_expose(widget, event)
 
     return True
Ejemplo n.º 17
0
 def init_button(self, status):
     if self.get_orientation() == gtk.ORIENTATION_HORIZONTAL:
         if self.shrink_first:
             self.button_pixbuf = ui_theme.get_pixbuf(
                 "paned/paned_left_%s.png" % status).get_pixbuf()
         else:
             self.button_pixbuf = ui_theme.get_pixbuf(
                 "paned/paned_right_%s.png" % status).get_pixbuf()
     else:
         if self.shrink_first:
             self.button_pixbuf = ui_theme.get_pixbuf(
                 "paned/paned_up_%s.png" % status).get_pixbuf()
         else:
             self.button_pixbuf = ui_theme.get_pixbuf(
                 "paned/paned_down_%s.png" % status).get_pixbuf()
Ejemplo n.º 18
0
 def __init__(self, 
              shrink_first,
              enable_animation=False,
              always_show_button=False,
              enable_drag=False,
              handle_color=ui_theme.get_color("paned_line")
              ):
     '''
     Initialize Paned class.
     '''
     gtk.Paned.__init__(self)
     self.shrink_first = shrink_first
     self.enable_animation = enable_animation
     self.always_show_button = always_show_button
     self.enable_drag = enable_drag
     self.handle_color = handle_color
     self.bheight = ui_theme.get_pixbuf("paned/paned_up_normal.png").get_pixbuf().get_width()
     self.saved_position = -1
     self.handle_size = PANED_HANDLE_SIZE - 1
     self.show_button = False
     self.init_button("normal")
     self.animation_delay = 20 # milliseconds
     self.animation_times = 10
     self.animation_position_frames = []
     self.press_coordinate = None
Ejemplo n.º 19
0
 def render_name(self, cr, rect):
     '''
     Render icon and name of DirItem.
     '''
     # Draw select background.
     if self.is_select:
         draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                      ui_theme.get_shadow_color("listview_select").get_color_info())
     
     # Init.
     expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right.png").get_pixbuf()
     
     # Draw directory icon.
     draw_pixbuf(cr, self.pixbuf, 
                 rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT,
                 rect.y + (rect.height - ICON_SIZE) / 2,
                 )
     
     # Draw directory name.
     draw_text(cr, self.name, 
               rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT + ICON_SIZE + ICON_PADDING_RIGHT,
               rect.y,
               rect.width, rect.height)
     
     # Draw drag line.
     if self.drag_line:
         with cairo_disable_antialias(cr):
             cr.set_line_width(1)
             if self.drag_line_at_bottom:
                 cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
             else:
                 cr.rectangle(rect.x, rect.y, rect.width, 1)
             cr.fill()
Ejemplo n.º 20
0
 def __init__(self,
              shrink_first,
              enable_animation=False,
              always_show_button=False,
              enable_drag=False,
              handle_color=ui_theme.get_color("paned_line")):
     '''
     Initialize Paned class.
     '''
     gtk.Paned.__init__(self)
     self.shrink_first = shrink_first
     self.enable_animation = enable_animation
     self.always_show_button = always_show_button
     self.enable_drag = enable_drag
     self.handle_color = handle_color
     self.bheight = ui_theme.get_pixbuf(
         "paned/paned_up_normal.png").get_pixbuf().get_width()
     self.saved_position = -1
     self.handle_size = PANED_HANDLE_SIZE - 1
     self.show_button = False
     self.init_button("normal")
     self.animation_delay = 20  # milliseconds
     self.animation_times = 10
     self.animation_position_frames = []
     self.press_coordinate = None
Ejemplo n.º 21
0
    def draw_handle(self, e):
        '''
        Draw the cusom handle apperance.
        '''
        handle = self.get_handle_window()
        line_width = 1
        cr = handle.cairo_create()
        cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("paned_line").get_color()))
        (width, height) = handle.get_size()
        if self.get_orientation() == gtk.ORIENTATION_HORIZONTAL:
            if self.shrink_first:
                cr.rectangle(0, 0, line_width, height)
                cr.fill()

                if self.show_button:
                    draw_pixbuf(cr, 
                                ui_theme.get_pixbuf("paned/paned_left_normal.png").get_pixbuf(),
                                0,
                                (height - self.bheight)  / 2)
            else:
                cr.rectangle(width - line_width, 0, line_width, height)
                cr.fill()
                
                if self.show_button:
                    draw_pixbuf(cr, 
                                ui_theme.get_pixbuf("paned/paned_right_normal.png").get_pixbuf(),
                                0,
                                (height - self.bheight)  / 2)
        else:
            if self.shrink_first:
                cr.rectangle(0, 0, width, line_width)
                cr.fill()
                
                if self.show_button:
                    draw_pixbuf(cr, 
                                ui_theme.get_pixbuf("paned/paned_up_normal.png").get_pixbuf(),
                                (width - self.bheight) / 2,
                                0)
            else:
                cr.rectangle(0, height - line_width, width, line_width)
                cr.fill()

                if self.show_button:
                    draw_pixbuf(cr, 
                                ui_theme.get_pixbuf("paned/paned_down_normal.png").get_pixbuf(),
                                (width - self.bheight) / 2,
                                0)
Ejemplo n.º 22
0
 def __init__(self, 
              slider_images=None, 
              pointer_images=None, 
              button_images=None, 
              show_button=True, 
              slide_delay=10000,
              ):
     '''
     Initialize WizardBox class.
     
     @param slider_images: Slider images, default is None.
     @param pointer_images: Pointer images, default is None.
     @param pointer_images: Button images, default is None.
     @param show_button: Set as True to show button.
     @param slide_delay: The time of delay between slider image, default is 10000ms.
     '''
     gtk.EventBox.__init__(self)
     self.set_visible_window(False)
     
     self.add_events(gtk.gdk.BUTTON_PRESS_MASK |
                     gtk.gdk.BUTTON_RELEASE_MASK |
                     gtk.gdk.POINTER_MOTION_MASK |
                     gtk.gdk.ENTER_NOTIFY_MASK |
                     gtk.gdk.LEAVE_NOTIFY_MASK
                     )
     
     self.connect("expose-event", self.on_expose_event)                
     self.connect("motion-notify-event", self.on_motion_notify)
     self.connect("button-press-event", self.on_button_press)
     
     # Init images.
     self.slider_pixbufs = map(gtk.gdk.pixbuf_new_from_file, slider_images)
     self.slider_numuber = len(slider_images)
     self.dot_normal_pixbuf, self.dot_active_pixbuf = map(gtk.gdk.pixbuf_new_from_file, pointer_images)
     self.button_normal_pixbuf, self.button_press_pixbuf = map(gtk.gdk.pixbuf_new_from_file, button_images)
     self.close_dpixbuf = ui_theme.get_pixbuf("button/window_close_normal.png")
     
     self.show_button = show_button
     
     # Init sizes.
     self.init_size()
     self.pointer_coords = {}
     
     # Move animation.
     self.active_index = 0
     self.target_index = None
     
     self.active_alpha = 1.0
     self.target_index = 0.0
     
     self.active_x = 0
     self.target_x = None
     self.slider_y = 0
     self.auto_animation_id = None
     self.auto_animation_timeout = slide_delay  # millisecond.
     self.slider_timeout = 1000 # millisecond.
     self.in_animation = False
     self.motion_index = None
     self.auto_animation()
Ejemplo n.º 23
0
 def __init__(self, preference_name):
     '''
     Initialize ExpandPreferenceItem class.
     '''
     IconTextItem.__init__(
         self,
         preference_name,
         (ui_theme.get_pixbuf("treeview/arrow_right.png"),
          ui_theme.get_pixbuf("treeview/arrow_right_hover.png")),
         (ui_theme.get_pixbuf("treeview/arrow_down.png"),
          ui_theme.get_pixbuf("treeview/arrow_down_hover.png")),
         )
     self.text_size = 10
     self.text_padding = 0
     self.alignment = pango.ALIGN_LEFT
     self.icon_padding = 15
     self.column_offset = 15
     self.height = 37
Ejemplo n.º 24
0
 def __init__(self, preference_name):
     '''
     Initialize ExpandPreferenceItem class.
     '''
     IconTextItem.__init__(
         self, 
         preference_name,
         (ui_theme.get_pixbuf("treeview/arrow_right.png"),
          ui_theme.get_pixbuf("treeview/arrow_right_hover.png")),
         (ui_theme.get_pixbuf("treeview/arrow_down.png"),
          ui_theme.get_pixbuf("treeview/arrow_down_hover.png")),
         )
     self.text_size = 10
     self.text_padding = 0
     self.alignment = pango.ALIGN_LEFT
     self.icon_padding = 15
     self.column_offset = 15
     self.height = 37
Ejemplo n.º 25
0
    def render_name(self, cr, rect):
        '''
        Render icon and name of DirItem.
        '''
        if self.pixbuf == None:
            self.pixbuf = get_file_icon_pixbuf(self.directory_path, ICON_SIZE)

        # Draw select background.
        if self.is_select or self.is_highlight:
            draw_vlinear(cr, rect.x ,rect.y, rect.width, rect.height,
                         ui_theme.get_shadow_color("listview_select").get_color_info())

        # Draw directory arrow icon.
        if self.is_expand:
            expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_down.png").get_pixbuf()
        else:
            expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_right.png").get_pixbuf()
        draw_pixbuf(cr, expand_indicator_pixbuf,
                    rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT,
                    rect.y + (rect.height - expand_indicator_pixbuf.get_height()) / 2,
                    )

        # Draw directory icon.
        draw_pixbuf(cr, self.pixbuf,
                    rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT,
                    rect.y + (rect.height - ICON_SIZE) / 2,
                    )

        # Draw directory name.
        draw_text(cr, self.name,
                  rect.x + COLUMN_OFFSET * self.column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT + ICON_SIZE + ICON_PADDING_RIGHT,
                  rect.y,
                  rect.width, rect.height)

        # Draw drag line.
        if self.drag_line:
            with cairo_disable_antialias(cr):
                cr.set_line_width(1)
                if self.drag_line_at_bottom:
                    cr.rectangle(rect.x, rect.y + rect.height - 1, rect.width, 1)
                else:
                    cr.rectangle(rect.x, rect.y, rect.width, 1)
                cr.fill()
Ejemplo n.º 26
0
    def get_star_pixbufs(self):
        star_paths = ["star_background.png"] * 5

        for index in range(0, self.star_level / 2):
            star_paths[index] = "star_foreground.png"

        if self.star_level % 2 == 1:
            star_paths[self.star_level / 2] = "halfstar_background.png"

        return map(lambda path: ui_theme.get_pixbuf("star/%s" % path).get_pixbuf(), star_paths)
Ejemplo n.º 27
0
    def get_star_pixbufs(self):
        star_paths = ["star_background.png"] * 5

        for index in range(0, self.star_level / 2):
            star_paths[index] = "star_foreground.png"

        if self.star_level % 2 == 1:
            star_paths[self.star_level / 2] = "halfstar_background.png"

        return map(lambda path: ui_theme.get_pixbuf("star/%s" % path).get_pixbuf(), star_paths)
Ejemplo n.º 28
0
    def __init__(self,
                 timezone=0,
                 width=800,
                 height=409,
                 padding_top=0,
                 padding_left=0,
                 ):
        '''
        Initialize TimeZone class.

        @param timezone: Timezone, default is 0.
        @param width: The width of timezone, default is 800 pixels.
        @param height: The height of timezone, default is 409 pixels.
        @param padding_top: The padding value of top, default is 0.
        @param padding_left: The padding value of left, default is 0.
        '''
        gtk.EventBox.__init__(self)

        self.__timezone = timezone + 9

        self.width = width
        self.height = height
        self.set_size_request(self.width, self.height)

        self.padding_top = padding_top
        self.padding_left = padding_left

        self.__const_width = 800
        self.__const_height = 409

        self.cache_bg_pixbuf = CachePixbuf()
        self.bg_pixbuf = ui_theme.get_pixbuf("timezone/bg.png")
        self.cache_timezone_pixbuf = CachePixbuf()
        self.timezone_pixbuf = []
        i = -9
        while i <= 13:
            self.timezone_pixbuf.append(ui_theme.get_pixbuf("timezone/timezone_%d.png" % i))

            i += 1

        self.connect("button-press-event", self.__button_press)
        self.connect("expose-event", self.__expose)
Ejemplo n.º 29
0
def draw_max_button(widget, cache_pixbuf, sub_dir, max_path_prefix, unmax_path_prefix):
    '''Create max button.'''
    # Init request size.
    pixbuf = ui_theme.get_pixbuf("%s/%s_normal.png" % (sub_dir, unmax_path_prefix)).get_pixbuf()
    widget.set_size_request(pixbuf.get_width(), pixbuf.get_height())
    
    # Redraw.
    widget.connect("expose-event", lambda w, e: 
                   expose_max_button(w, e, 
                                     cache_pixbuf,
                                     sub_dir, max_path_prefix, unmax_path_prefix))
Ejemplo n.º 30
0
 def __init__(self, label_text=None, padding_x=8):
     '''Init check button.'''
     ToggleButton.__init__(
         self,
         ui_theme.get_pixbuf("button/check_button_inactive_normal.png"),
         ui_theme.get_pixbuf("button/check_button_active_normal.png"),
         ui_theme.get_pixbuf("button/check_button_inactive_hover.png"),
         ui_theme.get_pixbuf("button/check_button_active_hover.png"),
         ui_theme.get_pixbuf("button/check_button_inactive_press.png"),
         ui_theme.get_pixbuf("button/check_button_active_press.png"),
         ui_theme.get_pixbuf("button/check_button_inactive_disable.png"),
         ui_theme.get_pixbuf("button/check_button_active_disable.png"),
         label_text, padding_x
         )
Ejemplo n.º 31
0
 def top_paned_paint(cr, handle_pos):
     in_pixbuf = ui_theme.get_pixbuf("paned/in.png").get_pixbuf()
     out_pixbuf = ui_theme.get_pixbuf("paned/out.png").get_pixbuf()
     #
     if handle_pos.can_visible:
         # 绘制例子.
         if handle_pos.can_in:
             # 判断要向那个方向的控件靠拢.
             if handle_pos.can_move_child2:
                 pixbuf = in_pixbuf
             else:
                 pixbuf = out_pixbuf
         else:
             # 判断要向那个方向的控件靠拢.
             if handle_pos.can_move_child2:
                 pixbuf = out_pixbuf
             else:
                 pixbuf = in_pixbuf
         # 判断是否为纵向.
         if top_paned.get_type() == gtk.ORIENTATION_VERTICAL:
             pixbuf = pixbuf.rotate_simple(270)
         #
         draw_pixbuf(cr, pixbuf, handle_pos.x, handle_pos.y)
Ejemplo n.º 32
0
 def top_paned_paint(cr, handle_pos):
     in_pixbuf = ui_theme.get_pixbuf("paned/in.png").get_pixbuf()
     out_pixbuf = ui_theme.get_pixbuf("paned/out.png").get_pixbuf()
     #
     if handle_pos.can_visible:
         # 绘制例子.
         if handle_pos.can_in:
             # 判断要向那个方向的控件靠拢.
             if handle_pos.can_move_child2:
                 pixbuf = in_pixbuf
             else:
                 pixbuf = out_pixbuf
         else:
             # 判断要向那个方向的控件靠拢.
             if handle_pos.can_move_child2:
                 pixbuf = out_pixbuf
             else:
                 pixbuf = in_pixbuf
         # 判断是否为纵向.
         if top_paned.get_type() == gtk.ORIENTATION_VERTICAL:
             pixbuf = pixbuf.rotate_simple(270)
         #
         draw_pixbuf(cr, pixbuf, handle_pos.x, handle_pos.y)
Ejemplo n.º 33
0
    def __init__(self, label_text=None, padding_x=8):
        '''Init radio button.'''
        ToggleButton.__init__(
            self,
            ui_theme.get_pixbuf("button/radio_button_inactive_normal.png"),
            ui_theme.get_pixbuf("button/radio_button_active_normal.png"),
            ui_theme.get_pixbuf("button/radio_button_inactive_hover.png"),
            ui_theme.get_pixbuf("button/radio_button_active_hover.png"),
            ui_theme.get_pixbuf("button/radio_button_inactive_press.png"),
            ui_theme.get_pixbuf("button/radio_button_active_press.png"),
            ui_theme.get_pixbuf("button/radio_button_inactive_disable.png"),
            ui_theme.get_pixbuf("button/radio_button_active_disable.png"),
            label_text,
            padding_x
            )

        self.switch_lock = False    
        self.connect("clicked", self.click_radio_button)
Ejemplo n.º 34
0
    def __init__(
        self,
        items,
        foreground_left_pixbuf=ui_theme.get_pixbuf(
            "notebook/foreground_left.png"),
        foreground_middle_pixbuf=ui_theme.get_pixbuf(
            "notebook/foreground_middle.png"),
        foreground_right_pixbuf=ui_theme.get_pixbuf(
            "notebook/foreground_right.png"),
        background_left_pixbuf=ui_theme.get_pixbuf(
            "notebook/background_left.png"),
        background_middle_pixbuf=ui_theme.get_pixbuf(
            "notebook/background_middle.png"),
        background_right_pixbuf=ui_theme.get_pixbuf(
            "notebook/background_right.png"),
    ):
        '''
        Initialize Notebook class.

        @param items: Notebook item, foramt (item_icon, item_content, item_callback).
        @param foreground_left_pixbuf: Left foreground pixbuf.
        @param foreground_middle_pixbuf: Middle foreground pixbuf.
        @param foreground_right_pixbuf: Right foreground pixbuf.
        @param background_left_pixbuf: Left background pixbuf.
        @param background_middle_pixbuf: Middle background pixbuf.
        @param background_right_pixbuf: Right background pixbuf.
        '''
        # Init.
        gtk.EventBox.__init__(self)
        self.set_visible_window(False)
        self.set_can_focus(True)
        self.add_events(gtk.gdk.ALL_EVENTS_MASK)

        self.items = items
        self.current_item_index = 0
        self.padding_side = 27  # pixel
        self.padding_middle = 10  # pixel
        self.foreground_left_pixbuf = foreground_left_pixbuf
        self.foreground_middle_pixbuf = foreground_middle_pixbuf
        self.foreground_right_pixbuf = foreground_right_pixbuf
        self.background_left_pixbuf = background_left_pixbuf
        self.background_middle_pixbuf = background_middle_pixbuf
        self.background_right_pixbuf = background_right_pixbuf
        self.cache_bg_pixbuf = CachePixbuf()
        self.cache_fg_pixbuf = CachePixbuf()

        # Calcuate tab width.
        (self.tab_width, self.tab_height) = self.calculate_tab_width()
        self.set_size_request(-1, self.tab_height)

        # Expose.
        self.connect("expose-event", self.expose_notebook)
        self.connect("button-press-event", self.button_press_notebook)
Ejemplo n.º 35
0
 def __init__(self,
              items,
              foreground_left_pixbuf = ui_theme.get_pixbuf("notebook/foreground_left.png"),
              foreground_middle_pixbuf = ui_theme.get_pixbuf("notebook/foreground_middle.png"),
              foreground_right_pixbuf = ui_theme.get_pixbuf("notebook/foreground_right.png"),
              background_left_pixbuf = ui_theme.get_pixbuf("notebook/background_left.png"),
              background_middle_pixbuf = ui_theme.get_pixbuf("notebook/background_middle.png"),
              background_right_pixbuf = ui_theme.get_pixbuf("notebook/background_right.png"),
              ):
     '''
     Initialize Notebook class.
     
     @param items: Notebook item, foramt (item_icon, item_content, item_callback).
     @param foreground_left_pixbuf: Left foreground pixbuf.
     @param foreground_middle_pixbuf: Middle foreground pixbuf.
     @param foreground_right_pixbuf: Right foreground pixbuf.
     @param background_left_pixbuf: Left background pixbuf.
     @param background_middle_pixbuf: Middle background pixbuf.
     @param background_right_pixbuf: Right background pixbuf.
     '''
     # Init.
     gtk.EventBox.__init__(self)
     self.set_visible_window(False)
     self.set_can_focus(True)
     self.add_events(gtk.gdk.ALL_EVENTS_MASK)
     
     self.items = items
     self.current_item_index = 0
     self.padding_side = 27  # pixel
     self.padding_middle = 10 # pixel
     self.foreground_left_pixbuf = foreground_left_pixbuf
     self.foreground_middle_pixbuf = foreground_middle_pixbuf
     self.foreground_right_pixbuf = foreground_right_pixbuf
     self.background_left_pixbuf = background_left_pixbuf
     self.background_middle_pixbuf = background_middle_pixbuf
     self.background_right_pixbuf = background_right_pixbuf
     self.cache_bg_pixbuf = CachePixbuf()
     self.cache_fg_pixbuf = CachePixbuf()
     
     # Calcuate tab width.
     (self.tab_width, self.tab_height) = self.calculate_tab_width()
     self.set_size_request(-1, self.tab_height)
     
     # Expose.
     self.connect("expose-event", self.expose_notebook)
     self.connect("button-press-event", self.button_press_notebook)
Ejemplo n.º 36
0
    def __init__(self, 
                 width=500, 
                 height=125, 
                 is_24hour=True, 
                 pixbuf_spacing=10,
                 comma_spacing=30, 
                 sec_visible=False):
        '''
        Initialize DateTimeHTCStyle class.
        
        @param width: Width of widget, default is 500 pixels.
        @param height: Height of widget, default is 125 pixels.
        @param is_24hour: Whether use 24 hours format, default is True.
        @param pixbuf_spacing: Spacing around widget pixbuf, default is 10 pixels.
        @param comma_spacing: Spacing around comma, default is 30 pixels.
        @param sec_visible: Whether display second, default is False.
        '''
        gtk.VBox.__init__(self)

        self.width = width
        self.height = height
        self.set_size_request(self.width, self.height)

        self.is_24hour = is_24hour
        self.pixbuf_spacing = pixbuf_spacing
        self.comma_spacing = comma_spacing
        self.sec_visible = sec_visible

        self.time_pixbuf = []
        i = 0
        while i < 10:
            self.time_pixbuf.append(ui_theme.get_pixbuf("datetime/%d.png" % i))

            i += 1

        self.connect("expose-event", self.__expose)
        
        SecondThread(self).start()
Ejemplo n.º 37
0
    def __init__(self,
                 width=500,
                 height=125,
                 is_24hour=True,
                 pixbuf_spacing=10,
                 comma_spacing=30,
                 sec_visible=False):
        '''
        Initialize DateTimeHTCStyle class.

        @param width: Width of widget, default is 500 pixels.
        @param height: Height of widget, default is 125 pixels.
        @param is_24hour: Whether use 24 hours format, default is True.
        @param pixbuf_spacing: Spacing around widget pixbuf, default is 10 pixels.
        @param comma_spacing: Spacing around comma, default is 30 pixels.
        @param sec_visible: Whether display second, default is False.
        '''
        gtk.VBox.__init__(self)

        self.width = width
        self.height = height
        self.set_size_request(self.width, self.height)

        self.is_24hour = is_24hour
        self.pixbuf_spacing = pixbuf_spacing
        self.comma_spacing = comma_spacing
        self.sec_visible = sec_visible

        self.time_pixbuf = []
        i = 0
        while i < 10:
            self.time_pixbuf.append(ui_theme.get_pixbuf("datetime/%d.png" % i))

            i += 1

        self.connect("expose-event", self.__expose)

        SecondThread(self).start()
Ejemplo n.º 38
0
 def __init__(self, element, index, font_size, padding_x, padding_y, set_index, get_index):
     '''Init navigate item.'''
     # Init.
     self.index = index
     self.font_size = font_size
     self.set_index = set_index
     self.get_index = get_index
     (self.icon_dpixbuf, self.content, self.clicked_callback) = element
     pixbuf = ui_theme.get_pixbuf("navigatebar/nav_item_hover.png").get_pixbuf()
     
     # Init item button.
     self.item_button = gtk.Button()
     self.item_button.set_size_request(pixbuf.get_width(), pixbuf.get_height())
     
     widget_fix_cycle_destroy_bug(self.item_button)
     
     self.item_button.connect("expose-event", self.expose_nav_item)
     self.item_button.connect("clicked", lambda w: self.wrap_nav_item_clicked_action())
     
     # Init item box.
     self.item_box = gtk.Alignment()
     self.item_box.set(0.0, 0.0, 0.0, 0.0)
     self.item_box.set_padding(padding_y, padding_y, padding_x, padding_x)
     self.item_box.add(self.item_button)
Ejemplo n.º 39
0
    def __init__(
        self,
        items,
        foreground_left_pixbuf=ui_theme.get_pixbuf("notebook/foreground_left.png"),
        foreground_middle_pixbuf=ui_theme.get_pixbuf("notebook/foreground_middle.png"),
        foreground_right_pixbuf=ui_theme.get_pixbuf("notebook/foreground_right.png"),
        background_left_pixbuf=ui_theme.get_pixbuf("notebook/background_left.png"),
        background_middle_pixbuf=ui_theme.get_pixbuf("notebook/background_middle.png"),
        background_right_pixbuf=ui_theme.get_pixbuf("notebook/background_right.png"),
    ):
        """Init notebook."""
        # Init.
        gtk.EventBox.__init__(self)
        self.set_visible_window(False)
        self.set_can_focus(True)
        self.add_events(gtk.gdk.ALL_EVENTS_MASK)

        self.items = items
        self.current_item_index = 0
        self.padding_side = 27  # pixel
        self.padding_middle = 10  # pixel
        self.foreground_left_pixbuf = foreground_left_pixbuf
        self.foreground_middle_pixbuf = foreground_middle_pixbuf
        self.foreground_right_pixbuf = foreground_right_pixbuf
        self.background_left_pixbuf = background_left_pixbuf
        self.background_middle_pixbuf = background_middle_pixbuf
        self.background_right_pixbuf = background_right_pixbuf
        self.cache_bg_pixbuf = CachePixbuf()
        self.cache_fg_pixbuf = CachePixbuf()

        # Calcuate tab width.
        (self.tab_width, self.tab_height) = self.calculate_tab_width()
        self.set_size_request(-1, self.tab_height)

        # Expose.
        self.connect("expose-event", self.expose_notebook)
        self.connect("button-press-event", self.button_press_notebook)
Ejemplo n.º 40
0
def expose_max_button(widget, event, cache_pixbuf, sub_dir, max_path_prefix, unmax_path_prefix):
    '''Expose function to replace event box's image.'''
    # Get dynamic pixbuf.
    if window_is_max(widget):
        normal_dpixbuf = ui_theme.get_pixbuf("%s/%s_normal.png" % (sub_dir, unmax_path_prefix))
        hover_dpixbuf = ui_theme.get_pixbuf("%s/%s_hover.png" % (sub_dir, unmax_path_prefix))
        press_dpixbuf = ui_theme.get_pixbuf("%s/%s_press.png" % (sub_dir, unmax_path_prefix))
    else:
        normal_dpixbuf = ui_theme.get_pixbuf("%s/%s_normal.png" % (sub_dir, max_path_prefix))
        hover_dpixbuf = ui_theme.get_pixbuf("%s/%s_hover.png" % (sub_dir, max_path_prefix))
        press_dpixbuf = ui_theme.get_pixbuf("%s/%s_press.png" % (sub_dir, max_path_prefix))

    # Get pixbuf along with button's sate.
    if widget.state == gtk.STATE_NORMAL:
        image = normal_dpixbuf.get_pixbuf()
    elif widget.state == gtk.STATE_PRELIGHT:
        image = hover_dpixbuf.get_pixbuf()
    elif widget.state == gtk.STATE_ACTIVE:
        image = press_dpixbuf.get_pixbuf()
    
    # Init size.
    image_width = image.get_width()
    image_height = image.get_height()
    
    # Draw button.
    pixbuf = image
    if pixbuf.get_width() != image_width or pixbuf.get_height() != image_height:
        cache_pixbuf.scale(image, image_width, image_height)
        pixbuf = cache_pixbuf.get_cache()
    cr = widget.window.cairo_create()
    draw_pixbuf(cr, pixbuf, widget.allocation.x, widget.allocation.y)

    # Propagate expose to children.
    propagate_expose(widget, event)
    
    return True
Ejemplo n.º 41
0
        remove_timeout_id(self.test_hide_id)
            
        self.panel.start_show()    
        
    def leave_notify_callback(self):
        '''docs'''
        self.test_hide_id = gtk.timeout_add(5000, self.panel.start_hide)        

if __name__ == "__main__":
    # Init window.
    window = gtk.Window()
    window.set_decorated(False)
    window.add_events(gtk.gdk.ALL_EVENTS_MASK)        
    window.connect("destroy", lambda w: gtk.main_quit())
    window.move(100, 100)
    window.add(gtk.image_new_from_pixbuf(ui_theme.get_pixbuf("background12.png").get_pixbuf()))

    window.show_all()
    
    panel = Panel()
    panel.move(100, 592)
    panel.add(gtk.image_new_from_pixbuf(ui_theme.get_pixbuf("background13.png").get_pixbuf()))
    panel.hide_panel()
    
    test_widget = TestWidget(panel)
    window.connect("motion-notify-event", lambda w, e: test_widget.show_panel())
    panel.connect("enter-notify-event", lambda w, e: test_widget.enter_notify_callback())
    panel.connect("leave-notify-event", lambda w, e: test_widget.leave_notify_callback())
    
    gtk.main()
Ejemplo n.º 42
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("&lt;")
        self.right_btn = Button("&gt;")
        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)
Ejemplo n.º 43
0
def get_name_width(column_index, name):
    expand_indicator_pixbuf = ui_theme.get_pixbuf("treeview/arrow_down.png").get_pixbuf()
    return COLUMN_OFFSET * column_index + INDICATOR_PADDING_LEFT + expand_indicator_pixbuf.get_width() + INDICATOR_PADDING_RIGHT + ICON_PADDING_LEFT + ICON_SIZE + ICON_PADDING_RIGHT + get_content_size(name)[0]
Ejemplo n.º 44
0
    def leave_notify_callback(self):
        '''docs'''
        self.test_hide_id = gtk.timeout_add(5000, self.panel.start_hide)


if __name__ == "__main__":
    # Init window.
    window = gtk.Window()
    window.set_decorated(False)
    window.add_events(gtk.gdk.ALL_EVENTS_MASK)
    window.connect("destroy", lambda w: gtk.main_quit())
    window.move(100, 100)
    window.add(
        gtk.image_new_from_pixbuf(
            ui_theme.get_pixbuf("background12.png").get_pixbuf()))

    window.show_all()

    panel = Panel()
    panel.move(100, 592)
    panel.add(
        gtk.image_new_from_pixbuf(
            ui_theme.get_pixbuf("background13.png").get_pixbuf()))
    panel.hide_panel()

    test_widget = TestWidget(panel)
    window.connect("motion-notify-event",
                   lambda w, e: test_widget.show_panel())
    panel.connect("enter-notify-event",
                  lambda w, e: test_widget.enter_notify_callback())
Ejemplo n.º 45
0
    def __init__(
        self,
        slider_images=None,
        pointer_images=None,
        button_images=None,
        show_button=True,
        slide_delay=10000,
    ):
        '''
        Initialize WizardBox class.

        @param slider_images: Slider images, default is None.
        @param pointer_images: Pointer images, default is None.
        @param pointer_images: Button images, default is None.
        @param show_button: Set as True to show button.
        @param slide_delay: The time of delay between slider image, default is 10000ms.
        '''
        gtk.EventBox.__init__(self)
        self.set_visible_window(False)

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK
                        | gtk.gdk.POINTER_MOTION_MASK
                        | gtk.gdk.ENTER_NOTIFY_MASK
                        | gtk.gdk.LEAVE_NOTIFY_MASK)

        self.connect("expose-event", self.on_expose_event)
        self.connect("motion-notify-event", self.on_motion_notify)
        self.connect("button-press-event", self.on_button_press)

        # Init images.
        self.slider_pixbufs = map(gtk.gdk.pixbuf_new_from_file, slider_images)
        self.slider_numuber = len(slider_images)
        self.dot_normal_pixbuf, self.dot_active_pixbuf = map(
            gtk.gdk.pixbuf_new_from_file, pointer_images)
        self.button_normal_pixbuf, self.button_press_pixbuf = map(
            gtk.gdk.pixbuf_new_from_file, button_images)
        self.close_dpixbuf = ui_theme.get_pixbuf(
            "button/window_close_normal.png")

        self.show_button = show_button

        # Init sizes.
        self.init_size()
        self.pointer_coords = {}

        # Move animation.
        self.active_index = 0
        self.target_index = None

        self.active_alpha = 1.0
        self.target_index = 0.0

        self.active_x = 0
        self.target_x = None
        self.slider_y = 0
        self.auto_animation_id = None
        self.auto_animation_timeout = slide_delay  # millisecond.
        self.slider_timeout = 1000  # millisecond.
        self.in_animation = False
        self.motion_index = None
        self.auto_animation()
Ejemplo n.º 46
0
    def expose_button(self, widget, event):
        '''
        Internal function to handle `expose-event` signal.

        @param widget: ColorButton instance.
        @param event: Expose event.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        x, y, w, h = rect.x, rect.y, rect.width, rect.height

        # Get color info.
        if widget.state == gtk.STATE_NORMAL:
            border_color = ui_theme.get_color(
                "button_border_normal").get_color()
            background_color = ui_theme.get_shadow_color(
                "button_background_normal").get_color_info()
        elif widget.state == gtk.STATE_PRELIGHT:
            border_color = ui_theme.get_color(
                "button_border_prelight").get_color()
            background_color = ui_theme.get_shadow_color(
                "button_background_prelight").get_color_info()
        elif widget.state == gtk.STATE_ACTIVE:
            border_color = ui_theme.get_color(
                "button_border_active").get_color()
            background_color = ui_theme.get_shadow_color(
                "button_background_active").get_color_info()
        elif widget.state == gtk.STATE_INSENSITIVE:
            border_color = ui_theme.get_color("disable_frame").get_color()
            disable_background_color = ui_theme.get_color(
                "disable_background").get_color()
            background_color = [(0, (disable_background_color, 1.0)),
                                (1, (disable_background_color, 1.0))]

        # Draw background.
        draw_vlinear(cr, x + 1, y + 1, w - 2, h - 2, background_color)

        # Draw border.
        cr.set_source_rgb(*color_hex_to_cairo(border_color))
        draw_line(cr, x + 2, y + 1, x + w - 2, y + 1)  # top
        draw_line(cr, x + 2, y + h, x + w - 2, y + h)  # bottom
        draw_line(cr, x + 1, y + 2, x + 1, y + h - 2)  # left
        draw_line(cr, x + w, y + 2, x + w, y + h - 2)  # right

        # Draw four point.
        if widget.state == gtk.STATE_INSENSITIVE:
            top_left_point = ui_theme.get_pixbuf(
                "button/disable_corner.png").get_pixbuf()
        else:
            top_left_point = ui_theme.get_pixbuf(
                "button/corner.png").get_pixbuf()
        top_right_point = top_left_point.rotate_simple(270)
        bottom_right_point = top_left_point.rotate_simple(180)
        bottom_left_point = top_left_point.rotate_simple(90)

        draw_pixbuf(cr, top_left_point, x, y)
        draw_pixbuf(cr, top_right_point, x + w - top_left_point.get_width(), y)
        draw_pixbuf(cr, bottom_left_point, x,
                    y + h - top_left_point.get_height())
        draw_pixbuf(cr, bottom_right_point, x + w - top_left_point.get_width(),
                    y + h - top_left_point.get_height())

        # Draw color frame.
        cr.set_source_rgb(*color_hex_to_cairo("#c0c0c0"))
        cr.rectangle(x + (w - self.color_area_width) / 2,
                     y + (h - self.color_area_height) / 2,
                     self.color_area_width, self.color_area_height)
        cr.stroke()

        # Draw color.
        cr.set_source_rgb(*color_hex_to_cairo(self.color))
        cr.rectangle(x + (w - self.color_area_width) / 2,
                     y + (h - self.color_area_height) / 2,
                     self.color_area_width, self.color_area_height)
        cr.fill()

        # Draw mask when widget is insensitive.
        if widget.state == gtk.STATE_INSENSITIVE:
            cr.set_source_rgba(*alpha_color_hex_to_cairo(
                ui_theme.get_alpha_color(
                    "color_button_disable_mask").get_color_info()))
            cr.rectangle(x + (w - self.color_area_width) / 2,
                         y + (h - self.color_area_height) / 2,
                         self.color_area_width, self.color_area_height)
            cr.fill()

        return True
Ejemplo n.º 47
0
    def __init__(
        self,
        volume_max_value=100,
        volume_width=52,
        volume_x=0,
        volume_y=15,
        line_height=3,
        volume_padding_x=5,
        volume_level_values=[(1, 33), (34, 66), (67, 100)],
        scroll_bool=False,
        press_emit_bool=False,
        inc_value=5,
        bg_pixbuf=ui_theme.get_pixbuf("volumebutton/bg.png"),
        fg_pixbuf=ui_theme.get_pixbuf("volumebutton/fg.png"),
        zero_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/zero_normal.png"),
        zero_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/zero_hover.png"),
        zero_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/zero_press.png"),
        min_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/lower_normal.png"),
        min_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/lower_hover.png"),
        min_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/lower_press.png"),
        mid_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/middle_normal.png"),
        mid_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/middle_hover.png"),
        mid_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/middle_press.png"),
        max_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/high_normal.png"),
        max_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/high_hover.png"),
        max_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/high_press.png"),
        mute_volume_normal_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/mute_normal.png"),
        mute_volume_hover_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/mute_hover.png"),
        mute_volume_press_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/mute_press.png"),
        point_volume_pixbuf=ui_theme.get_pixbuf(
            "volumebutton/point_normal.png"),
    ):
        '''
        Initialize VolumeButton class.

        @param volume_max_value: Maximum value of volume, default is 100.
        @param volume_width: Width of volume button widget, default is 52 pixel.
        @param volume_x: X padding of volume button widget.
        @param volume_y: Y padding of volume button widget.
        @param line_height: Height of volume progressbar, default is 3 pixel.
        @param volume_padding_x: X padding value around volume progressbar.
        @param volume_level_values: The values of volume level.
        @param scroll_bool: True allowed scroll to change value, default is False.
        @param press_emit_bool: True to emit `volume-state-changed` signal when press, default is False.
        @param inc_value: The increase value of volume change, default is 5.
        '''
        gtk.Button.__init__(self)
        ###########################
        if volume_x < max_volume_normal_pixbuf.get_pixbuf().get_width():
            volume_x = max_volume_normal_pixbuf.get_pixbuf().get_width()
        '''Init pixbuf.'''
        self.__bg_pixbuf = bg_pixbuf
        self.__fg_pixbuf = fg_pixbuf
        self.__bg_cache_pixbuf = CachePixbuf()
        self.__fg_cache_pixbuf = CachePixbuf()
        # zero volume pixbuf.
        self.__zero_volume_normal_pixbuf = zero_volume_normal_pixbuf
        self.__zero_volume_hover_pixbuf = zero_volume_hover_pixbuf
        self.__zero_volume_press_pixbuf = zero_volume_press_pixbuf
        # min volume pixbuf.
        self.__min_volume_normal_pixbuf = min_volume_normal_pixbuf
        self.__min_volume_hover_pixbuf = min_volume_hover_pixbuf
        self.__min_volume_press_pixbuf = min_volume_press_pixbuf
        # mid volume pixbuf:
        self.__mid_volume_normal_pixbuf = mid_volume_normal_pixbuf
        self.__mid_volume_hover_pixbuf = mid_volume_hover_pixbuf
        self.__mid_volume_press_pixbuf = mid_volume_press_pixbuf
        # max volume pixbuf[normal, hover, press].
        self.__max_volume_normal_pixbuf = max_volume_normal_pixbuf
        self.__max_volume_hover_pixbuf = max_volume_hover_pixbuf
        self.__max_volume_press_pixbuf = max_volume_press_pixbuf
        # mute volume pixbuf[normal, hover, press].
        self.__mute_volume_normal_pixbuf = mute_volume_normal_pixbuf
        self.__mute_volume_hover_pixbuf = mute_volume_hover_pixbuf
        self.__mute_volume_press_pixbuf = mute_volume_press_pixbuf
        # point volume pixbuf.
        self.__point_volume_pixbuf = point_volume_pixbuf
        '''Init Set VolumeButton attr.'''
        '''Init value.'''
        self.__press_emit_bool = press_emit_bool
        self.__line_height = line_height
        self.__current_value = 0
        self.__mute_bool = False
        self.temp_mute_bool = False
        self.__drag = False
        self.__volume_max_value = volume_max_value
        self.__volume_width = volume_width

        self.__volume_left_x = volume_x - self.__max_volume_normal_pixbuf.get_pixbuf(
        ).get_width() - volume_padding_x
        self.__volume_left_y = volume_y - self.__max_volume_normal_pixbuf.get_pixbuf(
        ).get_height() / 2 + self.__point_volume_pixbuf.get_pixbuf(
        ).get_height() / 2
        self.__volume_right_x = volume_x
        self.__volume_right_y = volume_y
        '''Left'''
        self.volume_level_values = volume_level_values
        self.__volume_state = MIN_STATE
        self.__mouse_state = MOUSE_VOLUME_STATE_NORMAL
        '''Right'''
        # bg value.
        self.__bg_x = 0
        self.__bg_y = self.__volume_right_y
        self.__bg_padding_x = self.__volume_right_x
        # fg value.
        self.__fg_x = 0
        self.__fg_y = self.__volume_right_y
        self.__fg_padding_x = self.__volume_right_x
        # point value.
        self.__point_y = self.__volume_right_y
        self.__point_padding_x = self.__volume_right_x
        self.inc_value = inc_value
        '''Init VolumeButton event.'''
        self.add_events(gtk.gdk.ALL_EVENTS_MASK)
        self.connect("expose-event", self.__expose_draw_volume)
        self.connect("motion-notify-event", self.__motion_mouse_set_point)
        self.connect("button-press-event", self.__press_mouse_set_point)
        self.connect("button-release-event", self.__release_mouse_set_point)
        '''Event value'''
        self.press_bool = False
        # scroll event.
        if scroll_bool:
            self.connect("scroll-event", self.__scroll_mouse_set_point)

        self.set_size_request(
            volume_width + self.__volume_left_x + self.__volume_right_x +
            self.__mute_volume_normal_pixbuf.get_pixbuf().get_width(), 30)

        set_clickable_cursor(self)
Ejemplo n.º 48
0
    def __init__(
        self,
        items=[],
        droplist_height=None,
        select_index=0,
        max_width=None,
        fixed_width=None,
        min_width=120,
        min_height=100,
        editable=False,
    ):
        '''
        Initialize ComboBox class.

        @param items: Init item list, default is empty list.
        @param droplist_height: The height of droplist, default is None that droplist's height will calculate with items' height automatically.
        @param select_index: Init index of selected item, default is 0.
        @param max_width: Maximum width of combobox, default is None.
        @param fixed_width: Fixed width of combobox, after you set this value combobox won't care the width of droplist and items, default is None.
        @param min_width: Minimum width of combobox, default is 120 pixels.
        @param min_height: Minimum height of combobox, default is 100 pixels.
        @param editable: Set True to make combobox can edit, default is False.
        '''
        gtk.VBox.__init__(self)
        self.set_can_focus(True)

        # Init variables.
        self.focus_flag = False
        self.select_index = select_index
        self.editable = editable
        if self.editable:
            self.padding_x = 0
        else:
            self.padding_x = 5

        self.combo_list = ComboList(min_width=min_width,
                                    max_width=max_width,
                                    fixed_width=fixed_width,
                                    min_height=min_height,
                                    max_height=droplist_height)

        self.drop_button = DisableButton(
            (ui_theme.get_pixbuf("combo/dropbutton_normal.png"),
             ui_theme.get_pixbuf("combo/dropbutton_hover.png"),
             ui_theme.get_pixbuf("combo/dropbutton_press.png"),
             ui_theme.get_pixbuf("combo/dropbutton_disable.png")), )
        self.drop_button_width = ui_theme.get_pixbuf(
            "combo/dropbutton_normal.png").get_pixbuf().get_width()
        self.panel_align = gtk.Alignment()
        self.panel_align.set(0.5, 0.5, 0.0, 0.0)

        if self.editable:
            self.label = Entry()
        else:
            self.label = Label("",
                               enable_select=False,
                               enable_double_click=False)

            self.label.connect("button-press-event", self.on_drop_button_press)
            self.panel_align.set_padding(0, 0, self.padding_x, 0)

        self.panel_align.add(self.label)

        # Init items.
        self.add_items(items)

        # set selected index
        if len(items) > 0:
            self.set_select_index(select_index)

        hbox = gtk.HBox()
        hbox.pack_start(self.panel_align, True, False)
        hbox.pack_start(self.drop_button, False, False)
        box_align = gtk.Alignment()
        box_align.set(0.5, 0.5, 0.0, 0.0)
        box_align.add(hbox)
        self.add(box_align)

        # Connect signals.
        box_align.connect("expose-event", self.on_expose_combo_frame)
        self.drop_button.connect("button-press-event",
                                 self.on_drop_button_press)
        self.connect("focus-in-event", self.on_focus_in_combo)
        self.connect("focus-out-event", self.on_focus_out_combo)
        self.combo_list.treeview.connect("button-press-item",
                                         self.on_combo_single_click)
Ejemplo n.º 49
0
    def __init__(self,
                 point_dpixbuf=ui_theme.get_pixbuf("hscalebar/point.png"),
                 show_value=False,
                 show_value_type=gtk.POS_TOP,
                 show_point_num=0,
                 format_value="",
                 value_min = 0,
                 value_max = 100,
                 line_height=6,
                 gray_progress=False
                 ):
        '''
        @param point_dpixbuf: a DynamicPixbuf object.
        @param show_value: If True draw the current value next to the slider.
        @param show_value_type: The position where the current value is displayed. gtk.POS_TOP or gtk.POS_BOTTOM.
        @param show_point_num: The accuracy of the value. If 0 value is int type.
        @param format_value: A string that displayed after the value.
        @param value_min: The min value, default is 0.
        @param value_max: The max value, default is 100.
        @param line_height: The line height, default is 6 pixels.
        @param gray_progress: If True the HScalebar looks gray, default is False.
        '''
        gtk.Button.__init__(self)
        self.position_list = []
        self.mark_check = False
        self.enable_check = True
        self.new_mark_x = 0
        self.next_mark_x = 0
        self.value = 0
        self.show_value_type = show_value_type
        self.show_point_num = show_point_num
        self.value_max = value_max - value_min
        self.value_min = value_min
        self.drag = False
        self.gray_progress = gray_progress
        self.magnetic_values = []

        # Init color.
        self.fg_side_color = "#0071B3"
        self.bg_side_color = "#B3B3B3"
        self.fg_inner_color = "#30ABEE"
        self.bg_inner1_color = "#CCCCCC"
        self.bg_inner2_color = "#E6E6E6"
        self.fg_corner_color = "#2E84B7"
        self.bg_corner_color = "#C1C5C6"

        self.point_pixbuf = point_dpixbuf
        self.line_height = line_height
        self.line_width = 1.0
        self.progress_border = 1
        self.mark_height = 6
        self.mark_width = 1
        self.bottom_space = 2 # vertical space between bottom mark line and drag point
        self.format_value = format_value
        self.show_value = show_value

        self.point_width = self.point_pixbuf.get_pixbuf().get_width()
        self.point_height = self.point_pixbuf.get_pixbuf().get_height()
        self.text_height_factor = 2
        self.set_size_request(-1, self.point_height + get_content_size("0")[1] * self.text_height_factor + self.bottom_space)

        self.add_events(gtk.gdk.ALL_EVENTS_MASK)
        self.connect("expose-event", self.__progressbar_expose_event)
        self.connect("button-press-event", self.__progressbar_press_event)
        self.connect("button-release-event", self.__progressbar_release_event)
        self.connect("motion-notify-event", self.__progressbar_motion_notify_event)
        self.connect("scroll-event", self.__progressbar_scroll_event)
Ejemplo n.º 50
0
 def __init__(self,
              volume_max_value = 100,
              volume_width = 52,
              volume_x = 0,
              volume_y = 15,
              line_height = 3,
              volume_padding_x = 5,
              volume_level_values = [(1, 33),(34, 66),(67, 100)],
              scroll_bool = False,
              press_emit_bool = False,
              inc_value=5,
              bg_pixbuf = ui_theme.get_pixbuf("volumebutton/bg.png"),
              fg_pixbuf = ui_theme.get_pixbuf("volumebutton/fg.png"),
              zero_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_normal.png"),
              zero_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_hover.png"),
              zero_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/zero_press.png"),
              min_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/lower_normal.png"),
              min_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/lower_hover.png"),
              min_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/lower_press.png"),
              mid_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/middle_normal.png"),
              mid_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/middle_hover.png"),
              mid_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/middle_press.png"),
              max_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/high_normal.png"),
              max_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/high_hover.png"),
              max_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/high_press.png"),
              mute_volume_normal_pixbuf = ui_theme.get_pixbuf("volumebutton/mute_normal.png"),
              mute_volume_hover_pixbuf = ui_theme.get_pixbuf("volumebutton/mute_hover.png"),
              mute_volume_press_pixbuf = ui_theme.get_pixbuf("volumebutton/mute_press.png"),
              point_volume_pixbuf = ui_theme.get_pixbuf("volumebutton/point_normal.png"),
              ):        
     '''
     Initialize VolumeButton class.
     
     @param volume_max_value: Maximum value of volume, default is 100.
     @param volume_width: Width of volume button widget, default is 52 pixel.
     @param volume_x: X padding of volume button widget.
     @param volume_y: Y padding of volume button widget.
     @param line_height: Height of volume progressbar, default is 3 pixel.
     @param volume_padding_x: X padding value around volume progressbar.
     @param volume_level_values: The values of volume level.
     @param scroll_bool: True allowed scroll to change value, default is False.
     @param press_emit_bool: True to emit `volume-state-changed` signal when press, default is False.
     @param inc_value: The increase value of volume change, default is 5.
     '''
     gtk.Button.__init__(self)
     ###########################
     if volume_x < max_volume_normal_pixbuf.get_pixbuf().get_width():
         volume_x = max_volume_normal_pixbuf.get_pixbuf().get_width()
     '''Init pixbuf.'''
     self.__bg_pixbuf = bg_pixbuf
     self.__fg_pixbuf = fg_pixbuf
     self.__bg_cache_pixbuf = CachePixbuf()
     self.__fg_cache_pixbuf = CachePixbuf()
     # zero volume pixbuf.
     self.__zero_volume_normal_pixbuf  = zero_volume_normal_pixbuf
     self.__zero_volume_hover_pixbuf   = zero_volume_hover_pixbuf
     self.__zero_volume_press_pixbuf   = zero_volume_press_pixbuf
     # min volume pixbuf.
     self.__min_volume_normal_pixbuf  = min_volume_normal_pixbuf
     self.__min_volume_hover_pixbuf   = min_volume_hover_pixbuf
     self.__min_volume_press_pixbuf   = min_volume_press_pixbuf
     # mid volume pixbuf:        
     self.__mid_volume_normal_pixbuf     = mid_volume_normal_pixbuf
     self.__mid_volume_hover_pixbuf      = mid_volume_hover_pixbuf
     self.__mid_volume_press_pixbuf        = mid_volume_press_pixbuf
     # max volume pixbuf[normal, hover, press].        
     self.__max_volume_normal_pixbuf  = max_volume_normal_pixbuf
     self.__max_volume_hover_pixbuf   = max_volume_hover_pixbuf
     self.__max_volume_press_pixbuf   = max_volume_press_pixbuf
     # mute volume pixbuf[normal, hover, press].
     self.__mute_volume_normal_pixbuf    = mute_volume_normal_pixbuf
     self.__mute_volume_hover_pixbuf     = mute_volume_hover_pixbuf 
     self.__mute_volume_press_pixbuf     = mute_volume_press_pixbuf
     # point volume pixbuf.
     self.__point_volume_pixbuf    = point_volume_pixbuf        
     '''Init Set VolumeButton attr.'''
     '''Init value.'''
     self.__press_emit_bool  = press_emit_bool
     self.__line_height       = line_height
     self.__current_value    = 0
     self.__mute_bool        = False
     self.temp_mute_bool     = False
     self.__drag             = False 
     self.__volume_max_value = volume_max_value
     self.__volume_width     = volume_width
     
     self.__volume_left_x    = volume_x - self.__max_volume_normal_pixbuf.get_pixbuf().get_width() - volume_padding_x
     self.__volume_left_y    = volume_y - self.__max_volume_normal_pixbuf.get_pixbuf().get_height()/2 + self.__point_volume_pixbuf.get_pixbuf().get_height()/2
     self.__volume_right_x   = volume_x
     self.__volume_right_y   = volume_y
     '''Left'''
     self.volume_level_values = volume_level_values
     self.__volume_state = MIN_STATE
     self.__mouse_state  = MOUSE_VOLUME_STATE_NORMAL
     '''Right'''
     # bg value.
     self.__bg_x         = 0
     self.__bg_y         = self.__volume_right_y
     self.__bg_padding_x = self.__volume_right_x
     # fg value.
     self.__fg_x         = 0
     self.__fg_y         = self.__volume_right_y
     self.__fg_padding_x = self.__volume_right_x
     # point value.
     self.__point_y         = self.__volume_right_y
     self.__point_padding_x = self.__volume_right_x
     self.inc_value = inc_value
     
     '''Init VolumeButton event.'''
     self.add_events(gtk.gdk.ALL_EVENTS_MASK)
     self.connect("expose-event",         self.__expose_draw_volume)
     self.connect("motion-notify-event",  self.__motion_mouse_set_point)
     self.connect("button-press-event",   self.__press_mouse_set_point)
     self.connect("button-release-event", self.__release_mouse_set_point)
     '''Event value'''
     self.press_bool = False
     # scroll event.
     if scroll_bool:
         self.connect("scroll-event",     self.__scroll_mouse_set_point)
         
     self.set_size_request(volume_width + self.__volume_left_x + self.__volume_right_x + self.__mute_volume_normal_pixbuf.get_pixbuf().get_width(), 30)
     
     set_clickable_cursor(self)
Ejemplo n.º 51
0
    def __init__(self,
                 images,
                 pointer_offset_x=-130,
                 pointer_offset_y=-20,
                 pointer_padding=20,
                 hover_animation_time=500,
                 auto_animation_time=2000,
                 auto_slide_timeout=5000,
                 horizontal_align=ALIGN_START,
                 vertical_align=ALIGN_START,
                 height_offset=0,
                 hover_switch=True,
                 auto_switch=True,
                 navigate_switch=False,
                 active_dpixbuf=ui_theme.get_pixbuf("slide_switcher/active.png"),
                 inactive_dpixbuf=ui_theme.get_pixbuf("slide_switcher/inactive.png"),
                 ):
        '''
        Initialize SlideSwitcher class.

        @param images: The image list of sliders.
        @param pointer_offset_x: The offset x of pointer relative to right edge of slider image, default is -130 pixels.
        @param pointer_offset_y: The offset y of pointer relative to bottom edge of slider image, default is -20 pixels.
        @param pointer_padding: The padding between pointers, default is 20 pixels.
        @param hover_animation_time: The animation time of hover operation, default is 500 milliseconds.
        @param auto_animation_time: The animation time of automatic play, default is 2000 milliseconds.
        @param auto_slide_timeout: The slide timeout of automatic play, default is 2000 milliseconds.
        @param horizontal_align: The horizontal alignment, default is ALIGN_START.
        @param vertical_align: The vertical alignment, default is ALIGN_START.
        @param height_offset: The height offset, default is 0 pixels.
        @param hover_switch: Set as True to make slider switch when hover operation active.
        @param auto_switch: Set as True to make slider play automatically.
        @param navigate_switch: Set as True to make slider switch navigate.
        @param active_dpixbuf: The dynamic pixbuf of active status.
        @param inactive_dpixbuf: The dynamic pixbuf of inactive status.
        '''
        EventBox.__init__(self)
        self.add_events(gtk.gdk.ALL_EVENTS_MASK)
        self.slide_images = images
        self.image_number = len(self.slide_images)
        self.active_index = 0
        self.motion_index = None
        self.target_index = None
        self.active_alpha = 1.0
        self.target_alpha = 0.0
        self.in_animiation = False
        self.hover_animation_time = hover_animation_time # animiation time of hover, in milliseconds
        self.auto_animation_time = auto_animation_time # animiation time automatically, in milliseconds
        self.auto_slide_timeout = auto_slide_timeout # slide timeout, in milliseconds
        self.auto_slide_timeout_id = None
        self.horizontal_align = horizontal_align
        self.vertical_align = vertical_align
        self.hover_switch = hover_switch
        self.auto_switch = auto_switch
        self.navigate_switch = navigate_switch
        self.in_right_nav = False
        self.in_left_nav = False
        self.active_dpixbuf = active_dpixbuf
        self.inactive_dpixbuf = inactive_dpixbuf
        size_pixbuf = self.slide_images[0]

        self.pointer_offset_x = pointer_offset_x
        self.pointer_offset_y = pointer_offset_y
        self.pointer_radious = self.active_dpixbuf.get_pixbuf().get_width() / 2
        self.pointer_padding = pointer_padding
        self.set_size_request(-1, size_pixbuf.get_height() + height_offset)

        self.connect("expose-event", self.expose_slide_switcher)
        self.connect("motion-notify-event", self.motion_notify_slide_switcher)
        self.connect("leave-notify-event", self.leave_notify_slide_switcher)
        self.connect("enter-notify-event", self.enter_notify_slide_switcher)
        self.connect("button-press-event", lambda w, e: self.handle_animation(w, e, True))

        self.start_auto_slide()
Ejemplo n.º 52
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("&lt;")
        self.right_btn = Button("&gt;")
        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)
Ejemplo n.º 53
0
    def expose_menu_item(self, widget, event):
        '''
        Internal callback for `expose` signal.
        '''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        font_color = ui_theme.get_color("menu_font").get_color()
        (item_icons, item_content, item_node) = self.item[0:3]

        # Draw select effect.
        if widget.state == gtk.STATE_INSENSITIVE:
            # Set font color.
            font_color = ui_theme.get_color("menu_disable_font").get_color()
        elif self.submenu_active or widget.state in [
                gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
        ]:
            # Draw background.
            if self.menu_item_select_color:
                item_select_color = self.menu_item_select_color
            else:
                item_select_color = ui_theme.get_shadow_color(
                    "menu_item_select").get_color_info()
            draw_vlinear(cr, rect.x, rect.y, rect.width, rect.height,
                         item_select_color, MENU_ITEM_RADIUS)

            # Set font color.
            font_color = ui_theme.get_color("menu_select_font").get_color()

        # Draw item icon.
        pixbuf = None
        pixbuf_width = 0
        if item_icons:
            (item_normal_dpixbuf, item_hover_dpixbuf,
             item_disable_dpixbuf) = item_icons
            if widget.state == gtk.STATE_INSENSITIVE:
                pixbuf = item_disable_dpixbuf.get_pixbuf()
            elif self.submenu_active or widget.state in [
                    gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
            ]:
                if item_hover_dpixbuf == None:
                    pixbuf = item_normal_dpixbuf.get_pixbuf()
                else:
                    pixbuf = item_hover_dpixbuf.get_pixbuf()
            else:
                pixbuf = item_normal_dpixbuf.get_pixbuf()
            pixbuf_width += pixbuf.get_width()
            draw_pixbuf(cr, pixbuf, rect.x + self.item_padding_x,
                        rect.y + (rect.height - pixbuf.get_height()) / 2)

        # Draw item content.
        draw_text(
            cr,
            item_content,
            rect.x + self.item_padding_x * 2 + self.icon_width,
            rect.y,
            rect.width,
            rect.height,
            self.font_size,
            font_color,
        )

        # Draw submenu arrow.
        if isinstance(item_node, Menu):
            if widget.state == gtk.STATE_INSENSITIVE:
                submenu_pixbuf = ui_theme.get_pixbuf(
                    "menu/arrow_disable.png").get_pixbuf()
            elif self.submenu_active or widget.state in [
                    gtk.STATE_PRELIGHT, gtk.STATE_ACTIVE
            ]:
                submenu_pixbuf = ui_theme.get_pixbuf(
                    "menu/arrow_hover.png").get_pixbuf()
            else:
                submenu_pixbuf = ui_theme.get_pixbuf(
                    "menu/arrow_normal.png").get_pixbuf()
            draw_pixbuf(
                cr, submenu_pixbuf, rect.x + rect.width - self.item_padding_x -
                submenu_pixbuf.get_width() - self.arrow_padding_x,
                rect.y + (rect.height - submenu_pixbuf.get_height()) / 2)

        # Propagate expose to children.
        propagate_expose(widget, event)

        return True