Permalink
Browse files

Fix installation location of data files

Merge branch 'fix-issue-5' into integration

This fixes #5 ("Installer puts $installdir/share stuff in wrong place").
  • Loading branch information...
2 parents 21b0bc8 + 0df7981 commit 1eb1e5313a8b694a3c8de98b75eb281a189a50e8 @multani committed Jan 2, 2012
Showing with 100 additions and 96 deletions.
  1. +3 −0 .gitignore
  2. +3 −0 setup.cfg
  3. +64 −55 setup.py
  4. +4 −4 sonata/artwork.py
  5. +26 −37 sonata/main.py
View
@@ -6,3 +6,6 @@ mo/
tags
TAGS
cscope*
+RECORD
+*.egg-info/
+build/
View
@@ -0,0 +1,3 @@
+[install]
+single_version_externally_managed = 1
+record = RECORD
View
@@ -59,61 +59,70 @@ def rmgeneric(path, __func__):
]
-setup(name='Sonata',
- version=version,
- description='GTK+ client for the Music Player Daemon (MPD).',
- author='Scott Horowitz',
- author_email='stonecrest@gmail.com',
- url='http://sonata.berlios.de/',
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'Environment :: X11 Applications',
- 'Intended Audience :: End Users/Desktop',
- 'License :: GNU General Public License (GPL)',
- 'Operating System :: Linux',
- 'Programming Language :: Python',
- 'Topic :: Multimedia :: Sound :: Players',
- ],
- packages=["sonata", "sonata.plugins"],
- package_dir={"sonata": "sonata/"},
- ext_modules=[Extension(
- "mmkeys", ["mmkeys/mmkeyspy.c", "mmkeys/mmkeys.c", "mmkeys/mmkeysmodule.c"],
- extra_compile_args=capture("pkg-config --cflags gtk+-2.0 pygtk-2.0").split(),
- extra_link_args=capture("pkg-config --libs gtk+-2.0 pygtk-2.0").split()
- ),],
- data_files=[('share/sonata', ['README.old', 'CHANGELOG', 'TODO', 'TRANSLATORS']),
- ('share/applications', ['sonata.desktop']),
- ('share/pixmaps', glob.glob('sonata/pixmaps/*')),
- ('share/man/man1', ['sonata.1']),
- ('share/locale/de/LC_MESSAGES', ['mo/de/sonata.mo']),
- ('share/locale/pl/LC_MESSAGES', ['mo/pl/sonata.mo']),
- ('share/locale/ru/LC_MESSAGES', ['mo/ru/sonata.mo']),
- ('share/locale/fr/LC_MESSAGES', ['mo/fr/sonata.mo']),
- ('share/locale/zh_CN/LC_MESSAGES', ['mo/zh_CN/sonata.mo']),
- ('share/locale/sv/LC_MESSAGES', ['mo/sv/sonata.mo']),
- ('share/locale/es/LC_MESSAGES', ['mo/es/sonata.mo']),
- ('share/locale/fi/LC_MESSAGES', ['mo/fi/sonata.mo']),
- ('share/locale/nl/LC_MESSAGES', ['mo/nl/sonata.mo']),
- ('share/locale/it/LC_MESSAGES', ['mo/it/sonata.mo']),
- ('share/locale/cs/LC_MESSAGES', ['mo/cs/sonata.mo']),
- ('share/locale/da/LC_MESSAGES', ['mo/da/sonata.mo']),
- ('share/locale/ca/LC_MESSAGES', ['mo/ca/sonata.mo']),
- ('share/locale/ar/LC_MESSAGES', ['mo/ar/sonata.mo']),
- ('share/locale/pt_BR/LC_MESSAGES', ['mo/pt_BR/sonata.mo']),
- ('share/locale/et/LC_MESSAGES', ['mo/et/sonata.mo']),
- ('share/locale/tr/LC_MESSAGES', ['mo/tr/sonata.mo']),
- ('share/locale/be@latin/LC_MESSAGES', ['mo/be@latin/sonata.mo']),
- ('share/locale/el_GR/LC_MESSAGES', ['mo/el_GR/sonata.mo']),
- ('share/locale/sk/LC_MESSAGES', ['mo/sk/sonata.mo']),
- ('share/locale/ja/LC_MESSAGES', ['mo/ja/sonata.mo']),
- ('share/locale/sl/LC_MESSAGES', ['mo/sl/sonata.mo']),
- ('share/locale/zh_TW/LC_MESSAGES', ['mo/zh_TW/sonata.mo']),
- ('share/locale/uk/LC_MESSAGES', ['mo/uk/sonata.mo'])],
- entry_points={
- 'console_scripts': [
- 'sonata=sonata.launcher:run',
- ]
- },
+setup(
+ name='Sonata',
+ version=version,
+ description='GTK+ client for the Music Player Daemon (MPD).',
+ author='Scott Horowitz',
+ author_email='stonecrest@gmail.com',
+ url='http://sonata.berlios.de/',
+ classifiers=[
+ 'Development Status :: 4 - Beta',
+ 'Environment :: X11 Applications',
+ 'Intended Audience :: End Users/Desktop',
+ 'License :: GNU General Public License (GPL)',
+ 'Operating System :: Linux',
+ 'Programming Language :: Python',
+ 'Topic :: Multimedia :: Sound :: Players',
+ ],
+ packages=["sonata", "sonata.plugins"],
+ package_dir={"sonata": "sonata"},
+ ext_modules=[
+ Extension(
+ "mmkeys",
+ ["mmkeys/mmkeyspy.c", "mmkeys/mmkeys.c",
+ "mmkeys/mmkeysmodule.c"],
+ extra_compile_args=capture("pkg-config --cflags gtk+-2.0 pygtk-2.0").split(),
+ extra_link_args=capture("pkg-config --libs gtk+-2.0 pygtk-2.0").split()
+ ),
+ ],
+ data_files=[
+ ('share/sonata', ['README.old', 'CHANGELOG', 'TODO', 'TRANSLATORS']),
+ ('share/applications', ['sonata.desktop']),
+ ('share/man/man1', ['sonata.1']),
+ ('share/locale/de/LC_MESSAGES', ['mo/de/sonata.mo']),
+ ('share/locale/pl/LC_MESSAGES', ['mo/pl/sonata.mo']),
+ ('share/locale/ru/LC_MESSAGES', ['mo/ru/sonata.mo']),
+ ('share/locale/fr/LC_MESSAGES', ['mo/fr/sonata.mo']),
+ ('share/locale/zh_CN/LC_MESSAGES', ['mo/zh_CN/sonata.mo']),
+ ('share/locale/sv/LC_MESSAGES', ['mo/sv/sonata.mo']),
+ ('share/locale/es/LC_MESSAGES', ['mo/es/sonata.mo']),
+ ('share/locale/fi/LC_MESSAGES', ['mo/fi/sonata.mo']),
+ ('share/locale/nl/LC_MESSAGES', ['mo/nl/sonata.mo']),
+ ('share/locale/it/LC_MESSAGES', ['mo/it/sonata.mo']),
+ ('share/locale/cs/LC_MESSAGES', ['mo/cs/sonata.mo']),
+ ('share/locale/da/LC_MESSAGES', ['mo/da/sonata.mo']),
+ ('share/locale/ca/LC_MESSAGES', ['mo/ca/sonata.mo']),
+ ('share/locale/ar/LC_MESSAGES', ['mo/ar/sonata.mo']),
+ ('share/locale/pt_BR/LC_MESSAGES', ['mo/pt_BR/sonata.mo']),
+ ('share/locale/et/LC_MESSAGES', ['mo/et/sonata.mo']),
+ ('share/locale/tr/LC_MESSAGES', ['mo/tr/sonata.mo']),
+ ('share/locale/be@latin/LC_MESSAGES', ['mo/be@latin/sonata.mo']),
+ ('share/locale/el_GR/LC_MESSAGES', ['mo/el_GR/sonata.mo']),
+ ('share/locale/sk/LC_MESSAGES', ['mo/sk/sonata.mo']),
+ ('share/locale/ja/LC_MESSAGES', ['mo/ja/sonata.mo']),
+ ('share/locale/sl/LC_MESSAGES', ['mo/sl/sonata.mo']),
+ ('share/locale/zh_TW/LC_MESSAGES', ['mo/zh_TW/sonata.mo']),
+ ('share/locale/uk/LC_MESSAGES', ['mo/uk/sonata.mo'])
+ ],
+ package_data={
+ 'sonata': ['pixmaps/*.*'],
+ },
+ entry_points={
+ 'console_scripts': [
+ 'sonata=sonata.launcher:run',
+ ]
+ },
test_suite='sonata.tests',
tests_require=tests_require,
extras_require={
View
@@ -17,7 +17,7 @@
class Artwork(object):
- def __init__(self, config, find_path, is_lang_rtl,
+ def __init__(self, config, path_to_icon, is_lang_rtl,
info_imagebox_get_size_request, schedule_gc_collect,
target_image_filename, imagelist_append,
remotefilelist_append, notebook_get_allocation,
@@ -42,9 +42,9 @@ def __init__(self, config, find_path, is_lang_rtl,
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')
- path = find_path('sonata-case.png')
+ self.sonatacd = path_to_icon('sonatacd.png')
+ self.sonatacd_large = path_to_icon('sonatacd_large.png')
+ path = path_to_icon('sonata-case.png')
self.casepb = gtk.gdk.pixbuf_new_from_file(path)
self.albumpb = None
self.currentpb = None
View
@@ -38,6 +38,8 @@
import gtk
import pango
+import pkg_resources
+
# Default to no sugar, then test...
HAVE_SUGAR = False
@@ -216,10 +218,10 @@ def __init__(self, args, window=None, _sugar=False):
# Add some icons, assign pixbufs:
self.iconfactory = gtk.IconFactory()
- ui.icon(self.iconfactory, 'sonata', self.find_path('sonata.png'))
+ ui.icon(self.iconfactory, 'sonata', self.path_to_icon('sonata.png'))
ui.icon(self.iconfactory, 'artist',
- self.find_path('sonata-artist.png'))
- ui.icon(self.iconfactory, 'album', self.find_path('sonata-album.png'))
+ self.path_to_icon('sonata-artist.png'))
+ ui.icon(self.iconfactory, 'album', self.path_to_icon('sonata-album.png'))
icon_theme = gtk.icon_theme_get_default()
if HAVE_SUGAR:
activity_root = activity.get_bundle_path()
@@ -235,7 +237,7 @@ def __init__(self, args, window=None, _sugar=False):
except:
# Fallback to Sonata-included icons:
ui.icon(self.iconfactory, iconname,
- self.find_path('sonata-%s.png' % iconname))
+ self.path_to_icon('sonata-%s.png' % iconname))
# Main window
if window is None:
@@ -260,12 +262,12 @@ def __init__(self, args, window=None, _sugar=False):
# Artwork
self.artwork = artwork.Artwork(
- self.config, self.find_path, misc.is_lang_rtl(self.window),
+ self.config, self.path_to_icon, misc.is_lang_rtl(self.window),
lambda: self.info_imagebox.get_size_request(),
self.schedule_gc_collect, self.target_image_filename,
self.imagelist_append, self.remotefilelist_append,
self.notebook.get_allocation, self.set_allow_art_search,
- self.status_is_play_or_pause, self.find_path('sonata-album.png'),
+ self.status_is_play_or_pause, self.path_to_icon('sonata-album.png'),
self.get_current_song_text)
@@ -528,7 +530,7 @@ def __init__(self, args, window=None, _sugar=False):
# Library tab
self.library = library.Library(
self.config, self.mpd, self.artwork, self.TAB_LIBRARY,
- self.find_path('sonata-album.png'), self.settings_save,
+ self.path_to_icon('sonata-album.png'), self.settings_save,
self.current.filtering_entry_make_red,
self.current.filtering_entry_revert_color,
self.current.filter_key_pressed, self.on_add_item, self.connected,
@@ -1317,7 +1319,7 @@ def handle_change_conn(self):
self.currentdata.clear()
if self.current_treeview.get_model():
self.current_treeview.get_model().clear()
- self.tray_icon.update_icon(self.find_path('sonata_disconnect.png'))
+ self.tray_icon.update_icon(self.path_to_icon('sonata_disconnect.png'))
self.info_update(True)
if self.current.filterbox_visible:
gobject.idle_add(self.current.searchfilter_toggle, None)
@@ -1627,7 +1629,7 @@ def handle_change_status(self):
child[1].set_text('')
self.UIManager.get_widget('/traymenu/playmenu').show()
self.UIManager.get_widget('/traymenu/pausemenu').hide()
- self.tray_icon.update_icon(self.find_path('sonata.png'))
+ self.tray_icon.update_icon(self.path_to_icon('sonata.png'))
elif self.status['state'] == 'pause':
self.ppbutton.set_image(ui.image(
stock=gtk.STOCK_MEDIA_PLAY,
@@ -1636,7 +1638,7 @@ def handle_change_status(self):
child[1].set_text('')
self.UIManager.get_widget('/traymenu/playmenu').show()
self.UIManager.get_widget('/traymenu/pausemenu').hide()
- self.tray_icon.update_icon(self.find_path('sonata_pause.png'))
+ self.tray_icon.update_icon(self.path_to_icon('sonata_pause.png'))
elif self.status['state'] == 'play':
self.ppbutton.set_image(ui.image(
stock=gtk.STOCK_MEDIA_PAUSE,
@@ -1649,7 +1651,7 @@ def handle_change_status(self):
if self.prevstatus['state'] == 'pause':
# Forces the notification to popup if specified
self.on_currsong_notify()
- self.tray_icon.update_icon(self.find_path('sonata_play.png'))
+ self.tray_icon.update_icon(self.path_to_icon('sonata_play.png'))
self.playing_song_change()
if self.status_is_play_or_pause():
@@ -3446,34 +3448,21 @@ def update_menu_visibility(self, show_songinfo_only=False):
'pl', 'update', 'sort', 'tag']:
self.UIManager.get_widget('/mainmenu/' + menu + 'menu/').hide()
- def find_path(self, filename):
- full_filename = None
+ def path_to_icon(self, icon_name):
+ # TOOD: when Sugar support has been removed, simplify this function:
+ # remove temporary variables, simplify the check on the file existence
if HAVE_SUGAR:
full_filename = os.path.join(activity.get_bundle_path(),
- 'share', filename)
+ 'share', icon_name)
else:
- if os.path.exists(os.path.join(os.path.split(__file__)[0],
- filename)):
- full_filename = os.path.join(os.path.split(__file__)[0],
- filename)
- elif os.path.exists(os.path.join(os.path.split(__file__)[0],
- 'pixmaps', filename)):
- full_filename = os.path.join(os.path.split(__file__)[0],
- 'pixmaps', filename)
- elif os.path.exists(os.path.join(os.path.split(__file__)[0],
- 'share', filename)):
- full_filename = os.path.join(os.path.split(__file__)[0],
- 'share', filename)
- elif os.path.exists(os.path.join(__file__.split('/lib')[0],
- 'share', 'pixmaps', filename)):
- full_filename = os.path.join(__file__.split('/lib')[0],
- 'share', 'pixmaps', filename)
- elif os.path.exists(os.path.join(sys.prefix,
- 'share', 'pixmaps', filename)):
- full_filename = os.path.join(sys.prefix,
- 'share', 'pixmaps', filename)
+ full_filename = pkg_resources.resource_filename(
+ __name__, "pixmaps/%s" % icon_name)
+
+ if not os.path.exists(full_filename):
+ full_filename = None
+
if not full_filename:
- self.logger.critical("%r cannot be found. Aborting...", filename)
+ self.logger.critical("Icon %r cannot be found. Aborting...", icon_name)
sys.exit(1)
return full_filename
@@ -3524,7 +3513,7 @@ def on_about(self, _action):
self.config,
version,
__license__,
- self.find_path('sonata_large.png'))
+ self.path_to_icon('sonata_large.png'))
stats = None
if self.conn:
@@ -3550,7 +3539,7 @@ def systemtray_initialize(self):
self.tray_icon.show()
else:
self.tray_icon.hide()
- self.tray_icon.update_icon(self.find_path('sonata.png'))
+ self.tray_icon.update_icon(self.path_to_icon('sonata.png'))
def dbus_show(self):
self.window.hide()

0 comments on commit 1eb1e53

Please sign in to comment.