small improvements
authorDaniel Martin Yerga <yerga@ubuntu.(none)>
Tue, 23 Feb 2010 13:20:33 +0000 (14:20 +0100)
committerDaniel Martin Yerga <yerga@ubuntu.(none)>
Tue, 23 Feb 2010 13:20:33 +0000 (14:20 +0100)
changelog
stockthis.py

index 67d450e..b6a543a 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,9 @@
+2010-02-23  Daniel Martin Yerga  <dyerga@gmail.com>
+
+  * A bit improved search dialog (and using Nokia icon).
+  * Enter key activates most dialogs.
+  * New, improved About dialog.
+
 2010-02-17  Daniel Martin Yerga  <dyerga@gmail.com>
 
   * Change and percentage columns added to portfolio view.
index 328853e..b180771 100644 (file)
@@ -19,7 +19,8 @@
 # StocksThis: Application to get stocks data from Yahoo Finance.
 #
 
-_version = "StockThis 0.3 rev1"
+_version = "StockThis 0.4 rev1"
+VERSION = "0.4"
 
 import urllib2
 import gtk, gobject
@@ -639,16 +640,13 @@ class StocksPy:
                             widgets, symbol)
 
 
-        stockiconspath = "/usr/share/icons/hicolor/48x48/hildon/"
         info_btn = hildon.Button(fhsize, horbtn)
-        img = gtk.Image()
-        img.set_from_file(stockiconspath + "general_information.png")
+        img = gtk.image_new_from_icon_name("general_information", gtk.ICON_SIZE_SMALL_TOOLBAR)
         info_btn.set_image(img)
         info_btn.connect("clicked", self.show_app_information)
 
         search_btn = hildon.Button(fhsize, horbtn)
-        img = gtk.Image()
-        img.set_from_file(stockiconspath + "general_search.png")
+        img = gtk.image_new_from_icon_name("general_search", gtk.ICON_SIZE_SMALL_TOOLBAR)
         search_btn.set_image(img)
         search_btn.connect("clicked", self.show_search_dialog)
 
@@ -671,13 +669,19 @@ class StocksPy:
         dlg = gtk.Dialog(title='Search company', parent=None, flags=0)
         dlg.set_has_separator(False)
 
+        hbox = gtk.HBox()
+
         entry = hildon.Entry(fhsize)
-        dlg.vbox.pack_start(entry, False, False, 0)
+        entry.connect("activate", self.do_search, entry, dlg)
+        hbox.pack_start(entry, True, True, 0)
 
         button = hildon.Button(fhsize, horbtn)
-        button.set_label("Search")
+        img = gtk.image_new_from_icon_name("general_search", gtk.ICON_SIZE_SMALL_TOOLBAR)
+        button.set_image(img)
         button.connect("clicked", self.do_search, entry, dlg)
-        dlg.vbox.pack_start(button, False, False, 0)
+        hbox.pack_start(button, False, False, 0)
+
+        dlg.vbox.pack_start(hbox, False, False, 0)
 
         dlg.show_all()
         dlg.run()
@@ -834,10 +838,14 @@ class StocksPy:
         dlg.vbox.pack_start(button1, False, False, 0)
 
         entry1 = hildon.Entry(fhsize)
+        entry2 = hildon.Entry(fhsize)
+
         entry1.set_placeholder("Name")
+        entry1.connect("activate", self.add_item, dlg, button1, entry1, entry2)
         dlg.vbox.pack_start(entry1, False, False, 0)
 
-        entry2 = hildon.Entry(fhsize)
+
+        entry2.connect("activate", self.add_item, dlg, button1, entry1, entry2)
         entry2.set_placeholder("Yahoo Finance symbol")
         dlg.vbox.pack_start(entry2, False, False, 0)
 
@@ -1030,142 +1038,193 @@ class StocksPy:
 class About:
 
     def __init__(self, widget):
-        self.abdialog = gtk.Dialog(title='About', parent=None, flags=0)
-        self.abdialog.set_has_separator(False)
-        self.abdialog.set_size_request(-1, 400)
+        self.abdialog = gtk.Dialog()
+        self.abdialog.set_title("About StockThis")
 
-        self.info_lb = gtk.Label()
-        self.info_lb.set_line_wrap(True)
+        notebook = gtk.Notebook()
+        notebook.set_show_tabs(False)
+        notebook.set_scrollable(False)
+        notebook.set_show_border(False)
 
-        self.id = False
+        # Description page #
+        vbox = gtk.VBox()
 
-        hbox1 = gtk.HBox()
+        label = gtk.Label()
+        label.set_markup("<b><big>StockThis %s</big></b>" % VERSION)
+        vbox.pack_start(label, True, True, 0)
 
-        button = hildon.Button(fhsize, horbtn)
-        button.set_title('Description')
-        button.connect("clicked", self.show_info, 'description')
-        hbox1.pack_start(button, True, True, 0)
+        label = gtk.Label("Stocks application with big database")
+        vbox.pack_start(label, True, True, 0)
 
-        button = hildon.Button(fhsize, horbtn)
-        button.set_title('Credits')
-        button.connect("clicked", self.show_info, 'credits')
-        hbox1.pack_start(button, True, True, 0)
+        label = gtk.Label("GNU General Public License")
+        vbox.pack_start(label, True, True, 0)
+
+        url = "http://stockthis.garage.maemo.org"
+        webbtn = gtk.LinkButton(url, "Web")
+        vbox.pack_start(webbtn, True, True, 0)
+        gtk.link_button_set_uri_hook(self.launch_browser)
+
+        notebook.append_page(vbox, gtk.Label())
+
+        # Credits page #
+        vbox = gtk.VBox()
+        textview = hildon.TextView()
+        textview.set_cursor_visible(False)
+        textview.set_wrap_mode(gtk.WRAP_WORD)
+        text = "Written by Daniel Martin Yerga (dyerga@gmail.com)"
+        textview.get_buffer().set_text(text)
+
+        parea = hildon.PannableArea()
+        parea.add(textview)
+
+        vbox.pack_start(parea, True, True, 0)
+        notebook.append_page(vbox, gtk.Label())
+
+
+        # Donate page #
+        vbox = gtk.VBox()
+
+        textview = hildon.TextView()
+        textview.set_cursor_visible(False)
+        textview.set_wrap_mode(gtk.WRAP_WORD)
+        text = """StockThis is a free software application.
+Developing good software takes time and hard work.
+StockThis's author develops the program in his spare time.
+If you like the program and it's helpful, consider donating a small amount of money.
+Donations are a great incentive and help the developer feel that the hard work is appreciated.
+"""
+        textview.get_buffer().set_text(text)
+
+        parea = hildon.PannableArea()
+        parea.add(textview)
 
         button = hildon.Button(fhsize, horbtn)
-        button.set_title('License')
-        button.connect("clicked", self.show_info, 'license')
-        hbox1.pack_start(button, True, True, 0)
+        button.set_title("Make donation")
+        url = "http://stockthis.garage.maemo.org/donate.html"
+        button.connect("clicked", self.launch_browser, url)
+        vbox.pack_start(button, False, False, 0)
+        vbox.pack_start(parea, True, True, 0)
+
+        notebook.append_page(vbox, gtk.Label())
+
+        # Report page #
+        vbox = gtk.VBox()
+
+        textview = hildon.TextView()
+        textview.set_cursor_visible(False)
+        textview.set_wrap_mode(gtk.WRAP_WORD)
+        text = """StockThis is being improved thanks to bug reports that users have submitted. The author appreciates these reports.
+If the application is having an error when you're using it, you have two choices to report this error:
+1) Send the log from the button above (if there's an error in the log).
+2) Press the button and read how to report a bug."""
+        textview.get_buffer().set_text(text)
+
+        parea = hildon.PannableArea()
+        parea.add(textview)
+
+        hbox = gtk.HBox()
+        hbox.set_homogeneous(True)
 
         button = hildon.Button(fhsize, horbtn)
-        button.set_title('Donate')
-        button.connect("clicked", self.show_info, 'donate')
-        hbox1.pack_start(button, True, True, 0)
+        button.set_title("Report error")
+        url = "http://stockthis.garage.maemo.org/reporting.html"
+        button.connect("clicked", self.launch_browser, url)
+        hbox.pack_start(button, True, True, 0)
 
         button = hildon.Button(fhsize, horbtn)
-        button.set_title('Report ')
-        button.connect("clicked", self.show_info, 'report')
-        hbox1.pack_start(button, True, True, 0)
+        button.set_title("Log")
+        button.connect("clicked", self.on_show_log)
+        hbox.pack_start(button, True, True, 0)
+
+        vbox.pack_start(hbox, False, False, 0)
+        vbox.pack_start(parea, True, True, 0)
+
+        notebook.append_page(vbox, gtk.Label())
+
+        # Rate page #
+        vbox = gtk.VBox()
+
+        textview = hildon.TextView()
+        textview.set_cursor_visible(False)
+        textview.set_wrap_mode(gtk.WRAP_WORD)
+        text = """The downloads section in maemo.org has a nice system where you can rate applications.
+If you consider StockThis a good application (or a bad one too), you could rate it in maemo.org site."""
+        textview.get_buffer().set_text(text)
 
         button = hildon.Button(fhsize, horbtn)
-        button.set_title(' Rate ')
-        button.connect("clicked", self.show_info, 'vote')
-        hbox1.pack_start(button, True, True, 0)
+        button.set_title("Rate StockThis")
+        url = "http://maemo.org/downloads/product/Maemo5/stockthis"
+        button.connect("clicked", self.launch_browser, url)
+        image = gtk.Image()
+        image.set_from_file(imgdir + "maemoorg.png")
+        vbox.pack_start(button, False, False, 0)
+        vbox.pack_start(image, False, False, 5)
+        vbox.pack_start(textview, True, True, 0)
 
-        self.action_btn = hildon.Button(fhsize, horbtn)
-        self.image = gtk.Image()
+        notebook.append_page(vbox, gtk.Label())
 
-        self.show_info(None, 'description')
+        # Buttons #
+        self.abdialog.vbox.pack_start(notebook, True, True, 0)
 
-        self.abdialog.vbox.pack_start(self.action_btn, False, False, 0)
-        self.abdialog.vbox.pack_start(self.image, False, False, 5)
-        self.abdialog.vbox.pack_start(self.info_lb, True, True, 0)
-        self.abdialog.vbox.pack_start(hbox1, False, False, 0)
+        hbox = gtk.HBox()
+
+        descbutton = hildon.GtkRadioButton(fhsize)
+        descbutton.set_mode(False)
+        descbutton.set_active(True)
+        descbutton.set_label('Description')
+        descbutton.connect("toggled", self.change_tab, notebook, 0)
+        hbox.pack_start(descbutton, True, True, 0)
+
+        button = hildon.GtkRadioButton(fhsize)
+        button.set_mode(False)
+        button.set_active(True)
+        button.set_label('Credits')
+        button.set_group(descbutton)
+        button.connect("toggled", self.change_tab, notebook, 1)
+        hbox.pack_start(button, True, True, 0)
+
+        button = hildon.GtkRadioButton(fhsize)
+        button.set_mode(False)
+        button.set_label('Donate')
+        button.set_group(descbutton)
+        button.connect("clicked", self.change_tab, notebook, 2)
+        hbox.pack_start(button, True, True, 0)
+
+        button = hildon.GtkRadioButton(fhsize)
+        button.set_mode(False)
+        button.set_label('Report')
+        button.set_group(descbutton)
+        button.connect("clicked", self.change_tab, notebook, 3)
+        hbox.pack_start(button, True, True, 0)
+
+        button = hildon.GtkRadioButton(fhsize)
+        button.set_mode(False)
+        button.set_label('Rate')
+        button.set_group(descbutton)
+        button.connect("clicked", self.change_tab, notebook, 4)
+        hbox.pack_start(button, True, True, 0)
+
+        self.abdialog.vbox.pack_start(hbox, False, False, 0)
 
         self.abdialog.show_all()
-        self.action_btn.hide()
-        self.image.hide()
         self.abdialog.run()
         self.abdialog.destroy()
 
-    def do_action(self, widget, action):
-        import dbus
-
-        self.abdialog.destroy()
+    def change_tab(self, widget, notebook, number):
+        notebook.set_current_page(number)
 
+    def launch_browser(self, widget, url):
+        import dbus
         bus = dbus.SystemBus()
         proxy = bus.get_object("com.nokia.osso_browser", "/com/nokia/osso_browser/request")
         iface = dbus.Interface(proxy, 'com.nokia.osso_browser')
 
-        if action == "donate":
-            url = "http://stockthis.garage.maemo.org/donate.html"
-        elif action == "report":
-            url = "http://stockthis.garage.maemo.org/reporting.html"
-        elif action == "vote":
-            url = "http://maemo.org/downloads/product/Maemo5/stockthis"
+        self.abdialog.destroy()
 
         iface.open_new_window(url)
 
-    def show_info(self, widget, kind):
-        if kind == 'license':
-            self.action_btn.hide()
-            self.image.hide()
-            info = """<small><b>StockThis</b> is free software. It's using a GPL version 2 license or at your election any later version.
-
-Logo by Daniel Martin Yerga.
-</small>"""
-        elif kind == 'credits':
-            self.action_btn.hide()
-            self.image.hide()
-            info = """<small><b>Written by</b> Daniel Martin Yerga (dyerga@gmail.com)
-
-<b>Thanks</b> to everyone who has reported bugs, suggestions, giving spirits, critiques, writing blog articles about StockThis, and so on. Like always the list is extremely big and for not forget anybody, THANKS TO ALL!</small>"""
-        elif kind == 'description':
-            self.action_btn.hide()
-            self.image.hide()
-            info = """<b><big>StockThis 0.3</big></b>
-
-<i>StockThis is a stocks application for Maemo</i>
-
-<b>Web Page</b>:
-stockthis.garage.maemo.org"""
-
-        elif kind == 'donate':
-            self.action_btn.show()
-            self.image.hide()
-            self.action_btn.set_title('Make donation')
-            if self.id:
-                self.action_btn.disconnect(self.id)
-            self.id = self.action_btn.connect("clicked", self.do_action, "donate")
-            info = """<small><b>StockThis</b> is a free (and gratis) software application.
-Developing good software takes time and hard work.
-
-<b>StockThis's author</b> develops the program in his spare time.
-If you like the program and it's helpful, consider donating a small amount of money.
-Donations are a great incentive and help the developer feel that the hard work is appreciated.</small>
-"""
-        elif kind == 'report':
-            self.action_btn.show()
-            self.image.hide()
-            self.action_btn.set_title('Report bug')
-            if self.id:
-                self.action_btn.disconnect(self.id)
-            self.id = self.action_btn.connect("clicked", self.do_action, "report")
-            info = """<small>StockThis is being improved thanks to bug reports that users have submitted. The author appreciates these reports.
-If the application is raising an error when you're using it, you have two choices to report this error:
-1) Send the log from the application menu (if there's an error in the log).
-2) Press the button and write a bug report with as much information as possible.</small>"""
-        elif kind == 'vote':
-            self.action_btn.show()
-            self.image.show()
-            self.image.set_from_file(imgdir + "maemoorg.png")
-            self.action_btn.set_title('Rate StockThis')
-            if self.id:
-                self.action_btn.disconnect(self.id)
-            self.id = self.action_btn.connect("clicked", self.do_action, "vote")
-            info = """<small>The downloads section in maemo.org has a nice system where you can rate applications.
-If you consider StockThis a good application (or a bad one too), you could rate it in maemo.org site.</small>"""
-
-        self.info_lb.set_markup(info)
+    def on_show_log(self, widget):
+        Log(widget, logfile)
 
 
 class Log: