Re: Storing GObject in GtkListStore

2006-08-03 Thread Tomasz Jankowski
Thank you for help! :)

I decided to read more about GtkTree* stuff in gtk and now I understand it
much beter!

thx again!
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Storing GObject in GtkListStore

2006-08-02 Thread Tomasz Jankowski
Hi!

Generally it isn't a problem, I'm only nosy :P I'd like to know if there is
some other (more recommended) way to store, for example GObject in
GtkListStore/GtkTreeStore. So far I do it, by creating column with type
G_TYPE_INT and storing there pointer to object.

-- 
Pozdrawiam!
Tom
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Storing GObject in GtkListStore

2006-08-02 Thread Lance Dillon
As far as I can tell you can, as per this example:


http://developer.gnome.org/doc/API/2.0/gtk/GtkListStore.html#gtk-list-store-new

Notice how they set a column as a GDK_TYPE_PIXBUF, which is derived from 
G_OBJECT.  This implies that you can store anything derived from G_OBJECT in a 
column designated as such.  Of course, you may not be able to display that 
column unless you have a CellRenderer capable of grabbing some useful 
information from your object.

- Original Message 
From: Tomasz Jankowski [EMAIL PROTECTED]
To: gtk-app-devel-list@gnome.org
Sent: Wednesday, August 2, 2006 9:51:08 AM
Subject: Storing GObject in GtkListStore

Hi!

Generally it isn't a problem, I'm only nosy :P I'd like to know if there is
some other (more recommended) way to store, for example GObject in
GtkListStore/GtkTreeStore. So far I do it, by creating column with type
G_TYPE_INT and storing there pointer to object.

-- 
Pozdrawiam!
Tom
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Storing GObject in GtkListStore

2006-08-02 Thread Philip Van Hoof
On Wed, 2006-08-02 at 15:51 +0200, Tomasz Jankowski wrote:
 Hi!

Hey Tomasz!

 Generally it isn't a problem, I'm only nosy :P I'd like to know if there is
 some other (more recommended) way to store, for example GObject in
 GtkListStore/GtkTreeStore. So far I do it, by creating column with type
 G_TYPE_INT and storing there pointer to object.

Use G_TYPE_OBJECT if you want it to work behind for example a language
binding.

Checkout tinymail for this.

https://svn.tinymail.org/svn/tinymail/trunk/libtinymail-test/tinymail-python-test.py

What you see here is a GObject (actually a GTypeInterface) of the type
TnyMsgHeaderIface and in this case an implementation called TnyMsgHeader
being put in the store model, which is of type TnyMsgHeaderListModel.
This list-model type implements GtkTreeModel and TnyListIface.

I assume you at some point want language bindings to work, else you
perhaps shouldn't develop GObject/C but rather pick a higher programming
language like C#, D or Python, Ruby, whatevery (but that's a personal
opinion, remove this last line .. hehe)

def on_headerstree_selected (treeselection, msgview) :
model, iter = treeselection.get_selected ()
if iter:
header = model.get_value (iter, 
tinymail.uigtk.MSG_HEADER_LIST_MODEL_INSTANCE_COLUMN)
if header:
folder = header.get_folder ()
msg = folder.get_message (header)
msgview.set_msg (msg)

If you don't use G_TYPE_OBJECT, you would get a PyGTK error/warning here.

You can see the INSTANCE_COLUMN in tny-msg-header-list-model.c

https://svn.tinymail.org/svn/tinymail/trunk/libtinymailui-gtk/tny-msg-header-list-model.c

static GType
tny_msg_header_list_model_get_column_type (GtkTreeModel *self, gint column)
{
...
case TNY_MSG_HEADER_LIST_MODEL_INSTANCE_COLUMN:
retval = G_TYPE_OBJECT;
break;
...
}

It's a custom tree model. But you can also do this with a GtkListStore 
implementation of GtkTreeModel.

In tinymail you can see such a GtkTreeModel at 

https://svn.tinymail.org/svn/tinymail/trunk/libtinymailui-gtk/tny-attach-list-model.c

and

https://svn.tinymail.org/svn/tinymail/trunk/libtinymailui-gtk/tny-account-tree-model.c

For example look at this:

static void
tny_account_tree_model_instance_init (GTypeInstance *instance, gpointer g_class)
{
GtkTreeStore *store = (GtkTreeStore*) instance;
TnyAccountTreeModel *me = (TnyAccountTreeModel*) instance;
static GType types[] = { G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INT, 
G_TYPE_OBJECT };

me-iterator_lock = g_mutex_new ();

gtk_tree_store_set_column_types (store, 
TNY_ACCOUNT_TREE_MODEL_N_COLUMNS, types);

return;
}





-- 
Philip Van Hoof, software developer at x-tend 
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
work: vanhoof at x-tend dot be 
http://www.pvanhoof.be - http://www.x-tend.be

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Storing GObject in GtkListStore

2006-08-02 Thread Rick Jones
Tomasz Jankowski wrote:
 Hi!
 
 Generally it isn't a problem, I'm only nosy :P I'd like to know if there is
 some other (more recommended) way to store, for example GObject in
 GtkListStore/GtkTreeStore. So far I do it, by creating column with type
 G_TYPE_INT and storing there pointer to object.

Others will have far more informed asnwers than I but I thought I'd ask 
- wouldn't you use some other fundamental type if you were storing a 
pointer?  I'm thinking when one goes to 64-bit or has code snippets 
copied into a 64-bit application that mixing int and pointer would be 
bad news.

rick jones

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list