From 389da396f4056cbd04652b76c8e57eb3994344d0 Mon Sep 17 00:00:00 2001 From: Abhay Rana Date: Wed, 4 Dec 2013 17:28:35 +0530 Subject: [PATCH] Fixes icon issues completely. -Refers #11 - No longer searches in different places for the icon - Sets title of GtkStatusIcon for accessibility - Uses hackertray.data to package the image file - Bumps version to 1.9 Signed-off-by: Abhay Rana --- MANIFEST.in | 2 +- hackertray/appindicator_replacement.py | 19 ++++--------------- hackertray/data/__init__.py | 0 {images => hackertray/data}/hacker-tray.png | Bin setup.py | 13 ++++++++----- 5 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 hackertray/data/__init__.py rename {images => hackertray/data}/hacker-tray.png (100%) diff --git a/MANIFEST.in b/MANIFEST.in index 143dc53..6829684 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include images/hacker-tray.png \ No newline at end of file +include hackertray/data/hacker-tray.png \ No newline at end of file diff --git a/hackertray/appindicator_replacement.py b/hackertray/appindicator_replacement.py index 1167c99..0ce5d70 100644 --- a/hackertray/appindicator_replacement.py +++ b/hackertray/appindicator_replacement.py @@ -16,6 +16,8 @@ import gobject import os import sys +from pkg_resources import resource_filename + # Types CATEGORY_APPLICATION_STATUS = 0 @@ -24,25 +26,11 @@ STATUS_ACTIVE = 0 STATUS_ATTENTION = 1 # Locations to search for the given icon -search_locations = [ os.path.join(os.path.dirname(sys.executable), "images"), - os.path.join(os.path.dirname(__file__), "images"), - os.path.join(os.path.dirname(__file__), "../images"), - '/usr/share/pixmaps' ] def get_icon_filename(icon_name): # Determine where the icon is - global search_locations - - for folder in search_locations: - - filename = os.path.join(folder, icon_name + ".png") - - if os.path.isfile(filename): - return filename - - return None - + return os.path.abspath(resource_filename('hackertray.data', 'hacker-tray.png')) # The main class class Indicator: @@ -84,6 +72,7 @@ class Indicator: self.icon.set_from_file(self.active_icon) def set_label(self, label): + self.icon.set_title(label) return def set_icon(self, icon): diff --git a/hackertray/data/__init__.py b/hackertray/data/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/images/hacker-tray.png b/hackertray/data/hacker-tray.png similarity index 100% rename from images/hacker-tray.png rename to hackertray/data/hacker-tray.png diff --git a/setup.py b/setup.py index 1d681ba..dd3b5e3 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from setuptools import setup +from setuptools import find_packages import sys requirements = ['requests'] @@ -6,7 +7,7 @@ if sys.version_info < (2, 7): requirements.append('argparse') setup(name='hackertray', - version='1.8.3', + version='1.9', description='Hacker News app that sits in your System Tray', long_description='HackerTray is a simple Hacker News Linux application that lets you view top HN stories in your System Tray. It relies on appindicator, so it is not guaranteed to work on all systems. It also provides a Gtk StatusIcon fallback in case AppIndicator is not available.', keywords='hacker news hn tray system tray icon hackertray', @@ -14,12 +15,14 @@ setup(name='hackertray', author='Abhay Rana', author_email='me@captnemo.in', license='MIT', - packages=['hackertray'], - data_files=[('images', ['images/hacker-tray.png'])], + packages=find_packages(), + package_data={ + 'hackertray.data':['hacker-tray.png'] + }, install_requires=[ - 'requests', + 'requests', ], entry_points={ - 'console_scripts': ['hackertray = hackertray:main'], + 'console_scripts': ['hackertray = hackertray:main'], }, zip_safe=False)