+++ /dev/null
-#!/usr/bin/env python
-# coding=UTF-8
-#
-# Copyright (C) 2010 Stefanos Harhalakis
-#
-# This file is part of wifieye.
-#
-# wifieye 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.
-#
-# wifieye 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 wifieye. 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 $"
-
-import gtk
-from hildondesktop import *
-from gtk import gdk
-import cairo
-
-from portrait import FremantleRotation
-
-class Icons:
- def __init__(self):
- self.mode='l'
-
- self.size=3
- self.iconsize=64
-
- self.icons=[]
-
- fn=["maegirls.png", "mc.png"]*3
- for f in fn:
- #p=gtk.gdk.pixbuf_new_from_file(f)
- p=gtk.gdk.pixbuf_new_from_file_at_size(f, self.iconsize,
- self.iconsize)
- print "pix:", p
- self.icons.append(p)
-
- print "end of Icons init"
-
- def setMode(self, mode):
- self.mode=mode
-
-class MyQ(gtk.DrawingArea, Icons):
- def __init__(self):
- Icons.__init__(self)
- gtk.DrawingArea.__init__(self)
-
-# self.set_size_request(-1, -1)
-
-# self.connect('size-request', self.do_size_request)
-# self.connect('size-allocate', self.do_size_allocate)
- self.connect('expose-event', self.expose)
- self.connect('button-press-event', self.butpress)
-
-# self.show_all()
- print "MyQ init"
-
- def butpress(self, widget, ev):
- if ev.type==gdk.BUTTON_PRESS:
- print "press", ev.type
- if self.mode=='p':
- self.setMode('l')
- else:
- self.setMode('p')
- widget.queue_draw()
- return True
-
- def expose(self, widget, event):
- print "expose"
-
- x=0
- y=0
-
- print "mode:", self.mode
- for i in self.icons:
- if self.mode=='l':
- widget.window.draw_pixbuf(None, i, 0, 0, x*self.iconsize,
- y*self.iconsize)
- else:
- x2=y*self.iconsize
- y2=(self.size-x-1)*self.iconsize
- print x,y,x2,y2
- i2=i.rotate_simple(gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE)
- widget.window.draw_pixbuf(None, i2, 0, 0, x2, y2)
-
- x+=1
- if x>=self.size:
- x=0
- y+=1
-
- return(True)
-
-# def do_size_request(self, requisition, param):
-# print "szreq"
-# requisition.width = self.size*self.iconsize
-# requisition.height = self.size*self.iconsize
-
-# def do_size_allocate(self, allocation, param):
-# print "szalloc", allocation.width, allocation.height
-#
-# if self.flags() & gtk.REALIZED:
-# self.window.move_resize(*allocation)
-
-class TestPlugin(HomePluginItem, Icons, FremantleRotation):
- def __init__(self):
- HomePluginItem.__init__(self)
- Icons.__init__(self)
- FremantleRotation.__init__(self, 'TestPlugin')
-
- self.setMode('l')
-
- self.set_size_request(self.size * self.iconsize,
- self.size * self.iconsize)
-
-## myq=MyQ()
-# myq.show_all()
-# self.add(myq)
-
-# self.show_all()
-
- def _draw(self, cr):
- cr.save()
- cr.set_source_rgba(0.5, 0.5, 0.5, 0.5)
- cr.set_operator(cairo.OPERATOR_SOURCE)
- cr.paint()
- cr.restore()
-
-# cr.save()
-
- x=0
- y=0
-
- print "mode:", self.mode
- for i in self.icons:
- print x,y
-
- if self.mode=='l':
- x2=x*self.iconsize
- y2=y*self.iconsize
- i2=i
- else:
- x2=y*self.iconsize
- y2=(self.size-x-1)*self.iconsize
- #print x,y,x2,y2
- i2=i.rotate_simple(gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE)
-
- cr.save()
- cr.set_source_pixbuf(i2, x2, y2)
- cr.paint()
- cr.restore()
-
- x+=1
- if x>=self.size:
- x=0
- y+=1
-
- def do_expose_event(self, event):
- print "do_expose"
-
- cr=self.window.cairo_create()
-
- cr.rectangle(event.area.x, event.area.y,
- event.area.width, event.area.height)
-
- cr.clip()
-
- self._draw(cr)
-
-# HomePluginItem.do_expose_event(self, event)
-
- def do_realize(self):
- screen=self.get_screen()
- self.set_colormap(screen.get_rgba_colormap())
- self.set_app_paintable(True)
-
- HomePluginItem.do_realize(self)
-
- def do_button_press_event(self, event):
- print "press"
-
- def do_button_press_event_old(self, event):
- print "press"
- if event.type==gdk.BUTTON_PRESS:
- print "press", event.type
- if self.mode=='p':
- self.setMode('l')
- else:
- self.setMode('p')
- self.queue_draw()
- return True
-
- def butTest(self, arg):
- print "but", arg
-
- def on_orientation_changed(self, orientation):
- print "orch:", orientation
- o=orientation[0]
- self.setMode(o)
- self.queue_draw()
-
-hd_plugin_type = TestPlugin
-
-def do1():
- import gobject
-# gobject.type_register(MyQ)
- gobject.type_register(hd_plugin_type)
- obj=gobject.new(hd_plugin_type, plugin_id="plugin_id")
- obj.show_all()
- gtk.main()
-
-def do2():
- win=TestPlugin()
- win.connect('delete-event', gtk.main_quit)
-
- print "win:", win
-
-# t=TestPlugin()
-# win.add(t)
-
- win.show_all()
- gtk.main()
-
-if __name__=="__main__":
- do1()
-
-
-
-# vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent:
-