[Bugs] #3066 UNSP: BrowseV124 regressions

Sugar Labs Bugs bugtracker-noreply at sugarlabs.org
Thu Sep 1 06:36:35 EDT 2011


#3066: BrowseV124 regressions
------------------------------------------+---------------------------------
    Reporter:  tonyforster                |          Owner:  erikos     
        Type:  defect                     |         Status:  assigned   
    Priority:  Unspecified by Maintainer  |      Milestone:  0.94       
   Component:  Browse                     |        Version:  Unspecified
    Severity:  Unspecified                |       Keywords:  11.3.0     
Distribution:  Unspecified                |   Status_field:  Unconfirmed
------------------------------------------+---------------------------------

Comment(by erikos):

 I have been thinking a bit about it: once we connect to the 'clicked'
 signal of the button it is up to the activity to handle the
 copying/pasting to the clipboard.

 In Write for example you can only use the copy and paste functionality
 when you select text on the widget. If you select something in the title
 entry for example you can not copy it. In Chat you can copy/paste
 from/into the title entry but here the edit toolbar and therefore the copy
 button with the accelerator is not present.

 One fix would be to check in the callback for the 'clicked' signal from
 the copy-button if the entry has been focused and copy the selected text
 then to the clipboard. A rough patch would be:

 {{{
 diff --git a/edittoolbar.py b/edittoolbar.py
 index f0cdb1a..a93d9b3 100644
 --- a/edittoolbar.py
 +++ b/edittoolbar.py
 @@ -110,8 +110,38 @@ class EditToolbar(activity.EditToolbar):
          command_manager.doCommand('cmd_redo', None, None)

      def __copy_cb(self, button):
 -        command_manager = self._get_command_manager()
 -        command_manager.doCommand('cmd_copy', None, None)
 +        if self._activity._primary_toolbar.entry.has_focus():
 +            bounds =
 self._activity._primary_toolbar.entry.get_selection_bounds()
 +
 self._copy_to_clipboard(self._activity._primary_toolbar.entry.get_chars(bounds[0],
 bounds[1]))
 +        else:
 +            command_manager = self._get_command_manager()
 +            command_manager.doCommand('cmd_copy', None, None)
 +
 +    def _copy_to_clipboard(self, text):
 +        clipboard = gtk.Clipboard()
 +        targets = gtk.target_list_add_uri_targets()
 +        targets = gtk.target_list_add_text_targets(targets)
 +        targets.append(('text/x-moz-url', 0, 0))
 +
 +        clipboard.set_with_data(targets,
 +                                self.__clipboard_get_func_cb,
 +                                self.__clipboard_clear_func_cb, text)
 +
 +    def __clipboard_get_func_cb(self, clipboard, selection_data, info,
 data):
 +        uri_targets = \
 +            [target[0] for target in gtk.target_list_add_uri_targets()]
 +        text_targets = \
 +            [target[0] for target in gtk.target_list_add_text_targets()]
 +
 +        if selection_data.target in uri_targets:
 +            selection_data.set_uris([data])
 +        elif selection_data.target in text_targets:
 +            selection_data.set_text(data)
 +        elif selection_data.target == 'text/x-moz-url':
 +            selection_data.set('text/x-moz-url', 8, data)
 +
 +    def __clipboard_clear_func_cb(self, clipboard, data):
 +        pass

      def __paste_cb(self, button):
          command_manager = self._get_command_manager()
 }}}

 We would need to as well do something similar for the paste button.

-- 
Ticket URL: <http://bugs.sugarlabs.org/ticket/3066#comment:14>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list