Skip to content

Commit

Permalink
Use icon themes on GNOME.
Browse files Browse the repository at this point in the history
  • Loading branch information
lalinsky committed Dec 30, 2006
1 parent 067e1b9 commit dd5c991
Show file tree
Hide file tree
Showing 19 changed files with 754 additions and 795 deletions.
1,432 changes: 664 additions & 768 deletions picard/resources.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion picard/ui/itemviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from picard.file import File
from picard.track import Track
from picard.util import format_time, encode_filename, decode_filename
from picard.util import icontheme
from picard.config import TextOption

__all__ = ["FileTreeView", "AlbumTreeView"]
Expand All @@ -50,7 +51,7 @@ def __init__(self, main_window, parent):
self.setHeaderLabels([_(h) for h, n in self.columns])
self.restoreState()

self.dirIcon = QtGui.QIcon(":/images/dir.png")
self.dirIcon = icontheme.lookup('folder', icontheme.ICON_SIZE_MENU)
self.fileIcon = QtGui.QIcon(":/images/file.png")
self.cdIcon = QtGui.QIcon(":/images/cd.png")
self.noteIcon = QtGui.QIcon(":/images/note.png")
Expand Down
39 changes: 24 additions & 15 deletions picard/ui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from picard.ui.filebrowser import FileBrowser
from picard.ui.options import OptionsDialogProvider
from picard.ui.tageditor import TagEditor
from picard.util import icontheme

class MainWindow(QtGui.QMainWindow):

Expand Down Expand Up @@ -152,15 +153,15 @@ def get_icon(name, menu=True, toolbar=True):
icon.addFile(":/images/22x22/%s.png" % name)
return icon

self.options_action = QtGui.QAction(get_icon("preferences-system"), _("&Options..."), self)
self.options_action = QtGui.QAction(icontheme.lookup('preferences-desktop'), _("&Options..."), self)
self.connect(self.options_action, QtCore.SIGNAL("triggered()"), self.show_options)

self.cut_action = QtGui.QAction(QtGui.QIcon(":/images/16x16/edit-cut.png"), _(u"&Cut"), self)
self.cut_action = QtGui.QAction(icontheme.lookup('edit-cut', icontheme.ICON_SIZE_MENU), _(u"&Cut"), self)
self.cut_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+X")))
self.cut_action.setEnabled(False)
self.connect(self.cut_action, QtCore.SIGNAL("triggered()"), self.cut)

self.paste_action = QtGui.QAction(QtGui.QIcon(":/images/16x16/edit-paste.png"), _(u"&Paste"), self)
self.paste_action = QtGui.QAction(icontheme.lookup('edit-paste', icontheme.ICON_SIZE_MENU), _(u"&Paste"), self)
self.paste_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+V")))
self.paste_action.setEnabled(False)
self.connect(self.paste_action, QtCore.SIGNAL("triggered()"), self.paste)
Expand All @@ -173,27 +174,27 @@ def get_icon(name, menu=True, toolbar=True):
self.about_action = QtGui.QAction(_("&About..."), self)
self.connect(self.about_action, QtCore.SIGNAL("triggered()"), self.show_about)

self.add_files_action = QtGui.QAction(get_icon("document-open"), _(u"&Add Files..."), self)
self.add_files_action = QtGui.QAction(icontheme.lookup('document-open'), _(u"&Add Files..."), self)
self.add_files_action.setStatusTip(_(u"Add files to the tagger"))
# TR: Keyboard shortcut for "Add Files..."
self.add_files_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+O")))
self.connect(self.add_files_action, QtCore.SIGNAL("triggered()"), self.add_files)

self.add_directory_action = QtGui.QAction(get_icon("folder"), _(u"A&dd Directory..."), self)
self.add_directory_action = QtGui.QAction(icontheme.lookup('folder'), _(u"A&dd Directory..."), self)
self.add_directory_action.setStatusTip(_(u"Add a directory to the tagger"))
# TR: Keyboard shortcut for "Add Directory..."
self.add_directory_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+D")))
self.connect(self.add_directory_action, QtCore.SIGNAL("triggered()"),
self.add_directory)

self.save_action = QtGui.QAction(get_icon("document-save"), _(u"&Save"), self)
self.save_action = QtGui.QAction(icontheme.lookup('document-save'), _(u"&Save"), self)
self.save_action.setStatusTip(_(u"Save selected files"))
# TR: Keyboard shortcut for "Save"
self.save_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+S")))
self.save_action.setEnabled(False)
self.connect(self.save_action, QtCore.SIGNAL("triggered()"), self.save)

self.submit_action = QtGui.QAction(QtGui.QIcon(":/images/ToolbarSubmit.png"), _(u"S&ubmit PUIDs to MusicBrainz"), self)
self.submit_action = QtGui.QAction(icontheme.lookup('picard-submit'), _(u"S&ubmit PUIDs to MusicBrainz"), self)
self.submit_action.setEnabled(False)
self.connect(self.submit_action, QtCore.SIGNAL("triggered()"), self.tagger.puidmanager.submit)

Expand All @@ -203,7 +204,7 @@ def get_icon(name, menu=True, toolbar=True):
self.connect(self.exit_action, QtCore.SIGNAL("triggered()"),
self.close)

self.remove_action = QtGui.QAction(QtGui.QIcon(":/images/remove.png"), _(u"&Remove"), self)
self.remove_action = QtGui.QAction(icontheme.lookup('list-remove'), _(u"&Remove"), self)
self.remove_action.setShortcut(QtGui.QKeySequence("Del"))
self.remove_action.setEnabled(False)
self.connect(self.remove_action, QtCore.SIGNAL("triggered()"), self.remove)
Expand All @@ -220,21 +221,21 @@ def get_icon(name, menu=True, toolbar=True):
self.show_cover_art_action.setChecked(True)
self.connect(self.show_cover_art_action, QtCore.SIGNAL("triggered()"), self.show_cover_art)

self.search_action = QtGui.QAction(QtGui.QIcon(":/images/search.png"), _(u"Search"), self)
self.search_action = QtGui.QAction(icontheme.lookup('system-search'), _(u"Search"), self)
self.connect(self.search_action, QtCore.SIGNAL("triggered()"), self.search)

self.cd_lookup_action = QtGui.QAction(QtGui.QIcon(":/images/ToolbarLookup.png"), _(u"&Lookup CD"), self)
self.cd_lookup_action = QtGui.QAction(icontheme.lookup('media-optical'), _(u"&Lookup CD"), self)
# TR: Keyboard shortcut for "Lookup CD"
self.cd_lookup_action.setShortcut(QtGui.QKeySequence(_("Ctrl+L")))
self.connect(self.cd_lookup_action, QtCore.SIGNAL("triggered()"), self.tagger.lookup_cd)

self.analyze_action = QtGui.QAction(QtGui.QIcon(":/images/analyze.png"), _(u"Anal&yze"), self)
self.analyze_action = QtGui.QAction(icontheme.lookup('picard-analyze'), _(u"Anal&yze"), self)
self.analyze_action.setEnabled(False)
# TR: Keyboard shortcut for "Analyze"
self.analyze_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+Y")))
self.connect(self.analyze_action, QtCore.SIGNAL("triggered()"), self.analyze)

self.cluster_action = QtGui.QAction(QtGui.QIcon(":/images/ToolbarCluster.png"), _(u"Cluster"), self)
self.cluster_action = QtGui.QAction(icontheme.lookup('picard-cluster'), _(u"Cluster"), self)
self.cluster_action.setEnabled(False)
# TR: Keyboard shortcut for "Cluster"
self.cluster_action.setShortcut(QtGui.QKeySequence(_(u"Ctrl+U")))
Expand All @@ -250,14 +251,20 @@ def get_icon(name, menu=True, toolbar=True):
self.edit_tags_action.setEnabled(False)
self.connect(self.edit_tags_action, QtCore.SIGNAL("triggered()"), self.edit_tags)

self.refresh_action = QtGui.QAction(get_icon("view-refresh", toolbar=False), _("&Refresh"), self)
self.refresh_action = QtGui.QAction(icontheme.lookup('view-refresh', icontheme.ICON_SIZE_MENU), _("&Refresh"), self)
self.connect(self.refresh_action, QtCore.SIGNAL("triggered()"), self.refresh)

self.generate_cuesheet_action = QtGui.QAction(_("Generate &Cuesheet..."), self)
self.connect(self.generate_cuesheet_action, QtCore.SIGNAL("triggered()"), self.generate_cuesheet)
self.generate_playlist_action = QtGui.QAction(_("Generate &Playlist..."), self)
self.connect(self.generate_playlist_action, QtCore.SIGNAL("triggered()"), self.generate_playlist)

self.enable_renaming_action = QtGui.QAction(_(u"&Rename Files"), self)
self.enable_renaming_action.setCheckable(True)
#if self.config.persist["view_file_browser"]:
# self.show_file_browser_action.setChecked(True)
#self.connect(self.show_file_browser_action, QtCore.SIGNAL("triggered()"), self.show_file_browser)

def create_menus(self):
menu = self.menuBar().addMenu(_(u"&File"))
menu.addAction(self.add_files_action)
Expand All @@ -270,11 +277,13 @@ def create_menus(self):
menu = self.menuBar().addMenu(_(u"&Edit"))
menu.addAction(self.cut_action)
menu.addAction(self.paste_action)
menu.addSeparator()
menu.addAction(self.options_action)
menu = self.menuBar().addMenu(_(u"&View"))
menu.addAction(self.show_file_browser_action)
menu.addAction(self.show_cover_art_action)
menu = self.menuBar().addMenu(_(u"&Options"))
menu.addAction(self.enable_renaming_action)
menu.addSeparator()
menu.addAction(self.options_action)
menu = self.menuBar().addMenu(_(u"&Tools"))
menu.addAction(self.generate_cuesheet_action)
menu.addAction(self.generate_playlist_action)
Expand Down
55 changes: 55 additions & 0 deletions picard/util/icontheme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
#
# Picard, the next-generation MusicBrainz tagger
# Copyright (C) 2006 Lukáš Lalinský
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

import sys
import os.path
from PyQt4 import QtGui

if sys.platform == 'win32':
_search_paths = []
else:
_search_paths = [
os.path.expanduser('~/.icons'),
os.path.join(os.environ.get('XDG_DATA_DIRS', '/usr/share'), 'icons'),
'/usr/share/pixmaps',
]

if 'GNOME_DESKTOP_SESSION_ID' in os.environ:
_current_theme = os.popen('gconftool-2 -g /desktop/gnome/interface/icon_theme').read().strip() or None
else:
_current_theme = None

ICON_SIZE_MENU = ('16x16',)
ICON_SIZE_TOOLBAR = ('22x22',)
ICON_SIZE_ALL = ('22x22', '16x16')

def lookup(name, size=ICON_SIZE_ALL):
icon = QtGui.QIcon()
if _current_theme:
for path in _search_paths:
for subdir in ('actions', 'places', 'devices'):
fullpath = os.path.join(path, _current_theme, size[0], subdir, name)
if os.path.exists(fullpath + '.png'):
icon.addFile(fullpath + '.png')
for s in size[1:]:
icon.addFile(os.path.join(path, _current_theme, s, subdir, name) + '.png')
return icon
for s in size:
icon.addFile(os.path.join(':', 'images', s, name) + '.png')
return icon
Binary file added resources/images/16x16/preferences-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/images/16x16/preferences-system.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added resources/images/22x22/preferences-desktop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed resources/images/22x22/preferences-system.png
Binary file not shown.
File renamed without changes
Binary file removed resources/images/ToolbarAnalyze.png
Binary file not shown.
Binary file removed resources/images/ToolbarRemove.png
Binary file not shown.
Binary file removed resources/images/reload.png
Binary file not shown.
18 changes: 8 additions & 10 deletions resources/picard.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@
<file>images/note.png</file>
<file>images/Picard16.png</file>
<file>images/Picard32.png</file>
<file>images/ToolbarAnalyze.png</file>
<file>images/ToolbarCluster.png</file>
<file>images/22x22/picard-analyze.png</file>
<file>images/ToolbarListen.png</file>
<file>images/ToolbarLookup.png</file>
<file>images/ToolbarRemove.png</file>
<file>images/search.png</file>
<file>images/ToolbarSubmit.png</file>
<file>images/remove.png</file>
<file>images/analyze.png</file>
<file>images/22x22/media-optical.png</file>
<file>images/22x22/list-remove.png</file>
<file>images/22x22/system-search.png</file>
<file>images/22x22/picard-submit.png</file>
<file>images/match-50.png</file>
<file>images/match-60.png</file>
<file>images/match-70.png</file>
Expand All @@ -32,10 +29,11 @@
<file>images/22x22/document-open.png</file>
<file>images/16x16/folder.png</file>
<file>images/22x22/folder.png</file>
<file>images/16x16/preferences-system.png</file>
<file>images/22x22/preferences-system.png</file>
<file>images/16x16/preferences-desktop.png</file>
<file>images/22x22/preferences-desktop.png</file>
<file>images/16x16/document-save.png</file>
<file>images/22x22/document-save.png</file>
<file>images/16x16/view-refresh.png</file>
<file>images/22x22/picard-cluster.png</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def run(self):
pyfile = os.path.join("picard", "ui", pyfile)
if newer(uifile, pyfile):
log.info("compiling %s -> %s", uifile, pyfile)
uic.compileUi(uifile, file(pyfile, "w"), gettext=True)
uic.compileUi(uifile, file(pyfile, "w"))
qrcfile = os.path.join("resources", "picard.qrc")
pyfile = os.path.join("picard", "resources.py")
build_resources = False
Expand Down

0 comments on commit dd5c991

Please sign in to comment.