RES: gtktreeview problem.
- From: Ubirajara Marques da Cruz <biracruz cemig com br>
- To: John Coppens <john jcoppens com>, "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: RES: gtktreeview problem.
- Date: Mon, 23 Mar 2015 20:36:41 +0000
John,
I did my app studing example found with wikbook did for Vikram Ambrose follow link:
http://en.wikibooks.org/wiki/GTK%2B_By_Example/Tree_View/DnD
I did test with this examples change it into many configuretions like liststores, treestores and combination
of boths. I am programming into C pure not in Python. But I can understand the similarity between languages.
My problem is a little bit difficult.
When I was studing these examples I saw vikram plan this app with initial conditions that he knew and into
this example gtktreemodel won´t change(can not be exchanged or column change). But in my app the program will
read a data base file get a query, work with this query to fulfill a treestore and a list store too. The
treestore will store a structure (like building material) and liststore will store each material individual.
When I wanna build some house (for example) I need to pick each material in a liststore with dnd and copy to
a place into another gtktreeview with treestore I will start my construction place first the basement, put
walls, put ceiling and others. Into gtk program I will give me a list of material inside a liststore and a
treestore that will receive a copy of this materials but showing the parent relationship. After a built a
new structure I will save it into data base file again. Many other things will be done with this structure
like time to build, price and others.
When I start my searchs into internet I found I few material about this conditions. Most part of material
explains basic dnd app with inicial conditions and gtktreeview/gtktreemodel and stores aren´t change in run
time execution.
After long time with gtk docs I understood one thing. Gtk drag and drop isn´t a simple copy/move method! It´s
to professionals. Into my case I am a beginner! But to become a professional I need to start like a beginner
than let´s go.
To explain my doubt detailed I need you see into link above example of dnd with to gtktreeview to understand
it.
There, Vikram plains source and dest into main function like I read in your link. Creates a public var with
targets that dnd will can change between source and destiny widget. Creates a struct that will receive data
copied from gtktreemodel. He connects two signals into this example drag_get and drag_receive.
In drag_get it collects selected line , read data of each column and stores this data into a temp var struct
that he creates at begin of this app. And finaly it inform to gtk_selection_data_set this temporary var
struct to fulfill selection of source widget.
In drag_receive it copy data from selectiondata struct to a temporary var struct and populates other
tree/liststore with this datas. This sequence of procedures is easy to understand.
I followed this procedure but to become this function general to my case I need to work with a generic var
which can receive any kind of data and that can be created in run time execution. Gtk, Gdk and Glib offer
many type of generic variables and structures that hold data. I chose gvalue and gvaluearray to hold this
data. Function gtk_tree_model_get_value holds a GValues that is stored into treestore or listore. Another
benefit to work gvalue is low level definition of var type It is near of glib runtime and you can become
interprocess very easy to exchange data to another apps out of gtk.
The problem is into drag-get signal after I fulfill gvaluearray with data. After this I need to attach (copy
pointer) to selectiondata structure and I did like I sent into first email. But when I take it into
drag-received signal. Struct is copied but data not. I have a gvaluearray that show the quantity of data but
when I try to access data they are not there.
I don´t know what is wrong. All times I used memcpy function it works fine but in this case it´s not working.
I don´t know if this problem is in drag-get or in drag-received handler. I search in internet about
Problems to copy structures with variable array like members of a structure in runtime. And there are few
doc´s too and this could be one solution. But I never did some code with this functionality. Another solution
is a more experience programmer analise my code and discover what I´m doing wrong.
I will appreciate a lot your help.
Thank you.
Ubirajara.
-----Mensagem original-----
De: gtk-app-devel-list [mailto:gtk-app-devel-list-bounces gnome org] Em nome de John Coppens
Enviada em: segunda-feira, 23 de março de 2015 15:06
Para: gtk-app-devel-list gnome org
Assunto: Re: gtktreeview problem.
On Mon, 23 Mar 2015 12:50:28 +0000
Ubirajara Marques da Cruz <biracruz cemig com br> wrote:
Into ON_DRAG_RECEIVED signal when I copy selection data with memcpy I have a surprise. Gtk selection has
the same structure but data is empty. And only one data is copied and it is wrong. It is a genum.
Maybe this tutorial I wrote a few years ago might be of help. It copies one cell of a TreeView to a list, but
the mechanism is the same. There are quite a few steps involved, however...
http://jcoppens.com/soft/howto/pygtk_dnd/index.en.php
(The code is in Python, but all the steps are also needed in C or C++)
John
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
As informações contidas nesta mensagem e nos arquivos anexados sao para uso exclusivo do destinatario aqui
indicado e podem conter assuntos comerciais, de propriedade intelectual ou outras informações confidenciais,
protegidas pelas leis aplicaveis.
Caso não seja o destinatario correto, por favor, notifique o remetente.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]