Re: gtk.gdk.threads_init and paste

From: Daniel Carvalho <idnael_at_gmail.com>
Date: Tue Feb 17 2009 - 15:53:41 CET

I'm using trunk now!

I configured abiword with:
configure --enable-dynamic --enable-plugins="loadbindings"

And pyabiword with just no extra options.

It seems the behaviour with pasting is exactly the same.

J.M.Maurer told
> Note: AbiWord itself initializes glib threading already,
> so no need to do that yourself.

In that case there would be no effect if I also call
"gtk.gdk.threads_init". I think there is no problem if it is
initialized two times...

Anyway I have other parts of the program that depend on the gtk
multiple-thread feature and they are not working well if I don't call
gtk.gdk.threads_init, even if the program also uses an abiword.Canvas.

Please run the following demonstration program:

It has a second button, "paste2", that will get the content of the
clipboard and insert it in the canvas with the insert_data function.
And it looks it is working that way... at least this simple demo
program works. But I have another larger program that dont :-(

So... i'm confused.

If you send a SIGUSR1 to the program it will paste in the canvas. This
is to test the threads_enter/leave functions.

daniel

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import pygtk
pygtk.require('2.0')
import gtk

gtk.gdk.threads_init()

import abiword

import os
from signal import *

# see
# http://www.moeraki.com/pygtktutorial/pygtk2reference/gdk-functions.html#function-gdk--threads-init

window=gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_default_size(640, 480)

box=gtk.VBox(False,5)
box.show()
window.add(box)

editor=abiword.Canvas()
box.add(editor)

status=gtk.Entry()
box.pack_end(status,False,False)

b=gtk.Button("paste")
b.show()
def paste_cb(w,u=None):
    editor.paste()
b.connect("clicked", paste_cb, None)
box.pack_start(b,False,False)

b=gtk.Button("paste2")
b.show()
def paste2_cb(w,u=None):
    clip_primary=gtk.clipboard_get("CLIPBOARD")
    text=clip_primary.wait_for_text()
    print "text="+text
    res=editor.insert_data(text)
    print "res="+str(res)
b.connect("clicked", paste2_cb, None)
box.pack_start(b,False,False)

def sigusr_cb(sig,arg2):
    gtk.gdk.threads_enter()
    print "sinal!"
    status.set_text(status.get_text()+" sinal!")
    editor.paste()
    gtk.gdk.threads_leave()

pid=os.getpid()
print "Test:kill -SIGUSR1 "+str(pid)
signal(SIGUSR1, sigusr_cb)

window.show_all()
gtk.main()

2009/2/16 Martin Sevior <msevior@gmail.com>:
>
> On Tue, Feb 17, 2009 at 4:16 AM, sum1abi@gmail.com <sum1abi@gmail.com> wrote:
>>
>> On Mon, Feb 16, 2009 at 11:58 AM, Daniel Carvalho <idnael@gmail.com> wrote:
>>>
>>> I was not using trunk... I'm trying it now:
>>>
>>> svn co http://svn.abisource.com/abiword/trunk abiword
>>> svn co http://svn.abisource.com/abiword-extras/trunk abiword-extras
>>> svn co http://svn.abisource.com/abiword-plugins/branches/ABI-2-6-0-STABLE
>>> abiword-plugins
>>
>> The plug-ins are in the abiword module now, so there's no need to
>> checkout abiword-plugins separately (it probably wouldn't work anyway,
>> since you'd be mixing versions).
>>
>
> Hi Daniel,
> The configure command line needed to build abiword and
> pyabiword changed between version 2.6 and TRUNK.
>
> See the wiki at:
>
> http://www.abisource.com/wiki/AbiWord_SDK
>
> Building the python bindings for TRUNK is described in:
>
> http://www.abisource.com/wiki/PyAbiWord
>
> Cheers
>
> Martin
>
Received on Tue Feb 17 15:53:48 2009

This archive was generated by hypermail 2.1.8 : Tue Feb 17 2009 - 15:53:48 CET