[Sugar-devel] Does it make sense to have Activities copy text to the clipboard?
James Simmons
nicestep at gmail.com
Wed Jan 15 10:55:18 EST 2014
The code for the Activity is here:
http://git.sugarlabs.org/myo-sugar-activities-examples/mainline/blobs/master/Add_Refinements_gtk3/ReadEtextsActivity2.py
The code being executed is:
def edit_toolbar_copy_cb(self, button):
textbuffer = self.textview.get_buffer()
begin, end = textbuffer.get_selection_bounds()
copy_text = textbuffer.get_text(begin, end, False)
self.clipboard.set_text(copy_text)
The definition for self.clipboard is:
self.clipboard = Gtk.Clipboard()
on line 166.
This code is similar to what was in my Read Etexts Activity. I'll have
to see if that one still works. I know textbuffer.get_text() used to
take only two parameters and now needs three.
But thanks for confirming that the clipboard works as I described.
That means it's my problem and I can try and figure it out.
James Simmons
On Tue, Jan 14, 2014 at 6:40 PM, Walter Bender <walter.bender at gmail.com>wrote:
> On Tue, Jan 14, 2014 at 6:20 PM, James Simmons <nicestep at gmail.com> wrote:
> > GCI has come and gone and none of my MYOSA tasks got done so I decided
> that
> > if I'm going to get a GCI T-shirt this year I'd better do something to
> earn
> > it. So I'm doing the tasks that I tried to get GCI-ers to do for me.
> >
> > I'm really rusty at this, but I did manage to update the Gtk3 version of
> the
> > Adding Refinements example to use the current toolbar. However, when
> testing
> > it I discovered that copying text to the clipboard doesn't work the way I
> > remembered it. It seems to me that when I did the copy in the past there
> > would be an object in the frame that was the clipboard entry. You could
> have
> > several of these, and there was a menu option to make Journal entries
> out of
> > them. That's how I remember it, anyway.
> >
> > I don't see this anymore, and I wonder if it is a change to Sugar itself
> or
> > just a bug in my code.
>
> Hard to say without a link to your code :P
>
> You prob. want something like this:
>
> clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
> text_buffer.copy_clipboard(clipboard)
>
> regards
>
> -walter
>
> >
> > James Simmons
> >
> >
> > _______________________________________________
> > Sugar-devel mailing list
> > Sugar-devel at lists.sugarlabs.org
> > http://lists.sugarlabs.org/listinfo/sugar-devel
> >
>
>
>
> --
> Walter Bender
> Sugar Labs
> http://www.sugarlabs.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140115/c2be06f5/attachment-0001.html>
More information about the Sugar-devel
mailing list