fix icon resource fetching to work in Ubuntu 13.10
This commit is contained in:
parent
27fb60cc26
commit
12d655998d
|
@ -8,7 +8,7 @@ import requests
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import json
|
import json
|
||||||
import argparse
|
import argparse
|
||||||
from os.path import expanduser
|
from os.path import expanduser, join, extsep
|
||||||
import signal
|
import signal
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -25,6 +25,15 @@ except ImportError, e:
|
||||||
|
|
||||||
from hackernews import HackerNews
|
from hackernews import HackerNews
|
||||||
|
|
||||||
|
def res_pth(fn):
|
||||||
|
res = join('hackertray/data', extsep.join([fn, 'png']))
|
||||||
|
try:
|
||||||
|
from pkg_resources import resource_filename, Requirement
|
||||||
|
return resource_filename(Requirement.parse('hackertray'), res)
|
||||||
|
except ImportError, e:
|
||||||
|
# just return what we got in the first place
|
||||||
|
return fn
|
||||||
|
|
||||||
class HackerNewsApp:
|
class HackerNewsApp:
|
||||||
HN_URL_PREFIX="https://news.ycombinator.com/item?id="
|
HN_URL_PREFIX="https://news.ycombinator.com/item?id="
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -39,16 +48,16 @@ class HackerNewsApp:
|
||||||
self.db = set()
|
self.db = set()
|
||||||
|
|
||||||
# create an indicator applet
|
# create an indicator applet
|
||||||
self.ind = appindicator.Indicator ("Hacker Tray", "hacker-tray", appindicator.CATEGORY_APPLICATION_STATUS)
|
self.ind = appindicator.Indicator ("Hacker Tray", res_pth("hacker-tray"), appindicator.CATEGORY_APPLICATION_STATUS)
|
||||||
self.ind.set_status (appindicator.STATUS_ACTIVE)
|
self.ind.set_status (appindicator.STATUS_ACTIVE)
|
||||||
self.ind.set_label("Y")
|
#self.ind.set_label("Y")
|
||||||
|
|
||||||
# create a menu
|
# create a menu
|
||||||
self.menu = gtk.Menu()
|
self.menu = gtk.Menu()
|
||||||
|
|
||||||
#The default state is false, and it toggles when you click on it
|
#The default state is false, and it toggles when you click on it
|
||||||
self.commentState = False
|
self.commentState = False
|
||||||
|
|
||||||
# create items for the menu - refresh, quit and a separator
|
# create items for the menu - refresh, quit and a separator
|
||||||
menuSeparator = gtk.SeparatorMenuItem()
|
menuSeparator = gtk.SeparatorMenuItem()
|
||||||
menuSeparator.show()
|
menuSeparator.show()
|
||||||
|
@ -148,3 +157,6 @@ def main():
|
||||||
parser.parse_args()
|
parser.parse_args()
|
||||||
indicator = HackerNewsApp()
|
indicator = HackerNewsApp()
|
||||||
indicator.run()
|
indicator.run()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
5
setup.py
5
setup.py
|
@ -1,6 +1,7 @@
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools import find_packages
|
from setuptools import find_packages
|
||||||
import sys
|
import sys
|
||||||
|
import glob
|
||||||
|
|
||||||
requirements = ['requests']
|
requirements = ['requests']
|
||||||
if sys.version_info < (2, 7):
|
if sys.version_info < (2, 7):
|
||||||
|
@ -19,6 +20,10 @@ setup(name='hackertray',
|
||||||
package_data={
|
package_data={
|
||||||
'hackertray.data':['hacker-tray.png']
|
'hackertray.data':['hacker-tray.png']
|
||||||
},
|
},
|
||||||
|
include_package_data = True,
|
||||||
|
data_files = [
|
||||||
|
('share/hackertray/', glob.glob('hackertray/data/*'))
|
||||||
|
],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'requests>=2.0',
|
'requests>=2.0',
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue