Adds comments support via a toggle switch.

pull/17/head 1.9.1
Abhay Rana 9 years ago
parent 3536201784
commit c5bdb2a362
  1. 16
      hackertray/__init__.py
  2. 2
      setup.py

@ -26,6 +26,7 @@ except ImportError, e:
from hackernews import HackerNews
class HackerNewsApp:
HN_URL_PREFIX="https://news.ycombinator.com/item?id="
def __init__(self):
#Load the database
home = expanduser("~")
@ -45,11 +46,19 @@ class HackerNewsApp:
# create a menu
self.menu = gtk.Menu()
#The default state is false, and it toggles when you click on it
self.commentState = False
# create items for the menu - refresh, quit and a separator
menuSeparator = gtk.SeparatorMenuItem()
menuSeparator.show()
self.menu.append(menuSeparator)
btnComments = gtk.CheckMenuItem("Show Comments")
btnComments.show()
btnComments.connect("activate", self.toggleComments)
self.menu.append(btnComments)
btnAbout = gtk.MenuItem("About")
btnAbout.show()
btnAbout.connect("activate", self.showAbout)
@ -70,6 +79,10 @@ class HackerNewsApp:
self.ind.set_menu(self.menu)
self.refresh()
'''Whether comments page is opened or not'''
def toggleComments(self, widget):
self.commentState = not self.commentState
'''Handle the about btn'''
def showAbout(self, widget):
webbrowser.open("https://github.com/captn3m0/hackertray/")
@ -99,6 +112,8 @@ class HackerNewsApp:
widget.signal_id = widget.connect('activate', self.open)
self.db.add(widget.item_id)
webbrowser.open(widget.url)
if(self.commentState):
webbrowser.open(self.HN_URL_PREFIX+widget.hn_id)
'''Adds an item to the menu'''
def addItem(self, item):
@ -108,6 +123,7 @@ class HackerNewsApp:
i.set_active(item['id'] in self.db)
i.url = item['url']
i.signal_id = i.connect('activate', self.open)
i.hn_id = item['id']
i.item_id = item['id']
self.menu.prepend(i)
i.show()

@ -7,7 +7,7 @@ if sys.version_info < (2, 7):
requirements.append('argparse')
setup(name='hackertray',
version='1.9',
version='1.9.1',
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',

Loading…
Cancel
Save