From 674fb47bbaec3d11b0fc833dde70b26b361b5d91 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 21 Oct 2008 09:55:33 +0000 Subject: Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar --- diff --git a/src/jarabe/desktop/favoritesview.py b/src/jarabe/desktop/favoritesview.py index 2afb933..3db90ac 100644 --- a/src/jarabe/desktop/favoritesview.py +++ b/src/jarabe/desktop/favoritesview.py @@ -79,6 +79,8 @@ class FavoritesView(hippo.Canvas): self._pressed_button = None self._press_start_x = None self._press_start_y = None + self._hot_x = None + self._hot_y = None self._last_clicked_icon = None self._box = hippo.CanvasBox() @@ -227,8 +229,9 @@ class FavoritesView(hippo.Canvas): # TODO: we should get the pixbuf from the widget, so it has colors, etc pixbuf = gtk.gdk.pixbuf_new_from_file(icon_file_name) - hot_spot = style.zoom(10) - context.set_icon_pixbuf(pixbuf, hot_spot, hot_spot) + self._hot_x = pixbuf.props.width / 2 + self._hot_y = pixbuf.props.height / 2 + context.set_icon_pixbuf(pixbuf, self._hot_x, self._hot_y) def __drag_motion_cb(self, widget, context, x, y, time): if self._last_clicked_icon is not None: @@ -241,11 +244,14 @@ class FavoritesView(hippo.Canvas): if self._last_clicked_icon is not None: self.drag_get_data(context, _ICON_DND_TARGET[0]) - self._layout.move_icon(self._last_clicked_icon, x, y) + self._layout.move_icon(self._last_clicked_icon, + x - self._hot_x, y - self._hot_y) self._pressed_button = None self._press_start_x = None self._press_start_y = None + self._hot_x = None + self._hot_y = None self._last_clicked_icon = None return True diff --git a/src/jarabe/frame/clipboardicon.py b/src/jarabe/frame/clipboardicon.py index ff182dc..ff63ad9 100644 --- a/src/jarabe/frame/clipboardicon.py +++ b/src/jarabe/frame/clipboardicon.py @@ -23,6 +23,7 @@ import gtk from sugar.graphics.radiotoolbutton import RadioToolButton from sugar.graphics.icon import Icon from sugar.graphics.xocolor import XoColor +from sugar.graphics import style from jarabe.frame import clipboard from jarabe.frame.clipboardmenu import ClipboardMenu @@ -114,10 +115,10 @@ class ClipboardIcon(RadioToolButton): self._icon.props.icon_name = 'application-octet-stream' child = self.get_child() + child.connect('drag-begin', self._drag_begin_cb) child.drag_source_set(gtk.gdk.BUTTON1_MASK, self._get_targets(), gtk.gdk.ACTION_COPY) - child.drag_source_set_icon_name(self._icon.props.icon_name) if cb_object.get_percent() == 100: self.props.sensitive = True @@ -136,6 +137,14 @@ class ClipboardIcon(RadioToolButton): gtk.CORNER_BOTTOM_LEFT) self._current_percent = cb_object.get_percent() + def _drag_begin_cb(self, widget, context): + # TODO: We should get the pixbuf from the icon, with colors, etc. + icon_theme = gtk.icon_theme_get_default() + pixbuf = icon_theme.load_icon(self._icon.props.icon_name, + style.STANDARD_ICON_SIZE, 0) + context.set_icon_pixbuf(pixbuf, hot_x=pixbuf.props.width / 2, + hot_y=pixbuf.props.height / 2) + def _notify_active_cb(self, widget, pspec): if self.props.active: self._put_in_clipboard() diff --git a/src/jarabe/frame/clipboardobject.py b/src/jarabe/frame/clipboardobject.py index cf758ef..51d0470 100644 --- a/src/jarabe/frame/clipboardobject.py +++ b/src/jarabe/frame/clipboardobject.py @@ -18,6 +18,7 @@ import os import logging import urlparse +from gettext import gettext as _ from sugar import mime from sugar.bundle.activitybundle import ActivityBundle @@ -39,9 +40,12 @@ class ClipboardObject(object): def get_name(self): name = self._name if not name: - name = mime.get_mime_description(self.get_mime_type()) - if not name: - name = '' + type = mime.get_mime_description(self.get_mime_type()) + + if not type: + type = 'Data' + name = _('%s clipping') % type + return name def get_icon(self): diff --git a/src/jarabe/frame/clipboardpanelwindow.py b/src/jarabe/frame/clipboardpanelwindow.py index 2a479a5..7093199 100644 --- a/src/jarabe/frame/clipboardpanelwindow.py +++ b/src/jarabe/frame/clipboardpanelwindow.py @@ -44,6 +44,7 @@ class ClipboardPanelWindow(FrameWindow): # Receiving dnd drops self.drag_dest_set(0, [], 0) self.connect("drag_motion", self._clipboard_tray.drag_motion_cb) + self.connect("drag_leave", self._clipboard_tray.drag_leave_cb) self.connect("drag_drop", self._clipboard_tray.drag_drop_cb) self.connect("drag_data_received", self._clipboard_tray.drag_data_received_cb) diff --git a/src/jarabe/frame/clipboardtray.py b/src/jarabe/frame/clipboardtray.py index e915d15..40f0a32 100644 --- a/src/jarabe/frame/clipboardtray.py +++ b/src/jarabe/frame/clipboardtray.py @@ -125,11 +125,27 @@ class ClipboardTray(tray.VTray): def drag_motion_cb(self, widget, context, x, y, time): logging.debug('ClipboardTray._drag_motion_cb') - context.drag_status(gtk.gdk.ACTION_COPY, time) + + if self._internal_drag(context): + context.drag_status(gtk.gdk.ACTION_MOVE, time) + else: + context.drag_status(gtk.gdk.ACTION_COPY, time) + self.props.drag_active = True + return True + def drag_leave_cb(self, widget, context, time): + self.props.drag_active = False + def drag_drop_cb(self, widget, context, x, y, time): logging.debug('ClipboardTray._drag_drop_cb') + + if self._internal_drag(context): + # TODO: We should move the object within the clipboard here + if not self._context_map.has_context(context): + context.drop_finish(False, gtk.get_current_event_time()) + return False + cb_service = clipboard.get_instance() object_id = cb_service.add_object(name="") @@ -191,3 +207,10 @@ class ClipboardTray(tray.VTray): if not self._context_map.has_context(context): context.drop_finish(True, gtk.get_current_event_time()) + def _internal_drag(self, context): + view_ancestor = context.get_source_widget().get_ancestor(gtk.Viewport) + if view_ancestor is self._viewport: + return True + else: + return False + diff --git a/src/jarabe/view/tabbinghandler.py b/src/jarabe/view/tabbinghandler.py index 87a36a1..b1c85c6 100644 --- a/src/jarabe/view/tabbinghandler.py +++ b/src/jarabe/view/tabbinghandler.py @@ -86,7 +86,7 @@ class TabbingHandler(object): if self._tabbing: shell_model = shell.get_model() - zoom_level = shell_model.get_zoom_level() + zoom_level = shell_model.zoom_level zoom_activity = (zoom_level == shell.ShellModel.ZOOM_ACTIVITY) if not zoom_activity and first_switch: @@ -109,7 +109,7 @@ class TabbingHandler(object): if self._tabbing: shell_model = shell.get_model() - zoom_level = shell_model.get_zoom_level() + zoom_level = shell_model.zoom_level zoom_activity = (zoom_level == shell.ShellModel.ZOOM_ACTIVITY) if not zoom_activity and first_switch: -- cgit v0.9.1