diff --git a/.gitignore b/.gitignore index d78e1b2..ce85a3d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ *.o *.so *.pyc +*.egg +*.egg-info # Packages # ############ diff --git a/src/jsoninspector.desktop b/res/jsoninspector.desktop similarity index 82% rename from src/jsoninspector.desktop rename to res/jsoninspector.desktop index 5f94e0b..2b6e906 100644 --- a/src/jsoninspector.desktop +++ b/res/jsoninspector.desktop @@ -3,9 +3,9 @@ Encoding=UTF-8 Version=2.0 Name[en_US]=JSON Inspector GenericName=JSON Inspector -Exec=jsoninspector +Exec=jsoninspector.py Terminal=false -Icon[en_US]=/usr/share/icons/ +Icon[en_US]=/usr/local/share/jsoninspector/ Type=Application Categories=Application;Programming Comment[en_US]=JSON Inspector diff --git a/src/jsoninspector.glade b/res/jsoninspector.glade similarity index 99% rename from src/jsoninspector.glade rename to res/jsoninspector.glade index 6c34472..9970013 100644 --- a/src/jsoninspector.glade +++ b/res/jsoninspector.glade @@ -19,6 +19,7 @@ https://github.com/resetreboot/jsoninspector José Carlos Cuevas Albadalejo José Carlos Cuevas Albadalejo + jsoninspector gpl-3-0 @@ -173,6 +174,7 @@ False JSON Inspector center + jsoninspector.png @@ -284,7 +286,6 @@ treeviewcolumn1 0 1 - both diff --git a/res/jsoninspector128x128.png b/res/jsoninspector128x128.png new file mode 100644 index 0000000..b7b8e29 Binary files /dev/null and b/res/jsoninspector128x128.png differ diff --git a/res/jsoninspector16x16.png b/res/jsoninspector16x16.png new file mode 100644 index 0000000..b1247fd Binary files /dev/null and b/res/jsoninspector16x16.png differ diff --git a/res/jsoninspector32x32.png b/res/jsoninspector32x32.png new file mode 100644 index 0000000..cc768a5 Binary files /dev/null and b/res/jsoninspector32x32.png differ diff --git a/res/jsoninspector64x64.png b/res/jsoninspector64x64.png new file mode 100644 index 0000000..d002999 Binary files /dev/null and b/res/jsoninspector64x64.png differ diff --git a/setup.py b/setup.py index 2f65984..fb4748e 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,62 @@ -import ez_setup, sys, shutils +import ez_setup, sys, shutil, os ez_setup.use_setuptools() from setuptools import setup, find_packages +from setuptools.command.install import install +from distutils.dir_util import copy_tree + +class CustomInstall(install): + """ + We subclass the install command to add some more mojo + """ + def run(self): + install.run(self) # Do the usual setuptools magic + # Now we do our own magic + if sys.platform != 'win32' and sys.platform != 'darwin': + try: + os.mkdir("/usr/local/share/jsoninspector", mode = 0755) + + except: + print "Warning: Couldn't create /usr/local/share/jsoninspector" + + # Copy the translations + try: + copy_tree('locale/po/', '/usr/share/locale/') + + except: + print "Warning: error copying translation files." + + # Copy the icons + for icon_size in ['16x16', '32x32', '64x64', '128x128']: + try: + shutil.copyfile('res/jsoninspector' + icon_size + ".png", + '/usr/share/icons/hicolor/' + icon_size + "/apps/jsoninspector.png") + + except: + print "Warning: error copying icon {size}.".format(icon_size) + + try: + shutil.copyfile('res/jsoninspector.glade', '/usr/local/share/jsoninspector/jsoninspector.desktop') + + except: + print "Warning: error copyin .glade file." + + try: + shutil.copyfile('res/jsoninspector.desktop', '/usr/share/applications/jsoninspector.desktop') + + except: + print "Warning: error copying .desktop entry." + setup( name = "jsoninspector", version = "2.0", - packages = find_packages('src', exclude=['distribute_setup']), - scripts = ['jsoninspector.py'], + packages = find_packages('src', exclude=['ez_setup']), + scripts = ['src/jsoninspector.py'], include_package_data = True, package_data = { # If any package contains *.glade files, include them: - '': ['*.glade'], + 'src': ['*.glade'], }, # metadata for upload to PyPI @@ -21,7 +66,5 @@ setup( license = "GPLv3", keywords = "json inspect gtk gnome", url = "https://github.com/resetreboot/jsoninspector", # project home page, if any + cmdclass = { 'install' : CustomInstall } ) - -# if sys.path != 'win32' and sys.path != 'darwin': -# shutils.copytree('locale/po/', '/usr/share/locale/') diff --git a/src/jsoninspector.py b/src/jsoninspector.py index d52432c..42a5f23 100644 --- a/src/jsoninspector.py +++ b/src/jsoninspector.py @@ -1,7 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from pkg_resources import resource_filename from gi.repository import Gtk, Gio import json, sys, os.path @@ -12,15 +11,18 @@ import locale APP = "jsoninspector" -if os.path.exists('../locale/po'): +if os.path.exists('../locale/po') and os.path.exists('../res'): # We're in the development tree DIR = "../locale/po/" + RESOURCES = "../res/" elif sys.platform != 'win32' and sys.platform != 'darwin': DIR = "/usr/share/locale/" + RESOURCES = "/usr/local/share/jsoninspector" else: DIR = "po" + RESOURCES = "res/" locale.setlocale(locale.LC_ALL, '') @@ -51,7 +53,7 @@ class MainWindowMethods(Gtk.Application): """ self.builder = Gtk.Builder() self.builder.set_translation_domain(APP) - self.builder.add_from_file(resource_filename(__name__,'jsoninspector.glade')) + self.builder.add_from_file(os.path.join(RESOURCES, 'jsoninspector.glade')) self.builder.connect_signals(self) # Prepares the renders of columns and assigns the values