From 70e6d08f8d0fc385b8e7c539b09fced609b9c5a4 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 04 Jul 2007 10:33:12 +0000 Subject: Hide active palette if zoom level changes. --- diff --git a/shell/shellservice.py b/shell/shellservice.py index b4c96ff..dd5e224 100644 --- a/shell/shellservice.py +++ b/shell/shellservice.py @@ -56,11 +56,13 @@ class ShellService(dbus.service.Object): self._home_model.connect('active-activity-changed', self._cur_activity_changed_cb) + self._shell_model.connect('notify::zoom-level', + self._shell_model_notify_zoom_level_cb) + bus = dbus.SessionBus() bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus) dbus.service.Object.__init__(self, bus_name, _DBUS_PATH) - @dbus.service.method(_DBUS_SHELL_IFACE, in_signature="ss", out_signature="") def NotifyLaunch(self, bundle_id, activity_id): @@ -146,6 +148,10 @@ class ShellService(dbus.service.Object): def CurrentActivityChanged(self, activity_id): pass + @dbus.service.signal(_DBUS_SHELL_IFACE, signature="i") + def ZoomLevelChanged(self, new_level): + pass + def _cur_activity_changed_cb(self, owner, new_activity): new_id = "" if new_activity: @@ -153,6 +159,9 @@ class ShellService(dbus.service.Object): if new_id: self.CurrentActivityChanged(new_id) + def _shell_model_notify_zoom_level_cb(self, shell_model, pspec): + self.ZoomLevelChanged(shell_model.props.zoom_level) + def _bundle_to_dict(self, bundle): return {'name': bundle.get_name(), 'icon': bundle.get_icon(), diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py index ef1a61c..9c23c2f 100644 --- a/sugar/graphics/palette.py +++ b/sugar/graphics/palette.py @@ -21,6 +21,7 @@ import gtk import gobject import time import hippo +import dbus from sugar.graphics import animator from sugar.graphics import units @@ -87,6 +88,15 @@ class Palette(gobject.GObject): self._menu.connect('button-press-event', self._button_press_event_cb) + gobject.idle_add(self._listen_for_zoom_level_change) + + def _listen_for_zoom_level_change(self): + bus = dbus.Bus() + proxy = bus.get_object('org.laptop.Shell', '/org/laptop/Shell') + shell_service = dbus.Interface(proxy, 'org.laptop.Shell') + shell_service.connect_to_signal('ZoomLevelChanged', + self._zoom_level_changed_cb) + def set_primary_text(self, label, accel_path=None): self._primary.set_label(label, accel_path) @@ -234,6 +244,9 @@ class Palette(gobject.GObject): def _button_press_event_cb(self, widget, event): pass + def _zoom_level_changed_cb(self, zoom_level): + self._hide() + class _PrimaryMenuItem(gtk.MenuItem): def __init__(self, label, accel_path): gtk.MenuItem.__init__(self) @@ -378,6 +391,8 @@ class CanvasInvoker(Invoker): context = self._item.get_context() if context: x, y = context.translate_to_screen(self._item) + else: + x, y = 0, 0 width, height = self._item.get_allocation() -- cgit v0.9.1