From: Neal H. Walfield Date: Sat, 30 Jul 2011 20:47:19 +0000 (+0200) Subject: Quit after completing an update triggered by Woodchuck. X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=b702e747c0944aa61f7db2aeb1bb4d2eaac4f9b8;p=feedingit Quit after completing an update triggered by Woodchuck. If started via DBus, an update is trigger, but no user interaction occurs by the time the update completes, quit when the update completes. --- diff --git a/src/FeedingIt.py b/src/FeedingIt.py index 55c0497..35aa2aa 100644 --- a/src/FeedingIt.py +++ b/src/FeedingIt.py @@ -36,7 +36,7 @@ from webkit import WebView # import gtkhtml2 # has_webkit=False from os.path import isfile, isdir, exists -from os import mkdir, remove, stat +from os import mkdir, remove, stat, environ import gobject from aboutdialog import HeAboutDialog from portrait import FremantleRotation @@ -1007,6 +1007,12 @@ class FeedingIt: self.window.show_all() self.config = Config(self.window, CONFIGDIR+"config.ini") gobject.idle_add(self.createWindow) + + # This is set to try when the user interacts with the program. + # If, after an update is complete, we discover that the + # environment variable DBUS_STARTED_ADDRESS is set and + # self.had_interaction is False, we quit. + self.had_interaction = False def createWindow(self): self.category = 0 @@ -1124,6 +1130,9 @@ class FeedingIt: self.updateDbusHandler.UpdateFinished() self.updateDbusHandler.ArticleCountUpdated() + if not self.had_interaction and 'DBUS_STARTER_ADDRESS' in environ: + print "Update complete. No interaction, started by dbus: quitting." + self.quit() def stop_running_update(self, button): self.stopButton.set_sensitive(False) import dbus @@ -1182,6 +1191,7 @@ class FeedingIt: self.system_inactivity_ind) def button_markAll(self, button): + self.had_interaction = True for key in self.listing.getListOfFeeds(): feed = self.listing.getFeed(key) feed.markAllAsRead() @@ -1191,6 +1201,7 @@ class FeedingIt: self.displayListing() def button_about_clicked(self, button): + self.had_interaction = True HeAboutDialog.present(self.window, \ __appname__, \ ABOUT_ICON, \ @@ -1202,9 +1213,11 @@ class FeedingIt: ABOUT_DONATE) def button_export_clicked(self, button): + self.had_interaction = True opml = ExportOpmlData(self.window, self.listing) def button_import_clicked(self, button): + self.had_interaction = True opml = GetOpmlData(self.window) feeds = opml.getData() for (title, url) in feeds: @@ -1212,6 +1225,7 @@ class FeedingIt: self.displayListing() def addFeed(self, urlIn="http://"): + self.had_interaction = True wizard = AddWidgetWizard(self.window, self.listing, urlIn, self.listing.getListOfCategories()) ret = wizard.run() if ret == 2: @@ -1222,11 +1236,13 @@ class FeedingIt: self.displayListing() def button_organize_clicked(self, button): + self.had_interaction = True def after_closing(): self.displayListing() SortList(self.window, self.listing, self, after_closing) def button_update_clicked(self, button, key): + self.had_interaction = True for k in self.listing.getListOfFeeds(): self.listing.updateFeed (k) #self.displayListing() @@ -1239,6 +1255,7 @@ class FeedingIt: self.updateDbusHandler.ArticleCountUpdated() def button_preferences_clicked(self, button): + self.had_interaction = True dialog = self.config.createDialog() dialog.connect("destroy", self.prefsClosed) @@ -1332,6 +1349,7 @@ class FeedingIt: # pass def on_feedList_row_activated(self, treeview, path, column): + self.had_interaction = True model = treeview.get_model() iter = model.get_iter(path) key = model.get_value(iter, COLUMN_KEY)