Re: Fwd: Re: PROP_TYPE_LIST declaration [lrclause cs uiuc edu]
- From: <ashalper cox net>
- To: dia-list gnome org
- Subject: Re: Fwd: Re: PROP_TYPE_LIST declaration [lrclause cs uiuc edu]
- Date: Fri, 11 Apr 2003 13:24:52 -0400
Note that if your list is static, you may want to use PROP_TYPE_ENUM. I
think it's prettier and easier to deal with (though I may end up changing
the PROP_TYPE_LIST widget (or even removing it -- there's not much
difference between the two, all PROP_TYPE_LIST seems to have going for it
is that it uses GPtrArray)).
It's dynamic. Functionally quite similar to attributes in the UML (although I know the UML objects still
probably don't make use of StdProp yet). Should I avoid PROP_TYPE_LIST if you're considering removing it?
You need to declare the index within your structure as well:
GPtrArray *column_list; /* The list of items */
int column_list_index; /* The currently selected item */
To declare a ListProp in the PropOffset array, you give it the offset of
both the list and the index:
{ "column_list", PROP_TYPE_LIST, offsetof(Independent, column_list),
offsetof(Independent, column_list_index) },
And there are no name and flags fields? Looking at chronoline.c and what you have above, the maximalist in
me wants to do something like:
{ "column_list", PROP_TYPE_LIST, PROP_FLAG_VISIBLE,
N_("Column list"), offsetof(Independent, column_list),
N_("Column index"), offsetof(Independent, column_list_index), NULL },
Also, the quoted example leads to a GCC warning about the column_list_index parameter in offsetof(), which
worries me:
independent.c:156: warning: initialization makes pointer from integer without a cast
Thanks,
Andy
--- Begin Message ---
- From: Lars Clausen <lrclause cs uiuc edu>
- To: dia-list gnome org
- Subject: Re: PROP_TYPE_LIST declaration
- Date: Thu, 10 Apr 2003 21:19:39 -0500
On Thu, 10 Apr 2003, ashalper cox net wrote:
I was wondering if someone could help me out with a PROP_TYPE_LIST
declaration (I couldn't find any examples in the CVS code).
There aren't any, in fact.
Note that if your list is static, you may want to use PROP_TYPE_ENUM. I
think it's prettier and easier to deal with (though I may end up changing
the PROP_TYPE_LIST widget (or even removing it -- there's not much
difference between the two, all PROP_TYPE_LIST seems to have going for it
is that it uses GPtrArray)).
I think I've got my PropDescription struct correct, but I need help on
the offsets and the declaration in my object struct. The PROP_TYPE_LIST
macro in properties.h is:
#define PROP_TYPE_LIST "list" /* ListProperty */
/* (offset is a GPtrArray of (const gchar *). offset2 is a gint, index of the
active item, -1 if none active.) */
My object struct looks something like:
typedef struct _Independent {
Element element;
GPtrArray *column_list; /* the ListProperty? */
.
.
.
} Independent;
but I'm missing the index, and I'm not at all sure how to declare the
PropOffset array correctly.
You need to declare the index within your structure as well:
GPtrArray *column_list; /* The list of items */
int column_list_index; /* The currently selected item */
To declare a ListProp in the PropOffset array, you give it the offset of
both the list and the index:
{ "column_list", PROP_TYPE_LIST, offsetof(Independent, column_list),
offsetof(Independent, column_list_index) },
Remember to create the GPtrArray when you create the array, and set the
index to something reasonable (-1 for no initial selection). You may also
need to do a deep copy of the list when the object gets copied.
-Lars
--
Lars Clausen (http://shasta.cs.uiuc.edu/~lrclause)| HÃrdgrim of Numenor
"I do not agree with a word that you say, but I |----------------------------
will defend to the death your right to say it." | Where are we going, and
--Evelyn Beatrice Hall paraphrasing Voltaire | what's with the handbasket?
_______________________________________________
Dia-list mailing list
Dia-list gnome org
http://mail.gnome.org/mailman/listinfo/dia-list
FAQ at http://www.lysator.liu.se/~alla/dia/faq.html
Main page at http://www.lysator.liu.se/~alla/dia
--- End Message ---
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]