예제 #1
0
static void
theme_boxes_append_message (EmpathyChatTextView *view,
			    EmpathyMessage      *message)
{
	EmpathyContact *sender;

	theme_boxes_maybe_append_header (EMPATHY_THEME_BOXES (view), message);

	sender = empathy_message_get_sender (message);
	if (empathy_message_get_tptype (message) ==
	    TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) {
		gchar *body;

		body = g_strdup_printf (" * %s %s",
					empathy_contact_get_alias (sender),
					empathy_message_get_body (message));
		empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view),
						    body,
						    EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION);
	} else {
		empathy_chat_text_view_append_body (EMPATHY_CHAT_TEXT_VIEW (view),
						    empathy_message_get_body (message),
						    EMPATHY_CHAT_TEXT_VIEW_TAG_BODY);
	}
}
예제 #2
0
static void
theme_irc_append_message (EmpathyChatTextView *view,
			  EmpathyMessage      *message)
{
	GtkTextBuffer *buffer;
	const gchar   *name;
	const gchar   *nick_tag;
	GtkTextIter    iter;
	gchar         *tmp;
	EmpathyContact *contact;

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));

	contact = empathy_message_get_sender (message);
	name = empathy_contact_get_logged_alias (contact);

	if (empathy_message_get_tptype (message) == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) {
		tmp = g_strdup_printf (" * %s %s",
				       empathy_contact_get_logged_alias (contact),
				       empathy_message_get_body (message));
		empathy_chat_text_view_append_body (view, tmp,
						    EMPATHY_CHAT_TEXT_VIEW_TAG_ACTION);
		g_free (tmp);
		return;
	}

	if (empathy_contact_is_user (contact)) {
		nick_tag = EMPATHY_THEME_IRC_TAG_NICK_SELF;
	} else {
		if (empathy_message_should_highlight (message)) {
			nick_tag = EMPATHY_THEME_IRC_TAG_NICK_HIGHLIGHT;
		} else {
			nick_tag = EMPATHY_THEME_IRC_TAG_NICK_OTHER;
		}
	}

	gtk_text_buffer_get_end_iter (buffer, &iter);

	/* The nickname. */
	tmp = g_strdup_printf ("%s: ", name);
	gtk_text_buffer_insert_with_tags_by_name (buffer,
						  &iter,
						  tmp,
						  -1,
						  "cut",
						  nick_tag,
						  NULL);
	g_free (tmp);

	/* The text body. */
	empathy_chat_text_view_append_body (view,
					    empathy_message_get_body (message),
					    EMPATHY_CHAT_TEXT_VIEW_TAG_BODY);
}