Beispiel #1
0
 def tab_menu_creator(self, widget, tab_child):
     widget.menu = Popup()
     rename_icon = "document-edit" if icon_exists("document-edit") else "text-editor-symbolic"
     widget.menu.add_item(_("Rename tab"), rename_icon, lambda: self.on_rename_tab(tab_child, self.default_angle), None)
     widget.menu.add_item(_("Save playlist as"), "document-save-as", lambda: self.on_save_playlist(tab_child))
     widget.menu.add_item(_("Close tab"), "window-close", lambda: self.on_delete_tab(tab_child), None)
     widget.show()
     return widget
Beispiel #2
0
    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
Beispiel #3
0
    def __init__(self, controls, parent=None):
        FControl.__init__(self, controls)
        """TOP menu constructor"""

        decorator = MenuStyleDecorator()
        if not parent:
            parent = TopMenuBar()

        top = parent

        """File"""
        file = top.add_submenu(_("File"))
        file.add_image_item(_("Add File(s)"),      "folder-open",      self.controls.on_add_files)
        file.add_image_item(_("Add Folder(s)"),    "folder-open",      self.controls.on_add_folders)
        file.add_image_item(_("Save Playlist As"), "document-save-as", lambda: self.controls.notetabs.on_save_playlist(
            self.controls.notetabs.get_current_tree().scroll))
        file.separator()
        file.add_image_item(_("Quit"),             "application-exit", self.controls.quit)

        """View"""
        view = top.add_submenu(_("View"))
        view.set_no_show_all(True)
        self.view_music_tree = view.add_check_item(_("Left Panel"), FC().is_view_music_tree_panel)
        self.view_music_tree.connect("activate", lambda w: controls.layout.set_visible_musictree_panel(w.get_active()))

        self.view_search_panel = view.add_check_item(_("Search Panel"), FC().is_view_search_panel)
        self.view_search_panel.connect("activate", lambda w: controls.layout.set_visible_search_panel(w.get_active()))

        self.view_cover_lyrics = view.add_check_item(_("Cover & Lyrics Panel"), FC().is_view_coverlyrics_panel)
        self.view_cover_lyrics.connect("activate", lambda w: controls.layout.set_visible_coverlyrics_panel(w.get_active()))

        equalizer_icon = "view-media-equalizer" if icon_exists("view-media-equalizer") else "format-justify-right"
        view.add_image_item(_("Equalizer"),        equalizer_icon, self.controls.eq.show)
        view.add_image_item(_("Download Manager"), "go-down",      self.controls.dm.show)
        separator = view.separator()

        pref_icon = "gtk-preferences" if icon_exists("gtk-preferences") else "preferences-system"
        preferences_item = view.add_image_item(_("Preferences"), pref_icon, self.controls.show_preferences)

        """if new style menu - remove preferences from View"""
        if not isinstance(parent, TopMenuBar):
            separator.hide()
            preferences_item.hide()

        """Playback"""
        playback = top.add_submenu(_("Playback"))

        def set_random(flag=True):
            FC().is_order_random = flag
            logging.debug("set random" + str(flag))
            controls.os.on_load()

        """Playback - Order"""
        order = playback.add_text_item(_("Order"), sub_menu=True)
        playback_radio_group = []
        self.playback_order_linear = order.add_radio_item(_("Linear"), playback_radio_group, not FC().is_order_random)
        self.playback_order_random = order.add_radio_item(_("Random"), playback_radio_group, FC().is_order_random)

        self.playback_order_linear.connect("activate", lambda w: set_random(False))
        self.playback_order_random.connect("activate", lambda w: set_random(True))

        """Playback - Repeat"""
        repeat = playback.add_text_item(_("Repeat"), sub_menu=True)
        repeat_radio_group = []
        self.lopping_all     = repeat.add_radio_item(_("All"),     repeat_radio_group, FC().repeat_state == const.REPEAT_ALL)
        self.lopping_single  = repeat.add_radio_item(_("Single"),  repeat_radio_group, FC().repeat_state == const.REPEAT_SINGLE)
        self.lopping_disable = repeat.add_radio_item(_("Disable"), repeat_radio_group, FC().repeat_state == const.REPEAT_NO)

        def repeat_all():
            FC().repeat_state = const.REPEAT_ALL
            logging.debug("set repeat_all")
            controls.os.on_load()

        def repeat_single():
            FC().repeat_state = const.REPEAT_SINGLE
            logging.debug("set repeat_single")
            controls.os.on_load()

        def repeat_no():
            FC().repeat_state = const.REPEAT_NO
            logging.debug("set repeat_no")
            controls.os.on_load()

        self.lopping_all    .connect("activate", lambda * a:repeat_all())
        self.lopping_single .connect("activate", lambda * a:repeat_single())
        self.lopping_disable.connect("activate", lambda * a:repeat_no())

        """Playlist View"""
        #playlist = playback.add_text_item("Playlist")
        #self.playlist_plain = playlist.add_radio_item("Plain (normal style)", None, FC().playlist_type == const.PLAYLIST_PLAIN)
        #self.playlist_tree = playlist.add_radio_item("Tree (apollo style)", self.playlist_plain , FC().playlist_type == const.PLAYLIST_TREE)

        #self.playlist_plain.connect("activate", lambda w: w.get_active() and controls.set_playlist_plain())
        #self.playlist_tree.connect("activate", lambda w: w.get_active() and controls.set_playlist_tree())

        """Help"""
        help = top.add_submenu(_("Help"))
        help.add_image_item(_("About"), "help-about", self.show_about)
        help.separator()
        help.add_image_item(_("Project page"), "applications-internet", lambda * a:open_link_in_browser(_("http://www.foobnix.com")))
        help.add_image_item(_("Issue report"), "dialog-warning", lambda * a:open_link_in_browser("https://github.com/foobnix/foobnix/issues"))
        help.separator()
        help.add_image_item(_("Donate Participate"), "help-donate", lambda * a:open_link_in_browser(_("http://foobnix.com/en/faq.html#/faq4")))

        #help.add_image_item("Help", "help-contents")

        #top.decorate()

        decorator.apply(top)
        decorator.apply(file)
        decorator.apply(view)
        decorator.apply(playback)
        decorator.apply(repeat)
        decorator.apply(order)
        decorator.apply(help)

        self.widget = top

        self.on_load()
Beispiel #4
0
    def on_button_press(self, w, e):
        if self.header_pressed:
            self.header_pressed = False
            return
        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:
                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"), "system-file-manager", open_in_filemanager, local_paths[0])
                if inet_paths:
                    download_icon = "download" if icon_exists("download") else "emblem-downloads"
                    self.tree_menu.add_item(_('Download'), download_icon,
                                            self.controls.dm.append_tasks, self.get_all_selected_beans())
                    self.tree_menu.add_item(_('Download To...'), "folder-download",
                                            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))
                    converter_icon = "emblem-synchronizing" if icon_exists("emblem-synchronizing") else "gtk-convert"
                    self.tree_menu.add_item(_('Format Converter'), converter_icon, convert_files, local_paths)
                text = self.get_selected_bean().text
                self.tree_menu.add_item(_('Copy To Search Line'), "system-search",
                                        self.controls.searchPanel.set_search_text, text)
                self.tree_menu.add_separator()
                self.tree_menu.add_item(_('Copy link'), "insert-link",
                                        self.controls.copy_link, self.get_all_selected_beans())
                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(_('Add to My Audio (VK)'), "list-add",
                                        self.controls.add_to_my_playlist, self.get_all_selected_beans())
                self.tree_menu.add_item(_('Love This Track(s) by Last.fm'), "emote-love",
                                        self.controls.love_this_tracks, self.get_all_selected_beans())

                self.tree_menu.show(e)