Added auto-rotation, and line-wrap buttons
authorYves <ymarcoz@n900-sdk.(none)>
Sat, 2 Jan 2010 23:22:53 +0000 (15:22 -0800)
committerYves <ymarcoz@n900-sdk.(none)>
Sat, 2 Jan 2010 23:22:53 +0000 (15:22 -0800)
Makefile
debian/README.Debian [deleted file]
debian/changelog
debian/control
src/FeedingIt.desktop
src/FeedingIt.py
src/rss.py

index 10ae70f..195cd97 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -10,5 +10,11 @@ install:
        install -d ${DESTDIR}/opt/FeedingIt
        install src/FeedingIt.py ${DESTDIR}/opt/FeedingIt
        install src/feedparser.py ${DESTDIR}/opt/FeedingIt
+       install src/portrait.py ${DESTDIR}/opt/FeedingIt
+       install src/rss.py ${DESTDIR}/opt/FeedingIt
        install -d ${DESTDIR}/usr/share/applications/hildon
-       install src/FeedingIt.desktop ${DESTDIR}/usr/share/applications/hildon
\ No newline at end of file
+       install src/FeedingIt.desktop ${DESTDIR}/usr/share/applications/hildon
+       install -d ${DESTDIR}/usr/share/icons/hicolor/40x40/apps/
+       install data/40x40/feedingit.png ${DESTDIR}/usr/share/icons/hicolor/40x40/apps/
+       install -d ${DESTDIR}/usr/share/icons/hicolor/26x26/apps/
+       install data/26x26/feedingit.png ${DESTDIR}/usr/share/icons/hicolor/26x26/apps/
\ No newline at end of file
diff --git a/debian/README.Debian b/debian/README.Debian
deleted file mode 100644 (file)
index 5f7fc10..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-feedingit for Debian
---------------------
-
-<possible notes regarding this package - if none, delete this file>
-
- -- unknown <yves@marcoz.org>  Mon, 28 Dec 2009 17:59:19 -0800
index d11bac0..360ec85 100644 (file)
@@ -1,6 +1,13 @@
+feedingit (0.1.1-1) unstable; urgency=low
+
+  * Adding portrait mode support / Better gtk gui
+
+ -- Yves <yves@marcoz.org>  Mon, 28 Dec 2009 17:59:19 -0800
+
+
 feedingit (0.1-1) unstable; urgency=low
 
   * Initial release (Closes: #nnnn)  <nnnn is the bug number of your ITP>
 
- -- unknown <yves@marcoz.org>  Mon, 28 Dec 2009 17:59:19 -0800
+ -- Yves <yves@marcoz.org>  Mon, 28 Dec 2009 17:59:19 -0800
 
index 166fe74..e9db4cb 100644 (file)
@@ -1,12 +1,48 @@
 Source: feedingit
-Section: unknown
+Section: user/network
 Priority: extra
-Maintainer: unknown <yves@marcoz.org>
+Maintainer: Yves <yves@marcoz.org>
 Build-Depends: debhelper (>= 5)
 Standards-Version: 3.7.2
 
 Package: feedingit
 Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, python-gtkhtml2, python
+Depends: ${shlibs:Depends}, ${misc:Depends}, python-gtkhtml2, python, python-hildon
 Description: Simple RSS Reader
  Simple RSS Reader, based on feedparser.py
+XB-Maemo-Icon-26:
+ iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAYAAACpSkzOAAAAAXNSR0IArs4c
+ 6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0
+ SU1FB9oBAgQxJ4xGbtcAAAWmSURBVEjHrZZdiF1XFcd/a59z7r1z585MZjKT
+ zJgMHVuaWE38aBqqhbEdRJCA+tISg2BfBPETBfWp+NAXQUQKWlRqlYggiLVq
+ wKiorRFaUpjpqImhbb6aTGYyM5mP+32+9lo+3JvpbUzTPLjgsPdhn71/+7/W
+ 2WsvAYhP7OOff740qml9J2oixlubcltmDpNCtHz/kU9ck/c+Qwhw6m8LkwPD
+ 4dFoYO+Mi7ZhEgCuO0VApNNef9/q3wLkm2TVS8/NPvOnR4HLIYBP4/1DE/tm
+ xvdMGhgmBcFycH0QlMAVIShD0Aeu20rQeXDADS4QMSFgafa3M/Xl4/u3QJpn
+ SHmCfOVF03jduR0fIbzv51hW66jRBG1egGQF25xDm+eRcFt3E1HXA73uNXGF
+ IZW+3aJ5x9cdkBcsb6MSO8tTM+kTVxxFC9u7zlKk/24ww3YfxjWvoAu/xNfO
+ gCshQQRS6PGbmKl35nO0G1MH4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GRELzDcBcu4Q4vDZq1A
+ vO8BgVteX9xcL5V3jQSV8W4Ghqkd0F9Qy7NUtFU1NzhOo23i3/6WlUbSZn3x
+ yjq4ZfAdULkUzi+tZp9ZWDx7wLTz+6jSHqxw+N79/R8Y2fdBTavr8p+Tp2Vp
+ KX0qyVl4u2tWHBZE4WylHM6Dv/W2jh5yz77+xD228fuH7cSXRuxnh+SJz72v
+ WLqdq/xGC3v6DigBZYBP3SN39xdtb3liiotz8/z7zPqxn5ySJ19eToZvoUa6
+ 5UsGtID4ejlzM9AoEA2E7sFi5O9YefUcz/3l7Nmnz8iTp9dspDv+VhADcqAO
+ rADpzUAeSIAGUAgDW3ptNfjVmeOv+rl1OXZ6zS4Chf+tRG4KanTX8r2D3KAq
+ CoTQG747SYBQILDbLOm687LbrwL/j/ZfPR8PIxnX9dcAAAAASUVORK5CYII
\ No newline at end of file
index 4ba47e6..fa98319 100644 (file)
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Encoding=UTF-8
-Version=0.10
+Version=0.1.1
 Type=Application
 Name=FeedingIt
 Exec=/usr/bin/FeedingIt
-Icon=xournal
+Icon=feedingit
index f6706a7..918dc8e 100644 (file)
@@ -19,7 +19,7 @@
 # ============================================================================
 # Name        : FeedingIt.py
 # Author      : Yves Marcoz
-# Version     : 0.1
+# Version     : 0.1.1
 # Description : PyGtk Example 
 # ============================================================================
 
@@ -33,9 +33,10 @@ import webbrowser
 import pickle
 from os.path import isfile, isdir
 from os import mkdir
-import md5
 import sys   
 import urllib2
+import gobject
+from portrait import FremantleRotation
 
 from rss import *
    
@@ -67,18 +68,15 @@ class AddWidgetWizard(hildon.WizardDialog):
         self.set_forward_page_func(self.some_page_func)
    
         self.show_all()
-        print dir(self)
         
     def getData(self):
         return (self.nameEntry.get_text(), self.urlEntry.get_text())
         
     def on_page_switch(self, notebook, page, num, dialog):
-        print >>sys.stderr, "Page %d" % num
         return True
    
     def some_page_func(self, nb, current, userdata):
         # Validate data for 1st page
-        print current
         if current == 0:
             entry = nb.get_nth_page(current)
             # Check the name is not null
@@ -86,17 +84,28 @@ class AddWidgetWizard(hildon.WizardDialog):
         elif current == 1:
             entry = nb.get_nth_page(current)
             # Check the url is not null, and starts with http
-            print ( (len(entry.get_text()) != 0) and (entry.get_text().startswith("http")) )
             return ( (len(entry.get_text()) != 0) and (entry.get_text().startswith("http")) )
         elif current != 2:
             return False
         else:
             return True
 
+class DisplayFeed(hildon.StackableWindow):
+    def __init__(self, listing, key):
+        hildon.StackableWindow.__init__(self)
+        self.listing = listing
+        self.key = key
+        
+    
+
 class FeedingIt:
     def __init__(self):
+        self.listing = Listing()
+        
         # Init the windows
         self.window = hildon.StackableWindow()
+        self.window.set_title("FeedingIt")
+        FremantleRotation("FeedingIt", main_window=self.window)
         menu = hildon.AppMenu()
         # Create a button and add it to the menu
         button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
@@ -108,13 +117,18 @@ class FeedingIt:
         button.connect("clicked", self.button_add_clicked)
         menu.append(button)
         
+        button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+        button.set_label("Delete Feed")
+        #button.set_selector(self.create_selector())
+        button.connect("clicked", self.button_delete_clicked)
+        menu.append(button)
+        
         self.window.set_app_menu(menu)
         menu.show_all()
         
         self.feedWindow = hildon.StackableWindow()
         self.articleWindow = hildon.StackableWindow()
 
-        self.listing = Listing()
         #self.listing.downloadFeeds()
         self.displayListing() 
         
@@ -132,13 +146,55 @@ class FeedingIt:
         self.displayListing()
         
     def button_update_clicked(self, button, key):
-        hildon.hildon_gtk_window_set_progress_indicator(self.window, 1)
+        #hildon.hildon_gtk_window_set_progress_indicator(self.window, 1)
         if key == "All":
             self.listing.updateFeeds()
         else:
             self.listing.getFeed(key).updateFeed()
+            self.displayFeed(key)            
+        self.displayListing()
+        #hildon.hildon_gtk_window_set_progress_indicator(self.window, 0)
+
+    def button_delete_clicked(self, button):
+        self.pickerDialog = hildon.PickerDialog(self.window)
+        #HildonPickerDialog
+        self.pickerDialog.set_selector(self.create_selector())
+        self.pickerDialog.show_all()
+        
+    def create_selector(self):
+        selector = hildon.TouchSelector(text=True)
+        # Selection multiple
+        #selector.set_column_selection_mode(hildon.TOUCH_SELECTOR_SELECTION_MODE_MULTIPLE)
+        self.mapping = {}
+        selector.connect("changed", self.selection_changed)
+
+        for key in self.listing.getListOfFeeds():
+            title=self.listing.getFeedTitle(key)
+            selector.append_text(title)
+            self.mapping[title]=key
+
+        return selector
+
+    def selection_changed(self, widget, data):
+        current_selection = widget.get_current_text()
+        #print 'Current selection: %s' % current_selection
+        #print "To Delete: %s" % self.mapping[current_selection]
+        self.pickerDialog.destroy()
+        if self.show_confirmation_note(self.window, current_selection):
+            self.listing.removeFeed(self.mapping[current_selection])
+        del self.mapping
         self.displayListing()
-        hildon.hildon_gtk_window_set_progress_indicator(self.window, 0)
+
+    def show_confirmation_note(self, parent, title):
+        note = hildon.Note("confirmation", parent, "Are you sure you want to delete " + title +"?")
+
+        retcode = gtk.Dialog.run(note)
+        note.destroy()
+        
+        if retcode == gtk.RESPONSE_OK:
+            return True
+        else:
+            return False
         
     def displayListing(self):
         try:
@@ -164,46 +220,67 @@ class FeedingIt:
         
     def displayFeed(self, key):
         # Initialize the feed panel
+        try:
+            self.feedWindow.destroy()
+        except:
+            pass
+        self.feedWindow.set_title(self.listing.getFeedTitle(key))
         self.vboxFeed = gtk.VBox(False, 10)
         self.pannableFeed = hildon.PannableArea()
         self.pannableFeed.add_with_viewport(self.vboxFeed)
+        self.pannableFeed.set_property("mov-mode", hildon.MOVEMENT_MODE_BOTH)
+        
+        menu = hildon.AppMenu()
+        # Create a button and add it to the menu
+        button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+        button.set_label("Update Feed")
+        button.connect("clicked", self.button_update_clicked, key)
+        menu.append(button)
+        self.feedWindow.set_app_menu(menu)
+        menu.show_all()
         
         index = 0
         for item in self.listing.getFeed(key).getEntries():
-            #button = hildon.Button(gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
-            #                  hildon.BUTTON_ARRANGEMENT_HORIZONTAL)
-            #button.set_text(item["title"], time.strftime("%a, %d %b %Y %H:%M:%S",item["updated_parsed"]))
-            #button.set_text(item["title"], time.asctime(item["updated_parsed"]))
-            #button.set_text(item["title"],"")
-            #button.set_alignment(0,0,1,1)
-            #button.set_markup(True)
             button = gtk.Button(item["title"])
             button.set_alignment(0,0)
             label = button.child
-            #label.set_markup(item["title"])
             label.modify_font(pango.FontDescription("sans 16"))
+            label.set_line_wrap(True)
+            
+            label.set_size_request(self.feedWindow.get_size()[0]-50, -1)
             button.connect("clicked", self.button_clicked, self, self.window, key, index)
             
-            self.vboxFeed.pack_start(button, expand=False)
+            self.vboxFeed.pack_start(button, expand=False)           
             index=index+1
 
         self.feedWindow.add(self.pannableFeed)
         self.feedWindow.show_all()
      
     def displayArticle(self, key, index):
-        text = self.listing.getFeed(key).getArticle(index)
+        self.text = self.listing.getFeed(key).getArticle(index)
         self.articleWindow = hildon.StackableWindow()
+        self.articleWindow.set_title(self.listing.getFeedTitle(key))
+        
+        menu = hildon.AppMenu()
+        # Create a button and add it to the menu
+        button = hildon.GtkButton(gtk.HILDON_SIZE_AUTO)
+        button.set_label("Display Images")
+        button.connect("clicked", self.reloadArticle)
+        menu.append(button)
+        self.articleWindow.set_app_menu(menu)
+        menu.show_all()
 
         # Init the article display    
         self.view = gtkhtml2.View()
         self.pannable_article = hildon.PannableArea()
         self.pannable_article.add(self.view)
+        self.pannable_article.set_property("mov-mode", hildon.MOVEMENT_MODE_BOTH)
         self.document = gtkhtml2.Document()
         self.view.set_document(self.document)
         
         self.document.clear()
         self.document.open_stream("text/html")
-        self.document.write_stream(text)
+        self.document.write_stream(self.text)
         self.document.close_stream()
         
         self.articleWindow.add(self.pannable_article)
@@ -212,14 +289,13 @@ class FeedingIt:
         
         self.document.connect("link_clicked", self._signal_link_clicked)
         self.document.connect("request-url", self._signal_request_url)
+        #self.document.connect("ReloadArticle", self.reloadArticle)
         
+    def reloadArticle(self, widget):
         self.document.open_stream("text/html")
-        self.document.write_stream(text)
+        self.document.write_stream(self.text)
         self.document.close_stream()
-        self.document.show()
      
-    def tap(self):
-        pass
 #    def _signal_on_url(self, object, url):
 #        if url == None: url = ""
 #        else: url = self._complete_url(url)
@@ -250,19 +326,21 @@ class FeedingIt:
 #    def _fetch_url(self, url, headers=[]):
 #        return self._open_url(url, headers).read()
         
-        
     def button_clicked(widget, button, app, window, key, index):
         app.displayArticle(key, index)
+        #app.document.emit("ReloadArticle")
     
     def buttonFeedClicked(widget, button, app, window, key):
         app.displayFeed(key)
      
     def run(self):
         self.window.connect("destroy", gtk.main_quit)
-        #self.window.show_all()
         gtk.main()
 
 if __name__ == "__main__":
+    #gobject.signal_new("ReloadArticle", gtkhtml2.Document,
+    #                   gobject.SIGNAL_RUN_LAST,
+    #                   gobject.TYPE_NONE, ())
     if not isdir(CONFIGDIR):
         try:
             mkdir(CONFIGDIR)
index 41f4d31..63ecbc6 100644 (file)
@@ -25,6 +25,7 @@
 
 from os.path import isfile
 from os.path import isdir
+from os import remove
 import pickle
 import md5
 import feedparser
@@ -70,10 +71,22 @@ class Feed:
     
     def getArticle(self, index):
         entry = self.feed["entries"][index]
-        text = "<h4><a href=\"" + entry["link"] + "\">" + entry["title"] + "</a></h4>"
-        text = text + "<small><i>Date: " + time.strftime("%a, %d %b %Y %H:%M:%S",entry["updated_parsed"]) + "</i></small>"
-        text = text + "<BR />"
-        text = text + entry["summary"]
+        title = entry.get('title', 'No title')
+        #content = entry.get('content', entry.get('summary_detail', {}))
+        if entry.has_key('content'):
+            content = entry.content[0].value
+        else:
+            content = entry.get('summary', '')
+        #print content.keys()
+        #.get('value', "No Data")
+        link = entry.get('link', 'NoLink')
+        date = time.strftime("%a, %d %b %Y %H:%M:%S",entry["updated_parsed"])
+        #text = '''<div style="color: black; background-color: white;">'''
+        text = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>'
+        text = text + '<div><a href=\"' + link + '\">' + title + "</a>"
+        text = text + "<BR /><small><i>Date: " + date + "</i></small></div>"
+        text = text + "<BR /><BR />"
+        text = text + content
         return text    
     
 class Listing:
@@ -102,6 +115,12 @@ class Listing:
         self.listOfFeeds[getId(title)] = {"title":title, "url":url}
         self.saveConfig()
         self.feeds[getId(title)] = Feed(title, url)
+        
+    def removeFeed(self, key):
+        del self.listOfFeeds[key]
+        del self.feeds[key]
+        if isfile(CONFIGDIR+key):
+           remove(CONFIGDIR+key)
     
     def saveConfig(self):
         file = open(CONFIGDIR+"feeds.pickle", "w")