From 031d8f5adafaade8b4d6cdcfa98c99fbad19ca82 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 30 Jun 2012 18:00:41 +0000 Subject: use same mechanism for sharing stacks as in copying stacks --- diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index 8f37de7..78b0d0b 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -1269,7 +1269,8 @@ class TurtleArtWindow(): # From the sprite at x, y, look for a corresponding block blk = self.block_list.spr_to_block(spr) ''' If we were copying and didn't click on a block... ''' - if self.running_sugar and self.activity.copying: + if self.running_sugar and \ + (self.activity.copying or self.activity.sharing_blocks): if blk is None or blk.type != 'block': self.activity.restore_cursor() if blk is not None: @@ -1651,13 +1652,17 @@ class TurtleArtWindow(): self.drag_group = find_group(blk) (sx, sy) = blk.spr.get_xy() self.drag_pos = x - sx, y - sy - if self.running_sugar and self.activity.copying: + if self.running_sugar and \ + (self.activity.copying or self.activity.sharing_blocks): for blk in self.drag_group: if blk.status != 'collapsed': blk.spr.set_layer(TOP_LAYER) blk.highlight() self.block_operation = 'copying' - self.activity.send_to_clipboard() + if self.activity.copying: + self.activity.send_to_clipboard() + else: + self.activity.share_blocks() if self.running_sugar and self._sharing and \ hasattr(self.activity, 'share_button'): self.activity.share_button.set_tooltip( @@ -2168,6 +2173,9 @@ class TurtleArtWindow(): abs(self.dy < MOTION_THRESHOLD))): self._click_block(x, y) elif self.block_operation == 'copying': + gobject.timeout_add(500, self._unhighlight_drag_group, blk) + + def _unhighlight_drag_group(self, blk): self.drag_group = find_group(blk) for gblk in self.drag_group: gblk.unhighlight() diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 86991da..9bab7f9 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -871,6 +871,7 @@ class TurtleArtActivity(activity.Activity): if self.has_toolbarbox: self._old_cursor = self.get_window().get_cursor() self.copying = False + self.sharing_blocks = False def _setup_sharing(self): ''' Setup the Collabora stack. ''' @@ -1101,8 +1102,9 @@ in order to use the plugin.')) self._jobject.destroy() def restore_cursor(self): - ''' No longer copying, so restore standard cursor. ''' + ''' No longer copying or sharing, so restore standard cursor. ''' self.copying = False + self.sharing_blocks = False if self.has_toolbarbox: self.get_window().set_cursor(self._old_cursor) @@ -1147,9 +1149,20 @@ in order to use the plugin.')) def _share_cb(self, button): ''' Share a stack of blocks. ''' + if self.sharing_blocks: + self.restore_cursor() + else: + self.sharing_blocks = True + if self.has_toolbarbox: + self._old_cursor = self.get_window().get_cursor() + self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1)) + + def share_blocks(self): + ''' Share selected stack. ''' if not self.tw.sharing(): return _logger.debug('Serialize a stack and send as event.') + self.restore_cursor() data = self.tw.assemble_data_to_save(False, False) if data is not []: text = data_to_string(data) -- cgit v0.9.1