Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar

This commit is contained in:
Marco Pesenti Gritti 2006-12-17 00:02:38 +01:00
commit 09b096d4d0
4 changed files with 66 additions and 7 deletions

View File

@ -127,6 +127,7 @@ class Shell(gobject.GObject):
self._frame.notify_key_release()
def __window_opened_cb(self, screen, window):
logging.debug('Shell.__window_opened_cb')
if window.get_window_type() == wnck.WINDOW_NORMAL:
try:
activity_host = ActivityHost(self.get_model(), window)
@ -140,6 +141,7 @@ class Shell(gobject.GObject):
self.emit('activity-opened', activity_host)
def __active_window_changed_cb(self, screen):
logging.debug('Shell.__active_window_changed_cb')
window = screen.get_active_window()
if not window or window.get_window_type() != wnck.WINDOW_NORMAL:
return
@ -154,6 +156,7 @@ class Shell(gobject.GObject):
self._set_current_activity(activity_host)
def __window_closed_cb(self, screen, window):
logging.debug('Shell.__window_closed_cb')
if window.get_window_type() != wnck.WINDOW_NORMAL:
return
@ -204,6 +207,7 @@ class Shell(gobject.GObject):
logging.error('Cannot start activity.')
def start_activity(self, activity_type):
logging.debug('Shell.start_activity')
activity = ActivityFactory.create(activity_type)
activity.execute('test', [])
return activity

View File

@ -79,6 +79,10 @@ class EventFrame(gobject.GObject):
invisible.connect('enter-notify-event', self._enter_notify_cb)
invisible.connect('leave-notify-event', self._leave_notify_cb)
invisible.drag_dest_set(0, [], 0)
invisible.connect('drag_motion', self._drag_motion_cb)
invisible.connect('drag_leave', self._drag_leave_cb)
invisible.realize()
invisible.window.set_events(gtk.gdk.POINTER_MOTION_MASK |
gtk.gdk.ENTER_NOTIFY_MASK |
@ -89,9 +93,17 @@ class EventFrame(gobject.GObject):
def _enter_notify_cb(self, widget, event):
self._notify_enter(event.x, event.y)
logging.debug('EventFrame._enter_notify_cb ' + str(self._hover))
def _motion_notify_cb(self, widget, event):
self._notify_enter(event.x, event.y)
logging.debug('EventFrame._motion_notify_cb ' + str(self._hover))
def _drag_motion_cb(self, widget, drag_context, x, y, timestamp):
drag_context.drag_status(0, timestamp);
self._notify_enter(x, y)
logging.debug('EventFrame._drag_motion_cb ' + str(self._hover))
return True
def _notify_enter(self, x, y):
screen_w = gtk.gdk.screen_width()
@ -110,6 +122,15 @@ class EventFrame(gobject.GObject):
self.emit('enter-edge')
def _leave_notify_cb(self, widget, event):
self._notify_leave()
logging.debug('EventFrame._leave_notify_cb ' + str(self._hover))
def _drag_leave_cb(self, widget, drag_context, timestamp):
self._notify_leave()
logging.debug('EventFrame._drag_leave_cb ' + str(self._hover))
return True
def _notify_leave(self):
self._hover = EventFrame.HOVER_NONE
if self._active:
self.emit('leave')
@ -220,8 +241,12 @@ class Frame:
def _create_clipboard_panel(self, grid, x, y, width, height):
[x, y, width, height] = grid.rectangle(x, y, width, height)
panel = ClipboardPanelWindow(x, y, width, height)
panel = ClipboardPanelWindow(self, x, y, width, height)
self._connect_to_panel(panel)
panel.connect('drag-motion', self._drag_motion_cb)
panel.connect('drag-leave', self._drag_leave_cb)
self._windows.append(panel)
return panel
@ -253,12 +278,26 @@ class Frame:
def _enter_notify_cb(self, window, event):
self._timeline.goto('slide_in', True)
logging.debug('Frame._enter_notify_cb ' + str(self._mode))
def _drag_motion_cb(self, window, context, x, y, time):
self._timeline.goto('slide_in', True)
logging.debug('Frame._drag_motion_cb ' + str(self._mode))
return True
def _drag_leave_cb(self, window, drag_context, timestamp):
self._leave_notify()
logging.debug('Frame._drag_leave_cb ' + str(self._mode))
def _leave_notify_cb(self, window, event):
# FIXME for some reason every click cause also a leave-notify
if event.state == gtk.gdk.BUTTON1_MASK:
return
self._leave_notify()
logging.debug('Frame._leave_notify_cb ' + str(self._mode))
def _leave_notify(self):
if self._active_menus == 0 and \
(self._mode == Frame.HIDE_ON_LEAVE or \
self._mode == Frame.AUTOMATIC):
@ -267,14 +306,17 @@ class Frame:
def _enter_edge_cb(self, event_frame):
self._mode = Frame.HIDE_ON_LEAVE
self._timeline.play(None, 'slide_in')
logging.debug('Frame._enter_edge_cb ' + str(self._mode))
def _enter_corner_cb(self, event_frame):
self._mode = Frame.HIDE_ON_LEAVE
self._timeline.play('slide_in', 'slide_in')
logging.debug('Frame._enter_corner_cb ' + str(self._mode))
def _event_frame_leave_cb(self, event_frame):
if self._mode != Frame.STICKY:
self._timeline.goto('slide_out', True)
logging.debug('Frame._event_frame_leave_cb ' + str(self._mode))
def show_and_hide(self, seconds):
self._mode = Frame.AUTOMATIC

View File

@ -33,6 +33,9 @@ class _ContextMap:
return object_id
def has_context(self, context):
return context in self._context_map
class ClipboardBox(hippo.CanvasBox):
def __init__(self, menu_shell):
@ -91,10 +94,12 @@ class ClipboardBox(hippo.CanvasBox):
logging.debug('ClipboardBox: ' + object_id + ' state was changed.')
def drag_motion_cb(self, widget, context, x, y, time):
logging.debug('ClipboardBox._drag_motion_cb')
context.drag_status(gtk.gdk.ACTION_COPY, time)
return True
def drag_drop_cb(self, widget, context, x, y, time):
logging.debug('ClipboardBox._drag_drop_cb')
object_id = util.unique_id()
self._context_map.add_context(context, object_id, len(context.targets))
@ -117,6 +122,10 @@ class ClipboardBox(hippo.CanvasBox):
else:
logging.warn('ClipboardBox: empty selection for target ' + selection.target)
# If it's the last target to be processed, finish the dnd transaction
if not self._context_map.has_context(context):
context.finish(True, False, time)
def drag_data_get_cb(self, widget, context, selection, targetType, eventTime):
logging.debug("drag_data_get_cb: requested target " + selection.target)

View File

@ -8,9 +8,11 @@ from sugar.clipboard import clipboardservice
from sugar import util
class ClipboardPanelWindow(PanelWindow):
def __init__(self, x, y, width, height):
def __init__(self, frame, x, y, width, height):
PanelWindow.__init__(self, x, y, width, height)
self._frame = frame
# Listening for new clipboard objects
clipboard = gtk.Clipboard()
clipboard.connect("owner-change", self._owner_change_cb)
@ -52,6 +54,8 @@ class ClipboardPanelWindow(PanelWindow):
if selection:
self._add_selection(key, selection)
self._frame.show_and_hide(0)
def _add_selection(self, key, selection):
if selection.data:
logging.debug('adding type ' + selection.type + '.')