Exemplo n.º 1
0
 def _widgets_lyrics(self):
     horiz_spacing = 2
     vert_spacing = 1
     self.info_lyrics = ui.expander(markup="<b>%s</b>" % _("Lyrics"),
                 expand=self.config.info_lyrics_expanded,
                 can_focus=False)
     self.info_lyrics.connect("activate", self._expanded, "lyrics")
     lyricsbox = gtk.VBox()
     self.lyricsText = ui.textview(text="", edit=False, wrap=True)
     self._populate_lyrics_tag_table()
     self.lyricsSw = ui.scrollwindow(policy_x=gtk.POLICY_NEVER,
                                     policy_y=gtk.POLICY_NEVER,
                                     add=self.lyricsText)
     lyricsbox.pack_start(self.lyricsSw, True, True, vert_spacing)
     lyricsbox_bottom = gtk.HBox()
     self._searchlabel = ui.label(y=0)
     self._editlyricslabel = ui.label(y=0)
     searchevbox = ui.eventbox(add=self._searchlabel)
     editlyricsevbox = ui.eventbox(add=self._editlyricslabel)
     self._apply_link_signals(searchevbox, 'search',
                              _("Search Lyricwiki.org for lyrics"))
     self._apply_link_signals(editlyricsevbox, 'editlyrics',
                              _("Edit lyrics at Lyricwiki.org"))
     lyricsbox_bottom.pack_start(searchevbox, False, False, horiz_spacing)
     lyricsbox_bottom.pack_start(editlyricsevbox, False, False,
                                 horiz_spacing)
     lyricsbox.pack_start(lyricsbox_bottom, False, False, vert_spacing)
     self.info_lyrics.add(lyricsbox)
     return self.info_lyrics
Exemplo n.º 2
0
 def _widgets_lyrics(self):
     horiz_spacing = 2
     vert_spacing = 1
     self.info_lyrics = ui.expander(markup='<b>%s</b>' % _('Lyrics'),
                                    expand=self.config.info_lyrics_expanded,
                                    can_focus=False)
     self.info_lyrics.connect('activate', self._expanded, 'lyrics')
     lyricsbox = gtk.VBox()
     self.lyricsText = ui.label(markup=' ', y=0, select=True, wrap=True)
     lyricsbox.pack_start(self.lyricsText, True, True, vert_spacing)
     lyricsbox_bottom = gtk.HBox()
     self._searchlabel = ui.label(y=0)
     self._editlyricslabel = ui.label(y=0)
     searchevbox = ui.eventbox(add=self._searchlabel)
     editlyricsevbox = ui.eventbox(add=self._editlyricslabel)
     self._apply_link_signals(searchevbox, 'search',
                              _('Search Lyricwiki.org for lyrics'))
     self._apply_link_signals(editlyricsevbox, 'editlyrics',
                              _('Edit lyrics at Lyricwiki.org'))
     lyricsbox_bottom.pack_start(searchevbox, False, False, horiz_spacing)
     lyricsbox_bottom.pack_start(editlyricsevbox, False, False,
                                 horiz_spacing)
     lyricsbox.pack_start(lyricsbox_bottom, False, False, vert_spacing)
     self.info_lyrics.add(lyricsbox)
     return self.info_lyrics
Exemplo n.º 3
0
 def _widgets_lyrics(self):
     horiz_spacing = 2
     vert_spacing = 1
     self.info_lyrics = ui.expander(markup='<b>%s</b>' % _('Lyrics'),
                 expand=self.config.info_lyrics_expanded,
                 can_focus=False)
     self.info_lyrics.connect('activate', self._expanded, 'lyrics')
     lyricsbox = gtk.VBox()
     self.lyricsText = ui.label(markup=' ', y=0, select=True, wrap=True)
     lyricsbox.pack_start(self.lyricsText, True, True, vert_spacing)
     lyricsbox_bottom = gtk.HBox()
     self._searchlabel = ui.label(y=0)
     self._editlyricslabel = ui.label(y=0)
     searchevbox = ui.eventbox(add=self._searchlabel)
     editlyricsevbox = ui.eventbox(add=self._editlyricslabel)
     self._apply_link_signals(searchevbox, 'search',
             _('Search Lyricwiki.org for lyrics'))
     self._apply_link_signals(editlyricsevbox,
             'editlyrics', _('Edit lyrics at Lyricwiki.org'))
     lyricsbox_bottom.pack_start(searchevbox, False, False, horiz_spacing)
     lyricsbox_bottom.pack_start(editlyricsevbox, False,
             False, horiz_spacing)
     lyricsbox.pack_start(lyricsbox_bottom, False, False, vert_spacing)
     self.info_lyrics.add(lyricsbox)
     return self.info_lyrics
Exemplo n.º 4
0
    def _widgets_song(self):
        info_song = ui.expander(markup="<b>%s</b>" % _("Song Info"),
                expand=self.config.info_song_expanded,
                can_focus=False)
        info_song.connect("activate", self._expanded, "song")

        self.info_labels = {}
        self.info_boxes_in_more = []
        labels = [(_("Title"), 'title', False, "", False),
            (_("Artist"), 'artist', True,
                _("Launch artist in Wikipedia"), False),
            (_("Album"), 'album', True,
                 _("Launch album in Wikipedia"), False),
            (_("Date"), 'date', False, "", False),
            (_("Track"), 'track', False, "", False),
            (_("Genre"), 'genre', False, "", False),
            (_("File"), 'file', False, "", True),
            (_("Bitrate"), 'bitrate', False, "", True)]

        tagtable = gtk.Table(len(labels), 2)
        tagtable.set_col_spacings(12)
        for i,(text, name, link, tooltip, in_more) in enumerate(labels):
            label = ui.label(markup="<b>%s:</b>" % text, y=0)
            tagtable.attach(label, 0, 1, i, i+1, yoptions=gtk.SHRINK)
            if i == 0:
                self.info_left_label = label
            # Using set_selectable overrides the hover cursor that
            # sonata tries to set for the links, and I can't figure
            # out how to stop that. So we'll disable set_selectable
            # for those labels until it's figured out.
            tmplabel2 = ui.label(wrap=True, y=0, select=not link)
            if link:
                tmpevbox = ui.eventbox(add=tmplabel2)
                self._apply_link_signals(tmpevbox, name, tooltip)
            to_pack = tmpevbox if link else tmplabel2
            tagtable.attach(to_pack, 1, 2, i, i+1, yoptions=gtk.SHRINK)
            self.info_labels[name] = tmplabel2
            if in_more:
                self.info_boxes_in_more.append(label)
                self.info_boxes_in_more.append(to_pack)

        self._morelabel = ui.label(y=0)
        self.toggle_more()
        moreevbox = ui.eventbox(add=self._morelabel)
        self._apply_link_signals(moreevbox, 'more', _("Toggle extra tags"))
        self._editlabel = ui.label(y=0)
        editevbox = ui.eventbox(add=self._editlabel)
        self._apply_link_signals(editevbox, 'edit', _("Edit song tags"))
        mischbox = gtk.HBox()
        mischbox.pack_start(moreevbox, False, False, 3)
        mischbox.pack_start(editevbox, False, False, 3)

        tagtable.attach(mischbox, 0, 2, len(labels), len(labels) + 1)
        inner_hbox = gtk.HBox()
        inner_hbox.pack_start(self._imagebox, False, False, 6)
        inner_hbox.pack_start(tagtable, False, False, 6)
        info_song.add(inner_hbox)
        return info_song
Exemplo n.º 5
0
    def _widgets_song(self):
        info_song = ui.expander(markup="<b>%s</b>" % _("Song Info"),
                expand=self.config.info_song_expanded,
                can_focus=False)
        info_song.connect("activate", self._expanded, "song")

        self.info_labels = {}
        self.info_boxes_in_more = []
        labels = [(_("Title"), 'title', False, "", False),
            (_("Artist"), 'artist', True,
                _("Launch artist in Wikipedia"), False),
            (_("Album"), 'album', True,
                 _("Launch album in Wikipedia"), False),
            (_("Date"), 'date', False, "", False),
            (_("Track"), 'track', False, "", False),
            (_("Genre"), 'genre', False, "", False),
            (_("File"), 'file', False, "", True),
            (_("Bitrate"), 'bitrate', False, "", True)]

        tagtable = gtk.Table(len(labels), 2)
        tagtable.set_col_spacings(12)
        for i, (text, name, link, tooltip, in_more) in enumerate(labels):
            label = ui.label(markup="<b>%s:</b>" % text, y=0)
            tagtable.attach(label, 0, 1, i, i + 1, yoptions=gtk.SHRINK)
            if i == 0:
                self.info_left_label = label
            # Using set_selectable overrides the hover cursor that
            # sonata tries to set for the links, and I can't figure
            # out how to stop that. So we'll disable set_selectable
            # for those labels until it's figured out.
            tmplabel2 = ui.label(wrap=True, y=0, select=not link)
            if link:
                tmpevbox = ui.eventbox(add=tmplabel2)
                self._apply_link_signals(tmpevbox, name, tooltip)
            to_pack = tmpevbox if link else tmplabel2
            tagtable.attach(to_pack, 1, 2, i, i + 1, yoptions=gtk.SHRINK)
            self.info_labels[name] = tmplabel2
            if in_more:
                self.info_boxes_in_more.append(label)
                self.info_boxes_in_more.append(to_pack)

        self._morelabel = ui.label(y=0)
        self.toggle_more()
        moreevbox = ui.eventbox(add=self._morelabel)
        self._apply_link_signals(moreevbox, 'more', _("Toggle extra tags"))
        self._editlabel = ui.label(y=0)
        editevbox = ui.eventbox(add=self._editlabel)
        self._apply_link_signals(editevbox, 'edit', _("Edit song tags"))
        mischbox = gtk.HBox()
        mischbox.pack_start(moreevbox, False, False, 3)
        mischbox.pack_start(editevbox, False, False, 3)

        tagtable.attach(mischbox, 0, 2, len(labels), len(labels) + 1)
        inner_hbox = gtk.HBox()
        inner_hbox.pack_start(self._imagebox, False, False, 6)
        inner_hbox.pack_start(tagtable, False, False, 6)
        info_song.add(inner_hbox)
        return info_song
Exemplo n.º 6
0
	def __init__(self, config, info_image, linkcolor, on_link_click_cb, library_return_search_items, get_playing_song, TAB_INFO, on_image_activate, on_image_motion_cb, on_image_drop_cb):
		self.config = config
		self.info_image = info_image
		self.linkcolor = linkcolor
		self.on_link_click_cb = on_link_click_cb
		self.library_return_search_items = library_return_search_items
		self.get_playing_song = get_playing_song
		self.TAB_INFO = TAB_INFO
		self.on_image_activate = on_image_activate
		self.on_image_motion_cb = on_image_motion_cb
		self.on_image_drop_cb = on_image_drop_cb

		try:
			self.enc = locale.getpreferredencoding()
		except:
			print "Locale cannot be found; please set your system's locale. Aborting..."
			sys.exit(1)

		self.lyricServer = None
		self.last_info_bitrate = None

		self.info_boxes_in_more = None
		self.info_editlabel = None
		self.info_editlyricslabel = None
		self.info_labels = None
		self.info_left_label = None
		self.info_lyrics = None
		self.info_morelabel = None
		self.info_searchlabel = None
		self.info_tagbox = None
		self.info_type = None

		self.lyricsText = None
		self.albumText = None

		# Info tab
		self.info_area = ui.scrollwindow()

		if self.config.info_art_enlarged:
			self.info_imagebox = ui.eventbox()
		else:
			self.info_imagebox = ui.eventbox(w=152)

		self.info_imagebox.add(self.info_image)

		infohbox = gtk.HBox()
		infohbox.pack_start(ui.image(stock=gtk.STOCK_JUSTIFY_FILL), False, False, 2)
		infohbox.pack_start(ui.label(text=self.TAB_INFO), False, False, 2)
		self.infoevbox = ui.eventbox(add=infohbox)
		self.infoevbox.show_all()

		self.info_imagebox.drag_dest_set(gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [("text/uri-list", 0, 80), ("text/plain", 0, 80)], gtk.gdk.ACTION_DEFAULT)
		self.info_imagebox.connect('button_press_event', self.on_image_activate)
		self.info_imagebox.connect('drag_motion', self.on_image_motion_cb)
		self.info_imagebox.connect('drag_data_received', self.on_image_drop_cb)

		self.widgets_initialize(self.info_area)
Exemplo n.º 7
0
	def __init__(self, config, find_path, is_lang_rtl, info_imagebox_get_size_request, schedule_gc_collect, target_image_filename, imagelist_append, remotefilelist_append, notebook_get_allocation, allow_art_search, status_is_play_or_pause, album_filename):
		self.config = config
		self.album_filename = album_filename

		# constants from main
		self.is_lang_rtl = is_lang_rtl

		# callbacks to main XXX refactor to clear this list
		self.info_imagebox_get_size_request = info_imagebox_get_size_request
		self.schedule_gc_collect = schedule_gc_collect
		self.target_image_filename = target_image_filename
		self.imagelist_append = imagelist_append
		self.remotefilelist_append = remotefilelist_append
		self.notebook_get_allocation = notebook_get_allocation
		self.allow_art_search = allow_art_search
		self.status_is_play_or_pause = status_is_play_or_pause

		# local pixbufs, image file names
		self.sonatacd = find_path('sonatacd.png')
		self.sonatacd_large = find_path('sonatacd_large.png')
		self.casepb = gtk.gdk.pixbuf_new_from_file(find_path('sonata-case.png'))
		self.albumpb = None

		# local UI widgets provided to main by getter methods
		self.albumimage = ui.image()
		self.albumimage.set_from_file(self.sonatacd)

		self.trayalbumimage1 = ui.image(w=51, h=77, x=1)
		self.trayalbumeventbox = ui.eventbox(w=59, h=90, add=self.trayalbumimage1, state=gtk.STATE_SELECTED, visible=True)

		self.trayalbumimage2 = ui.image(w=26, h=77)

		self.fullscreenalbumimage = ui.image(w=consts.FULLSCREEN_COVER_SIZE, h=consts.FULLSCREEN_COVER_SIZE, x=1)
		self.fullscreen_cover_art_set_image(self.sonatacd_large)

		self.info_image = ui.image(y=0)
		self.info_image.set_from_file(self.sonatacd_large)

		# local version of Main.songinfo mirrored by update_songinfo
		self.songinfo = None

		# local state
		self.lastalbumart = None
		self.single_img_in_dir = None
		self.misc_img_in_dir = None
		self.stop_art_update = False
		self.downloading_image = False
		self.lib_art_cond = None
		
		# local artwork, cache for library
		self.lib_model = None
		self.lib_art_rows_local = []
		self.lib_art_rows_remote = []
		self.lib_art_pb_size = 0
		self.cache = {}
		
		self.artwork_load_cache()
Exemplo n.º 8
0
    def __init__(self, config, window, client, UIManager,
                 update_menu_visibility, iterate_now, on_add_item,
                 on_playlists_button_press, get_current_songs, connected,
                 TAB_PLAYLISTS):
        self.config = config
        self.window = window
        self.client = client
        self.UIManager = UIManager
        self.update_menu_visibility = update_menu_visibility
        self.iterate_now = iterate_now  # XXX Do we really need this?
        self.on_add_item = on_add_item
        self.on_playlists_button_press = on_playlists_button_press
        self.get_current_songs = get_current_songs
        self.connected = connected
        self.TAB_PLAYLISTS = TAB_PLAYLISTS

        self.mergepl_id = None
        self.actionGroupPlaylists = None

        # Playlists tab
        self.playlists = ui.treeview()
        self.playlists_selection = self.playlists.get_selection()
        self.playlistswindow = ui.scrollwindow(add=self.playlists)
        playlistshbox = gtk.HBox()
        playlistshbox.pack_start(ui.image(stock=gtk.STOCK_JUSTIFY_CENTER),
                                 False, False, 2)
        playlistshbox.pack_start(ui.label(text=self.TAB_PLAYLISTS), False,
                                 False, 2)
        self.playlistsevbox = ui.eventbox(add=playlistshbox)
        self.playlistsevbox.show_all()

        self.playlists.connect('button_press_event',
                               self.on_playlists_button_press)
        self.playlists.connect('row_activated', self.playlists_activated)
        self.playlists.connect('key-press-event', self.playlists_key_press)

        # Initialize playlist data and widget
        self.playlistsdata = gtk.ListStore(str, str)
        self.playlists.set_model(self.playlistsdata)
        self.playlists.set_search_column(1)
        self.playlistsimg = gtk.CellRendererPixbuf()
        self.playlistscell = gtk.CellRendererText()
        self.playlistscell.set_property("ellipsize", pango.ELLIPSIZE_END)
        self.playlistscolumn = gtk.TreeViewColumn()
        self.playlistscolumn.pack_start(self.playlistsimg, False)
        self.playlistscolumn.pack_start(self.playlistscell, True)
        self.playlistscolumn.set_attributes(self.playlistsimg, stock_id=0)
        self.playlistscolumn.set_attributes(self.playlistscell, markup=1)
        self.playlists.append_column(self.playlistscolumn)
        self.playlists_selection.set_mode(gtk.SELECTION_MULTIPLE)
Exemplo n.º 9
0
    def __init__(self, config, info_image, linkcolor, on_link_click_cb,
                 get_playing_song, TAB_INFO, on_image_activate,
                 on_image_motion_cb, on_image_drop_cb,
                 album_return_artist_and_tracks, new_tab):

        self.consts = consts.Constants()
        self.config = config
        self.linkcolor = linkcolor
        self.on_link_click_cb = on_link_click_cb
        self.get_playing_song = get_playing_song
        self.album_return_artist_and_tracks = album_return_artist_and_tracks

        try:
            self.enc = locale.getpreferredencoding()
        except:
            print('Locale cannot be found; please set your system\'s locale. '
                  'Aborting...')
            sys.exit(1)

        self.last_bitrate = None

        self.info_boxes_in_more = None
        self._editlabel = None
        self._editlyricslabel = None
        self.info_left_label = None
        self.info_lyrics = None
        self._morelabel = None
        self._searchlabel = None

        self.lyricsText = None
        self.albumText = None

        self.info_area = ui.scrollwindow(shadow=gtk.SHADOW_NONE)
        self.tab = new_tab(self.info_area, gtk.STOCK_JUSTIFY_FILL, TAB_INFO,
                           self.info_area)

        image_width = -1 if self.config.info_art_enlarged else 152
        imagebox = ui.eventbox(w=image_width, add=info_image)
        imagebox.drag_dest_set(
            gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,
            [('text/uri-list', 0, 80),
             ('text/plain', 0, 80)], gtk.gdk.ACTION_DEFAULT)
        imagebox.connect('button_press_event', on_image_activate)
        imagebox.connect('drag_motion', on_image_motion_cb)
        imagebox.connect('drag_data_received', on_image_drop_cb)
        self._imagebox = imagebox

        self._widgets_initialize()
Exemplo n.º 10
0
    def __init__(self, config, info_image, linkcolor, on_link_click_cb,
            get_playing_song, TAB_INFO, on_image_activate, on_image_motion_cb,
            on_image_drop_cb, album_return_artist_and_tracks, new_tab):

        self.consts = consts.Constants()
        self.config = config
        self.linkcolor = linkcolor
        self.on_link_click_cb = on_link_click_cb
        self.get_playing_song = get_playing_song
        self.album_return_artist_and_tracks = album_return_artist_and_tracks

        try:
            self.enc = locale.getpreferredencoding()
        except:
            print('Locale cannot be found; please set your system\'s locale. '
                'Aborting...')
            sys.exit(1)

        self.last_bitrate = None

        self.info_boxes_in_more = None
        self._editlabel = None
        self._editlyricslabel = None
        self.info_left_label = None
        self.info_lyrics = None
        self._morelabel = None
        self._searchlabel = None

        self.lyricsText = None
        self.albumText = None

        self.info_area = ui.scrollwindow(shadow=gtk.SHADOW_NONE)
        self.tab = new_tab(self.info_area, gtk.STOCK_JUSTIFY_FILL,
                TAB_INFO, self.info_area)

        image_width = -1 if self.config.info_art_enlarged else 152
        imagebox = ui.eventbox(w=image_width, add=info_image)
        imagebox.drag_dest_set(gtk.DEST_DEFAULT_HIGHLIGHT |
                gtk.DEST_DEFAULT_DROP,
                [('text/uri-list', 0, 80),
                 ('text/plain', 0, 80)], gtk.gdk.ACTION_DEFAULT)
        imagebox.connect('button_press_event', on_image_activate)
        imagebox.connect('drag_motion', on_image_motion_cb)
        imagebox.connect('drag_data_received', on_image_drop_cb)
        self._imagebox = imagebox

        self._widgets_initialize()
Exemplo n.º 11
0
	def __init__(self, config, window, client, UIManager, update_menu_visibility, iterate_now, on_add_item, on_playlists_button_press, get_current_songs, connected, TAB_PLAYLISTS):
		self.config = config
		self.window = window
		self.client = client
		self.UIManager = UIManager
		self.update_menu_visibility = update_menu_visibility
		self.iterate_now = iterate_now # XXX Do we really need this?
		self.on_add_item = on_add_item
		self.on_playlists_button_press = on_playlists_button_press
		self.get_current_songs = get_current_songs
		self.connected = connected
		self.TAB_PLAYLISTS = TAB_PLAYLISTS

		self.mergepl_id = None
		self.actionGroupPlaylists = None

		# Playlists tab
		self.playlists = ui.treeview()
		self.playlists_selection = self.playlists.get_selection()
		self.playlistswindow = ui.scrollwindow(add=self.playlists)
		playlistshbox = gtk.HBox()
		playlistshbox.pack_start(ui.image(stock=gtk.STOCK_JUSTIFY_CENTER), False, False, 2)
		playlistshbox.pack_start(ui.label(text=self.TAB_PLAYLISTS), False, False, 2)
		self.playlistsevbox = ui.eventbox(add=playlistshbox)
		self.playlistsevbox.show_all()

		self.playlists.connect('button_press_event', self.on_playlists_button_press)
		self.playlists.connect('row_activated', self.playlists_activated)
		self.playlists.connect('key-press-event', self.playlists_key_press)

		# Initialize playlist data and widget
		self.playlistsdata = gtk.ListStore(str, str)
		self.playlists.set_model(self.playlistsdata)
		self.playlists.set_search_column(1)
		self.playlistsimg = gtk.CellRendererPixbuf()
		self.playlistscell = gtk.CellRendererText()
		self.playlistscell.set_property("ellipsize", pango.ELLIPSIZE_END)
		self.playlistscolumn = gtk.TreeViewColumn()
		self.playlistscolumn.pack_start(self.playlistsimg, False)
		self.playlistscolumn.pack_start(self.playlistscell, True)
		self.playlistscolumn.set_attributes(self.playlistsimg, stock_id=0)
		self.playlistscolumn.set_attributes(self.playlistscell, markup=1)
		self.playlists.append_column(self.playlistscolumn)
		self.playlists_selection.set_mode(gtk.SELECTION_MULTIPLE)
Exemplo n.º 12
0
	def __init__(self, config, window, on_streams_button_press, on_add_item, settings_save, iterate_now, TAB_STREAMS):
		self.config = config
		self.window = window
		self.on_streams_button_press = on_streams_button_press
		self.on_add_item = on_add_item
		self.settings_save = settings_save
		self.iterate_now = iterate_now # XXX Do we really need this?
		self.TAB_STREAMS = TAB_STREAMS

		# Streams tab
		self.streams = ui.treeview()
		self.streams_selection = self.streams.get_selection()
		self.streamswindow = ui.scrollwindow(add=self.streams)
		streamshbox = gtk.HBox()
		streamshbox.pack_start(ui.image(stock=gtk.STOCK_NETWORK), False, False, 2)
		streamshbox.pack_start(ui.label(text=self.TAB_STREAMS), False, False, 2)
		self.streamsevbox = ui.eventbox(add=streamshbox)
		self.streamsevbox.show_all()

		self.streams.connect('button_press_event', self.on_streams_button_press)
		self.streams.connect('row_activated', self.on_streams_activated)
		self.streams.connect('key-press-event', self.on_streams_key_press)

		# Initialize streams data and widget
		self.streamsdata = gtk.ListStore(str, str, str)
		self.streams.set_model(self.streamsdata)
		self.streams.set_search_column(1)
		self.streamsimg = gtk.CellRendererPixbuf()
		self.streamscell = gtk.CellRendererText()
		self.streamscell.set_property("ellipsize", pango.ELLIPSIZE_END)
		self.streamscolumn = gtk.TreeViewColumn()
		self.streamscolumn.pack_start(self.streamsimg, False)
		self.streamscolumn.pack_start(self.streamscell, True)
		self.streamscolumn.set_attributes(self.streamsimg, stock_id=0)
		self.streamscolumn.set_attributes(self.streamscell, markup=1)
		self.streams.append_column(self.streamscolumn)
		self.streams_selection.set_mode(gtk.SELECTION_MULTIPLE)
Exemplo n.º 13
0
    def __init__(
        self,
        config,
        info_image,
        linkcolor,
        on_link_click_cb,
        library_return_search_items,
        get_playing_song,
        TAB_INFO,
        on_image_activate,
        on_image_motion_cb,
        on_image_drop_cb,
        album_return_artist_and_tracks,
        new_tab,
    ):
        self.config = config
        self.info_image = info_image
        self.linkcolor = linkcolor
        self.on_link_click_cb = on_link_click_cb
        self.library_return_search_items = library_return_search_items
        self.get_playing_song = get_playing_song
        self.on_image_activate = on_image_activate
        self.on_image_motion_cb = on_image_motion_cb
        self.on_image_drop_cb = on_image_drop_cb
        self.album_return_artist_and_tracks = album_return_artist_and_tracks

        try:
            self.enc = locale.getpreferredencoding()
        except:
            print "Locale cannot be found; please set your system's locale. Aborting..."
            sys.exit(1)

        self.lyricServer = None
        self.last_info_bitrate = None

        self.info_boxes_in_more = None
        self.info_editlabel = None
        self.info_editlyricslabel = None
        self.info_labels = None
        self.info_left_label = None
        self.info_lyrics = None
        self.info_morelabel = None
        self.info_searchlabel = None
        self.info_tagbox = None
        self.info_type = None

        self.lyricsText = None
        self.albumText = None

        # Info tab
        self.info_area = ui.scrollwindow(shadow=gtk.SHADOW_NONE)

        if self.config.info_art_enlarged:
            self.info_imagebox = ui.eventbox()
        else:
            self.info_imagebox = ui.eventbox(w=152)

        self.info_imagebox.add(self.info_image)

        self.tab = new_tab(self.info_area, gtk.STOCK_JUSTIFY_FILL, TAB_INFO, self.info_area)

        self.info_imagebox.drag_dest_set(
            gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP,
            [("text/uri-list", 0, 80), ("text/plain", 0, 80)],
            gtk.gdk.ACTION_DEFAULT,
        )
        self.info_imagebox.connect("button_press_event", self.on_image_activate)
        self.info_imagebox.connect("drag_motion", self.on_image_motion_cb)
        self.info_imagebox.connect("drag_data_received", self.on_image_drop_cb)

        self.widgets_initialize(self.info_area)
Exemplo n.º 14
0
    def __init__(
        self,
        config,
        client,
        TAB_CURRENT,
        on_current_button_press,
        parse_formatting_colnames,
        parse_formatting,
        connected,
        sonata_loaded,
        songinfo,
        update_statusbar,
        iterate_now,
        libsearchfilter_get_style,
    ):
        self.config = config
        self.client = client
        self.TAB_CURRENT = TAB_CURRENT
        self.on_current_button_press = on_current_button_press
        self.parse_formatting_colnames = parse_formatting_colnames
        self.parse_formatting = parse_formatting
        self.connected = connected
        self.sonata_loaded = sonata_loaded
        self.songinfo = songinfo
        self.update_statusbar = update_statusbar
        self.iterate_now = iterate_now
        self.libsearchfilter_get_style = libsearchfilter_get_style

        self.currentdata = None
        self.filterbox_visible = False
        self.current_update_skip = False
        self.filter_row_mapping = []  # Mapping between filter rows and self.currentdata rows
        self.columnformat = None
        self.columns = None

        self.current_songs = None
        self.filterbox_cmd_buf = None
        self.filterbox_cond = None
        self.filterbox_source = None
        self.column_sorted = (None, gtk.SORT_DESCENDING)  # TreeViewColumn, order
        self.total_time = 0
        self.edit_style_orig = None
        self.resizing_columns = None
        self.prev_boldrow = -1
        self.prevtodo = None
        self.plpos = None
        self.playlist_pos_before_filter = None
        self.sel_rows = None

        # Current tab
        self.current = ui.treeview(reorder=True, search=False, headers=True)
        self.current_selection = self.current.get_selection()
        self.expanderwindow = ui.scrollwindow(shadow=gtk.SHADOW_IN, add=self.current)
        self.filterpattern = ui.entry()
        self.filterbox = gtk.HBox()
        self.filterbox.pack_start(ui.label(text=_("Filter") + ":"), False, False, 5)
        self.filterbox.pack_start(self.filterpattern, True, True, 5)
        filterclosebutton = ui.button(img=ui.image(stock=gtk.STOCK_CLOSE), relief=gtk.RELIEF_NONE)
        self.filterbox.pack_start(filterclosebutton, False, False, 0)
        self.filterbox.set_no_show_all(True)
        self.vbox_current = gtk.VBox()
        self.vbox_current.pack_start(self.expanderwindow, True, True)
        self.vbox_current.pack_start(self.filterbox, False, False, 5)
        playlisthbox = gtk.HBox()
        playlisthbox.pack_start(ui.image(stock=gtk.STOCK_CDROM), False, False, 2)
        playlisthbox.pack_start(ui.label(text=self.TAB_CURRENT), False, False, 2)
        self.playlistevbox = ui.eventbox(add=playlisthbox)
        self.playlistevbox.show_all()

        self.current.connect("drag_data_received", self.on_dnd)
        self.current.connect("row_activated", self.on_current_click)
        self.current.connect("button_press_event", self.on_current_button_press)
        self.current.connect("drag-begin", self.on_current_drag_begin)
        self.current.connect_after("drag-begin", self.dnd_after_current_drag_begin)
        self.current.connect("button_release_event", self.on_current_button_release)

        self.filter_changed_handler = self.filterpattern.connect("changed", self.searchfilter_feed_loop)
        self.filterpattern.connect("activate", self.searchfilter_on_enter)
        self.filterpattern.connect("key-press-event", self.searchfilter_key_pressed)
        filterclosebutton.connect("clicked", self.searchfilter_toggle)

        # Set up current view
        self.initialize_columns()
        self.current_selection.set_mode(gtk.SELECTION_MULTIPLE)
        target_reorder = ("MY_TREE_MODEL_ROW", gtk.TARGET_SAME_WIDGET, 0)
        target_file_managers = ("text/uri-list", 0, 0)
        self.current.enable_model_drag_source(
            gtk.gdk.BUTTON1_MASK, [target_reorder, target_file_managers], gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_DEFAULT
        )
        self.current.enable_model_drag_dest(
            [target_reorder, target_file_managers], gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_DEFAULT
        )
        self.current.connect("drag-data-get", self.dnd_get_data_for_file_managers)
Exemplo n.º 15
0
    def widgets_initialize(self, info_scrollwindow):

        vert_spacing = 1
        horiz_spacing = 2
        margin = 5
        outter_hbox = gtk.HBox()
        outter_vbox = gtk.VBox()

        # Song info
        info_song = ui.expander(
            markup="<b>" + _("Song Info") + "</b>", expand=self.config.info_song_expanded, can_focus=False
        )
        info_song.connect("activate", self.info_expanded, "song")
        inner_hbox = gtk.HBox()

        inner_hbox.pack_start(self.info_imagebox, False, False, horiz_spacing)

        self.info_tagbox = gtk.VBox()

        labels_left = []
        self.info_type = {}
        self.info_labels = []
        self.info_boxes_in_more = []
        labels = [
            (_("Title"), "title", False, "", False),
            (_("Artist"), "artist", True, _("Launch artist in Wikipedia"), False),
            (_("Album"), "album", True, _("Launch album in Wikipedia"), False),
            (_("Date"), "date", False, "", False),
            (_("Track"), "track", False, "", False),
            (_("Genre"), "genre", False, "", False),
            (_("File"), "file", False, "", True),
            (_("Bitrate"), "bitrate", False, "", True),
        ]

        for i, (text, name, link, tooltip, in_more) in enumerate(labels):
            self.info_type[name] = i
            tmphbox = gtk.HBox()
            if in_more:
                self.info_boxes_in_more += [tmphbox]
            tmplabel = ui.label(markup="<b>%s:</b>" % text, y=0)
            if i == 0:
                self.info_left_label = tmplabel
                # Using set_selectable overrides the hover cursor that
                # sonata tries to set for the links, and I can't figure
                # out how to stop that. So we'll disable set_selectable
                # for those labels until it's figured out.
            tmplabel2 = ui.label(wrap=True, y=0, select=not link)
            if link:
                tmpevbox = ui.eventbox(add=tmplabel2)
                self.info_apply_link_signals(tmpevbox, name, tooltip)
            tmphbox.pack_start(tmplabel, False, False, horiz_spacing)
            to_pack = tmpevbox if link else tmplabel2
            tmphbox.pack_start(to_pack, False, False, horiz_spacing)
            self.info_labels += [tmplabel2]
            labels_left += [tmplabel]
            self.info_tagbox.pack_start(tmphbox, False, False, vert_spacing)
        ui.set_widths_equal(labels_left)

        mischbox = gtk.HBox()
        self.info_morelabel = ui.label(y=0)
        moreevbox = ui.eventbox(add=self.info_morelabel)
        self.info_apply_link_signals(moreevbox, "more", _("Toggle extra tags"))
        self.info_editlabel = ui.label(y=0)
        editevbox = ui.eventbox(add=self.info_editlabel)
        self.info_apply_link_signals(editevbox, "edit", _("Edit song tags"))
        mischbox.pack_start(moreevbox, False, False, horiz_spacing)
        mischbox.pack_start(editevbox, False, False, horiz_spacing)

        self.info_tagbox.pack_start(mischbox, False, False, vert_spacing)
        inner_hbox.pack_start(self.info_tagbox, False, False, horiz_spacing)
        info_song.add(inner_hbox)
        outter_vbox.pack_start(info_song, False, False, margin)

        # Lyrics
        self.info_lyrics = ui.expander(
            markup="<b>" + _("Lyrics") + "</b>", expand=self.config.info_lyrics_expanded, can_focus=False
        )
        self.info_lyrics.connect("activate", self.info_expanded, "lyrics")
        lyricsbox = gtk.VBox()
        lyricsbox_top = gtk.HBox()
        self.lyricsText = ui.label(markup=" ", y=0, select=True, wrap=True)
        lyricsbox_top.pack_start(self.lyricsText, True, True, horiz_spacing)
        lyricsbox.pack_start(lyricsbox_top, True, True, vert_spacing)
        lyricsbox_bottom = gtk.HBox()
        self.info_searchlabel = ui.label(y=0)
        self.info_editlyricslabel = ui.label(y=0)
        searchevbox = ui.eventbox(add=self.info_searchlabel)
        editlyricsevbox = ui.eventbox(add=self.info_editlyricslabel)
        self.info_apply_link_signals(searchevbox, "search", _("Search Lyricwiki.org for lyrics"))
        self.info_apply_link_signals(editlyricsevbox, "editlyrics", _("Edit lyrics at Lyricwiki.org"))
        lyricsbox_bottom.pack_start(searchevbox, False, False, horiz_spacing)
        lyricsbox_bottom.pack_start(editlyricsevbox, False, False, horiz_spacing)
        lyricsbox.pack_start(lyricsbox_bottom, False, False, vert_spacing)
        self.info_lyrics.add(lyricsbox)
        outter_vbox.pack_start(self.info_lyrics, False, False, margin)

        # Album info
        info_album = ui.expander(
            markup="<b>" + _("Album Info") + "</b>", expand=self.config.info_album_expanded, can_focus=False
        )
        info_album.connect("activate", self.info_expanded, "album")
        albumbox = gtk.VBox()
        albumbox_top = gtk.HBox()
        self.albumText = ui.label(markup=" ", y=0, select=True, wrap=True)
        albumbox_top.pack_start(self.albumText, False, False, horiz_spacing)
        albumbox.pack_start(albumbox_top, False, False, vert_spacing)
        info_album.add(albumbox)
        outter_vbox.pack_start(info_album, False, False, margin)

        # Finish..
        if not self.config.show_lyrics:
            ui.hide(self.info_lyrics)
        if not self.config.show_covers:
            ui.hide(self.info_imagebox)
            # self.config.info_song_more will be overridden on on_link_click, so
            # store it in a temporary var..
        temp = self.config.info_song_more
        self.on_link_click(moreevbox, None, "more")
        self.config.info_song_more = temp
        if self.config.info_song_more:
            self.on_link_click(moreevbox, None, "more")
        outter_hbox.pack_start(outter_vbox, False, False, margin)
        info_scrollwindow.add_with_viewport(outter_hbox)
Exemplo n.º 16
0
    def widgets_initialize(self, info_scrollwindow):

        vert_spacing = 1
        horiz_spacing = 2
        margin = 5
        outter_hbox = gtk.HBox()
        outter_vbox = gtk.VBox()

        # Song info
        info_song = ui.expander(markup="<b>" + _("Song Info") + "</b>",
                                expand=self.config.info_song_expanded,
                                can_focus=False)
        info_song.connect("activate", self.info_expanded, "song")
        inner_hbox = gtk.HBox()

        inner_hbox.pack_start(self.info_imagebox, False, False, horiz_spacing)

        self.info_tagbox = gtk.VBox()

        labels_left = []
        self.info_type = {}
        self.info_labels = []
        self.info_boxes_in_more = []
        labels_type = [
            'title', 'artist', 'album', 'date', 'track', 'genre', 'file',
            'bitrate'
        ]
        labels_text = [
            _("Title"),
            _("Artist"),
            _("Album"),
            _("Date"),
            _("Track"),
            _("Genre"),
            _("File"),
            _("Bitrate")
        ]
        labels_link = [False, True, True, False, False, False, False, False]
        labels_tooltip = [
            "",
            _("Launch artist in Wikipedia"),
            _("Launch album in Wikipedia"), "", "", "", "", ""
        ]
        labels_in_more = [False, False, False, False, False, False, True, True]
        for i in range(len(labels_text)):
            self.info_type[labels_text[i]] = i
            tmphbox = gtk.HBox()
            if labels_in_more[i]:
                self.info_boxes_in_more += [tmphbox]
            tmplabel = ui.label(markup="<b>" + labels_text[i] + ":</b>", y=0)
            if i == 0:
                self.info_left_label = tmplabel
            if not labels_link[i]:
                tmplabel2 = ui.label(wrap=True, y=0, select=True)
            else:
                # Using set_selectable overrides the hover cursor that sonata
                # tries to set for the links, and I can't figure out how to
                # stop that. So we'll disable set_selectable for these two
                # labels until it's figured out.
                tmplabel2 = ui.label(wrap=True, y=0, select=False)
            if labels_link[i]:
                tmpevbox = ui.eventbox(add=tmplabel2)
                self.info_apply_link_signals(tmpevbox, labels_type[i],
                                             labels_tooltip[i])
            tmphbox.pack_start(tmplabel, False, False, horiz_spacing)
            if labels_link[i]:
                tmphbox.pack_start(tmpevbox, False, False, horiz_spacing)
            else:
                tmphbox.pack_start(tmplabel2, False, False, horiz_spacing)
            self.info_labels += [tmplabel2]
            labels_left += [tmplabel]
            self.info_tagbox.pack_start(tmphbox, False, False, vert_spacing)
        ui.set_widths_equal(labels_left)

        mischbox = gtk.HBox()
        self.info_morelabel = ui.label(y=0)
        moreevbox = ui.eventbox(add=self.info_morelabel)
        self.info_apply_link_signals(moreevbox, 'more', _("Toggle extra tags"))
        self.info_editlabel = ui.label(y=0)
        editevbox = ui.eventbox(add=self.info_editlabel)
        self.info_apply_link_signals(editevbox, 'edit', _("Edit song tags"))
        mischbox.pack_start(moreevbox, False, False, horiz_spacing)
        mischbox.pack_start(editevbox, False, False, horiz_spacing)

        self.info_tagbox.pack_start(mischbox, False, False, vert_spacing)
        inner_hbox.pack_start(self.info_tagbox, False, False, horiz_spacing)
        info_song.add(inner_hbox)
        outter_vbox.pack_start(info_song, False, False, margin)

        # Lyrics
        self.info_lyrics = ui.expander(markup="<b>" + _("Lyrics") + "</b>",
                                       expand=self.config.info_lyrics_expanded,
                                       can_focus=False)
        self.info_lyrics.connect("activate", self.info_expanded, "lyrics")
        lyricsbox = gtk.VBox()
        lyricsbox_top = gtk.HBox()
        self.lyricsText = ui.label(markup=" ", y=0, select=True, wrap=True)
        lyricsbox_top.pack_start(self.lyricsText, True, True, horiz_spacing)
        lyricsbox.pack_start(lyricsbox_top, True, True, vert_spacing)
        lyricsbox_bottom = gtk.HBox()
        self.info_searchlabel = ui.label(y=0)
        self.info_editlyricslabel = ui.label(y=0)
        searchevbox = ui.eventbox(add=self.info_searchlabel)
        editlyricsevbox = ui.eventbox(add=self.info_editlyricslabel)
        self.info_apply_link_signals(searchevbox, 'search',
                                     _("Search Lyricwiki.org for lyrics"))
        self.info_apply_link_signals(editlyricsevbox, 'editlyrics',
                                     _("Edit lyrics at Lyricwiki.org"))
        lyricsbox_bottom.pack_start(searchevbox, False, False, horiz_spacing)
        lyricsbox_bottom.pack_start(editlyricsevbox, False, False,
                                    horiz_spacing)
        lyricsbox.pack_start(lyricsbox_bottom, False, False, vert_spacing)
        self.info_lyrics.add(lyricsbox)
        outter_vbox.pack_start(self.info_lyrics, False, False, margin)

        # Album info
        info_album = ui.expander(markup="<b>" + _("Album Info") + "</b>",
                                 expand=self.config.info_album_expanded,
                                 can_focus=False)
        info_album.connect("activate", self.info_expanded, "album")
        albumbox = gtk.VBox()
        albumbox_top = gtk.HBox()
        self.albumText = ui.label(markup=" ", y=0, select=True, wrap=True)
        albumbox_top.pack_start(self.albumText, False, False, horiz_spacing)
        albumbox.pack_start(albumbox_top, False, False, vert_spacing)
        info_album.add(albumbox)
        outter_vbox.pack_start(info_album, False, False, margin)

        # Finish..
        if not self.config.show_lyrics:
            ui.hide(self.info_lyrics)
        if not self.config.show_covers:
            ui.hide(self.info_imagebox)
        # self.config.info_song_more will be overridden on on_link_click, so
        # store it in a temporary var..
        temp = self.config.info_song_more
        self.on_link_click(moreevbox, None, 'more')
        self.config.info_song_more = temp
        if self.config.info_song_more:
            self.on_link_click(moreevbox, None, 'more')
        outter_hbox.pack_start(outter_vbox, False, False, margin)
        info_scrollwindow.add_with_viewport(outter_hbox)
Exemplo n.º 17
0
    def __init__(self, config, client, TAB_CURRENT, on_current_button_press,
                 parse_formatting_colnames, parse_formatting, connected,
                 sonata_loaded, songinfo, update_statusbar, iterate_now,
                 libsearchfilter_get_style):
        self.config = config
        self.client = client
        self.TAB_CURRENT = TAB_CURRENT
        self.on_current_button_press = on_current_button_press
        self.parse_formatting_colnames = parse_formatting_colnames
        self.parse_formatting = parse_formatting
        self.connected = connected
        self.sonata_loaded = sonata_loaded
        self.songinfo = songinfo
        self.update_statusbar = update_statusbar
        self.iterate_now = iterate_now
        self.libsearchfilter_get_style = libsearchfilter_get_style

        self.currentdata = None
        self.filterbox_visible = False
        self.current_update_skip = False
        self.filter_row_mapping = [
        ]  # Mapping between filter rows and self.currentdata rows
        self.columnformat = None
        self.columns = None

        self.current_songs = None
        self.filterbox_cmd_buf = None
        self.filterbox_cond = None
        self.filterbox_source = None
        self.column_sorted = (None, gtk.SORT_DESCENDING
                              )  # TreeViewColumn, order
        self.total_time = 0
        self.edit_style_orig = None
        self.resizing_columns = None
        self.prev_boldrow = -1
        self.prevtodo = None
        self.plpos = None
        self.playlist_pos_before_filter = None
        self.sel_rows = None

        # Current tab
        self.current = ui.treeview(reorder=True, search=False, headers=True)
        self.current_selection = self.current.get_selection()
        self.expanderwindow = ui.scrollwindow(shadow=gtk.SHADOW_IN,
                                              add=self.current)
        self.filterpattern = ui.entry()
        self.filterbox = gtk.HBox()
        self.filterbox.pack_start(ui.label(text=_("Filter") + ":"), False,
                                  False, 5)
        self.filterbox.pack_start(self.filterpattern, True, True, 5)
        filterclosebutton = ui.button(img=ui.image(stock=gtk.STOCK_CLOSE),
                                      relief=gtk.RELIEF_NONE)
        self.filterbox.pack_start(filterclosebutton, False, False, 0)
        self.filterbox.set_no_show_all(True)
        self.vbox_current = gtk.VBox()
        self.vbox_current.pack_start(self.expanderwindow, True, True)
        self.vbox_current.pack_start(self.filterbox, False, False, 5)
        playlisthbox = gtk.HBox()
        playlisthbox.pack_start(ui.image(stock=gtk.STOCK_CDROM), False, False,
                                2)
        playlisthbox.pack_start(ui.label(text=self.TAB_CURRENT), False, False,
                                2)
        self.playlistevbox = ui.eventbox(add=playlisthbox)
        self.playlistevbox.show_all()

        self.current.connect('drag_data_received', self.on_dnd)
        self.current.connect('row_activated', self.on_current_click)
        self.current.connect('button_press_event',
                             self.on_current_button_press)
        self.current.connect('drag-begin', self.on_current_drag_begin)
        self.current.connect_after('drag-begin',
                                   self.dnd_after_current_drag_begin)
        self.current.connect('button_release_event',
                             self.on_current_button_release)

        self.filter_changed_handler = self.filterpattern.connect(
            'changed', self.searchfilter_feed_loop)
        self.filterpattern.connect('activate', self.searchfilter_on_enter)
        self.filterpattern.connect('key-press-event',
                                   self.searchfilter_key_pressed)
        filterclosebutton.connect('clicked', self.searchfilter_toggle)

        # Set up current view
        self.initialize_columns()
        self.current_selection.set_mode(gtk.SELECTION_MULTIPLE)
        target_reorder = ('MY_TREE_MODEL_ROW', gtk.TARGET_SAME_WIDGET, 0)
        target_file_managers = ('text/uri-list', 0, 0)
        self.current.enable_model_drag_source(
            gtk.gdk.BUTTON1_MASK, [target_reorder, target_file_managers],
            gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_DEFAULT)
        self.current.enable_model_drag_dest(
            [target_reorder, target_file_managers],
            gtk.gdk.ACTION_MOVE | gtk.gdk.ACTION_DEFAULT)
        self.current.connect('drag-data-get',
                             self.dnd_get_data_for_file_managers)
Exemplo n.º 18
0
	def __init__(self, config, client, artwork, TAB_LIBRARY, album_filename, settings_save, filtering_entry_make_red, filtering_entry_revert_color, filter_key_pressed, on_add_item, parse_formatting, connected, on_library_button_press, on_library_search_text_click):
		self.artwork = artwork
		self.config = config
		self.client = client
		self.librarymenu = None # cyclic dependency, set later
		self.TAB_LIBRARY = TAB_LIBRARY
		self.album_filename = album_filename
		self.settings_save = settings_save
		self.filtering_entry_make_red = filtering_entry_make_red
		self.filtering_entry_revert_color = filtering_entry_revert_color
		self.filter_key_pressed = filter_key_pressed
		self.on_add_item = on_add_item
		self.parse_formatting = parse_formatting
		self.connected = connected
		self.on_library_button_press = on_library_button_press
		self.on_library_search_text_click = on_library_search_text_click

		self.NOTAG = _("Untagged")
		self.VAstr = _("Various Artists")
		self.search_terms = [_('Artist'), _('Title'), _('Album'), _('Genre'), _('Filename'), _('Everything')]
		self.search_terms_mpd = ['artist', 'title', 'album', 'genre', 'file', 'any']

		self.libfilterbox_cmd_buf = None
		self.libfilterbox_cond = None
		self.libfilterbox_source = None

		self.prevlibtodo_base = None
		self.prevlibtodo_base_results = None
		self.prevlibtodo = None

		self.save_timeout = None
		self.libsearch_last_tooltip = None

		self.lib_view_filesystem_cache = None
		self.lib_view_artist_cache = None
		self.lib_view_genre_cache = None
		self.lib_view_album_cache = None
		self.lib_list_genres = None
		self.lib_list_artists = None
		self.lib_list_albums = None
		self.lib_list_years = None
		self.view_caches_reset()

		self.libraryvbox = gtk.VBox()
		self.library = ui.treeview()
		self.library_selection = self.library.get_selection()
		expanderwindow2 = ui.scrollwindow(add=self.library)
		self.searchbox = gtk.HBox()
		self.searchcombo = ui.combo(items=self.search_terms)
		self.searchtext = ui.entry()
		self.searchbutton = ui.button(text=_('_End Search'), img=ui.image(stock=gtk.STOCK_CLOSE), h=self.searchcombo.size_request()[1])
		self.searchbutton.set_no_show_all(True)
		self.searchbutton.hide()
		self.libraryview = ui.button(relief=gtk.RELIEF_NONE)
		self.libraryview.set_tooltip_text(_("Library browsing view"))
		self.library_view_assign_image()
		self.searchbox.pack_start(self.libraryview, False, False, 1)
		self.searchbox.pack_start(gtk.VSeparator(), False, False, 0)
		self.searchbox.pack_start(self.searchcombo, False, False, 2)
		self.searchbox.pack_start(self.searchtext, True, True, 2)
		self.searchbox.pack_start(self.searchbutton, False, False, 2)
		self.libraryvbox.pack_start(expanderwindow2, True, True, 2)
		self.libraryvbox.pack_start(self.searchbox, False, False, 2)
		libraryhbox = gtk.HBox()
		libraryhbox.pack_start(ui.image(stock=gtk.STOCK_HARDDISK), False, False, 2)
		libraryhbox.pack_start(ui.label(text=self.TAB_LIBRARY), False, False, 2)
		self.libraryevbox = ui.eventbox(add=libraryhbox)
		self.libraryevbox.show_all()

		# Assign some pixbufs for use in self.library
		self.openpb = self.library.render_icon(gtk.STOCK_OPEN, gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.harddiskpb = self.library.render_icon(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.albumpb = gtk.gdk.pixbuf_new_from_file_at_size(album_filename, consts.LIB_COVER_SIZE, consts.LIB_COVER_SIZE)
		self.genrepb = self.library.render_icon('gtk-orientation-portrait', gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.artistpb = self.library.render_icon('artist', gtk.ICON_SIZE_LARGE_TOOLBAR)
		self.sonatapb = self.library.render_icon('sonata', gtk.ICON_SIZE_MENU)

		self.library.connect('row_activated', self.on_library_row_activated)
		self.library.connect('button_press_event', self.on_library_button_press)
		self.library.connect('key-press-event', self.on_library_key_press)
		self.library.connect('query-tooltip', self.on_library_query_tooltip)
		expanderwindow2.connect('scroll-event', self.on_library_scrolled)
		self.libraryview.connect('clicked', self.library_view_popup)
		self.searchtext.connect('button_press_event', self.on_library_search_text_click)
		self.searchtext.connect('key-press-event', self.libsearchfilter_key_pressed)
		self.searchtext.connect('activate', self.libsearchfilter_on_enter)
		self.searchbutton.connect('clicked', self.on_search_end)

		self.libfilter_changed_handler = self.searchtext.connect('changed', self.libsearchfilter_feed_loop)
		searchcombo_changed_handler = self.searchcombo.connect('changed', self.on_library_search_combo_change)

		# Initialize library data and widget
		self.libraryposition = {}
		self.libraryselectedpath = {}
		self.searchcombo.handler_block(searchcombo_changed_handler)
		self.searchcombo.set_active(self.config.last_search_num)
		self.searchcombo.handler_unblock(searchcombo_changed_handler)
		self.librarydata = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
		self.library.set_model(self.librarydata)
		self.library.set_search_column(2)
		self.librarycell = gtk.CellRendererText()
		self.librarycell.set_property("ellipsize", pango.ELLIPSIZE_END)
		self.libraryimg = gtk.CellRendererPixbuf()
		self.librarycolumn = gtk.TreeViewColumn()
		self.librarycolumn.pack_start(self.libraryimg, False)
		self.librarycolumn.pack_start(self.librarycell, True)
		self.librarycolumn.set_attributes(self.libraryimg, pixbuf=0)
		self.librarycolumn.set_attributes(self.librarycell, markup=2)
		self.librarycolumn.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
		self.library.append_column(self.librarycolumn)
		self.library_selection.set_mode(gtk.SELECTION_MULTIPLE)
Exemplo n.º 19
0
	def widgets_initialize(self, info_scrollwindow):

		vert_spacing = 1
		horiz_spacing = 2
		margin = 5
		outter_hbox = gtk.HBox()
		outter_vbox = gtk.VBox()

		# Song info
		info_song = ui.expander(markup="<b>" + _("Song Info") + "</b>", expand=self.config.info_song_expanded, can_focus=False)
		info_song.connect("activate", self.info_expanded, "song")
		inner_hbox = gtk.HBox()

		inner_hbox.pack_start(self.info_imagebox, False, False, horiz_spacing)

		self.info_tagbox = gtk.VBox()

		labels_left = []
		self.info_type = {}
		self.info_labels = []
		self.info_boxes_in_more = []
		labels_type = ['title', 'artist', 'album', 'date', 'track', 'genre', 'file', 'bitrate']
		labels_text = [_("Title"), _("Artist"), _("Album"), _("Date"), _("Track"), _("Genre"), _("File"), _("Bitrate")]
		labels_link = [False, True, True, False, False, False, False, False]
		labels_tooltip = ["", _("Launch artist in Wikipedia"), _("Launch album in Wikipedia"), "", "", "", "", ""]
		labels_in_more = [False, False, False, False, False, False, True, True]
		for i in range(len(labels_text)):
			self.info_type[labels_text[i]] = i
			tmphbox = gtk.HBox()
			if labels_in_more[i]:
				self.info_boxes_in_more += [tmphbox]
			tmplabel = ui.label(markup="<b>" + labels_text[i] + ":</b>", y=0)
			if i == 0:
				self.info_left_label = tmplabel
			if not labels_link[i]:
				tmplabel2 = ui.label(wrap=True, y=0, select=True)
			else:
				# Using set_selectable overrides the hover cursor that sonata
				# tries to set for the links, and I can't figure out how to
				# stop that. So we'll disable set_selectable for these two
				# labels until it's figured out.
				tmplabel2 = ui.label(wrap=True, y=0, select=False)
			if labels_link[i]:
				tmpevbox = ui.eventbox(add=tmplabel2)
				self.info_apply_link_signals(tmpevbox, labels_type[i], labels_tooltip[i])
			tmphbox.pack_start(tmplabel, False, False, horiz_spacing)
			if labels_link[i]:
				tmphbox.pack_start(tmpevbox, False, False, horiz_spacing)
			else:
				tmphbox.pack_start(tmplabel2, False, False, horiz_spacing)
			self.info_labels += [tmplabel2]
			labels_left += [tmplabel]
			self.info_tagbox.pack_start(tmphbox, False, False, vert_spacing)
		ui.set_widths_equal(labels_left)
		
		mischbox = gtk.HBox()
		self.info_morelabel = ui.label(y=0)
		moreevbox = ui.eventbox(add=self.info_morelabel)
		self.info_apply_link_signals(moreevbox, 'more', _("Toggle extra tags"))
		self.info_editlabel = ui.label(y=0)
		editevbox = ui.eventbox(add=self.info_editlabel)
		self.info_apply_link_signals(editevbox, 'edit', _("Edit song tags"))
		mischbox.pack_start(moreevbox, False, False, horiz_spacing)
		mischbox.pack_start(editevbox, False, False, horiz_spacing)

		self.info_tagbox.pack_start(mischbox, False, False, vert_spacing)
		inner_hbox.pack_start(self.info_tagbox, False, False, horiz_spacing)
		info_song.add(inner_hbox)
		outter_vbox.pack_start(info_song, False, False, margin)
		
		# Lyrics
		self.info_lyrics = ui.expander(markup="<b>" + _("Lyrics") + "</b>", expand=self.config.info_lyrics_expanded, can_focus=False)
		self.info_lyrics.connect("activate", self.info_expanded, "lyrics")
		lyricsbox = gtk.VBox()
		lyricsbox_top = gtk.HBox()
		self.lyricsText = ui.label(markup=" ", y=0, select=True, wrap=True)
		lyricsbox_top.pack_start(self.lyricsText, True, True, horiz_spacing)
		lyricsbox.pack_start(lyricsbox_top, True, True, vert_spacing)
		lyricsbox_bottom = gtk.HBox()
		self.info_searchlabel = ui.label(y=0)
		self.info_editlyricslabel = ui.label(y=0)
		searchevbox = ui.eventbox(add=self.info_searchlabel)
		editlyricsevbox = ui.eventbox(add=self.info_editlyricslabel)
		self.info_apply_link_signals(searchevbox, 'search', _("Search Lyricwiki.org for lyrics"))
		self.info_apply_link_signals(editlyricsevbox, 'editlyrics', _("Edit lyrics at Lyricwiki.org"))
		lyricsbox_bottom.pack_start(searchevbox, False, False, horiz_spacing)
		lyricsbox_bottom.pack_start(editlyricsevbox, False, False, horiz_spacing)
		lyricsbox.pack_start(lyricsbox_bottom, False, False, vert_spacing)
		self.info_lyrics.add(lyricsbox)
		outter_vbox.pack_start(self.info_lyrics, False, False, margin)
		
		# Album info
		info_album = ui.expander(markup="<b>" + _("Album Info") + "</b>", expand=self.config.info_album_expanded, can_focus=False)
		info_album.connect("activate", self.info_expanded, "album")
		albumbox = gtk.VBox()
		albumbox_top = gtk.HBox()
		self.albumText = ui.label(markup=" ", y=0, select=True, wrap=True)
		albumbox_top.pack_start(self.albumText, False, False, horiz_spacing)
		albumbox.pack_start(albumbox_top, False, False, vert_spacing)
		info_album.add(albumbox)
		outter_vbox.pack_start(info_album, False, False, margin)
		
		# Finish..
		if not self.config.show_lyrics:
			ui.hide(self.info_lyrics)
		if not self.config.show_covers:
			ui.hide(self.info_imagebox)
		# self.config.info_song_more will be overridden on on_link_click, so
		# store it in a temporary var..
		temp = self.config.info_song_more
		self.on_link_click(moreevbox, None, 'more')
		self.config.info_song_more = temp
		if self.config.info_song_more:
			self.on_link_click(moreevbox, None, 'more')
		outter_hbox.pack_start(outter_vbox, False, False, margin)
		info_scrollwindow.add_with_viewport(outter_hbox)
Exemplo n.º 20
0
    def __init__(self, config, find_path, is_lang_rtl,
                 info_imagebox_get_size_request, schedule_gc_collect,
                 target_image_filename, imagelist_append,
                 remotefilelist_append, notebook_get_allocation,
                 allow_art_search, status_is_play_or_pause, album_filename,
                 get_current_song_text):
        self.config = config
        self.album_filename = album_filename

        # constants from main
        self.is_lang_rtl = is_lang_rtl

        # callbacks to main XXX refactor to clear this list
        self.info_imagebox_get_size_request = info_imagebox_get_size_request
        self.schedule_gc_collect = schedule_gc_collect
        self.target_image_filename = target_image_filename
        self.imagelist_append = imagelist_append
        self.remotefilelist_append = remotefilelist_append
        self.notebook_get_allocation = notebook_get_allocation
        self.allow_art_search = allow_art_search
        self.status_is_play_or_pause = status_is_play_or_pause
        self.get_current_song_text = get_current_song_text

        # local pixbufs, image file names
        self.sonatacd = find_path('sonatacd.png')
        self.sonatacd_large = find_path('sonatacd_large.png')
        self.casepb = gtk.gdk.pixbuf_new_from_file(
            find_path('sonata-case.png'))
        self.albumpb = None
        self.currentpb = None

        # local UI widgets provided to main by getter methods
        self.albumimage = ui.image()
        self.albumimage.set_from_file(self.sonatacd)

        self.trayalbumimage1 = ui.image(w=51, h=77, x=1)
        self.trayalbumeventbox = ui.eventbox(w=59,
                                             h=90,
                                             add=self.trayalbumimage1,
                                             state=gtk.STATE_SELECTED,
                                             visible=True)

        self.trayalbumimage2 = ui.image(w=26, h=77)

        self.fullscreenalbumimage = ui.image(w=consts.FULLSCREEN_COVER_SIZE,
                                             h=consts.FULLSCREEN_COVER_SIZE,
                                             x=1)
        self.fullscreenalbumlabel = ui.label(x=0.5)
        self.fullscreenalbumlabel2 = ui.label(x=0.5)
        self.fullscreen_cover_art_reset_image()
        self.fullscreen_cover_art_reset_text()

        self.info_image = ui.image(y=0)
        self.info_image.set_from_file(self.sonatacd_large)

        # local version of Main.songinfo mirrored by update_songinfo
        self.songinfo = None

        # local state
        self.lastalbumart = None
        self.single_img_in_dir = None
        self.misc_img_in_dir = None
        self.stop_art_update = False
        self.downloading_image = False
        self.lib_art_cond = None

        # local artwork, cache for library
        self.lib_model = None
        self.lib_art_rows_local = []
        self.lib_art_rows_remote = []
        self.lib_art_pb_size = 0
        self.cache = {}

        self.artwork_load_cache()