From ea576330818699e188d7226b8bc6643efc38af26 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 30 Jun 2012 14:49:33 +0000 Subject: new copy button behavior --- (limited to 'TurtleArtActivity.py') diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 777bd79..86991da 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -868,6 +868,10 @@ class TurtleArtActivity(activity.Activity): else: # ...or else, load a Start Block onto the canvas. self.tw.load_start() + if self.has_toolbarbox: + self._old_cursor = self.get_window().get_cursor() + self.copying = False + def _setup_sharing(self): ''' Setup the Collabora stack. ''' self._collaboration = Collaboration(self.tw, self) @@ -1096,8 +1100,25 @@ in order to use the plugin.')) error_handler=self._internal_jobject_error_cb) self._jobject.destroy() + def restore_cursor(self): + ''' No longer copying, so restore standard cursor. ''' + self.copying = False + if self.has_toolbarbox: + self.get_window().set_cursor(self._old_cursor) + def _copy_cb(self, button): ''' Copy to the clipboard. ''' + if self.copying: + self.restore_cursor() + else: + self.copying = 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 send_to_clipboard(self): + ''' Send selected stack to clipboard. ''' + self.restore_cursor() clipboard = gtk.Clipboard() _logger.debug('Serialize the project and copy to clipboard.') data = self.tw.assemble_data_to_save(False, False) @@ -1106,20 +1127,10 @@ in order to use the plugin.')) clipboard.set_text(text) self.tw.paste_offset = 20 - def _share_cb(self, button): - ''' Share a stack of blocks. ''' - if not self.tw.sharing(): - return - _logger.debug('Serialize a stack and send as event.') - data = self.tw.assemble_data_to_save(False, False) - if data is not []: - text = data_to_string(data) - event = 'B|%s' % (data_to_string([self.tw.nick, text])) # Paste - self.tw.send_event(event) - self.tw.paste_offset = 20 - def _paste_cb(self, button): ''' Paste from the clipboard. ''' + if self.copying: + self.restore_cursor() clipboard = gtk.Clipboard() _logger.debug('Paste to the project.') text = clipboard.wait_for_text() @@ -1134,6 +1145,18 @@ in order to use the plugin.')) self.tw.paste_offset) self.tw.paste_offset += 20 + def _share_cb(self, button): + ''' Share a stack of blocks. ''' + if not self.tw.sharing(): + return + _logger.debug('Serialize a stack and send as event.') + data = self.tw.assemble_data_to_save(False, False) + if data is not []: + text = data_to_string(data) + event = 'B|%s' % (data_to_string([self.tw.nick, text])) # Paste + self.tw.send_event(event) + self.tw.paste_offset = 20 + def _add_label(self, string, toolbar, width=None): ''' Add a label to a toolbar. ''' label = gtk.Label(string) -- cgit v0.9.1