Re: Fwd: Re: PROP_TYPE_LIST declaration [lrclause cs uiuc edu]
- From: Lars Clausen <lrclause cs uiuc edu>
- To: dia-list gnome org
- Subject: Re: Fwd: Re: PROP_TYPE_LIST declaration [lrclause cs uiuc edu]
- Date: Fri, 11 Apr 2003 12:35:44 -0500
On Fri, 11 Apr 2003, ashalper cox net wrote:
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).
They don't.
Should I avoid PROP_TYPE_LIST if you're considering removing it?
Actually, I'd like to extend it to something more like the UML attributes.
There's little point to a dynamic list where the user can't do anything
more than select one item. That's just enum with a different container
type. But if we add ways to add new lines, it may be more interesting.
Now to make something that has all the extra widgets of UML would take a
more complex grouping style prop, something in between PROP_TYPE_FRAME and
PROP_TYPE_LIST. Once we have that, we could convert UML totally.
If the items in the list are always collected by the program, not to be
inserted directly by the user, you could just use an enum. Otherwise, I
think it'd better to extend list to be modifiable by the user.
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
You're thinking about the PropDescription array. Remember, there are two
arrays to fill out (Cyrille, why is that? Could they be combined?):
static PropDescription independent_props[] = {
...
{ "column_list", PROP_TYPE_LIST, PROP_FLAG_VISIBLE,
N_("Column List"), NULL, NULL },
...
};
static PropOffset independent_offsets[] = {
...
{ "column_list", PROP_TYPE_LIST,
offsetof(Independent, column_list),
offsetof(Independent, column_list_index) },
...
};
The N_() part is the name shown in the properties dialog. There's only one
name needed for the property. The two offsets point at the two places
where the data lives in your structure.
-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?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]