Re: gtk-mailund-980720-0.patch



>>>>> "D" == Didimo Emilio Grimaldo Tunon <emilio_tunon@nl.compuware.com> writes:

 >> Small extension of gtk-mailund-980713-0.patch:
 >> ============================================== This patch adds
 >> user data to text properties in gtktext, thus making it possible
 >> to associate abitrary data to sections of the text. This can be
 >> usefull when e.g. associating links from parts of the text to
 >> other parts or other files (html links, comments which can be
 >> hidden/show with double-clicks etc.).

 D>    Very nice feature indeed!

I find it useful.

I'm not sure this is the right way of doing this, though.  I
implemented this because i *needed* it, so it's really a very simple
and low-level way of associating data to text intervals.
Here you need to take care of all handeling of the data yourself, with
no abstraction really.

Perhaps it would be better if this worked somewhat like associating
data to objects. So instead of parsing a pointer to the text, and
back, like e.g. (made up):

typedef struct _TextData {
  enum {_link, _hidden} kind;
  struct {
    char *link;
    char *hidden;
  } val;
} TextData;

 .
 .
 .

TextData *td = g_new (TextData,1);
td->kind = _link;
td->link = "http://www.foo.bar";
gtk_text_set_property (text, 0, 10, NULL, NULL, NULL, td);

 .
 .
 .

TextData *td = gtk_text_get_property_data (text->point.property->data);
switch (td->kind) {
  case _link:
    ...
  break;
  case _hidden:
    ...
  break;
}

you could simply write stuff like

gtk_text_add_prop_data (text, from, to, "link", link);
link = gtk_text_get_prop_data (text, from, to, "link");

etc.

I think this nicer interface would be much more useful in the long
run, and I will look into it later, if there is a general need for it,
and if someone else doesn't beat me to it :)

/mailund



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]