From b4829343b77b53c66257e3056fef5f2c04309c57 Mon Sep 17 00:00:00 2001 From: Stefanos Harhalakis Date: Thu, 24 Jun 2010 15:44:38 +0000 Subject: [PATCH] --- maegirls.png | Bin 3920 -> 0 bytes mc.png | Bin 986 -> 0 bytes portrait.py.orig | 211 -------------------------------------------------- src/drlaunch.py | 125 ++++++++++++++++++++++++++++++ src/portrait.py.orig | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/widget.py | 125 ------------------------------ 6 files changed, 336 insertions(+), 336 deletions(-) delete mode 100644 maegirls.png delete mode 100644 mc.png delete mode 100755 portrait.py.orig create mode 100755 src/drlaunch.py create mode 100755 src/portrait.py.orig delete mode 100755 src/widget.py diff --git a/maegirls.png b/maegirls.png deleted file mode 100644 index be54b51b80c4028e98575aba57cfad5a2ff0d9bc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3920 zcmV-W53lfvP)Px#24YJ`L;wH)0002_L%V+f000SaNLh0L00A2S00A2TjrUIF00007bV*G`2igK0 z5;O}eBy-OI01nVeL_t(|+SQwRbW~Nghrd&)DM^KdB#;V$AV?rQhqT!G#0eD;MO$eR z8^KmU8|7)!u7@sE1eYj?*wElZ1YbL#0@@uDph2V9f`m~L24xbGfP}_N z#V<`FGDk#y77?Gv(@W1X54)9%~Duc*jO7*cD3-m zL}a^&NLE&s0HW9HB`z+mSpX6fd&!|M)5UpwcTmBDUADv7vTD&>F`LZ+ed+ajS-$+u z#@evEEn`<90^oWe3yAFAJ(kMK3K9~ml$4ZcV+^F>H{ZgVMbDvAiny3)lxp8F95qe` zjU3OJGlc=|qetJtrcE3D!vbb2rRKHNmo7v~&>M(6eY%i}igSdAN8s^zf(k!iK#G0M zqUQiGn@sH%9v~vz%<1e*=1iX&(EjPCo0vKCnTC`5n221`6##?-tY5#b?jhV9RCrMC ztalb!{C_eTJN!bW6fgewqpX-WE1-Sh!dKb1Z(sdmBJiMy7&{w)3cy!fTwK?wE{y7G zM-!&xzI}6}ED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p{`P!)W|J*88PWe zoNjlgFNNCL+Qep-M#I^UykGz{5Z zVEizqT!V;Uu|(l=x$t=0em8Bi z+3Hz82ks5Ff1opViB$kk0|(>ddl(@J!Nk~W#lgT7{y4P)ht(u000AJ zNklESnw!>U)aOPg4{|LDk+0)}D!WCgI0 zV-0|fKPe#RZQHH%diB`&b;QH;|C$&|DJAEWa?ZJw+pz}XYtZy*dbs>vd=&pLnji^q zL4IrWG?Vyw%@Bzv>9gwb@-;|)^MRDkYmn^qj-wUp z{A;VA9CCUGU>nEU`K|V~p5J;Lef*0ofDr=w?eyBwYoDgi$6r|kV1z(jPV-kNQB>-=jn4|JV>{=kNXWa_@H=Gdi9E&JhC9{a=Xy7$Fedf5#f&oFNe1|BFot z60mke#RRB;wIeDffC!8oQI1L=8oX~UwHu;+@>}(2a_jmd0#v}-5fu@j!lMgePqQf$ z6<9l>VgiW3*bx;epaRy8sE7a+uy#bn1gHSNDKxN*bMAD6ohq1c4w5L4lM~6oOy@TL_XuUu(OS zUauZ2p99nX9sgJGv$v>zt0`cw@6vI;gx>30`}ey3vHW*@J=|)@)_Qv7_Wr`fvHjn1 z4e;zOs^9VMuA3rfHgP$5KBX2M&!=<{Mhdd_(JFYd`6W_84uX z0B~F=gi}jDAjSI$ykFu;diW1iY1j4gB|AAE{rc3#%OG(40v&s8*CC>LZU6uP07*qo IM6N<$f(wn*RR910 diff --git a/portrait.py.orig b/portrait.py.orig deleted file mode 100755 index 8cefa3e..0000000 --- a/portrait.py.orig +++ /dev/null @@ -1,211 +0,0 @@ -# -*- 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 . -# - -import dbus -import dbus.glib - -import hildon -import osso - -# Replace this with your own gettext() functionality -import gpodder -_ = gpodder.gettext - - -class FremantleRotation(object): - """thp's screen rotation for Maemo 5 - - Simply instantiate an object of this class and let it auto-rotate - your StackableWindows depending on the device orientation. - - If you need to relayout a window, connect to its "configure-event" - signal and measure the ratio of width/height and relayout for that. - - You can set the mode for rotation to AUTOMATIC (default), NEVER or - ALWAYS with the set_mode() method. - """ - AUTOMATIC, NEVER, ALWAYS = range(3) - - # Human-readable captions for the above constants - MODE_CAPTIONS = (_('Automatic'), _('Landscape'), _('Portrait')) - - # Privately-used constants - _PORTRAIT, _LANDSCAPE = ('portrait', 'landscape') - _ENABLE_ACCEL = 'req_accelerometer_enable' - _DISABLE_ACCEL = 'req_accelerometer_disable' - - # Defined in mce/dbus-names.h - _MCE_SERVICE = 'com.nokia.mce' - _MCE_REQUEST_PATH = '/com/nokia/mce/request' - _MCE_REQUEST_IF = 'com.nokia.mce.request' - - # sysfs device name for the keyboard slider switch - KBD_SLIDER = '/sys/devices/platform/gpio-switch/slide/state' - _KBD_OPEN = 'open' - _KBD_CLOSED = 'closed' - - def __init__(self, app_name, main_window=None, version='1.0', mode=0): - """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) - """ - 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() - app_id = '-'.join((app_name, self.__class__.__name__)) - self._osso_context = osso.Context(app_id, version, False) - program = hildon.Program.get_instance() - program.connect('notify::is-topmost', self._on_topmost_changed) - system_bus = dbus.Bus.get_system() - system_bus.add_signal_receiver(self._on_orientation_signal, \ - signal_name='sig_device_orientation_ind', \ - dbus_interface='com.nokia.mce.signal', \ - path='/com/nokia/mce/signal') - system_bus.add_signal_receiver(self._on_keyboard_signal, \ - signal_name='Condition', \ - dbus_interface='org.freedesktop.Hal.Device', \ - path='/org/freedesktop/Hal/devices/platform_slide') - self.set_mode(mode) - - def get_mode(self): - """Get the currently-set rotation mode - - This will return one of three values: AUTOMATIC, ALWAYS or NEVER. - """ - 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, \ - self._MCE_REQUEST_PATH, \ - self._MCE_REQUEST_IF, \ - request, \ - use_system_bus=True) - - def _on_topmost_changed(self, program, property_spec): - # XXX: This seems to never get called on Fremantle(?) - if self._mode == self.AUTOMATIC: - if program.get_is_topmost(): - self._send_mce_request(self._ENABLE_ACCEL) - else: - self._send_mce_request(self._DISABLE_ACCEL) - - 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 - return self._main_window - else: - # The main window is at the "bottom" of the window stack, and as - # the list we get with get_windows() is sorted "topmost first", we - # simply take the last item of the list to get our main window - windows = self._stack.get_windows() - if windows: - return windows[-1] - else: - return None - - def _orientation_changed(self, orientation): - if self._orientation == orientation: - # Ignore repeated requests - return - - flags = 0 - - if orientation != self._LANDSCAPE: - flags |= hildon.PORTRAIT_MODE_SUPPORT - - 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) - - self._orientation = orientation - - def _get_keyboard_state(self): - # For sbox, if the device does not exist assume that it's closed - try: - return open(self.KBD_SLIDER).read().strip() - except IOError: - return self._KBD_CLOSED - - def _keyboard_state_changed(self): - state = self._get_keyboard_state() - - if state == self._KBD_OPEN: - self._orientation_changed(self._LANDSCAPE) - elif state == self._KBD_CLOSED: - if self._mode == self.AUTOMATIC: - self._orientation_changed(self._last_dbus_orientation) - elif self._mode == self.ALWAYS: - self._orientation_changed(self._PORTRAIT) - - self._keyboard_state = state - - def _on_keyboard_signal(self, condition, button_name): - if condition == 'ButtonPressed' and button_name == 'cover': - self._keyboard_state_changed() - - def _on_orientation_signal(self, orientation, stand, face, x, y, z): - if orientation in (self._PORTRAIT, self._LANDSCAPE): - if self._mode == self.AUTOMATIC and \ - self._keyboard_state != self._KBD_OPEN: - # Automatically set the rotation based on hardware orientation - self._orientation_changed(orientation) - - # Save the current orientation for "automatic" mode later on - self._last_dbus_orientation = orientation - diff --git a/src/drlaunch.py b/src/drlaunch.py new file mode 100755 index 0000000..01d8366 --- /dev/null +++ b/src/drlaunch.py @@ -0,0 +1,125 @@ +#!/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 . +# +# $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 +import gobject +import hildon +from hildondesktop import * +from gtk import gdk +from math import pi +import cairo +import time + +from portrait import FremantleRotation +import launcher +from xdg.IconTheme import getIconPath +from win_config import WinConfig + +import config +import apps +from icon import Icon +from icongrid import IconGrid + +# IconGrid must be before HomePluginItem for its connect() +# and do_button_*() to override those of HomePluginItem +class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation): + def __init__(self): + IconGrid.__init__(self) + HomePluginItem.__init__(self) + FremantleRotation.__init__(self, 'DrlaunchPlugin') + + launcher.init() + config.load() + self.setSize(config.getSize()) + self.reloadIcons() + + self.set_settings(True) + self.connect('show-settings', self.slot_show_settings) + self.connect('long-press', self.signalLongpress) + + 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 on_orientation_changed(self, orientation): + print "orch:", orientation + o=orientation[0] + self.setMode(o) +# self.queue_draw() + + def do_expose_event(self, event): + IconGrid.do_expose_event(self, event) + HomePluginItem.do_expose_event(self, event) + + def do_buttonn_press_event(self, event): + print "press0" + + def slot_show_settings(self, dt): + print "settings", dt + s=WinConfig() + s.show_all() + s.connect('destroy', self.slotConfigDestroy) + + def slotConfigDestroy(self, sender): + print "destroy", sender + dt=sender.getData() + print "dt:", dt + config.setSize(dt['size']) + config.setApps(dt['apps']) + config.save() + + # Resize widget + self.setSize(dt['size']) + self.reloadIcons() + +# self.queue_draw() + + def signalLongpress(self, sender, icon): + print "launch:", icon.name + launcher.launch(icon.name) + + def resize(self): + w=(self.size * config.iconsize) + \ + (self.size * config.iconspace) + self.set_size_request(w, w) + + def setSize(self, size): + IconGrid.setSize(self, size) + self.resize() + +hd_plugin_type = DrlaunchPlugin + +if __name__=="__main__": + gobject.type_register(hd_plugin_type) + obj=gobject.new(hd_plugin_type, plugin_id="plugin_id") + obj.show_all() + gtk.main() + + + +# vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: + diff --git a/src/portrait.py.orig b/src/portrait.py.orig new file mode 100755 index 0000000..8cefa3e --- /dev/null +++ b/src/portrait.py.orig @@ -0,0 +1,211 @@ +# -*- 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 . +# + +import dbus +import dbus.glib + +import hildon +import osso + +# Replace this with your own gettext() functionality +import gpodder +_ = gpodder.gettext + + +class FremantleRotation(object): + """thp's screen rotation for Maemo 5 + + Simply instantiate an object of this class and let it auto-rotate + your StackableWindows depending on the device orientation. + + If you need to relayout a window, connect to its "configure-event" + signal and measure the ratio of width/height and relayout for that. + + You can set the mode for rotation to AUTOMATIC (default), NEVER or + ALWAYS with the set_mode() method. + """ + AUTOMATIC, NEVER, ALWAYS = range(3) + + # Human-readable captions for the above constants + MODE_CAPTIONS = (_('Automatic'), _('Landscape'), _('Portrait')) + + # Privately-used constants + _PORTRAIT, _LANDSCAPE = ('portrait', 'landscape') + _ENABLE_ACCEL = 'req_accelerometer_enable' + _DISABLE_ACCEL = 'req_accelerometer_disable' + + # Defined in mce/dbus-names.h + _MCE_SERVICE = 'com.nokia.mce' + _MCE_REQUEST_PATH = '/com/nokia/mce/request' + _MCE_REQUEST_IF = 'com.nokia.mce.request' + + # sysfs device name for the keyboard slider switch + KBD_SLIDER = '/sys/devices/platform/gpio-switch/slide/state' + _KBD_OPEN = 'open' + _KBD_CLOSED = 'closed' + + def __init__(self, app_name, main_window=None, version='1.0', mode=0): + """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) + """ + 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() + app_id = '-'.join((app_name, self.__class__.__name__)) + self._osso_context = osso.Context(app_id, version, False) + program = hildon.Program.get_instance() + program.connect('notify::is-topmost', self._on_topmost_changed) + system_bus = dbus.Bus.get_system() + system_bus.add_signal_receiver(self._on_orientation_signal, \ + signal_name='sig_device_orientation_ind', \ + dbus_interface='com.nokia.mce.signal', \ + path='/com/nokia/mce/signal') + system_bus.add_signal_receiver(self._on_keyboard_signal, \ + signal_name='Condition', \ + dbus_interface='org.freedesktop.Hal.Device', \ + path='/org/freedesktop/Hal/devices/platform_slide') + self.set_mode(mode) + + def get_mode(self): + """Get the currently-set rotation mode + + This will return one of three values: AUTOMATIC, ALWAYS or NEVER. + """ + 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, \ + self._MCE_REQUEST_PATH, \ + self._MCE_REQUEST_IF, \ + request, \ + use_system_bus=True) + + def _on_topmost_changed(self, program, property_spec): + # XXX: This seems to never get called on Fremantle(?) + if self._mode == self.AUTOMATIC: + if program.get_is_topmost(): + self._send_mce_request(self._ENABLE_ACCEL) + else: + self._send_mce_request(self._DISABLE_ACCEL) + + 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 + return self._main_window + else: + # The main window is at the "bottom" of the window stack, and as + # the list we get with get_windows() is sorted "topmost first", we + # simply take the last item of the list to get our main window + windows = self._stack.get_windows() + if windows: + return windows[-1] + else: + return None + + def _orientation_changed(self, orientation): + if self._orientation == orientation: + # Ignore repeated requests + return + + flags = 0 + + if orientation != self._LANDSCAPE: + flags |= hildon.PORTRAIT_MODE_SUPPORT + + 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) + + self._orientation = orientation + + def _get_keyboard_state(self): + # For sbox, if the device does not exist assume that it's closed + try: + return open(self.KBD_SLIDER).read().strip() + except IOError: + return self._KBD_CLOSED + + def _keyboard_state_changed(self): + state = self._get_keyboard_state() + + if state == self._KBD_OPEN: + self._orientation_changed(self._LANDSCAPE) + elif state == self._KBD_CLOSED: + if self._mode == self.AUTOMATIC: + self._orientation_changed(self._last_dbus_orientation) + elif self._mode == self.ALWAYS: + self._orientation_changed(self._PORTRAIT) + + self._keyboard_state = state + + def _on_keyboard_signal(self, condition, button_name): + if condition == 'ButtonPressed' and button_name == 'cover': + self._keyboard_state_changed() + + def _on_orientation_signal(self, orientation, stand, face, x, y, z): + if orientation in (self._PORTRAIT, self._LANDSCAPE): + if self._mode == self.AUTOMATIC and \ + self._keyboard_state != self._KBD_OPEN: + # Automatically set the rotation based on hardware orientation + self._orientation_changed(orientation) + + # Save the current orientation for "automatic" mode later on + self._last_dbus_orientation = orientation + diff --git a/src/widget.py b/src/widget.py deleted file mode 100755 index 01d8366..0000000 --- a/src/widget.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/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 . -# -# $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 -import gobject -import hildon -from hildondesktop import * -from gtk import gdk -from math import pi -import cairo -import time - -from portrait import FremantleRotation -import launcher -from xdg.IconTheme import getIconPath -from win_config import WinConfig - -import config -import apps -from icon import Icon -from icongrid import IconGrid - -# IconGrid must be before HomePluginItem for its connect() -# and do_button_*() to override those of HomePluginItem -class DrlaunchPlugin(IconGrid, HomePluginItem, FremantleRotation): - def __init__(self): - IconGrid.__init__(self) - HomePluginItem.__init__(self) - FremantleRotation.__init__(self, 'DrlaunchPlugin') - - launcher.init() - config.load() - self.setSize(config.getSize()) - self.reloadIcons() - - self.set_settings(True) - self.connect('show-settings', self.slot_show_settings) - self.connect('long-press', self.signalLongpress) - - 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 on_orientation_changed(self, orientation): - print "orch:", orientation - o=orientation[0] - self.setMode(o) -# self.queue_draw() - - def do_expose_event(self, event): - IconGrid.do_expose_event(self, event) - HomePluginItem.do_expose_event(self, event) - - def do_buttonn_press_event(self, event): - print "press0" - - def slot_show_settings(self, dt): - print "settings", dt - s=WinConfig() - s.show_all() - s.connect('destroy', self.slotConfigDestroy) - - def slotConfigDestroy(self, sender): - print "destroy", sender - dt=sender.getData() - print "dt:", dt - config.setSize(dt['size']) - config.setApps(dt['apps']) - config.save() - - # Resize widget - self.setSize(dt['size']) - self.reloadIcons() - -# self.queue_draw() - - def signalLongpress(self, sender, icon): - print "launch:", icon.name - launcher.launch(icon.name) - - def resize(self): - w=(self.size * config.iconsize) + \ - (self.size * config.iconspace) - self.set_size_request(w, w) - - def setSize(self, size): - IconGrid.setSize(self, size) - self.resize() - -hd_plugin_type = DrlaunchPlugin - -if __name__=="__main__": - gobject.type_register(hd_plugin_type) - obj=gobject.new(hd_plugin_type, plugin_id="plugin_id") - obj.show_all() - gtk.main() - - - -# vim: set ts=8 sts=4 sw=4 noet formatoptions=r ai nocindent: - -- 1.7.9.5