Disable animations in configuration window.
Set the size request of about dialog to 800x800 to support portrait mode.
Pass the parent to about dialog and set it as needed to support postrait mode.
Add credits for postrait.py too.
Clear animation cache when animations are disabled.
Add code for portrait mode support: Disabled for now since it isn't reliable.
from gtk import AboutDialog
import config
from about0 import HeAboutDialog
+from portrait import FremantleRotation
-class DlgAbout(HeAboutDialog):
- def __init__(self, *args):
- HeAboutDialog.__init__(self, *args)
+class DlgAbout(HeAboutDialog, FremantleRotation):
+ def __init__(self):
+ HeAboutDialog.__init__(self)
+ FremantleRotation.__init__(self, "DrlaunchPlugin",
+ mode=FremantleRotation.AUTOMATIC)
@classmethod
- def present2(cls):
+ def present2(cls, parent):
_copyright="""\
Copyright (C) 2010 Stefanos Harhalakis <v13@v13.gr>
-Copyright (C) 2005-2010 Thomas Perl and the gPodder Team (for about0.py)
+Copyright (C) 2005-2010 Thomas Perl and the gPodder Team (for about0.py
+and portrait.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.
+
+Thanks to Thomas Perl and the gPodder Team.
"""
_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.
+distributed under the terms of the GPLv3 license. It also uses a
+modified version of portrait.py from gpodder which is also distributed
+under the terms of the GPLv3 license.
"""
args={
"copyright": _copyright + "\n" + _license,
"description": _description,
"bugtracker_url": "mailto:v13@v13.gr",
+ "parent": parent,
}
cls.present(**args)
def set_icon_name(self, icon_name):
- print "koko"
+ pass
# vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python
+# coding=UTF-8
#
# gPodder - A media aggregator and podcast client
# Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
self.image_icon.set_padding(5, 5)
#content_area = self.get_content_area() # Starting with PyGTK 2.14
- self.set_size_request(800,480)
+ self.set_size_request(800,800)
pa=hildon.PannableArea()
pa.set_property('mov-mode',
hildon.MOVEMENT_MODE_HORIZ | hildon.MOVEMENT_MODE_VERT )
self.name=dt['id']
self.icon=dt['icon2']
self.sicon=None
- self.cached_icons={}
+ self.clearAnimationCache()
self.invalidate()
+ def clearAnimationCache(self):
+ self.cached_icons={}
+
def getSize(self):
return(self.config.iconsize+self.config.iconspace)
def setAnimationEnable(self, value):
if value:
self.enableAnimation()
- else
+ else:
self.disableAnimation()
def timerAngle(self):
return(ret)
+ def clearAnimationCache(self):
+ """ Clear animation cache, freeing memory """
+ for x,y in self.icons:
+ ic=self.icons.get(x,y)
+ ic.clearAnimationCache()
+
def do_expose_event(self, event):
cr=self.window.cairo_create()
import osso
# Replace this with your own gettext() functionality
-#import gpodder
-#_ = gpodder.gettext
+_ = str
class FremantleRotation(object):
You can set the mode for rotation to AUTOMATIC (default), NEVER or
ALWAYS with the set_mode() method.
"""
-
AUTOMATIC, NEVER, ALWAYS = range(3)
- MODE_CAPTIONS = ('Automatic', 'Landscape', 'Portrait')
+ # Human-readable captions for the above constants
+ MODE_CAPTIONS = (_('Automatic'), _('Landscape'), _('Portrait'))
# Privately-used constants
_PORTRAIT, _LANDSCAPE = ('portrait', 'landscape')
_KBD_OPEN = 'open'
_KBD_CLOSED = 'closed'
- def __init__(self, app_name, main_window=None, version='1.0', mode=0):
+ def __init__(self, app_name, main_window=None, version='1.0', mode=0,
+ dontrotate=False):
"""Create a new rotation manager
app_name ... The name of your application (for osso.Context)
main_window ... The root window (optional, hildon.StackableWindow)
version ... The version of your application (optional, string)
mode ... Initial mode for this manager (default: AUTOMATIC)
+ dontrotate ... Don't rotate the window. (def: False)
"""
+ self.dontrotate = dontrotate # V13
self._orientation = None
self._main_window = main_window
+ self._stack = hildon.WindowStack.get_default()
self._mode = -1
self._last_dbus_orientation = None
self._keyboard_state = self._get_keyboard_state()
path='/org/freedesktop/Hal/devices/platform_slide')
self.set_mode(mode)
- self._send_mce_request(self._ENABLE_ACCEL)
-
- def set_mode(self, new_mode):
- self._mode=new_mode
-
def get_mode(self):
"""Get the currently-set rotation mode
"""
return self._mode
+ def set_mode(self, new_mode):
+ """Set the rotation mode
+
+ You can set the rotation mode to AUTOMATIC (use hardware rotation
+ info), ALWAYS (force portrait) and NEVER (force landscape).
+ """
+ if new_mode not in (self.AUTOMATIC, self.ALWAYS, self.NEVER):
+ raise ValueError('Unknown rotation mode')
+
+ if self._mode != new_mode:
+ if self._mode == self.AUTOMATIC:
+ # Remember the current "automatic" orientation for later
+ self._last_dbus_orientation = self._orientation
+ # Tell MCE that we don't need the accelerometer anymore
+ self._send_mce_request(self._DISABLE_ACCEL)
+
+ if new_mode == self.NEVER:
+ self._orientation_changed(self._LANDSCAPE)
+ elif new_mode == self.ALWAYS and \
+ self._keyboard_state != self._KBD_OPEN:
+ self._orientation_changed(self._PORTRAIT)
+ elif new_mode == self.AUTOMATIC:
+ # Restore the last-known "automatic" orientation
+ self._orientation_changed(self._last_dbus_orientation)
+ # Tell MCE that we need the accelerometer again
+ self._send_mce_request(self._ENABLE_ACCEL)
+
+ self._mode = new_mode
+
def _send_mce_request(self, request):
rpc = osso.Rpc(self._osso_context)
rpc.rpc_run(self._MCE_SERVICE, \
else:
self._send_mce_request(self._DISABLE_ACCEL)
- def NO_get_main_window(self):
+ def _get_main_window(self):
if self._main_window:
# If we have gotten the main window as parameter, return it and
# don't try "harder" to find another window using the stack
# Ignore repeated requests
return
- if orientation == None:
- return
-
flags = 0
if orientation != self._LANDSCAPE:
if orientation == self._PORTRAIT:
flags |= hildon.PORTRAIT_MODE_REQUEST
-# window = self._get_main_window()
-# if window is not None:
-# hildon.hildon_gtk_window_set_portrait_flags(window, flags)
+ window = self._get_main_window()
+ if window is not None and self.dontrotate==False:
+ hildon.hildon_gtk_window_set_portrait_flags(window, flags)
self._orientation = orientation
self.on_orientation_changed(orientation)
+ def on_orientation_changed(self, orientation):
+ pass
+
def _get_keyboard_state(self):
# For sbox, if the device does not exist assume that it's closed
try:
def __init__(self):
IconGrid.__init__(self)
HomePluginItem.__init__(self)
- FremantleRotation.__init__(self, 'DrlaunchPlugin')
+ FremantleRotation.__init__(self, 'DrlaunchPlugin',
+ mode=FremantleRotation.AUTOMATIC, dontrotate=True)
self.winConfig=None
self.setSize(dt['size'])
self.reloadIcons()
+ # Free memory that is used for animations if animations are disabled
+ if not dt['animate']:
+ self.clearAnimationCache()
+
self.queue_draw()
def handle_click(self, sender, icon):
#from portrait import FremantleRotation
#from xdg.IconTheme import getIconPath
-#import config
+import config
import apps
from icon import Icon, getIcon
from icongrid import IconGridWidget
from about import DlgAbout
+from portrait import FremantleRotation
-class WinConfig(StackableWindow):
+class WinConfig(StackableWindow): #, FremantleRotation):
def __init__(self, config, *args):
StackableWindow.__init__(self)
+# FremantleRotation.__init__(self, "DrlaunchPlugin",
+# mode=FremantleRotation.AUTOMATIC)
self.config=config
self.setupUi()
def setupUi(self):
- self.set_title("DrLaunch Configuration")
+ """
+ self.pa Main Pannable Area
+ self.col1 A VBox for the first column
+ self.col2 A VBox for the second column
+ self.w_igw The IGW in an alignment
+ """
+ self.set_title("DrLaunch v" + config.version)
self.pa=hildon.PannableArea()
- self.add(self.pa)
+# self.add(self.pa)
self.pa.set_property('mov-mode', hildon.MOVEMENT_MODE_HORIZ)
- hbox=gtk.HBox()
- self.pa.add_with_viewport(hbox)
+#1 hbox=gtk.HBox()
+#1 self.pa.add_with_viewport(hbox)
# Add the first column of options
al=gtk.Alignment(yscale=0)
- hbox.add(al)
+#1 hbox.add(al)
vbox=gtk.VBox()
al.add(vbox)
+ self.col1=al
maxsz=self.config.getMaxSize()
vbox=gtk.VBox()
al=gtk.Alignment(xalign=0, yalign=1, xscale=1)
al.add(vbox)
- hbox.add(al)
+ self.col2=al
+#1 hbox.add(al)
but=hildon.Button(
gtk.HILDON_SIZE_AUTO_WIDTH | gtk.HILDON_SIZE_FINGER_HEIGHT,
hildon.BUTTON_ARRANGEMENT_VERTICAL)
al=gtk.Alignment(xalign=0, xscale=0)
al.add(self.igw)
al.set_padding(0, 0, 20, 0)
- hbox.add(al)
+ self.w_igw=al
+#1 hbox.add(al)
self.igw.connect('long-press', self.slotLongpress)
self.igw.connect('click', self.slotLongpress)
self.setLongpress(self.config.getLongpress())
self.setAnimate(self.config.getAnimate())
+ hbox=gtk.HBox()
+ hbox.add(self.col1)
+ hbox.add(self.col2)
+ hbox.add(self.w_igw)
+ self.pa.add_with_viewport(hbox)
+
+ self.add(self.pa)
+
+# def setupUi(self, orientation):
+#
+# self.setupUi0()
+#
+# hbox=gtk.HBox()
+#
+# if orientation=='l':
+# hbox.add(self.col1)
+# hbox.add(self.col2)
+# hbox.add(self.w_igw)
+# else:
+# vbox=gtk.VBox()
+# hbox.add(vbox)
+# vbox.add(self.col1)
+# vbox.add(self.col2)
+# hbox.add(self.w_igw)
+#
+# self.pa.add_with_viewport(hbox)
+#
+# if self.get_child()!=None:
+# self.remove(self.get_child())
+# self.add(self.pa)
+# self.pa.show_all()
+
+ def setLayoutPortrait(self):
+ print "lo: p"
+ hbox=gtk.HBox()
+
+ vbox=gtk.VBox()
+ hbox.add(vbox)
+ self.col1.reparent(vbox)
+ self.col2.reparent(vbox)
+ self.w_igw.reparent(hbox)
+
+ r=self.pa.get_children()[0]
+ self.pa.remove(r)
+ r.destroy()
+ self.pa.add_with_viewport(hbox)
+
+ self.pa.show_all()
+
+ def setLayoutLandscape(self):
+ print "lo: l"
+ hbox=gtk.HBox()
+
+ self.col1.reparent(hbox)
+ self.col2.reparent(hbox)
+ self.w_igw.reparent(hbox)
+
+ r=self.pa.get_children()[0]
+ self.pa.remove(r)
+ r.destroy()
+ self.pa.add_with_viewport(hbox)
+
+ self.pa.show_all()
+
+ def on_orientation_changed(self, orientation):
+ # This is disabled for now since I've not found any reliable
+ # way for supporting orientation changes (#$#%$#*&% GTK)
+ return
+
+ print "orch:", orientation
+ if orientation=='portrait':
+ self.setLayoutPortrait()
+ else:
+ self.setLayoutLandscape()
+
def slotLongpress(self, sender, icon):
self.doConfig(icon)
print "about"
#dlg=DlgAbout()
#dlg.run()
- DlgAbout.present2()
+ DlgAbout.present2(self)
# def slotButtonLongpress(self, sender):
# but=self.buttonRequireLongpress