Toggle button which enables GtkTextTag



I created TextView with TextBuffer with TextTagTable, filled by my
TextTag's and ToggleButton.

With ToggleButton i want enable "mytag" mode. Button must work as like
in LibreOffice Writer. When i activate "bold mode" printing text will be
bold. And, if i disable "bold mode" printing text will be not tagged.

So, my pseudo-code ToggleButton activate callback:

GtkTextIter start;
GtkTextIter end;

gint cursor_offset;

if(buffer_has_selection)
{
  ... working code
}
else /* Enable my_tag mode here */
{
  if(button_is_active)
  {
   g_object_get(text_buff, "cursor-position", &cursor_offset, NULL);
   gtk_text_buffer_get_iter_at_offset(text_buff, &start, cursor_offset);
   gtk_text_buffer_apply_tag_by_name(text_buff, "mytag", &start, &end);
  }
}

It does not work. Printing text still untagged.
I am on right way?
How to make this button?




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