当前位置: 首页>>代码示例>>Python>>正文


Python Popup.add_separator方法代码示例

本文整理汇总了Python中foobnix.helpers.menu.Popup.add_separator方法的典型用法代码示例。如果您正苦于以下问题:Python Popup.add_separator方法的具体用法?Python Popup.add_separator怎么用?Python Popup.add_separator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在foobnix.helpers.menu.Popup的用法示例。


在下文中一共展示了Popup.add_separator方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
    def __init__(self, controls):
        FControl.__init__(self, controls)
        gtk.HBox.__init__(self, False, 0)

        self.old_menu = MenuBarWidget(controls)

        self.pack_start(self.old_menu.widget, False, False)

        self.new_menu_button = ImageButton(gtk.STOCK_PREFERENCES)
        self.new_menu_button.connect("button-press-event", self.on_button_press)

        self.pack_start(self.new_menu_button, False, False)
        self.pack_start(controls.playback, False, False)
        self.pack_start(controls.os, False, False)
        self.pack_start(controls.volume, False, False)
        self.pack_start(gtk.SeparatorToolItem(), False, False)
        self.pack_start(controls.seek_bar, True, True)

        self.show_all()
        """menu init"""
        menu = Popup()
        decorator = MenuStyleDecorator()
        MenuBarWidget(self.controls, menu)
        menu.add_separator()
        menu.add_item(_("Preferences"), gtk.STOCK_PREFERENCES, self.controls.show_preferences)
        menu.add_separator()
        menu.add_item(_("Quit"), gtk.STOCK_QUIT, self.controls.quit)

        decorator.apply(menu)
        self.menu = menu
开发者ID:Lomir,项目名称:foobnix,代码行数:32,代码来源:top.py

示例2: __init__

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
    def __init__(self, controls):
        FControl.__init__(self, controls)
        Gtk.HBox.__init__(self, False, 0)

        self.old_menu = MenuBarWidget(controls)


        self.pack_start(self.old_menu.widget, False, False, 0)

        self.new_menu_button = ImageButton("preferences-system", tooltip_text=_("Settings"))
        self.new_menu_button.connect("button-press-event", self.on_button_press)

        self.pack_start(self.new_menu_button, False, False, 0)
        self.pack_start(controls.playback, False, False, 0)
        self.pack_start(controls.os, False, False, 0)
        self.pack_start(controls.volume, False, False, 0)
        self.pack_start(Gtk.SeparatorToolItem.new(), False, False, 0)
        self.pack_start(controls.record, False, False, 0)
        self.pack_start(controls.seek_bar, True, True, 0)

        """menu init"""
        menu = Popup()
        decorator = MenuStyleDecorator()
        MenuBarWidget(self.controls, menu)
        menu.add_separator()
        menu.add_item(_("Preferences"), "preferences-system", self.controls.show_preferences)
        menu.add_separator()
        menu.add_item(_("Quit"), "application-exit", self.controls.quit)

        decorator.apply(menu)
        self.menu = menu
开发者ID:kagel,项目名称:foobnix,代码行数:33,代码来源:top.py

示例3: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
    def on_button_press(self, w, e):
        
        if is_middle_click(e):
            self.add_to_tab(True)
            return

        if is_left_click(e):
            # on left click expand selected folders
            return
        
        if is_double_left_click(e):
            # on middle click play selected beans 
            self.add_to_tab()
            return
        
        if is_rigth_click(e):
            # on right click, show pop-up menu
            menu = Popup()
            menu.add_item(_("Add to current tab"), gtk.STOCK_ADD, lambda: self.add_to_tab(True), None)
            menu.add_item(_("Add to new tab"), gtk.STOCK_MEDIA_PLAY, self.add_to_tab, None)
            menu.add_separator()
            menu.add_item(_("Add folder"), gtk.STOCK_OPEN, self.add_folder, None)
            menu.add_separator()

            if FC().tabs_mode == "Multi":
                menu.add_item(_("Add folder in new tab"), gtk.STOCK_OPEN, lambda : self.add_folder(True), None)
                menu.add_item(_("Clear Music Tree"), gtk.STOCK_CLEAR, lambda : self.controls.tabhelper.clear_tree(self.scroll), None)
            menu.add_item(_("Update Music Tree"), gtk.STOCK_REFRESH, lambda: self.controls.tabhelper.on_update_music_tree(self.scroll), None)
                
            menu.show(e)
开发者ID:Lomir,项目名称:foobnix,代码行数:32,代码来源:navigation_tree.py

示例4: on_button_release

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
 def on_button_release(self, w, e):
     if is_rigth_click_release(e):
         """to select item under cursor"""
         try:
             path, col, cellx, celly = self.get_path_at_pos(int(e.x), int(e.y)) #@UnusedVariable
             self.get_selection().select_path(path)
         except TypeError:
             pass
         #menu.add_item('Save as', gtk.STOCK_SAVE_AS, self.controls.save_beans_to, self.get_all_selected_beans())
         
         beans = self.get_selected_beans()
         
         if beans:
             menu = Popup()
             menu.add_item(_('Play'), gtk.STOCK_MEDIA_PLAY, self.controls.play_selected_song, None)
             menu.add_item(_('Download'), gtk.STOCK_ADD, self.controls.dm.append_tasks, self.get_all_selected_beans())
             menu.add_item(_('Download To...'), gtk.STOCK_ADD, self.controls.dm.append_tasks_with_dialog, self.get_all_selected_beans())
             menu.add_separator()
             paths = [bean.path for bean in beans]
             if paths[0]:
                 menu.add_item(_('Edit Tags'), gtk.STOCK_EDIT, edit_tags, (self.controls, paths))
                 menu.add_item(_('Format Converter'), gtk.STOCK_CONVERT, convert_files, paths)
             text = self.get_selected_bean().text
             menu.add_item(_('Copy To Search Line'), gtk.STOCK_COPY, self.controls.searchPanel.set_search_text, text)
             menu.add_separator()
             menu.add_item(_('Copy №-Title-Time'), gtk.STOCK_COPY, self.copy_info_to_clipboard)
             menu.add_item(_('Copy Artist-Title-Album'), gtk.STOCK_COPY, self.copy_info_to_clipboard, True)
             menu.add_separator()
             menu.add_item(_('Love This Track(s)'), None, self.controls.love_this_tracks, self.get_all_selected_beans())
             menu.add_separator()
             if paths[0]:
                 menu.add_item(_("Open In File Manager"), None, open_in_filemanager, paths[0])
             menu.show(e)
开发者ID:matttbe,项目名称:foobnix,代码行数:35,代码来源:playlist_tree.py

示例5: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
 def on_button_press(self, w, e):
     self.controls.notetabs.set_active_tree(self)
     if is_double_left_click(e):
         self.controls.play_selected_song()
     if is_rigth_click(e):
         menu = Popup()
         menu.add_item(_("Play"), gtk.STOCK_MEDIA_PLAY, self.controls.play_selected_song, None)
         menu.add_item(_("Download"), gtk.STOCK_ADD, self.controls.dm.append_tasks, self.get_all_selected_beans())
         # menu.add_item('Save as', gtk.STOCK_SAVE_AS, self.controls.save_beans_to, self.get_all_selected_beans())
         menu.add_separator()
         path = self.get_selected_bean().path
         menu.add_item(_("Edit tags"), gtk.STOCK_EDIT, edit_tags, path)
         text = self.get_selected_bean().text
         menu.add_item(_("Copy to Search Line"), gtk.STOCK_COPY, self.controls.searchPanel.set_search_text, text)
         menu.show(e)
开发者ID:Lomir,项目名称:foobnix,代码行数:17,代码来源:playlist_tree.py

示例6: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
 def on_button_press(self, w, e):
     if is_double_left_click(e):
         selected = self.get_selected_bean()
         beans = self.get_all_child_beans_by_selected()  
         self.controls.append_to_new_notebook(selected.text, [selected] + beans)
         "run radio channel"
         self.controls.play_first_file_in_playlist()
         
     if is_rigth_click(e): 
         menu = Popup()
         menu.add_item(_("Add Station"), gtk.STOCK_ADD, self.on_add_station, None)
         menu.add_item(_("Delete Station"), gtk.STOCK_DELETE, self.on_delete_station, None)
         menu.add_item(_("Edit Radio"), gtk.STOCK_EDIT, self.on_edit_radio, None)
         menu.add_separator()
         menu.add_item(_("Reload radio folder"), gtk.STOCK_REFRESH, self.update_radio_tree, None)            
         menu.show(e)
开发者ID:Lomir,项目名称:foobnix,代码行数:18,代码来源:radio_tree.py

示例7: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
 def on_button_press(self, w, e):
     if is_empty_click(w, e):
         w.get_selection().unselect_all()
     if is_double_left_click(e):
         self.controls.play_selected_song()
         
     if is_rigth_click(e):
         right_click_optimization_for_trees(w, e)
         beans = self.get_selected_beans()
         if beans:
             menu = Popup()
             menu.add_item(_('Play'), gtk.STOCK_MEDIA_PLAY, self.controls.play_selected_song, None)
             menu.add_item(_('Delete from playlist'), gtk.STOCK_DELETE, self.delete_selected, None)
         
             paths = []
             inet_paths = []
             local_paths = []
             for bean in beans:
                 if bean.path in paths:
                     continue
                 paths.append(bean.path)
                 if not bean.path or bean.path.startswith("http://"):
                     inet_paths.append(bean.path)
                 else:
                     local_paths.append(bean.path)
                                                 
             if local_paths:
                 menu.add_item(_('Copy To...'), gtk.STOCK_ADD, copy_to, local_paths)
                 menu.add_item(_("Open in file manager"), None, open_in_filemanager, local_paths[0])
             if inet_paths:
                 menu.add_item(_('Download'), gtk.STOCK_ADD, self.controls.dm.append_tasks, self.get_all_selected_beans())
                 menu.add_item(_('Download To...'), gtk.STOCK_ADD, self.controls.dm.append_tasks_with_dialog, self.get_all_selected_beans())
                             
             menu.add_separator()
             
             if paths[0]:
                 menu.add_item(_('Edit Tags'), gtk.STOCK_EDIT, edit_tags, (self.controls, paths))
                 menu.add_item(_('Format Converter'), gtk.STOCK_CONVERT, convert_files, paths)
             text = self.get_selected_bean().text
             menu.add_item(_('Copy To Search Line'), gtk.STOCK_COPY, self.controls.searchPanel.set_search_text, text)
             menu.add_separator()
             menu.add_item(_('Copy №-Title-Time'), gtk.STOCK_COPY, self.copy_info_to_clipboard)
             menu.add_item(_('Copy Artist-Title-Album'), gtk.STOCK_COPY, self.copy_info_to_clipboard, True)
             menu.add_separator()
             menu.add_item(_('Love This Track(s) by Last.fm'), None, self.controls.love_this_tracks, self.get_all_selected_beans())
             menu.add_separator()
             if paths[0]:
                 menu.add_item(_("Open In File Manager"), None, open_in_filemanager, paths[0])
             menu.show(e)
开发者ID:inferno1988,项目名称:foobnix,代码行数:51,代码来源:playlist_tree.py

示例8: __init__

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
    def __init__(self, controls):
        FControl.__init__(self, controls)
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0)

        self.old_menu = MenuBarWidget(controls)

        self.pack_start(self.old_menu.widget, False, False, 0)

        menu_icon = "open-menu"
        if not icon_exists("open-menu"):
            menu_icon = "open-menu-symbolic"
        if not icon_exists("open-menu-symbolic"):
            menu_icon = "application-menu"

        self.new_menu_button = ImageButton(menu_icon, tooltip_text=_("Menu"))
        self.new_menu_button.connect("button-press-event", self.on_button_press)

        self.pack_start(self.new_menu_button,        False, False, 0)
        self.pack_start(controls.playback,           False, False, 0)
        self.pack_start(controls.os,                 False, False, 0)
        self.pack_start(controls.volume,             False, False, 0)
        self.pack_start(Gtk.SeparatorToolItem.new(), False, False, 0)
        self.pack_start(controls.record,             False, False, 0)
        self.pack_start(controls.seek_bar,            True,  True, 0)

        """menu init"""
        menu = Popup()
        decorator = MenuStyleDecorator()
        MenuBarWidget(self.controls, menu)
        menu.add_separator()

        pref_icon = "gtk-preferences" if icon_exists("gtk-preferences") else "preferences-system"
        menu.add_item(_("Preferences"), pref_icon, self.controls.show_preferences)
        menu.add_separator()
        menu.add_item(_("Quit"), "application-exit", self.controls.quit)

        decorator.apply(menu)
        self.menu = menu
开发者ID:zavlab1,项目名称:foobnix,代码行数:40,代码来源:top.py

示例9: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
 def on_button_press(self, w, e):
     if is_double_left_click(e):
         selected = self.get_selected_bean()
         beans = self.get_all_child_beans_by_selected()  
         self.controls.notetabs._append_tab(selected.text, [selected] + beans, optimization=True)
         "run radio channel"
         self.controls.play_first_file_in_playlist()
         
     if is_rigth_click(e): 
         right_click_optimization_for_trees(w, e)
         
         menu = Popup()
         bean = self.get_selected_bean()
         if bean:
             if self.get_selected_bean().is_file:
                 menu.add_item(_("Edit Station"), gtk.STOCK_EDIT, self.on_edit_radio, None)
                 menu.add_item(_("Delete Station"), gtk.STOCK_DELETE, self.delete_selected, None)
             else:
                 menu.add_item(_("Rename Group"), gtk.STOCK_EDIT, self.on_rename_group, None)
                 menu.add_item(_("Delete Group"), gtk.STOCK_DELETE, self.delete_selected, None)
             menu.add_separator()
         menu.add_item(_("Reload radio folder"), gtk.STOCK_REFRESH, self.update_radio_tree, None)            
         menu.show(e)
开发者ID:atis,项目名称:foobnix,代码行数:25,代码来源:radio_tree.py

示例10: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
    def on_button_press(self, w, e):
        if is_empty_click(w, e):
            w.get_selection().unselect_all()
        if is_middle_click(e):
            """to avoid unselect all selected items"""
            self.stop_emission('button-press-event')
        if is_left_click(e):
            # on left click expand selected folders
            return
        
        if is_double_left_click(e):
            # on middle click play selected beans 
            self.add_to_tab()
            return
        
        if is_rigth_click(e):
            right_click_optimization_for_trees(w, e)
            # on right click, show pop-up menu
            menu = Popup()
            menu.add_item(_("Append to playlist"), gtk.STOCK_ADD, lambda: self.add_to_tab(True), None)
            menu.add_item(_("Open in new playlist"), gtk.STOCK_MEDIA_PLAY, self.add_to_tab, None)
            menu.add_separator()
            menu.add_item(_("Add folder here"), gtk.STOCK_OPEN, self.add_folder, None)
            menu.add_separator()

            if FC().tabs_mode == "Multi":
                menu.add_item(_("Add folder in new tab"), gtk.STOCK_OPEN, lambda : self.add_folder(True), None)
                menu.add_item(_("Clear"), gtk.STOCK_CLEAR, lambda : self.controls.tabhelper.clear_tree(self.scroll), None)
            menu.add_item(_("Update"), gtk.STOCK_REFRESH, lambda: self.controls.tabhelper.on_update_music_tree(self.scroll), None)
            
            f_model, f_t_paths = self.get_selection().get_selected_rows()
            if f_t_paths:
                model = f_model.get_model()
                t_paths = [f_model.convert_child_path_to_path(f_t_path) for f_t_path in f_t_paths]
                row = model[t_paths[0]]
                paths = [model[t_path][self.path[0]] for t_path in t_paths]
                row_refs = [gtk.TreeRowReference(model, t_path) for t_path in t_paths]
                menu.add_separator()
                menu.add_item(_("Open in file manager"), None, open_in_filemanager, self.get_selected_bean().path)
                menu.add_item(_("Create folder"), None, self.create_folder, (model, f_t_paths[0], row))
                menu.add_item(_("Rename file (folder)"), None, self.rename_files, (row, self.path[0], self.text[0]))    
                menu.add_item(_("Delete file(s) / folder(s)"), None, self.delete_files, (row_refs, paths, self.get_iter_from_row_reference))
            
            menu.show(e)
开发者ID:atis,项目名称:foobnix,代码行数:46,代码来源:navigation_tree.py

示例11: on_button_press

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
    def on_button_press(self, w, e):
        self.controls.notetabs.set_active_tree(self)
        if is_double_left_click(e):
            self.controls.play_selected_song()
        if is_rigth_click(e):
            menu = Popup()
            menu.add_item(_('Play'), gtk.STOCK_MEDIA_PLAY, self.controls.play_selected_song, None)
            menu.add_item(_('Download'), gtk.STOCK_ADD, self.controls.dm.append_tasks, self.get_all_selected_beans())
            #menu.add_item('Save as', gtk.STOCK_SAVE_AS, self.controls.save_beans_to, self.get_all_selected_beans())
            menu.add_separator()
            paths = [bean.path for bean in self.get_selected_beans()]
            menu.add_item(_('Edit tags'), gtk.STOCK_EDIT, edit_tags, paths)
            text = self.get_selected_bean().text
            menu.add_item(_('Copy to Search Line'), gtk.STOCK_COPY, self.controls.searchPanel.set_search_text, text)

            
            menu.add_separator()
            menu.add_item(_('Copy №-Title-Time'), gtk.STOCK_COPY, self.copy_info_to_clipboard)
            menu.add_item(_('Copy Artist-Title-Album'), gtk.STOCK_COPY, self.copy_info_to_clipboard, True)
            
            menu.add_separator()
            menu.add_item(_('Love this track(s)'), None, self.controls.love_this_tracks, self.get_all_selected_beans())

            menu.show(e)
开发者ID:fain182,项目名称:foobnix,代码行数:26,代码来源:playlist_tree.py

示例12: PlaylistTreeControl

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]

#.........这里部分代码省略.........
            w.get_selection().unselect_all()
        if is_double_left_click(e):
            self.controls.play_selected_song()

        if is_rigth_click(e):
            right_click_optimization_for_trees(w, e)
            beans = self.get_selected_beans()
            if beans:
                self.tree_menu.clear()
                self.tree_menu.add_item(_('Play'), "media-playback-start", self.controls.play_selected_song, None)
                self.tree_menu.add_item(_('Delete from playlist'), "edit-delete", self.delete_selected, None)

                paths = []
                inet_paths = []
                local_paths = []
                for bean in beans:
                    if bean.path in paths:
                        continue
                    paths.append(bean.path)
                    if not bean.path or bean.path.startswith("http://"):
                        inet_paths.append(bean.path)
                    else:
                        local_paths.append(bean.path)

                if local_paths:
                    self.tree_menu.add_item(_('Copy To...'), "list-add", copy_to, local_paths)
                    self.tree_menu.add_item(_("Open in file manager"), None, open_in_filemanager, local_paths[0])
                if inet_paths:
                    self.tree_menu.add_item(_('Download'), "list-add",
                                            self.controls.dm.append_tasks, self.get_all_selected_beans())
                    self.tree_menu.add_item(_('Download To...'), "list-add",
                                            self.controls.dm.append_tasks_with_dialog, self.get_all_selected_beans())

                self.tree_menu.add_separator()

                if local_paths:
                    self.tree_menu.add_item(_('Edit Tags'), "accessories-text-editor", edit_tags, (self.controls, local_paths))
                    self.tree_menu.add_item(_('Format Converter'), "applications-utilities", convert_files, local_paths)
                text = self.get_selected_bean().text
                self.tree_menu.add_item(_('Copy To Search Line'), "edit-copy",
                                        self.controls.searchPanel.set_search_text, text)
                self.tree_menu.add_separator()
                self.tree_menu.add_item(_('Copy №-Title-Time'), "edit-copy", self.copy_info_to_clipboard)
                self.tree_menu.add_item(_('Copy Artist-Title-Album'), "edit-copy",
                                        self.copy_info_to_clipboard, True)
                self.tree_menu.add_separator()
                self.tree_menu.add_item(_('Love This Track(s) by Last.fm'), None,
                                        self.controls.love_this_tracks, self.get_all_selected_beans())
                self.tree_menu.add_item(_('Add to My Audio (VK)'), None,
                                        self.controls.add_to_my_playlist, self.get_all_selected_beans())
                self.tree_menu.add_item(_('Copy link'), None,
                                        self.controls.copy_link, self.get_all_selected_beans())

                self.tree_menu.show(e)

    def on_click_header(self, w, e):
        self.header_pressed = True
        if is_rigth_click(e):
            if "menu" in w.__dict__:
                w.menu.show(e)
            else:
                self.menu.show(e)

    def on_toggled_num(self, *a):
        FC().numbering_by_order = not FC().numbering_by_order
        number_music_tabs = self.controls.notetabs.get_n_pages() - 1
开发者ID:kagel,项目名称:foobnix,代码行数:70,代码来源:playlist_tree.py

示例13: NavigationTreeControl

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
class NavigationTreeControl(CommonTreeControl, LoadSave):
    def __init__(self, controls):
        CommonTreeControl.__init__(self, controls)

        self.controls = controls
        self.full_name = ""
        self.label = Gtk.Label()

        self.tree_menu = Popup()

        self.set_headers_visible(True)
        self.set_headers_clickable(True)

        """column config"""
        self.column = Gtk.TreeViewColumn("File", Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
        self._append_column(self.column, _("File"))

        def func(column, cell, model, iter, ext=False):
            try:
                data = model.get_value(iter, self.text[0])
            except TypeError:
                data = None
                pass
            if not model.get_value(iter, self.path[0]):
                cell.set_property('text', '')
                return
            if os.path.isfile(model.get_value(iter, self.path[0])):
                if data:
                    if ext:
                        cell.set_property('text', os.path.splitext(data)[1][1:])
                    else:
                        cell.set_property('text', os.path.splitext(data)[0])
            else:
                if ext:
                    cell.set_property('text', '')

        self.name_column = Gtk.TreeViewColumn("Name", Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
        self.name_column.set_sizing(Gtk.TREE_VIEW_COLUMN_FIXED)
        for rend in self.name_column.get_cells():
            self.name_column.set_cell_data_func(rend, func, False)
        self._append_column(self.name_column, _("Name"))

        self.ext_column = Gtk.TreeViewColumn("Ext", Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
        for rend in self.ext_column.get_cells():
            self.ext_column.set_cell_data_func(rend, func, True)
        self._append_column(self.ext_column, _("Ext"))

        self.configure_send_drag()
        self.configure_recive_drag()

        self.set_type_tree()
        #self.is_empty = False
        self.connect("button-release-event", self.on_button_release)
        self.connect("drag-data-get", self.on_drag_data_get)
        '''to force the ext_column to take the minimum size'''
        self.name_column.set_fixed_width(2000)

        def task(*a):
            self.on_click_header(None, None, on_start=True)
        GLib.idle_add(task)

        self.scroll.get_vscrollbar().connect('show', task)
        self.scroll.get_vscrollbar().connect('hide', task)

    def on_button_release(self, w, e):
        if is_middle_click_release(e):
            # on left click add selected items to current tab
            """to select item under cursor"""
            try:
                path, col, cellx, celly = self.get_path_at_pos(int(e.x), int(e.y))  # @UnusedVariable
                self.get_selection().select_path(path)
            except TypeError:
                pass
            self.add_to_tab(True)
            return


    def on_button_press(self, w, e):
        if is_empty_click(w, e):
            w.get_selection().unselect_all()
        if is_middle_click(e):
            """to avoid unselect all selected items"""
            self.stop_emission('button-press-event')
        if is_left_click(e):
            # on left click expand selected folders
            return

        if is_double_left_click(e):
            # on middle click play selected beans
            self.add_to_tab()
            return

        if is_rigth_click(e):
            right_click_optimization_for_trees(w, e)
            tabhelper = self.controls.perspectives.get_perspective('fs').get_tabhelper()
            # on right click, show pop-up menu
            self.tree_menu.clear()
            self.tree_menu.add_item(_("Append to playlist"), Gtk.STOCK_ADD, lambda: self.add_to_tab(True), None)
            self.tree_menu.add_item(_("Open in new playlist"), Gtk.STOCK_MEDIA_PLAY, self.add_to_tab, None)
            self.tree_menu.add_separator()
#.........这里部分代码省略.........
开发者ID:strogo,项目名称:foobnix,代码行数:103,代码来源:navigation_tree.py

示例14: RadioTreeControl

# 需要导入模块: from foobnix.helpers.menu import Popup [as 别名]
# 或者: from foobnix.helpers.menu.Popup import add_separator [as 别名]
class RadioTreeControl(CommonTreeControl):
    def __init__(self, controls):
        CommonTreeControl.__init__(self, controls)
        self.set_reorderable(False)
        self.switcher_label = _("My channels")
        self.tree_menu = Popup()
        """column config"""
        column = Gtk.TreeViewColumn(_("Radio Stations"), Gtk.CellRendererText(), text=self.text[0], font=self.font[0])
        column.set_resizable(True)
        self.set_headers_visible(True)
        self.append_column(column)

        self.configure_send_drag()
        self.configure_recive_drag()
        self.set_type_tree()

    @idle_task
    def on_load(self):
        if FCache().cache_radio_tree_beans:
            self.restore_rows(FCache().cache_radio_tree_beans)
        else:
            self.update_radio_tree()

    def on_button_press(self, w, e):
        if is_double_left_click(e):
            selected = self.get_selected_bean()
            beans = self.get_all_child_beans_by_selected()
            self.controls.notetabs._append_tab(selected.text, [selected] + beans, optimization=True)
            "run radio channel"
            self.controls.play_first_file_in_playlist()

        if is_rigth_click(e):
            right_click_optimization_for_trees(w, e)

            self.tree_menu.clear()
            bean = self.get_selected_bean()
            if bean:
                if self.get_selected_bean().is_file:
                    self.tree_menu.add_item(_("Edit Station"), Gtk.STOCK_EDIT, self.on_edit_radio, None)
                    self.tree_menu.add_item(_("Delete Station"), Gtk.STOCK_DELETE, self.delete_selected, None)
                else:
                    self.tree_menu.add_item(_("Rename Group"), Gtk.STOCK_EDIT, self.on_rename_group, None)
                    self.tree_menu.add_item(_("Delete Group"), Gtk.STOCK_DELETE, self.delete_selected, None)
                self.tree_menu.add_separator()
            self.tree_menu.add_item(_("Reload radio folder"), Gtk.STOCK_REFRESH, self.update_radio_tree, None)
            self.tree_menu.show(e)

    def on_edit_radio(self):
        bean = self.get_selected_bean()
        name, url = two_line_dialog(_("Edit Radio"),
                                    parent = self.controls.main_window,
                                    message_text1 = _("Enter new name and URL"),
                                    message_text2 = None,
                                    entry_text1=bean.text,
                                    entry_text2 = bean.path)
        if not name or not url:
            return
        bean.add_text(name)
        bean.add_path(url)

        rows = self.find_rows_by_element(self.UUID, bean.UUID)
        if rows:
            rows[0][self.text[0]] = name
            rows[0][self.path[0]] = url

    def on_rename_group(self):
        bean = self.get_selected_bean()
        name = one_line_dialog(_("Rename Group"), self.controls.main_window,
                               entry_text=bean.text, message_text1=_("Enter new group name"))
        if not name:
            return
        rows = self.find_rows_by_element(self.UUID, bean.UUID)
        if rows:
            rows[0][self.text[0]] = name

    def on_add_station(self):
        name, url = two_line_dialog(_("Add New Radio Station"),
                                    parent = self.controls.main_window,
                                    message_text1 = _("Enter station name and URL"),
                                    message_text2 = None,
                                    entry_text1 = None,
                                    entry_text2 = "http://")
        if not name or not url:
            return
        bean = self.get_selected_bean()
        new_bean = FModel(name, url).add_type(FTYPE_RADIO).add_is_file(True)
        if bean:
            if bean.is_file:
                new_bean.add_parent(bean.parent_level)
            else:
                new_bean.add_parent(bean.level)
        self.append(new_bean)

    def on_save(self):
        pass

    #def update_radio_tree(self):
    #    self.controls.in_thread.run_with_progressbar(self._update_radio_tree)

    @idle_task
#.........这里部分代码省略.........
开发者ID:Andresteve07,项目名称:foobnix,代码行数:103,代码来源:radio_tree.py


注:本文中的foobnix.helpers.menu.Popup.add_separator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。