コード例 #1
0
ファイル: mini.py プロジェクト: smallevilbeast/deepin-music
 def draw_control(self, cr, allocation, alpha):
     rect = gtk.gdk.Rectangle(allocation.x, allocation.y, allocation.width, allocation.height)
     cr.push_group()
     
     # Draw lyrics button
     rect.x += self.lyrics_padding_left
     enable_lyrics = config.getboolean('lyrics', 'status')
     if enable_lyrics:
         lyrics_pixbuf = app_theme.get_pixbuf('mini/lyrics_active_normal.png').get_pixbuf()
     else:
         lyrics_pixbuf = app_theme.get_pixbuf('mini/lyrics_inactive_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - lyrics_pixbuf.get_height()) / 2
     draw_pixbuf(cr, lyrics_pixbuf, rect.x, icon_y)
     
     # Draw previous button.
     rect.x += lyrics_pixbuf.get_width() + self.lyrics_padding_right
     previous_pixbuf = app_theme.get_pixbuf('mini/previous_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - previous_pixbuf.get_height()) / 2
     draw_pixbuf(cr, previous_pixbuf, rect.x, icon_y)
     
     # Draw playpause button.
     rect.x += previous_pixbuf.get_width()
     is_played = config.getboolean('player', 'play')
     if is_played:
         playpause_pixbuf = app_theme.get_pixbuf('mini/pause_normal.png').get_pixbuf()
     else:
         playpause_pixbuf = app_theme.get_pixbuf('mini/play_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - playpause_pixbuf.get_height()) / 2
     draw_pixbuf(cr, playpause_pixbuf, rect.x, icon_y)
     
     # Draw next button.
     rect.x += playpause_pixbuf.get_width()
     next_pixbuf = app_theme.get_pixbuf('mini/next_normal.png').get_pixbuf()
     icon_y = rect.y + (rect.height - next_pixbuf.get_height()) / 2
     draw_pixbuf(cr, next_pixbuf, rect.x, icon_y)
     
     # Draw volume button.
     (v_w, v_h,) = self.volume_slider.volume_button.get_size()
     v_y = rect.y + (rect.height - v_h) / 2
     rect.x += self.volume_padding_left + next_pixbuf.get_width()
     volume_button_rect = gtk.gdk.Rectangle(rect.x, v_y, v_w, v_h)
     self.volume_slider.volume_button.draw_volume(cr, volume_button_rect)
     
     # Draw event box, draw close button.
     close_pixbuf = ui_theme.get_pixbuf('button/window_close_normal.png').get_pixbuf()
     event_box_x = rect.width - close_pixbuf.get_width() + 4
     draw_pixbuf(cr, close_pixbuf, event_box_x, rect.y)
     
     # Draw min button.
     min_pixbuf = ui_theme.get_pixbuf('button/window_min_normal.png').get_pixbuf()
     event_box_x -= min_pixbuf.get_width()
     draw_pixbuf(cr, min_pixbuf, event_box_x, rect.y)
     
     # draw quell button.
     quell_pixbuf = app_theme.get_pixbuf('mode/quell_normal.png').get_pixbuf()
     event_box_x -= quell_pixbuf.get_width()
     draw_pixbuf(cr, quell_pixbuf, event_box_x, rect.y)
     
     cr.pop_group_to_source()
     cr.paint_with_alpha(alpha)
コード例 #2
0
    def __init_values(self):
        self.max_value = 100
        self.min_value = 0
        self.value = 100
        self.mute_check = False
        self.move_check = False
        self.volume_level_values = [(1, 33), (34, 66), (67, 100)],

        self.bg_pixbuf = ui_theme.get_pixbuf("volumebutton/bg.png")
        self.fg_pixbuf = ui_theme.get_pixbuf("volumebutton/fg.png")

        self.zero_volume_normal_pixbuf = app_theme.get_pixbuf(
            "volume_button/zero_normal.png")
        self.zero_volume_hover_pixbuf = app_theme.get_pixbuf(
            "volume_button/zero_hover.png")
        self.zero_volume_press_pixbuf = app_theme.get_pixbuf(
            "volume_button/zero_press.png")

        self.min_volume_normal_pixbuf = app_theme.get_pixbuf(
            "volume_button/lower_normal.png")
        self.min_volume_hover_pixbuf = app_theme.get_pixbuf(
            "volume_button/lower_hover.png")
        self.min_volume_press_pixbuf = app_theme.get_pixbuf(
            "volume_button/lower_press.png")

        self.mid_volume_normal_pixbuf = app_theme.get_pixbuf(
            "volume_button/middle_normal.png")
        self.mid_volume_hover_pixbuf = app_theme.get_pixbuf(
            "volume_button/middle_hover.png")
        self.mid_volume_press_pixbuf = app_theme.get_pixbuf(
            "volume_button/middle_press.png")

        self.max_volume_normal_pixbuf = app_theme.get_pixbuf(
            "volume_button/high_normal.png")
        self.max_volume_hover_pixbuf = app_theme.get_pixbuf(
            "volume_button/high_hover.png")
        self.max_volume_press_pixbuf = app_theme.get_pixbuf(
            "volume_button/high_press.png")

        self.mute_volume_normal_pixbuf = app_theme.get_pixbuf(
            "volume_button/mute_normal.png")
        self.mute_volume_hover_pixbuf = app_theme.get_pixbuf(
            "volume_button/mute_hover.png")
        self.mute_volume_press_pixbuf = app_theme.get_pixbuf(
            "volume_button/mute_press.png")

        self.point_volume_pixbuf = ui_theme.get_pixbuf(
            "volumebutton/point_normal.png")

        mute_w = self.mute_volume_normal_pixbuf.get_pixbuf().get_width()
        mute_h = self.mute_volume_normal_pixbuf.get_pixbuf().get_height()
        volume_w = 54 + 12  #self.point_volume_pixbuf.get_width()
        volume_h = mute_h

        self.mute_btn.set_size_request(mute_w, mute_h)
        self.volume_btn.set_size_request(volume_w, volume_h)
コード例 #3
0
    def __init__(self, content, sp, code):
        TreeItem.__init__(self)
        self.content = content
        self.sp = sp
        self.code = code
        self.gsm_providers = sp.get_country_gsm_providers_name(code)
        self.is_expand = False
        self.show_arrow = False
        self.arrow_right = ui_theme.get_pixbuf("treeview/arrow_right.png")
        self.arrow_down = ui_theme.get_pixbuf("treeview/arrow_down.png")
        self.arrow_height = self.arrow_down.get_pixbuf().get_height()
        self.arrow_width = self.arrow_down.get_pixbuf().get_width()

        self.show_arrow = self.add_apns_name(code, content)
        self.is_hover = False
コード例 #4
0
    def __init__(self, content, sp, code):
        TreeItem.__init__(self)
        self.content = content
        self.sp = sp
        self.code = code
        self.gsm_providers = sp.get_country_gsm_providers_name(code)
        self.is_expand = False
        self.show_arrow = False
        self.arrow_right=ui_theme.get_pixbuf("treeview/arrow_right.png")
        self.arrow_down=ui_theme.get_pixbuf("treeview/arrow_down.png")
        self.arrow_height = self.arrow_down.get_pixbuf().get_height()
        self.arrow_width = self.arrow_down.get_pixbuf().get_width()

        self.show_arrow = self.add_apns_name(code, content)
        self.is_hover = False
コード例 #5
0
    def __init_values(self):
        self.max_value = 100
        self.min_value = 0
        self.value = 100
        self.mute_check = False
        self.move_check = False
        self.volume_level_values = [(1, 33),(34, 66),(67, 100)],

        self.bg_pixbuf = ui_theme.get_pixbuf("volumebutton/bg.png")
        self.fg_pixbuf = ui_theme.get_pixbuf("volumebutton/fg.png")

        self.zero_volume_normal_pixbuf = app_theme.get_pixbuf("volume_button/zero_normal.png")
        self.zero_volume_hover_pixbuf = app_theme.get_pixbuf("volume_button/zero_hover.png")
        self.zero_volume_press_pixbuf = app_theme.get_pixbuf("volume_button/zero_press.png")

        self.min_volume_normal_pixbuf = app_theme.get_pixbuf("volume_button/lower_normal.png")
        self.min_volume_hover_pixbuf = app_theme.get_pixbuf("volume_button/lower_hover.png")
        self.min_volume_press_pixbuf = app_theme.get_pixbuf("volume_button/lower_press.png")
        
        self.mid_volume_normal_pixbuf = app_theme.get_pixbuf("volume_button/middle_normal.png")
        self.mid_volume_hover_pixbuf = app_theme.get_pixbuf("volume_button/middle_hover.png")
        self.mid_volume_press_pixbuf = app_theme.get_pixbuf("volume_button/middle_press.png")

        self.max_volume_normal_pixbuf = app_theme.get_pixbuf("volume_button/high_normal.png")
        self.max_volume_hover_pixbuf = app_theme.get_pixbuf("volume_button/high_hover.png")
        self.max_volume_press_pixbuf = app_theme.get_pixbuf("volume_button/high_press.png")

        self.mute_volume_normal_pixbuf = app_theme.get_pixbuf("volume_button/mute_normal.png")
        self.mute_volume_hover_pixbuf = app_theme.get_pixbuf("volume_button/mute_hover.png")
        self.mute_volume_press_pixbuf = app_theme.get_pixbuf("volume_button/mute_press.png")

        self.point_volume_pixbuf = ui_theme.get_pixbuf("volumebutton/point_normal.png")

        mute_w = self.mute_volume_normal_pixbuf.get_pixbuf().get_width()
        mute_h = self.mute_volume_normal_pixbuf.get_pixbuf().get_height()
        volume_w = 54
        volume_h = mute_h
        
        self.mute_btn.set_size_request(mute_w, mute_h)
        self.volume_btn.set_size_request(volume_w, volume_h)
コード例 #6
0
from dtk.ui.init_skin import init_theme
init_theme()
from dtk.ui.application import Application
from dtk.ui.button import ToggleButton
from dtk.ui.theme import ui_theme
from dtk.ui.dialog import ConfirmDialog
import gtk

if __name__ == "__main__":
    application = Application()
    application.set_default_size(600, 450)
    application.add_titlebar(title="ToggleButton example!")

    toggle_button = ToggleButton(
        inactive_normal_dpixbuf=ui_theme.get_pixbuf("switchbutton/off.png"),
        active_normal_dpixbuf=ui_theme.get_pixbuf("switchbutton/on.png"),
        button_label="This is toggle button",
        padding_x=5,
    )
    toggle_button.connect(
        "toggled", lambda w: ConfirmDialog(
            "反馈对话框",
            "按钮开启" if w.get_active() else "按钮关闭",
        ).show_all())

    toggle_button_align = gtk.Alignment()
    toggle_button_align.set(0.5, 0.5, 0, 0)

    toggle_button_align.add(toggle_button)
    application.main_box.add(toggle_button_align)
from dtk.ui.init_skin import init_theme
init_theme()
from dtk.ui.application import Application
from dtk.ui.button import ToggleButton
from dtk.ui.theme import ui_theme
from dtk.ui.dialog import ConfirmDialog
import gtk

if __name__ == "__main__":
    application = Application()
    application.set_default_size(600, 450)
    application.add_titlebar(title="ToggleButton example!")
    
    toggle_button = ToggleButton(
        inactive_normal_dpixbuf=ui_theme.get_pixbuf("switchbutton/off.png"),
        active_normal_dpixbuf=ui_theme.get_pixbuf("switchbutton/on.png"),
        button_label="This is toggle button",
        padding_x=5,
        )
    toggle_button.connect(
        "toggled", 
        lambda w: ConfirmDialog(
            "反馈对话框",
            "按钮开启" if w.get_active() else "按钮关闭",
            ).show_all())
    
    toggle_button_align = gtk.Alignment()
    toggle_button_align.set(0.5, 0.5, 0, 0)
    
    toggle_button_align.add(toggle_button)
コード例 #8
0
    def __init__(self,
                 slide_infos,
                 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 slide_infos: infos fetched from network api
        @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_infos = slide_infos
        self.image_number = len(self.slide_infos)
        self.slide_images = []
        for i in xrange(self.image_number):
            self.slide_images.append(get_common_image_pixbuf('slide/default_cache.png'))

        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()
        self.fetch_image_id = 0
        FetchImageFromUpyun(self.slide_infos[self.fetch_image_id][2], lambda local_path: self.update_images(local_path, self.fetch_image_id)).start()
コード例 #9
0
    def __init__(
            self,
            slide_infos,
            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 slide_infos: infos fetched from network api
        @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_infos = slide_infos
        self.image_number = len(self.slide_infos)
        self.slide_images = []
        for i in xrange(self.image_number):
            self.slide_images.append(
                get_common_image_pixbuf('slide/default_cache.png'))

        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()
        self.fetch_image_id = 0
        FetchImageFromUpyun(
            self.slide_infos[self.fetch_image_id][2], lambda local_path: self.
            update_images(local_path, self.fetch_image_id)).start()
コード例 #10
0

def show_video(widget, xid):
    '''Show video.'''
    run_command("mplayer -fs -wid %s %s" % (xid, "/data/Video/Manatee.avi"))


if __name__ == "__main__":
    # Init application.
    application = Application("demo", False)

    # Set application default size.
    application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)

    # Set application icon.
    application.set_icon(ui_theme.get_pixbuf("icon.ico"))

    # Add titlebar.
    application.add_titlebar(["theme", "menu", "max", "min", "close"],
                             ui_theme.get_pixbuf("title.png"), "电影播放器",
                             "深度Linux视频演示")

    # Add mplayer view.
    mplayer_view = MplayerView()
    mplayer_view.connect("get-xid", show_video)
    mplayer_frame = HorizontalFrame()
    mplayer_frame.add(mplayer_view)

    main_box = gtk.VBox()
    main_box.pack_start(mplayer_frame)
コード例 #11
0
ファイル: browser_demo.py プロジェクト: Jiarui315/deepin-ui
from dtk.ui.application import Application
from dtk.ui.browser_client import BrowserClient
from dtk.ui.constant import DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT
from dtk.ui.frame import HorizontalFrame
from dtk.ui.theme import ui_theme

if __name__ == "__main__":
    # Init application.
    application = Application("browser_demo")
    
    # Set application default size.
    application.set_default_size(DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT)
    
    # Set application icon.
    application.set_icon(ui_theme.get_pixbuf("icon.ico"))
    
    # Add titlebar.
    application.add_titlebar(
        ["theme", "menu", "max", "min", "close"], 
        ui_theme.get_pixbuf("title.png"), 
        "深度图形库",
        "/home/andy/deepin-ui/browser_demo.py")
    
    # Add browser.
    horizontal_frame = HorizontalFrame()
    browser_client = BrowserClient(
        "http://ting.baidu.com",
        "/home/andy/cookie.txt",
        application.app_bus_name,
        application.app_dbus_name,
コード例 #12
0
    def __init__(
        self,
        items,
        add_separator=False,
        font_size=DEFAULT_FONT_SIZE,
        padding_x=10,
        padding_y=10,
        vertical=True,
        item_normal_pixbuf=None,
        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_normal_pixbuf = item_normal_pixbuf
        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.top_logo_box = TopLogoBox()
        self.nav_item_box = gtk.HBox()
        self.nav_item_box.pack_start(self.top_logo_box, False, False)
        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_normal_pixbuf,
                    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()
コード例 #13
0
    def __init__(
        self,
        items,
        add_separator=False,
        font_size=DEFAULT_FONT_SIZE,
        padding_x=10,
        padding_y=10,
        vertical=True,
        item_normal_pixbuf=None,
        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_normal_pixbuf = item_normal_pixbuf
        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.top_logo_box = TopLogoBox()
        self.nav_item_box = gtk.HBox()
        self.nav_item_box.pack_start(self.top_logo_box, False, False)
        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_normal_pixbuf,
                                   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()
コード例 #14
0
        return True
            
def test_window_event(widget, event):
    '''docs'''
    print "press window event"
            
def test_panel_event(widget, event):
    '''docs'''
    print "press panel event"
            
if __name__ == "__main__":
    # Init window.
    window = gtk.Window()
    window.add_events(gtk.gdk.ALL_EVENTS_MASK)        
    window.connect("destroy", lambda w: gtk.main_quit())
    window.add(gtk.image_new_from_pixbuf(ui_theme.get_pixbuf("background5.jpg").get_pixbuf()))
    
    # Init panel window.
    panel = TestPanel(-1, 25)
    
    # Full mplayer window first.
    window.fullscreen()
    
    # Full panel window.
    panel.move(0, 0)
    panel.resize_panel(-1, 50)
    panel.fullscreen()
    
    # Destroy window if destroy panel window. 
    window.set_transient_for(panel)
    window.set_destroy_with_parent(True)