Ejemplo n.º 1
0
 def __init_category_bar(self):    
     general_normal_item = NormalItem(_("General"), self.general_setting)
     hotkey_normal_item = NormalItem(_("Hotkeys"), self.hotkey_setting)
     self.lyrics_expand_item = ExpandItem(_("Lyrics"), None)
     self.lyrics_expand_item.add_childs([(_("Desktop"), self.desktop_lyrics_setting),
                                    (_("Window"), self.scroll_lyrics_setting)])
     self.plugins_expand_item = NormalItem(_("Plugins"), self.plugins_manager)
     about_normal_item = NormalItem(_("About"), AboutBox())
     
     items = [general_normal_item,
              hotkey_normal_item,
              self.lyrics_expand_item,
              self.plugins_expand_item,
              about_normal_item]
     self.category_bar.add_items(items)
     self.category_bar.select_items([general_normal_item])
Ejemplo n.º 2
0
class PreferenceDialog(DialogBox):
    
    def __init__(self):
        super(PreferenceDialog, self).__init__(_("Preferences"), 575, 495, 
                                               mask_type=DIALOG_MASK_MULTIPLE_PAGE,
                                               close_callback=self.hide_all)
        
        self.set_position(gtk.WIN_POS_CENTER)
        
        self.main_box = gtk.VBox()
        close_button = Button(_("Close"))
        close_button.connect("clicked", lambda w: self.hide_all())
        
        # Init widget.
        self.general_setting = GeneralSetting()
        self.hotkey_setting = HotKeySetting()
        self.desktop_lyrics_setting = DesktopLyricsSetting()
        self.scroll_lyrics_setting = ScrollLyricsSetting()
        self.plugins_manager = PluginsManager()
        
        # Category bar
        self.category_bar = TreeView(enable_drag_drop=False, enable_multiple_select=False)
        self.category_bar.set_expand_column(0)
        self.category_bar.draw_mask = self.draw_treeview_mask
        self.category_bar.set_size_request(132, 516)
        self.category_bar.connect("single-click-item", self.on_categorybar_single_click)

        # Init catagory bar.
        self.__init_category_bar()
        
        category_box = gtk.VBox()
        background_box = BackgroundBox()
        background_box.set_size_request(132, 11)
        background_box.draw_mask = self.draw_treeview_mask
        category_box.pack_start(background_box, False, False)
        
        category_bar_align = gtk.Alignment()
        category_bar_align.set(0, 0, 1, 1,)
        category_bar_align.set_padding(0, 1, 0, 0)
        category_bar_align.add(self.category_bar)
        category_box.pack_start(category_bar_align, True, True)
        
        # Pack widget.
        left_box = gtk.VBox()
        self.right_box = gtk.VBox()
        left_box.add(category_box)
        self.right_box.add(self.general_setting)
        right_align = gtk.Alignment()
        right_align.set_padding(0, 0, 10, 0)
        right_align.add(self.right_box)

        body_box = gtk.HBox()
        body_box.pack_start(left_box, False, False)
        body_box.pack_start(right_align, False, False)
        self.main_box.add(body_box)
        
        # DialogBox code.
        self.body_box.pack_start(self.main_box, True, True)
        self.right_button_box.set_buttons([close_button])        
        
    def __init_category_bar(self):    
        general_normal_item = NormalItem(_("General"), self.general_setting)
        hotkey_normal_item = NormalItem(_("Hotkeys"), self.hotkey_setting)
        self.lyrics_expand_item = ExpandItem(_("Lyrics"), None)
        self.lyrics_expand_item.add_childs([(_("Desktop"), self.desktop_lyrics_setting),
                                       (_("Window"), self.scroll_lyrics_setting)])
        self.plugins_expand_item = NormalItem(_("Plugins"), self.plugins_manager)
        about_normal_item = NormalItem(_("About"), AboutBox())
        
        items = [general_normal_item,
                 hotkey_normal_item,
                 self.lyrics_expand_item,
                 self.plugins_expand_item,
                 about_normal_item]
        self.category_bar.add_items(items)
        self.category_bar.select_items([general_normal_item])
        
    def switch_lyrics_page(self, index=3):
        self.lyrics_expand_item.try_to_expand()
        show_item = self.category_bar.visible_items[index]
        self.category_bar.select_items([show_item])
        self.on_categorybar_single_click(self.category_bar, show_item, None, None, None)
        
    def show_scroll_lyrics_page(self):
        self.switch_lyrics_page(4)
        self.show_all()
        
    def show_desktop_lyrics_page(self):    
        self.switch_lyrics_page(3)
        self.show_all()
    
    def draw_treeview_mask(self, cr, x, y, width, height):
        draw_alpha_mask(cr, x, y, width, height, ("#FFFFFF", 0.9))
    
    def on_categorybar_single_click(self, widget, item, column, x, y):
        if item.allocate_widget:
            switch_tab(self.right_box, item.allocate_widget)

    def load_plugins(self):        
        self.plugins_manager.flush_plugins()