Uses firefox module in the main app.

Abhay Rana 2014-10-03 18:57:42 +05:30
parent 0b0b5c92b8
commit bd322e5191
1 changed files with 16 additions and 9 deletions

View File

@ -90,7 +90,7 @@ class HackerNewsApp:
self.refresh(, firefox_data_directory=args.firefox)
def toggleComments(self, widget):
"""Whether comments page is opened or not"""
@ -160,14 +160,19 @@ class HackerNewsApp:
def refresh(self, widget=None, no_timer=False, chrome_data_directory=None):
def refresh(self, widget=None, no_timer=False, chrome_data_directory=None, firefox_data_directory=None):
"""Refreshes the menu """
# Create an array of 20 false to denote matches in History
searchResults = [False]*20
data = list(reversed(HackerNews.getHomePage()[0:20]))
urls = [item['url'] for item in data]
urls = [item['url'] for item in data]
searchResults =, chrome_data_directory)
searchResults = self.mergeBoolArray(searchResults,, chrome_data_directory))
searchResults = self.mergeBoolArray(searchResults,, firefox_data_directory))
#Remove all the current stories
for i in
@ -176,10 +181,7 @@ class HackerNewsApp:
#Add back all the refreshed news
for index, item in enumerate(data):
item['history'] = searchResults[index]
item['history'] = False
item['history'] = searchResults[index]
# Catch network errors
except requests.exceptions.RequestException as e:
@ -189,13 +191,18 @@ class HackerNewsApp:
if not no_timer:
gtk.timeout_add(10 * 30 * 1000, self.refresh, widget, no_timer, chrome_data_directory)
# Merges two boolean arrays, using OR operation against each pair
def mergeBoolArray(self, original, patch):
for index, var in enumerate(original):
original[index] = original[index] or patch[index]
return original
def main():
parser = argparse.ArgumentParser(description='Hacker News in your System Tray')
parser.add_argument('-v','--version', action='version', version=Version.current())
parser.add_argument('-c','--comments', dest='comments',action='store_true', help="Load the HN comments link for the article as well")
parser.add_argument('--chrome', dest='chrome', help="Specify a Google Chrome Profile directory to use for matching chrome history")
parser.add_argument('--firefox', dest='firefox', help="Specify a Firefox Profile directory to use for matching firefox history")
args = parser.parse_args()
indicator = HackerNewsApp(args)