Using "editable" tags in non-editable GtkTextView

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

 



  In an application I'm making I would like to have a GtkTextView with
most of its text as non-editable (most of the text is generated
automatically by other means than the user writing it).
  However, there are certain places here and there where the text should
be editable by the user.

  The GtkTextTag seems perfect for this purpose: I can set the GtkTextView
as non-editable and add proper GtkTextTags with the "editable" property
set in the places I want the user to be able to edit.

  However, there's one big problem with this: The start tag has right
gravity and the end tag has left gravity.
  This means that if the user edits the beginning or the end of the
editable part, his text will end up as non-editable (because if he writes
a character eg. at the beginning of the editable part, the start tag will
end up at the right of this character and the written character will thus
end up outside the tags and thus become non-editable).
  It also means that if the user completely deletes the text in the
editable part, he will be completely unable to add any text there anymore
(due to the gravity of the tags, if there's no text between them, it's
impossible to add any text there).

  I can't find any way of defining the gravity of GtkTextTags (as you can
do with GtkTextMarks).
  Any ideas?
  Perhaps what I want to achieve could be better done in a completely
different way?
  The text is very dynamic so having fixed-sized field widgets is not
an option. Also it should be possible for the user to write text which
extends to several lines (ie. he should be able to type newlines as well)
in the editable parts. The editable parts are not independent lines in
the text but parts of existing non-editable lines.

  Doing the opposite, that is, marking all non-editable text with
non-editable tags and leaving the editable parts untagged is not a
viable solution. Due to how I generate the text it's very difficult
to join uneditable parts so that they all end up inside the same pair
of tags (if I wouldn't join them, the user would be able to add text
between the tags in places I don't want to allow it). Also, doing it
this way would allow the user to add text at the very beginning and end
of the text buffer, which is not what I want.

  Btw, a second question: How do you set the default text properties
(eg. font) of a GtkTextView?
  (I would want the non-editable parts to have a certain style, but I can't
seem to find any way of setting this.)

							- Juha Nieminen

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux