# ============================================================================
import gtk
-from pango import FontDescription
import pango
import hildon
#import gtkhtml2
import gobject
from aboutdialog import HeAboutDialog
from portrait import FremantleRotation
-from threading import Thread, activeCount
from feedingitdbus import ServerObject
from config import Config
from cgi import escape
get_iface()
doit()
+def open_in_browser(link):
+ bus = dbus.SessionBus()
+ b_proxy = bus.get_object("com.nokia.osso_browser",
+ "/com/nokia/osso_browser/request")
+ b_iface = dbus.Interface(b_proxy, 'com.nokia.osso_browser')
+
+ notify("Opening %s" % link)
+
+ # We open the link asynchronously: if the web browser is not
+ # already running, this can take a while.
+ def error_handler():
+ """
+ Something went wrong opening the URL.
+ """
+ def e(exception):
+ notify("Error opening %s: %s" % (link, str(exception)))
+ return e
+
+ b_iface.open_new_window(link,
+ reply_handler=lambda *args: None,
+ error_handler=error_handler())
+
##
# Removes HTML or XML character references and entities from a text string.
#
if link == None:
link = self.currentUrl
- bus = dbus.SessionBus()
- b_proxy = bus.get_object("com.nokia.osso_browser",
- "/com/nokia/osso_browser/request")
- b_iface = dbus.Interface(b_proxy, 'com.nokia.osso_browser')
-
- notify("Opening %s" % link)
-
- # We open the link asynchronously: if the web browser is not
- # already running, this can take a while.
- def error_handler():
- """
- Something went wrong opening the URL.
- """
- def e(exception):
- notify("Error opening %s: %s" % (link, str(exception)))
- return e
-
- b_iface.open_new_window(link,
- reply_handler=lambda *args: None,
- error_handler=error_handler())
+ open_in_browser(link)
class DisplayFeed(hildon.StackableWindow):
def __init__(self, listing, config):
self.listing = Listing(self.config, CONFIGDIR)
self.downloadDialog = False
-
- menu = hildon.AppMenu()
- # Create a button and add it to the menu
- button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
- button.set_label("Update feeds")
- button.connect("clicked", self.button_update_clicked, "All")
- menu.append(button)
-
- button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
- button.set_label("Mark all as read")
- button.connect("clicked", self.button_markAll)
- menu.append(button)
-
- button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
- button.set_label("Add new feed")
- button.connect("clicked", lambda b: self.addFeed())
- menu.append(button)
-
- button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
- button.set_label("Manage subscriptions")
- button.connect("clicked", self.button_organize_clicked)
- menu.append(button)
- button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
- button.set_label("Settings")
- button.connect("clicked", self.button_preferences_clicked)
- menu.append(button)
-
- button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
- button.set_label("About")
- button.connect("clicked", self.button_about_clicked)
- menu.append(button)
-
- self.window.set_app_menu(menu)
- menu.show_all()
-
- #self.feedWindow = hildon.StackableWindow()
- #self.articleWindow = hildon.StackableWindow()
self.introLabel.destroy()
self.pannableListing = hildon.PannableArea()
+
+ # The main area is a view consisting of an icon and two
+ # strings. The view is bound to the Listing's database via a
+ # TreeStore.
+
self.feedItems = gtk.TreeStore(gtk.gdk.Pixbuf, str, str)
self.feedList = gtk.TreeView(self.feedItems)
self.feedList.connect('row-activated', self.on_feedList_row_activated)
- #self.feedList.set_enable_tree_lines(True)
- #self.feedList.set_show_expanders(True)
+
self.pannableListing.add(self.feedList)
icon_renderer = gtk.CellRendererPixbuf()
self.mainVbox.show_all()
self.displayListing()
- self.autoupdate = False
- self.checkAutoUpdate()
hildon.hildon_gtk_window_set_progress_indicator(self.window, 0)
gobject.idle_add(self.late_init)
-
+
def update_progress(self, percent_complete,
completed, in_progress, queued,
bytes_downloaded, bytes_updated, bytes_per_second,
self.displayListing()
def late_init(self):
+ # Finish building the GUI.
+ menu = hildon.AppMenu()
+ # Create a button and add it to the menu
+ button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+ button.set_label("Update feeds")
+ button.connect("clicked", self.button_update_clicked, "All")
+ menu.append(button)
+
+ button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+ button.set_label("Mark all as read")
+ button.connect("clicked", self.button_markAll)
+ menu.append(button)
+
+ button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+ button.set_label("Add new feed")
+ button.connect("clicked", lambda b: self.addFeed())
+ menu.append(button)
+
+ button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+ button.set_label("Manage subscriptions")
+ button.connect("clicked", self.button_organize_clicked)
+ menu.append(button)
+
+ button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+ button.set_label("Settings")
+ button.connect("clicked", self.button_preferences_clicked)
+ menu.append(button)
+
+ button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+ button.set_label("About")
+ button.connect("clicked", self.button_about_clicked)
+ menu.append(button)
+
+ self.window.set_app_menu(menu)
+ menu.show_all()
+
+ # Initialize the DBus interface.
self.dbusHandler = ServerObject(self)
bus = dbus.SessionBus()
bus.add_signal_receiver(handler_function=self.update_progress,
dbus_interface='org.marcoz.feedingit',
path='/org/marcoz/feedingit/update')
+ # Check whether auto-update is enabled.
+ self.autoupdate = False
+ #self.checkAutoUpdate()
+
gobject.idle_add(self.build_feed_display)
+ gobject.idle_add(self.check_for_woodchuck)
def build_feed_display(self):
if not hasattr(self, 'disp'):
self.disp = DisplayFeed(self.listing, self.config)
self.disp.connect("feed-closed", self.onFeedClosed)
+ def check_for_woodchuck(self):
+ if self.config.getAskedAboutWoodchuck():
+ return
+
+ try:
+ import woodchuck
+ # It is already installed successfully.
+ self.config.setAskedAboutWoodchuck(True)
+ return
+ except ImportError:
+ pass
+
+ note = hildon.hildon_note_new_confirmation(
+ self.window,
+ "\nFeedingIt can use Woodchuck, a network transfer "
+ + "daemon, to schedule transfers more intelligently.\n"
+ + "You can also use the FeedingIt widget for time-based\n"
+ + "updates.\n\n"
+ + "Install Woodchuck?\n")
+ note.set_button_texts("Install", "Cancel")
+ note.add_button("Learn More", 42)
+
+ while True:
+ response = gtk.Dialog.run(note)
+ if response == 42:
+ open_in_browser("http://hssl.cs.jhu.edu/~neal/woodchuck")
+ continue
+
+ break
+
+ note.destroy()
+
+ if response == gtk.RESPONSE_OK:
+ open_in_browser("http://maemo.org/downloads/product/raw/Maemo5/murmeltier?get_installfile")
+ self.config.setAskedAboutWoodchuck(True)
+
def button_markAll(self, button):
for key in self.listing.getListOfFeeds():
feed = self.listing.getFeed(key)