# for the config widget)
#class IconGrid(gtk.Widget, FremantleRotation):
-class IconGrid: #(gobject.GObject):
+class IconGrid:
def __init__(self, isconfig=False):
# self.__gobject_init__()
# gtk.Widget.__init__(self)
# Duration of the rotation effect
self.rotation_time=0.8
+ # Whether we're in CSSU's h-d portrait mode
+ self.cssuportrait=False
+
+ # Force modechange, even when mode doesn't change
+ self.force_modechange=False
+
# print "ig-init"
# def __del__(self):
ret=self.icons.getSize()
return(ret)
+ def setCSSUPortrait(self, cssuportrait):
+ if self.cssuportrait==cssuportrait:
+ # print "same portrait"
+ return
+
+ self.cssuportrait=cssuportrait
+ self.force_modechange=True
+
+ # TODO: Remove default value from cssuportrait
def setMode(self, mode):
- if self.mode==mode:
-# print "same mode"
+ if self.mode==mode and not self.force_modechange:
+ # print "same mode"
return
self.mode=mode
+ self.force_modechange=False
+
if not isinstance(self, gtk.Widget):
return
except TypeError:
do_draw=True
- if do_draw and self.config.getAnimate() and self.do_animations:
+ if do_draw and self.config.getAnimate() and self.do_animations \
+ and not self.cssuportrait:
#self.queue_draw()
# Don't start another timer
# Instead adjust the time start to produce a nice effect ;-)
dt2=da2*self.rotation_time/90.0
self.angle_timer_start=time.time()-dt2
else:
- if self.mode=='l':
+ if self.mode=='l' or self.cssuportrait:
self.setAngle(0)
else:
self.setAngle(90)
w=self.config.getIconSizeFull()
- if self.mode=='l' or self.config.getIndiv():
+ if self.cssuportrait:
+ x2=int(y / w)
+ y2=self.size[1] - int(x/w) - 1
+ elif self.mode=='l' or self.config.getIndiv():
x2=int(x / w)
y2=int(y / w)
else:
x2=self.size[1] - int(y/w) - 1
y2=int(x/w)
+# print "%d,%d -> %d,%d" % (int(x/w), int(y/w), x2, y2), \
+# self.cssuportrait, self.mode
ret=self.get(x2,y2)
return(ret)
w=self.config.getIconSizeFull()
for x,y in self.icons:
- if self.mode=='l' or self.config.getIndiv():
+ x2=(self.size[1]-y-1) * self.config.getIconSizeFull()
+ y2=x * self.config.getIconSizeFull()
+ if self.cssuportrait:
+ # What we do here is:
+ # We map the x,y of icons to x,y on the screen.
+ # x,y of icons is the x,y as if there is no desktop rotation
+ # and we're in landscape mode
+ #
+ # After that, iconAt() will work properly. It's a kind of
+ # double effort but it works nice
+ x2=(self.size[1]-y-1) * self.config.getIconSizeFull()
+ y2=x * self.config.getIconSizeFull()
+ elif not self.cssuportrait and \
+ (self.mode=='l' or self.config.getIndiv()):
#x2=x * (self.config.iconsize + self.config.iconspace)
#y2=y * (self.config.iconsize + self.config.iconspace)
x2=x * self.config.getIconSizeFull()
# Only repaint the needed icons
rect=gdk.Rectangle(x2, y2, w, w)
t=rect.intersect(event.area)
- if t.width==0 and t.height==0:
+ if t.width==0 and t.height==0 and False:
continue
ico=self.icons.get(x,y)
- ico.draw(cr, x2, y2)
+ if ico!=None:
+ ico.draw(cr, x2, y2)
+ else:
+ print "No icon for %d, %d (%d, %d)!" % (x,y, x2, y2)
def setAngle(self, angle):
""" Return True/False indicating that angle has changed """
ret=False
+
+ #print "angle:", angle, self.mode
+
for x,y in self.icons:
ic=self.icons.get(x,y)
+ #ic=self.iconAt(x,y)
if ic.setAngle(angle):
ret=True
""" Clear animation cache, freeing memory """
for x,y in self.icons:
ic=self.icons.get(x,y)
+ #ic=self.iconAt(x,y)
ic.clearAnimationCache()
def clearBgCache(self):
""" Clear backgrounds cache """
for x,y in self.icons:
ic=self.icons.get(x,y)
+ #ic=self.iconAt(x,y)
ic.clearBgCache()
def do_expose_event(self, event):
self.icons.setWindow(self.window)
self.init_done=True
+# print "expose:", event.area.x, event.area.y, event.area.width, \
+# event.area.height
+
self._draw(cr, event)
def setLastIcon(self, icon):
ret=self.iter.next()
return(ret)
-class Icons(gobject.GObject, Disconnector):
+class Icons(Disconnector, gobject.GObject):
#class Icons(gtk.Widget, Disconnector):
+ __gtype_name__ = "DrlaunchIcons"
#__gsignals__=Icon.gsignals
def __init__(self, isconfig, config):
- self.__gobject_init__()
- #gobject.GObject.__init__(self)
+ #self.__gobject_init__()
+ gobject.GObject.__init__(self)
#gtk.Widget.__init__(self)
Disconnector.__init__(self)
# y+=1
## self.icons.append(p)
-gobject.type_register(Icons)
-Icons.register_signals()
+icons_type=Icons
+
+def init_icons():
+ #gobject.type_register(icons_type)
+ print "bbbbbbbbbbbbbbBB"
+# Icons.register_signals()
+ print "bbbbbbbbbbbbbbBB222222222"
+Icons.register_signals()
# vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
import sys
import os
+import gobject
orig_path=sys.path[:]
tmp_path=os.path.dirname( os.path.realpath( __file__ ) )
sys.path.append(tmp_path)
# End of hack
import gtk
-import gobject
-import hildon
from hildondesktop import *
from gtk import gdk
from math import pi
from icongrid import IconGrid
from sig import Disconnector
+import icons
+
# Restore path
sys.path=orig_path
# IconGrid must be before HomePluginItem for its connect()
# and do_button_*() to override those of HomePluginItem
class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation, Disconnector):
+ __gtype_name__ = "DrlaunchPlugin"
+
def __init__(self):
IconGrid.__init__(self)
HomePluginItem.__init__(self)
# In case of a rotating desktop, force orientation to be
# 'landscape'
if rd:
+ # CSSU Portrait mode?
+ if o=='p':
+ csp=True
+ else:
+ csp=False
+
o='l'
+ self.setCSSUPortrait(csp)
+
+ if rd:
+ self.resize2()
+
self.setMode(o)
+
# self.queue_draw()
def do_expose_event(self, event):
(self.size[0] * config.getIconSpace())
h=(self.size[1] * config.iconsize) + \
(self.size[1] * config.getIconSpace())
+
+ if self.cssuportrait:
+ (w,h)=(h,w)
+
+ #print "w,h:", w, h
self.set_size_request(w, h)
self.resize(w, h)
+ self.queue_draw()
def setSize(self, size):
IconGrid.setSize(self, size)
hd_plugin_type = DrlaunchPlugin
if __name__=="__main__":
- gobject.type_register(hd_plugin_type)
+
+ icons.init_icons()
+
+ #gobject.type_register(hd_plugin_type)
obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
obj.show_all()
gtk.main()