Trying to get icons and such working. Setup is almost there.

This commit is contained in:
José Carlos Cuevas 2014-07-15 11:39:52 +02:00
parent d9accdd511
commit f13c0302a3
9 changed files with 61 additions and 13 deletions

2
.gitignore vendored
View file

@ -7,6 +7,8 @@
*.o
*.so
*.pyc
*.egg
*.egg-info
# Packages #
############

View file

@ -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

View file

@ -19,6 +19,7 @@
<property name="website_label">https://github.com/resetreboot/jsoninspector</property>
<property name="authors">José Carlos Cuevas Albadalejo</property>
<property name="translator_credits">José Carlos Cuevas Albadalejo</property>
<property name="logo_icon_name">jsoninspector</property>
<property name="license_type">gpl-3-0</property>
<signal name="close" handler="onAboutDialogClose" swapped="no"/>
<signal name="delete-event" handler="onAboutDialogDeleteEvent" swapped="no"/>
@ -173,6 +174,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">JSON Inspector</property>
<property name="window_position">center</property>
<property name="icon">jsoninspector.png</property>
<signal name="delete-event" handler="onMainWindowDelete" swapped="no"/>
<child>
<object class="GtkBox" id="box1">
@ -284,7 +286,6 @@
<property name="expander_column">treeviewcolumn1</property>
<property name="search_column">0</property>
<property name="level_indentation">1</property>
<property name="enable_grid_lines">both</property>
<child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection"/>
</child>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
res/jsoninspector16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,010 B

BIN
res/jsoninspector32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
res/jsoninspector64x64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

View file

@ -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/')

View file

@ -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