diff --git a/hackertray/__init__.py b/hackertray/__init__.py index 1b51958..fe88647 100644 --- a/hackertray/__init__.py +++ b/hackertray/__init__.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() diff --git a/setup.py b/setup.py index dd3b5e3..ff00e06 100644 --- a/setup.py +++ b/setup.py @@ -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',