コード例 #1
0
void win_chat_append(const gchar *id, const gchar *msg, gboolean me, const gchar *str_time)
{
	Chat *c;
	User *u;
	gchar *m = NULL;
	gchar *name = NULL;
	gchar *tim;
	time_t prev_time;

	c = win_chat_get(id, TRUE, TRUE);
	g_assert(c != NULL);

	if (str_time == NULL) {
		tim = (gchar *)get_time(NULL);
	} else {
		tim = (gchar *)str_time;
	}
	
	/* XXX: dodawanie usera do listy jako brak autoryzacji */
	u = user_get(id);
	if (u == NULL) {
		name = (gchar *)id;
	} else {
		name = u->name;
	}

	prev_time = u->last_chat;

	/* Zapisz czas ostatniej wypowiedzi */
	time(&u->last_chat);

	/* Sprawdz czy tekst nie pojawil sie po dlugiej przerwie. Jesli tak, traktujemy
	   to jako rozpoczecie nowej rozmowy */

	if (prev_time == 0 || u->last_chat - prev_time >= 60 * 60) {	/* Godzina, XXX: #define */
		arch_add(me ? ARCH_TYPE_CHAT_START_BY_ME : ARCH_TYPE_CHAT_START, u->last_chat, u, NULL);
	}

	/* Dodaj do archiwum */
	arch_add(me ? ARCH_TYPE_CHAT_FROM_ME : ARCH_TYPE_CHAT_TO_ME, u->last_chat, u, msg);

	m = markup_text(msg);

	if (me) {
		gtk_html_stream_printf(c->stream, append_fmt, my_bg, tim, pref_chat_my_name, pref_tlen_id, m);
	} else {
		gtk_html_stream_printf(c->stream, append_fmt, their_bg, tim, name, id, m);
	}

	/* scroll */
	gtk_html_flush(c->output);
	gtk_html_command(c->output, "scroll-eod");
	
	if (c->need_blinking == TRUE && c->blink_state == BlinkOff) {
		g_timeout_add(750, window_icon_blink, c);
	}

	g_free(m);
}
コード例 #2
0
ファイル: markup.c プロジェクト: lcp/glib_fun
int
main()
{
	char *input = "&howcan<I>Know"This'istrue";
	char *output;

//	output = g_markup_escape_text (input, -1);
	output = markup_text (input);
	printf("%s\n", output);

	return 0;
}
コード例 #3
0
ファイル: e-buffer-tagger.c プロジェクト: UIKit0/evolution
static void
buffer_cursor_position (GtkTextBuffer *buffer,
                        gpointer user_data)
{
	guint32 state;

	state = get_state (buffer);
	if (state & E_BUFFER_TAGGER_STATE_INSDEL) {
		state = (state & (~E_BUFFER_TAGGER_STATE_INSDEL)) | E_BUFFER_TAGGER_STATE_CHANGED;
	} else {
		if (state & E_BUFFER_TAGGER_STATE_CHANGED) {
			markup_text (buffer);
		}

		state = state & (~ (E_BUFFER_TAGGER_STATE_CHANGED | E_BUFFER_TAGGER_STATE_INSDEL));
	}

	set_state (buffer, state);
}
コード例 #4
0
ファイル: e-buffer-tagger.c プロジェクト: UIKit0/evolution
void
e_buffer_tagger_update_tags (GtkTextView *textview)
{
	GtkTextBuffer *buffer;
	GtkTextTagTable *tag_table;
	GtkTextTag *tag;

	g_return_if_fail (textview != NULL);
	g_return_if_fail (GTK_IS_TEXT_VIEW (textview));

	buffer = gtk_text_view_get_buffer (textview);
	tag_table = gtk_text_buffer_get_tag_table (buffer);
	tag = gtk_text_tag_table_lookup (tag_table, E_BUFFER_TAGGER_LINK_TAG);

	/* if tag is not there, then it is not connected, thus claim */
	g_return_if_fail (tag != NULL);

	update_state (buffer, E_BUFFER_TAGGER_STATE_INSDEL | E_BUFFER_TAGGER_STATE_CHANGED, FALSE);

	markup_text (buffer);
}