Exemplo n.º 1
0
 def show_website(self, _dialog, link):
     if not misc.browser_load(link, self.config.url_browser,
                              self.parent_window):
         ui.show_msg(self.about_dialog, _(('Unable to launch a '
                                          'suitable browser.')),
                     _('Launch Browser'), 'browserLoadError',
                     gtk.BUTTONS_CLOSE)
Exemplo n.º 2
0
    def tags_win_response(self, window, response, tags, entries, entries_names):
        if response == gtk.RESPONSE_REJECT:
            self.tags_win_hide(window, None, tags)
        elif response == gtk.RESPONSE_ACCEPT:
            window.action_area.set_sensitive(False)
            while window.action_area.get_property("sensitive") or gtk.events_pending():
                gtk.main_iteration()
            filetag = tagpy.FileRef(tags[self.tagnum]['fullpath'])
            tag = filetag.tag()
            # Set tag fields according to entry text
            for entry, field in zip(entries, entries_names):
                tag_value = entry.get_text().strip()
                if field in ('year', 'track'):
                    if len(tag_value) == 0:
                        tag_value = '0'
                    tag_value = int(tag_value)
                if field is 'comment':
                    if len(tag_value) == 0:
                        tag_value = ' '
                setattr(tag, field, tag_value)

            save_success = filetag.save()
            if not (save_success): # FIXME: was (save_success and self.conn and self.status):
                ui.show_msg(self.window, _("Unable to save tag to music file."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            if self.tags_next_tag(tags):
                # Next file:
                self.tags_win_update(window, tags, entries, entries_names)
            else:
                # No more (valid) files:
                self.tagnum = self.tagnum + 1 # To ensure we update the last file in tags_mpd_update
                self.tags_win_hide(window, None, tags)
Exemplo n.º 3
0
	def _window_response(self, window, response):
		if response == gtk.RESPONSE_CLOSE:
			self.last_tab = self.prefsnotebook.get_current_page()
			#XXX: These two are probably never triggered
			if self.config.show_lyrics and self.config.lyrics_location != consts.LYRICS_LOCATION_HOME:
				if not os.path.isdir(misc.file_from_utf8(self.config.musicdir[self.config.profile_num])):
					ui.show_msg(self.window, _("To save lyrics to the music file's directory, you must specify a valid music directory."), _("Music Dir Verification"), 'musicdirVerificationError', gtk.BUTTONS_CLOSE)
					# Set music_dir entry focused:
					self.prefsnotebook.set_current_page(0)
					self.direntry.grab_focus()
					return
			if self.config.show_covers and self.config.art_location != consts.ART_LOCATION_HOMECOVERS:
				if not os.path.isdir(misc.file_from_utf8(self.config.musicdir[self.config.profile_num])):
					ui.show_msg(self.window, _("To save artwork to the music file's directory, you must specify a valid music directory."), _("Music Dir Verification"), 'musicdirVerificationError', gtk.BUTTONS_CLOSE)
					# Set music_dir entry focused:
					self.prefsnotebook.set_current_page(0)
					self.direntry.grab_focus()
					return
			if not self.using_mpd_env_vars:
				if self.prev_host != self.config.host[self.config.profile_num] or self.prev_port != self.config.port[self.config.profile_num] or self.prev_password != self.config.password[self.config.profile_num]:
					# Try to connect if mpd connection info has been updated:
					ui.change_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
					self.reconnect()
			self.settings_save()
			self.populate_profiles_for_menu()
			ui.change_cursor(None)
		window.destroy()
Exemplo n.º 4
0
	def _window_response(self, window, response):
		if response == gtk.RESPONSE_CLOSE:
			self.last_tab = self.prefsnotebook.get_current_page()
			#XXX: These two are probably never triggered
			if self.config.show_lyrics and self.config.lyrics_location != consts.LYRICS_LOCATION_HOME:
				if not os.path.isdir(misc.file_from_utf8(self.config.musicdir[self.config.profile_num])):
					ui.show_msg(self.window, _("To save lyrics to the music file's directory, you must specify a valid music directory."), _("Music Dir Verification"), 'musicdirVerificationError', gtk.BUTTONS_CLOSE)
					# Set music_dir entry focused:
					self.prefsnotebook.set_current_page(0)
					self.direntry.grab_focus()
					return
			if self.config.show_covers and self.config.art_location != consts.ART_LOCATION_HOMECOVERS:
				if not os.path.isdir(misc.file_from_utf8(self.config.musicdir[self.config.profile_num])):
					ui.show_msg(self.window, _("To save artwork to the music file's directory, you must specify a valid music directory."), _("Music Dir Verification"), 'musicdirVerificationError', gtk.BUTTONS_CLOSE)
					# Set music_dir entry focused:
					self.prefsnotebook.set_current_page(0)
					self.direntry.grab_focus()
					return
			if not self.using_mpd_env_vars:
				if self.prev_host != self.config.host[self.config.profile_num] or self.prev_port != self.config.port[self.config.profile_num] or self.prev_password != self.config.password[self.config.profile_num]:
					# Try to connect if mpd connection info has been updated:
					ui.change_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
					self.reconnect()
			self.settings_save()
			self.populate_profiles_for_menu()
			ui.change_cursor(None)
		window.destroy()
Exemplo n.º 5
0
 def show_website(self, _dialog, link):
     if not misc.browser_load(link, self.config.url_browser,
                              self.parent_window):
         ui.show_msg(self.about_dialog,
                     _('Unable to launch a suitable browser.'),
                     _('Launch Browser'), 'browserLoadError',
                     gtk.BUTTONS_CLOSE)
Exemplo n.º 6
0
	def on_streams_new(self, _action, stream_num=-1):
		if stream_num > -1:
			edit_mode = True
		else:
			edit_mode = False
		# Prompt user for playlist name:
		dialog = ui.dialog(title=None, parent=self.window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), role="streamsNew")
		if edit_mode:
			dialog.set_title(_("Edit Stream"))
		else:
			dialog.set_title(_("New Stream"))
		hbox = gtk.HBox()
		namelabel = ui.label(text=_('Stream name') + ':')
		hbox.pack_start(namelabel, False, False, 5)
		nameentry = ui.entry()
		if edit_mode:
			nameentry.set_text(self.config.stream_names[stream_num])
		hbox.pack_start(nameentry, True, True, 5)
		hbox2 = gtk.HBox()
		urllabel = ui.label(text=_('Stream URL') + ':')
		hbox2.pack_start(urllabel, False, False, 5)
		urlentry = ui.entry()
		if edit_mode:
			urlentry.set_text(self.config.stream_uris[stream_num])
		hbox2.pack_start(urlentry, True, True, 5)
		ui.set_widths_equal([namelabel, urllabel])
		dialog.vbox.pack_start(hbox)
		dialog.vbox.pack_start(hbox2)
		ui.show(dialog.vbox)
		response = dialog.run()
		if response == gtk.RESPONSE_ACCEPT:
			name = nameentry.get_text()
			uri = urlentry.get_text()
			if len(name.decode('utf-8')) > 0 and len(uri.decode('utf-8')) > 0:
				# Make sure this stream name doesn't already exit:
				i = 0
				for item in self.config.stream_names:
					# Prevent a name collision in edit_mode..
					if not edit_mode or (edit_mode and i != stream_num):
						if item == name:
							dialog.destroy()
							if ui.show_msg(self.window, _("A stream with this name already exists. Would you like to replace it?"), _("New Stream"), 'newStreamError', gtk.BUTTONS_YES_NO) == gtk.RESPONSE_YES:
								# Pop existing stream:
								self.config.stream_names.pop(i)
								self.config.stream_uris.pop(i)
							else:
								return
					i = i + 1
				if edit_mode:
					self.config.stream_names.pop(stream_num)
					self.config.stream_uris.pop(stream_num)
				self.config.stream_names.append(name)
				self.config.stream_uris.append(uri)
				self.populate()
				self.settings_save()
		dialog.destroy()
		self.iterate_now()
Exemplo n.º 7
0
	def on_streams_new(self, _action, stream_num=-1):
		if stream_num > -1:
			edit_mode = True
		else:
			edit_mode = False
		# Prompt user for playlist name:
		dialog = ui.dialog(title=None, parent=self.window, flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT), role="streamsNew")
		if edit_mode:
			dialog.set_title(_("Edit Stream"))
		else:
			dialog.set_title(_("New Stream"))
		hbox = gtk.HBox()
		namelabel = ui.label(text=_('Stream name:'))
		hbox.pack_start(namelabel, False, False, 5)
		nameentry = ui.entry()
		if edit_mode:
			nameentry.set_text(self.config.stream_names[stream_num])
		hbox.pack_start(nameentry, True, True, 5)
		hbox2 = gtk.HBox()
		urllabel = ui.label(text=_('Stream URL:'))
		hbox2.pack_start(urllabel, False, False, 5)
		urlentry = ui.entry()
		if edit_mode:
			urlentry.set_text(self.config.stream_uris[stream_num])
		hbox2.pack_start(urlentry, True, True, 5)
		ui.set_widths_equal([namelabel, urllabel])
		dialog.vbox.pack_start(hbox)
		dialog.vbox.pack_start(hbox2)
		ui.show(dialog.vbox)
		response = dialog.run()
		if response == gtk.RESPONSE_ACCEPT:
			name = nameentry.get_text()
			uri = urlentry.get_text()
			if len(name.decode('utf-8')) > 0 and len(uri.decode('utf-8')) > 0:
				# Make sure this stream name doesn't already exit:
				i = 0
				for item in self.config.stream_names:
					# Prevent a name collision in edit_mode..
					if not edit_mode or (edit_mode and i != stream_num):
						if item == name:
							dialog.destroy()
							if ui.show_msg(self.window, _("A stream with this name already exists. Would you like to replace it?"), _("New Stream"), 'newStreamError', gtk.BUTTONS_YES_NO) == gtk.RESPONSE_YES:
								# Pop existing stream:
								self.config.stream_names.pop(i)
								self.config.stream_uris.pop(i)
							else:
								return
					i = i + 1
				if edit_mode:
					self.config.stream_names.pop(stream_num)
					self.config.stream_uris.pop(stream_num)
				self.config.stream_names.append(name)
				self.config.stream_uris.append(uri)
				self.populate()
				self.settings_save()
		dialog.destroy()
Exemplo n.º 8
0
 def on_playlist_menu_click(self, action):
     plname = misc.unescape_html(action.get_name().replace("Playlist: ", ""))
     response = ui.show_msg(self.window, _("Would you like to replace the existing playlist or append these songs?"), _("Existing Playlist"), "existingPlaylist", (_("Replace playlist"), 1, _("Append songs"), 2), default=self.config.existing_playlist_option)
     if response == 1: # Overwrite
         self.config.existing_playlist_option = response
         mpdh.call(self.client, 'playlistclear', plname)
         self.add_selected_to_playlist(plname)
     elif response == 2: # Append songs:
         self.config.existing_playlist_option = response
         self.add_selected_to_playlist(plname)
Exemplo n.º 9
0
	def on_playlist_menu_click(self, action):
		plname = misc.unescape_html(action.get_name().replace("Playlist: ", ""))
		response = ui.show_msg(self.window, _("Would you like to replace the existing playlist or append these songs?"), _("Existing Playlist"), "existingPlaylist", (_("Replace playlist"), 1, _("Append songs"), 2), default=self.config.existing_playlist_option)
		if response == 1: # Overwrite
			self.config.existing_playlist_option = response
			self.playlist_create(plname)
		elif response == 2: # Append songs:
			self.config.existing_playlist_option = response
			mpdh.call(self.client, 'command_list_ok_begin')
			for song in self.get_current_songs():
				mpdh.call(self.client, 'playlistadd', plname, mpdh.get(song, 'file'))
			mpdh.call(self.client, 'command_list_end')
		return
Exemplo n.º 10
0
	def playlist_name_exists(self, title, role, plname, skip_plname=""):
		# If the playlist already exists, and the user does not want to replace it, return True; In
		# all other cases, return False
		playlists = mpdh.call(self.client, 'listplaylists')
		if playlists is None:
			playlists = mpdh.call(self.client, 'lsinfo')
		for item in playlists:
			if 'playlist' in item:
				if mpdh.get(item, 'playlist') == plname and plname != skip_plname:
					if ui.show_msg(self.window, _("A playlist with this name already exists. Would you like to replace it?"), title, role, gtk.BUTTONS_YES_NO) == gtk.RESPONSE_YES:
						return False
					else:
						return True
		return False
Exemplo n.º 11
0
 def playlist_name_exists(self, title, role, plname, skip_plname=""):
     # If the playlist already exists, and the user does not want to replace it, return True; In
     # all other cases, return False
     playlists = mpdh.call(self.client, 'listplaylists')
     if playlists is None:
         playlists = mpdh.call(self.client, 'lsinfo')
     for item in playlists:
         if 'playlist' in item:
             if mpdh.get(item, 'playlist') == plname and plname != skip_plname:
                 if ui.show_msg(self.window, _("A playlist with this name already exists. Would you like to replace it?"), title, role, gtk.BUTTONS_YES_NO) == gtk.RESPONSE_YES:
                     return False
                 else:
                     return True
     return False
Exemplo n.º 12
0
 def on_playlist_menu_click(self, action):
     plname = misc.unescape_html(action.get_name().replace(
         "Playlist: ", ""))
     response = ui.show_msg(
         self.window,
         _("Would you like to replace the existing playlist or append these songs?"
           ),
         _("Existing Playlist"),
         "existingPlaylist",
         (_("Replace playlist"), 1, _("Append songs"), 2),
         default=self.config.existing_playlist_option)
     if response == 1:  # Overwrite
         self.config.existing_playlist_option = response
         self.playlist_create(plname)
     elif response == 2:  # Append songs:
         self.config.existing_playlist_option = response
         mpdh.call(self.client, 'command_list_ok_begin')
         for song in self.get_current_songs():
             mpdh.call(self.client, 'playlistadd', plname,
                       mpdh.get(song, 'file'))
         mpdh.call(self.client, 'command_list_end')
     return
Exemplo n.º 13
0
	def plugin_configure(self, _widget):
		plugin = self.plugin_get_selected()
		ui.show_msg(self.prefswindow, "Nothing yet implemented.", "Configure", "pluginConfigure", gtk.BUTTONS_CLOSE)
Exemplo n.º 14
0
    def on_tags_edit(self, files, temp_mpdpaths, music_dir):
        """Display the editing dialog"""
        # Try loading module
        global tagpy
        if tagpy is None:
            try:
                import tagpy
            except ImportError:
                ui.show_msg(self.window, _("Taglib and/or tagpy not found, tag editing support disabled."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
                ui.change_cursor(None)
                return
            # Set default tag encoding to utf8.. fixes some reported bugs.
            import tagpy.id3v2 as id3v2
            id3v2.FrameFactory.instance().setDefaultTextEncoding(tagpy.StringType.UTF8)

        # Make sure tagpy is at least 0.91
        if hasattr(tagpy.Tag.title, '__call__'):
            ui.show_msg(self.window, _("Tagpy version < 0.91. Please upgrade to a newer version, tag editing support disabled."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

        if not os.path.isdir(misc.file_from_utf8(music_dir)):
            ui.show_msg(self.window, _("The path %s does not exist. Please specify a valid music directory in preferences.") % music_dir, _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

                # XXX file list was created here

        if len(files) == 0:
            ui.change_cursor(None)
            return

        # Initialize:
        self.tagnum = -1

        tags = [{'title':'', 'artist':'', 'album':'', 'year':'', 'track':'',
             'genre':'', 'comment':'', 'title-changed':False,
             'artist-changed':False, 'album-changed':False,
             'year-changed':False, 'track-changed':False,
             'genre-changed':False, 'comment-changed':False,
             'fullpath':misc.file_from_utf8(filename),
             'mpdpath':path}
            for filename, path in zip(files, temp_mpdpaths)]

        if not os.path.exists(tags[0]['fullpath']):
            ui.change_cursor(None)
            ui.show_msg(self.window, _("File '%s' not found. Please specify a valid music directory in preferences.") % tags[0]['fullpath'], _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            return
        if not self.tags_next_tag(tags):
            ui.change_cursor(None)
            ui.show_msg(self.window, _("No music files with editable tags found."), _("Edit Tags"), 'editTagsError', gtk.BUTTONS_CLOSE, response_cb=ui.dialog_destroy)
            return
        editwindow = ui.dialog(parent=self.window, flags=gtk.DIALOG_MODAL, role='editTags', resizable=False, separator=False)
        editwindow.set_size_request(375, -1)
        table = gtk.Table(9, 2, False)
        table.set_row_spacings(2)
        self.filelabel = ui.label(select=True, wrap=True)
        filehbox = gtk.HBox()
        sonataicon = ui.image(stock='sonata', stocksize=gtk.ICON_SIZE_DND, x=1)
        expandbutton = ui.button(" ")
        self.set_expandbutton_state(expandbutton)
        expandvbox = gtk.VBox()
        expandvbox.pack_start(ui.label(), True, True)
        expandvbox.pack_start(expandbutton, False, False)
        expandvbox.pack_start(ui.label(), True, True)
        expandbutton.connect('clicked', self.toggle_path)
        blanklabel = ui.label(w=5, h=12)
        filehbox.pack_start(sonataicon, False, False, 2)
        filehbox.pack_start(self.filelabel, True, True, 2)
        filehbox.pack_start(expandvbox, False, False, 2)
        filehbox.pack_start(blanklabel, False, False, 2)

        titlelabel, titleentry, titlebutton, titlehbox = self._create_label_entry_button_hbox(_("Title:"))
        artistlabel, artistentry, artistbutton, artisthbox = self._create_label_entry_button_hbox(_("Artist:"))
        albumlabel, albumentry, albumbutton, albumhbox = self._create_label_entry_button_hbox(_("Album:"))
        yearlabel, yearentry, yearbutton, yearhbox = self._create_label_entry_button_hbox(_("Year:"))
        yearentry.set_size_request(50,-1)
        tracklabel, trackentry, trackbutton, trackhbox = self._create_label_entry_button_hbox("  " + _("Track:"), True)
        trackentry.set_size_request(50,-1)
        yearandtrackhbox = gtk.HBox()
        yearandtrackhbox.pack_start(yearhbox, True, True, 0)
        yearandtrackhbox.pack_start(trackhbox, True, True, 0)

        yearentry.connect("insert_text", self.tags_win_entry_constraint, True)
        trackentry.connect("insert_text", self.tags_win_entry_constraint, False)

        genrelabel = ui.label(text=_("Genre:"), x=1)
        genrecombo = ui.comboentry(items=self.tags_win_genres(), wrap=2)
        genreentry = genrecombo.get_child()
        genrehbox = gtk.HBox()
        genrebutton = ui.button()
        genrebuttonvbox = self.tags_win_create_apply_all_button(genrebutton,
                                                                genreentry)
        genrehbox.pack_start(genrelabel, False, False, 2)
        genrehbox.pack_start(genrecombo, True, True, 2)
        genrehbox.pack_start(genrebuttonvbox, False, False, 2)

        commentlabel, commententry, commentbutton, commenthbox = self._create_label_entry_button_hbox(_("Comment:"))

        ui.set_widths_equal([titlelabel, artistlabel, albumlabel, yearlabel, genrelabel, commentlabel, sonataicon])
        genrecombo.set_size_request(-1, titleentry.size_request()[1])
        tablewidgets = [ui.label(), filehbox, ui.label(), titlehbox, artisthbox, albumhbox, yearandtrackhbox, genrehbox, commenthbox, ui.label()]
        for i, widget in enumerate(tablewidgets):
            table.attach(widget, 1, 2, i+1, i+2, gtk.FILL|gtk.EXPAND, gtk.FILL|gtk.EXPAND, 2, 0)
        editwindow.vbox.pack_start(table)
        saveall_button = None
        if len(files) > 1:
            # Only show save all button if more than one song being edited.
            saveall_button = ui.button(text=_("Save _All"))
            editwindow.action_area.pack_start(saveall_button)
        editwindow.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
        editwindow.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
        editwindow.connect('delete_event', self.tags_win_hide, tags)
        entries = [titleentry, artistentry, albumentry, yearentry, trackentry, genreentry, commententry]
        buttons = [titlebutton, artistbutton, albumbutton, yearbutton, trackbutton, genrebutton, commentbutton]
        entries_names = ["title", "artist", "album", "year", "track", "genre", "comment"]
        editwindow.connect('response', self.tags_win_response, tags, entries, entries_names)
        if saveall_button:
            saveall_button.connect('clicked', self.tags_win_save_all, editwindow, tags, entries, entries_names)

        for button, name, entry in zip(buttons, entries_names, entries):
            entry.connect('changed', self.tags_win_entry_changed)
            button.connect('clicked', self.tags_win_apply_all, name, tags, entry)

        self.tags_win_update(editwindow, tags, entries, entries_names)
        ui.change_cursor(None)
        self.filelabel.set_size_request(editwindow.size_request()[0] - titlelabel.size_request()[0] - 70, -1)
        editwindow.show_all()
Exemplo n.º 15
0
	def plugin_configure(self, _widget):
		plugin = self.plugin_get_selected()
		ui.show_msg(self.prefswindow, "Nothing yet implemented.", "Configure", "pluginConfigure", gtk.BUTTONS_CLOSE)
Exemplo n.º 16
0
    def on_tags_edit(self, files, temp_mpdpaths, music_dir):
        """Display the editing dialog"""
        # Try loading module
        global tagpy
        if tagpy is None:
            try:
                import tagpy
            except ImportError:
                ui.show_msg(
                    self.window,
                    _("Taglib and/or tagpy not found, tag editing support disabled."
                      ),
                    _("Edit Tags"),
                    'editTagsError',
                    gtk.BUTTONS_CLOSE,
                    response_cb=ui.dialog_destroy)
                ui.change_cursor(None)
                return
            # Set default tag encoding to utf8.. fixes some reported bugs.
            import tagpy.id3v2 as id3v2
            id3v2.FrameFactory.instance().setDefaultTextEncoding(
                tagpy.StringType.UTF8)

        # Make sure tagpy is at least 0.91
        if hasattr(tagpy.Tag.title, '__call__'):
            ui.show_msg(
                self.window,
                _("Tagpy version < 0.91. Please upgrade to a newer version, tag editing support disabled."
                  ),
                _("Edit Tags"),
                'editTagsError',
                gtk.BUTTONS_CLOSE,
                response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

        if not os.path.isdir(misc.file_from_utf8(music_dir)):
            ui.show_msg(
                self.window,
                _("The path") + " " + music_dir + " " +
                _("does not exist. Please specify a valid music directory in preferences."
                  ),
                _("Edit Tags"),
                'editTagsError',
                gtk.BUTTONS_CLOSE,
                response_cb=ui.dialog_destroy)
            ui.change_cursor(None)
            return

# XXX file list was created here

        if len(files) == 0:
            ui.change_cursor(None)
            return

        # Initialize:
        self.tagnum = -1

        tags = [{
            'title': '',
            'artist': '',
            'album': '',
            'year': '',
            'track': '',
            'genre': '',
            'comment': '',
            'title-changed': False,
            'artist-changed': False,
            'album-changed': False,
            'year-changed': False,
            'track-changed': False,
            'genre-changed': False,
            'comment-changed': False,
            'fullpath': misc.file_from_utf8(filename),
            'mpdpath': path
        } for filename, path in zip(files, temp_mpdpaths)]

        if not os.path.exists(tags[0]['fullpath']):
            ui.change_cursor(None)
            ui.show_msg(
                self.window,
                _("File ") + "\"" + tags[0]['fullpath'] + "\"" +
                _(" not found. Please specify a valid music directory in preferences."
                  ),
                _("Edit Tags"),
                'editTagsError',
                gtk.BUTTONS_CLOSE,
                response_cb=ui.dialog_destroy)
            return
        if not self.tags_next_tag(tags):
            ui.change_cursor(None)
            ui.show_msg(self.window,
                        _("No music files with editable tags found."),
                        _("Edit Tags"),
                        'editTagsError',
                        gtk.BUTTONS_CLOSE,
                        response_cb=ui.dialog_destroy)
            return
        editwindow = ui.dialog(parent=self.window,
                               flags=gtk.DIALOG_MODAL,
                               role='editTags',
                               resizable=False,
                               separator=False)
        editwindow.set_size_request(375, -1)
        table = gtk.Table(9, 2, False)
        table.set_row_spacings(2)
        self.filelabel = ui.label(select=True, wrap=True)
        filehbox = gtk.HBox()
        sonataicon = ui.image(stock='sonata', stocksize=gtk.ICON_SIZE_DND, x=1)
        expandbutton = ui.button(" ")
        self.set_expandbutton_state(expandbutton)
        expandvbox = gtk.VBox()
        expandvbox.pack_start(ui.label(), True, True)
        expandvbox.pack_start(expandbutton, False, False)
        expandvbox.pack_start(ui.label(), True, True)
        expandbutton.connect('clicked', self.toggle_path)
        blanklabel = ui.label(w=5, h=12)
        filehbox.pack_start(sonataicon, False, False, 2)
        filehbox.pack_start(self.filelabel, True, True, 2)
        filehbox.pack_start(expandvbox, False, False, 2)
        filehbox.pack_start(blanklabel, False, False, 2)

        titlelabel, titleentry, titlebutton, titlehbox = self._create_label_entry_button_hbox(
            _("Title"))
        artistlabel, artistentry, artistbutton, artisthbox = self._create_label_entry_button_hbox(
            _("Artist"))
        albumlabel, albumentry, albumbutton, albumhbox = self._create_label_entry_button_hbox(
            _("Album"))
        yearlabel, yearentry, yearbutton, yearhbox = self._create_label_entry_button_hbox(
            _("Year"))
        yearentry.set_size_request(50, -1)
        tracklabel, trackentry, trackbutton, trackhbox = self._create_label_entry_button_hbox(
            "  " + _("Track"), True)
        trackentry.set_size_request(50, -1)
        yearandtrackhbox = gtk.HBox()
        yearandtrackhbox.pack_start(yearhbox, True, True, 0)
        yearandtrackhbox.pack_start(trackhbox, True, True, 0)

        yearentry.connect("insert_text", self.tags_win_entry_constraint, True)
        trackentry.connect("insert_text", self.tags_win_entry_constraint,
                           False)

        genrelabel = ui.label(text=_("Genre") + ":", x=1)
        genrecombo = ui.comboentry(items=self.tags_win_genres(), wrap=2)
        genreentry = genrecombo.get_child()
        genrehbox = gtk.HBox()
        genrebutton = ui.button()
        genrebuttonvbox = self.tags_win_create_apply_all_button(
            genrebutton, genreentry)
        genrehbox.pack_start(genrelabel, False, False, 2)
        genrehbox.pack_start(genrecombo, True, True, 2)
        genrehbox.pack_start(genrebuttonvbox, False, False, 2)

        commentlabel, commententry, commentbutton, commenthbox = self._create_label_entry_button_hbox(
            _("Comment"))

        ui.set_widths_equal([
            titlelabel, artistlabel, albumlabel, yearlabel, genrelabel,
            commentlabel, sonataicon
        ])
        genrecombo.set_size_request(-1, titleentry.size_request()[1])
        tablewidgets = [
            ui.label(), filehbox,
            ui.label(), titlehbox, artisthbox, albumhbox, yearandtrackhbox,
            genrehbox, commenthbox,
            ui.label()
        ]
        for i, widget in enumerate(tablewidgets):
            table.attach(widget, 1, 2, i + 1, i + 2, gtk.FILL | gtk.EXPAND,
                         gtk.FILL | gtk.EXPAND, 2, 0)
        editwindow.vbox.pack_start(table)
        saveall_button = None
        if len(files) > 1:
            # Only show save all button if more than one song being edited.
            saveall_button = ui.button(text=_("Save _All"))
            editwindow.action_area.pack_start(saveall_button)
        editwindow.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT)
        editwindow.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
        editwindow.connect('delete_event', self.tags_win_hide, tags)
        entries = [
            titleentry, artistentry, albumentry, yearentry, trackentry,
            genreentry, commententry
        ]
        buttons = [
            titlebutton, artistbutton, albumbutton, yearbutton, trackbutton,
            genrebutton, commentbutton
        ]
        entries_names = [
            "title", "artist", "album", "year", "track", "genre", "comment"
        ]
        editwindow.connect('response', self.tags_win_response, tags, entries,
                           entries_names)
        if saveall_button:
            saveall_button.connect('clicked', self.tags_win_save_all,
                                   editwindow, tags, entries, entries_names)

        for button, name, entry in zip(buttons, entries_names, entries):
            entry.connect('changed', self.tags_win_entry_changed)
            button.connect('clicked', self.tags_win_apply_all, name, tags,
                           entry)

        self.tags_win_update(editwindow, tags, entries, entries_names)
        ui.change_cursor(None)
        self.filelabel.set_size_request(
            editwindow.size_request()[0] - titlelabel.size_request()[0] - 70,
            -1)
        editwindow.show_all()
Exemplo n.º 17
0
	def plugin_show_website(self, _dialog, link):
		if not misc.browser_load(link, self.config.url_browser, self.window):
			ui.show_msg(self.window, _('Unable to launch a suitable browser.'), _('Launch Browser'), 'browserLoadError', gtk.BUTTONS_CLOSE)