Added about dialog.
authorStefanos Harhalakis <v13@v13.gr>
Thu, 5 Aug 2010 19:30:04 +0000 (19:30 +0000)
committerStefanos Harhalakis <v13@v13.gr>
Thu, 5 Aug 2010 19:30:04 +0000 (19:30 +0000)
src/about.py [new file with mode: 0755]
src/about0.py [new file with mode: 0644]
src/win_config.py

diff --git a/src/about.py b/src/about.py
new file mode 100755 (executable)
index 0000000..8156bd3
--- /dev/null
@@ -0,0 +1,80 @@
+#!/usr/bin/env python
+# coding=UTF-8
+# 
+# Copyright (C) 2010 Stefanos Harhalakis
+#
+# This file is part of DrLaunch.
+#
+# DrLaunch is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# DrLaunch is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with DrLaunch.  If not, see <http://www.gnu.org/licenses/>.
+#
+# $Id: 0.py 2265 2010-02-21 19:16:26Z v13 $
+
+__version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
+
+from gtk import AboutDialog
+import config
+from about0 import HeAboutDialog
+
+class DlgAbout(HeAboutDialog):
+    def __init__(self, *args):
+       HeAboutDialog.__init__(self, *args)
+
+    @classmethod
+    def present2(cls):
+       _copyright="""\
+Copyright (C) 2010 Stefanos Harhalakis <v13@v13.gr>
+Copyright (C) 2005-2010 Thomas Perl and the gPodder Team (for about0.py)
+"""
+       _description="""
+DrLaunch is a desktop launcher widget that
+supports portrait mode by rotating program
+icons. Whenever the device is rotated, icons
+are also rotated.
+"""
+
+       _license="""\
+Send bug reports and feature requests to Stefanos Harhalakis <v13@v13.gr>
+
+DrLaunch is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+DrLaunch is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with DrLaunch.  If not, see <http://www.gnu.org/licenses/>.
+
+DrLaunch uses a modified version of about.py from gpodder which is also
+distributed under the terms of the GPLv3 license.
+"""
+
+       args={
+       "app_name":         "DrLaunch",
+       "version":          config.version,
+       "copyright":        _copyright + "\n" + _license,
+       "description":      _description,
+       "bugtracker_url":   "mailto:v13@v13.gr",
+       }
+
+       cls.present(**args)
+
+    def set_icon_name(self, icon_name):
+       print "koko"
+
+# vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
+
diff --git a/src/about0.py b/src/about0.py
new file mode 100644 (file)
index 0000000..bd09e25
--- /dev/null
@@ -0,0 +1,155 @@
+# -*- coding: utf-8 -*-
+#
+# gPodder - A media aggregator and podcast client
+# Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
+#
+# gPodder is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# gPodder is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+# Python implementation of HeAboutDialog from hildon-extras
+# Copyright (c) 2010-04-11 Thomas Perl <thp@thpinfo.com>
+
+import hildon
+import gtk
+import dbus
+
+_ = str
+
+class HeAboutDialog(gtk.Dialog):
+    RESPONSE_WEBSITE, \
+    RESPONSE_BUGTRACKER, \
+    RESPONSE_DONATE = range(3)
+
+    def __init__(self):
+        gtk.Dialog.__init__(self)
+
+        self.website_url = None
+        self.bugtracker_url = None
+        self.donate_url = None
+
+        self.set_title(_('About'))
+
+        self.image_icon = gtk.Image()
+        self.label_app_name = gtk.Label()
+        self.label_version = gtk.Label()
+        self.label_description = gtk.Label()
+        self.label_copyright = gtk.Label()
+        self.table_layout = gtk.Table(3, 3, False)
+
+        hildon.hildon_helper_set_logical_font(self.label_app_name, 'X-LargeSystemFont')
+        hildon.hildon_helper_set_logical_font(self.label_version, 'LargeSystemFont')
+        hildon.hildon_helper_set_logical_font(self.label_copyright, 'SmallSystemFont')
+        hildon.hildon_helper_set_logical_color(self.label_copyright, gtk.RC_FG, gtk.STATE_NORMAL, 'SecondaryTextColor')
+
+        self.label_app_name.set_alignment(0, 1)
+        self.label_version.set_alignment(0, 1)
+        self.label_description.set_alignment(0, 0)
+        self.label_copyright.set_alignment(0, 1)
+        self.label_version.set_padding(10, 0)
+        self.label_copyright.set_padding(0, 5)
+        self.image_icon.set_padding(5, 5)
+
+        #content_area = self.get_content_area() # Starting with PyGTK 2.14
+       self.set_size_request(800,480)
+       pa=hildon.PannableArea()
+       pa.set_property('mov-mode', 
+               hildon.MOVEMENT_MODE_HORIZ | hildon.MOVEMENT_MODE_VERT )
+       vbox=gtk.VBox()
+       self.vbox.add(pa)
+       pa.add_with_viewport(vbox)
+        content_area = vbox
+
+        self.table_layout.attach(self.image_icon, 0, 1, 0, 2, 0, gtk.EXPAND, 0, 0)
+        self.table_layout.attach(self.label_app_name, 1, 2, 0, 1, 0, gtk.EXPAND | gtk.FILL, 0, 0)
+        self.table_layout.attach(self.label_version, 2, 3, 0, 1, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0)
+        self.table_layout.attach(self.label_description, 1, 3, 1, 2, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0)
+        self.table_layout.attach(self.label_copyright, 0, 3, 2, 3, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0)
+        content_area.add(self.table_layout)
+        self.connect('response', self._on_response)
+        self.show_all()
+
+    def _on_response(self, dialog, response_id):
+        if response_id == HeAboutDialog.RESPONSE_WEBSITE:
+            self.open_webbrowser(self.website_url)
+        elif response_id == HeAboutDialog.RESPONSE_BUGTRACKER:
+            self.open_webbrowser(self.bugtracker_url)
+        elif response_id == HeAboutDialog.RESPONSE_DONATE:
+            self.open_webbrowser(self.donate_url)
+
+    def set_app_name(self, app_name):
+        self.label_app_name.set_text(app_name)
+        self.set_title(_('About %s') % app_name)
+
+    def set_icon_name(self, icon_name):
+        self.image_icon.set_from_icon_name(icon_name, gtk.ICON_SIZE_DIALOG)
+
+    def set_version(self, version):
+        self.label_version.set_text(version)
+
+    def set_description(self, description):
+        self.label_description.set_text(description)
+
+    def set_copyright(self, copyright):
+        self.label_copyright.set_text(copyright)
+
+    def set_website(self, url):
+        if self.website_url is None:
+            self.add_button(_('Visit website'), HeAboutDialog.RESPONSE_WEBSITE)
+        self.website_url = url
+
+    def set_bugtracker(self, url):
+        if self.bugtracker_url is None:
+            self.add_button(_('Report bug'), HeAboutDialog.RESPONSE_BUGTRACKER)
+        self.bugtracker_url = url
+
+    def set_donate_url(self, url):
+        if self.donate_url is None:
+            self.add_button(_('Donate'), HeAboutDialog.RESPONSE_DONATE)
+        self.donate_url = url
+
+    def open_webbrowser(self, url):
+        bus = dbus.SessionBus()
+        proxy = bus.get_object('com.nokia.osso_browser', '/com/nokia/osso_browser/request', 'com.nokia.osso_browser')
+        proxy.load_url(url, dbus_interface='com.nokia.osso_browser')
+
+    @classmethod
+    def present(cls, parent=None, app_name=None, icon_name=None, \
+            version=None, description=None, copyright=None, \
+            website_url=None, bugtracker_url=None, donate_url=None):
+        ad = cls()
+
+        if parent is not None:
+            ad.set_transient_for(parent)
+            ad.set_destroy_with_parent(True)
+
+        if app_name is not None:
+            ad.set_app_name(app_name)
+
+        ad.set_icon_name(icon_name)
+        ad.set_version(version)
+        ad.set_description(description)
+        ad.set_copyright(copyright)
+
+        if website_url is not None:
+            ad.set_website(website_url)
+
+        if bugtracker_url is not None:
+            ad.set_bugtracker(bugtracker_url)
+
+        if donate_url is not None:
+            ad.set_donate_url(donate_url)
+
+        ad.run()
+        ad.destroy()
+
index 43db90d..77526ee 100755 (executable)
@@ -35,6 +35,7 @@ from hildon import StackableWindow
 import apps
 from icon import Icon, getIcon
 from icongrid import IconGridWidget
+from about import DlgAbout
 
 class WinConfig(StackableWindow):
     def __init__(self, config, *args):
@@ -45,9 +46,7 @@ class WinConfig(StackableWindow):
        self.setupUi()
 
     def setupUi(self):
-       self.igw=IconGridWidget(True, self.config)
-#      self.igw.do_realize()
-#      self.igw.setSize(config.getSize())
+       self.set_title("DrLaunch Configuration")
 
        self.pa=hildon.PannableArea()
        self.add(self.pa)
@@ -56,12 +55,11 @@ class WinConfig(StackableWindow):
        hbox=gtk.HBox()
        self.pa.add_with_viewport(hbox)
 
-       # Now go for the right side
+       # Add the first column of options
        al=gtk.Alignment(yscale=0)
        hbox.add(al)
 
        vbox=gtk.VBox()
-#      hbox.add(vbox)
        al.add(vbox)
 
        maxsz=self.config.getMaxSize()
@@ -119,7 +117,25 @@ class WinConfig(StackableWindow):
        self.buttonAnimateRotation=but
        vbox.add(but)
 
+       # -----------------------------------------------
+       # Second column of options
+       vbox=gtk.VBox()
+       al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
+       al.add(vbox)
+       hbox.add(al)
+       but=hildon.Button(
+               gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
+               hildon.BUTTON_ARRANGEMENT_VERTICAL)
+       but.set_title("About")
+       but.connect("clicked", self.slotButtonAbout)
+       vbox.add(but)
+       self.buttonAbout=but
+
+       # -----------------------------------------------
        # Add the icongrid
+       self.igw=IconGridWidget(True, self.config)
+#      self.igw.do_realize()
+#      self.igw.setSize(config.getSize())
        al=gtk.Alignment(xalign=0, xscale=0)
        al.add(self.igw)
        al.set_padding(0, 0, 20, 0)
@@ -156,6 +172,12 @@ class WinConfig(StackableWindow):
        but=self.buttonRotateIndividually
        self.setIndiv(but.get_active())
 
+    def slotButtonAbout(self, sender):
+       print "about"
+       #dlg=DlgAbout()
+       #dlg.run()
+       DlgAbout.present2()
+
 #    def slotButtonLongpress(self, sender):
 #      but=self.buttonRequireLongpress
 #      self.set