How pidgin text bold mode enabled?

Vlasov Vitaly vnigtha at gmail.com
Mon Nov 19 08:22:49 EST 2012


Hello list!

  I want ask you about how pidgin is working with "rich text" in
conversation window. My question is not related to development
pidgin/libpurple directly, but regard to in indirectly. I want know how
to set "text modes" (example: bold mode) in conversation window. In
"bold mode"(if enabled) next typed symbol will be bold.

  I was looking for this functionality in the source code and found the
two function's that are responsible for it.
First for enable bold mode:
static void imhtml_toggle_bold(GtkIMHtml *imhtml)
{
	GtkTextIter start, end;

	imhtml->edit.bold = !imhtml->edit.bold;
suggestions, comments, additions, examples, etc. please let me know
	if (!imhtml_get_iter_bounds(imhtml, &start, &end))
		return;

	if (imhtml->edit.bold)
		gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start,
&end);
	else
		gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD",
&start, &end);
}
And second for getting bound's of selection:
static gboolean
imhtml_get_iter_bounds(GtkIMHtml *imhtml, GtkTextIter *start,
GtkTextIter *end)
{
	if (imhtml->wbfo) {
		gtk_text_buffer_get_bounds(imhtml->text_buffer, start, end);
		return TRUE;
	} else if (imhtml->editable) {
		if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, start,
end)) {
			GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer);
			gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, start, mark);
			*end = *start;
		}
		return TRUE;
	}

	return FALSE;
}

  So i wrote simple test program that is repeating pidgin behaviour.
Source code: http://pastebin.com/CeHtGQ3L
My test program didn't work and i don't know why. Bold mode is not
enabled as in pidgin.

  If you have any suggestions, comments, additions, examples, etc.
please let me know. May be developers of this feature still there and
reading this message. Please feedback me.

  I was on gtk+ mailing list's and they don't know how to realize that
"simple" feature.




More information about the Devel mailing list