TextBuffer and dynamic colors and right clicks



Hello.

I'd like to insert structs in a text buffer and they should be right
click-able. Example:

struct file_t {
  char* short_name;
  char* complete_name;
  .....
};

In the textbuffer file_t->short_name is displayed, but the right-click
popup should operate on 'file_t' as it needs more information than the
displayed text.

With gtk+-1.2.x i used to manually create a conatiner with types

struct word_info_t {
  char* word;     // displayed word in the text buffer
  gint type;      // type of the token (example: TYPE_FILE)
  void* data;     // a pointer to the struct (example: file_t)
  gint start_pos; // offset in the text buffer
  gint length;    // length of the text.
};

A right click then looked up the container and passed the found
word_info_t to the function create_text_popup() which created a popup
menu dependent on word_info_t->type and word_info_t->data

Can i solve this with pure gtk+-2.x?

Another problem is: I'd like to insert words with colors dependent on
the word itself. For example in a chat text buffer different nicknames
should have different colors. Do i have to create a new tag for every
single nickname?

Markus.



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