Hide active palette if zoom level changes.
This commit is contained in:
parent
1796cbc0c7
commit
70e6d08f8d
@ -56,11 +56,13 @@ class ShellService(dbus.service.Object):
|
|||||||
self._home_model.connect('active-activity-changed',
|
self._home_model.connect('active-activity-changed',
|
||||||
self._cur_activity_changed_cb)
|
self._cur_activity_changed_cb)
|
||||||
|
|
||||||
|
self._shell_model.connect('notify::zoom-level',
|
||||||
|
self._shell_model_notify_zoom_level_cb)
|
||||||
|
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus)
|
bus_name = dbus.service.BusName(_DBUS_SERVICE, bus=bus)
|
||||||
dbus.service.Object.__init__(self, bus_name, _DBUS_PATH)
|
dbus.service.Object.__init__(self, bus_name, _DBUS_PATH)
|
||||||
|
|
||||||
|
|
||||||
@dbus.service.method(_DBUS_SHELL_IFACE,
|
@dbus.service.method(_DBUS_SHELL_IFACE,
|
||||||
in_signature="ss", out_signature="")
|
in_signature="ss", out_signature="")
|
||||||
def NotifyLaunch(self, bundle_id, activity_id):
|
def NotifyLaunch(self, bundle_id, activity_id):
|
||||||
@ -146,6 +148,10 @@ class ShellService(dbus.service.Object):
|
|||||||
def CurrentActivityChanged(self, activity_id):
|
def CurrentActivityChanged(self, activity_id):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@dbus.service.signal(_DBUS_SHELL_IFACE, signature="i")
|
||||||
|
def ZoomLevelChanged(self, new_level):
|
||||||
|
pass
|
||||||
|
|
||||||
def _cur_activity_changed_cb(self, owner, new_activity):
|
def _cur_activity_changed_cb(self, owner, new_activity):
|
||||||
new_id = ""
|
new_id = ""
|
||||||
if new_activity:
|
if new_activity:
|
||||||
@ -153,6 +159,9 @@ class ShellService(dbus.service.Object):
|
|||||||
if new_id:
|
if new_id:
|
||||||
self.CurrentActivityChanged(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):
|
def _bundle_to_dict(self, bundle):
|
||||||
return {'name': bundle.get_name(),
|
return {'name': bundle.get_name(),
|
||||||
'icon': bundle.get_icon(),
|
'icon': bundle.get_icon(),
|
||||||
|
@ -21,6 +21,7 @@ import gtk
|
|||||||
import gobject
|
import gobject
|
||||||
import time
|
import time
|
||||||
import hippo
|
import hippo
|
||||||
|
import dbus
|
||||||
|
|
||||||
from sugar.graphics import animator
|
from sugar.graphics import animator
|
||||||
from sugar.graphics import units
|
from sugar.graphics import units
|
||||||
@ -87,6 +88,15 @@ class Palette(gobject.GObject):
|
|||||||
self._menu.connect('button-press-event',
|
self._menu.connect('button-press-event',
|
||||||
self._button_press_event_cb)
|
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):
|
def set_primary_text(self, label, accel_path=None):
|
||||||
self._primary.set_label(label, accel_path)
|
self._primary.set_label(label, accel_path)
|
||||||
|
|
||||||
@ -234,6 +244,9 @@ class Palette(gobject.GObject):
|
|||||||
def _button_press_event_cb(self, widget, event):
|
def _button_press_event_cb(self, widget, event):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def _zoom_level_changed_cb(self, zoom_level):
|
||||||
|
self._hide()
|
||||||
|
|
||||||
class _PrimaryMenuItem(gtk.MenuItem):
|
class _PrimaryMenuItem(gtk.MenuItem):
|
||||||
def __init__(self, label, accel_path):
|
def __init__(self, label, accel_path):
|
||||||
gtk.MenuItem.__init__(self)
|
gtk.MenuItem.__init__(self)
|
||||||
@ -378,6 +391,8 @@ class CanvasInvoker(Invoker):
|
|||||||
context = self._item.get_context()
|
context = self._item.get_context()
|
||||||
if context:
|
if context:
|
||||||
x, y = context.translate_to_screen(self._item)
|
x, y = context.translate_to_screen(self._item)
|
||||||
|
else:
|
||||||
|
x, y = 0, 0
|
||||||
|
|
||||||
width, height = self._item.get_allocation()
|
width, height = self._item.get_allocation()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user