view plugins/timestamp.c @ 4145:b658b502b096

[gaim-migrate @ 4363] gtk1.2 code in anything except the buddy list window is a bug. this patch from David Brigada (jsi): " This patch changes the mechanism in which Gaim changes the colors on tabs for typing notification, new message notification, etc.. The previous mechanism was causing the font to change (possible mix of gtk1.2 and gtk2.0 code). Instead of loading the label's preferences with gtk_widget_get_modifier_style(), changing the color (with a -> edit), and then saving the label's preferences with gtk_widget_modify_style(), it changes the color with gtk_widget_modify_fg(). This fixes the font problem on my computer. The GTK 2.0 API docs seem to suggest the use of gtk_widget_modify_fg() over gtk_widget_modify_style() when necessary." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 26 Dec 2002 15:40:23 +0000
parents 74d27aa5b686
children ebfb80bbe1ed
line wrap: on
line source

/* iChat-like timestamps by Sean Egan.
 * <INSERT GPL HERE> */

#define GAIM_PLUGINS
#include <time.h>
#include "gaim.h"
#include "gtkimhtml.h"

#define TIMESTAMP_DELAY (5 * 60 * 1000)

GModule *handle;
GSList *timestamp_timeouts;

gboolean do_timestamp (struct conversation *c)
{
	char *buf;
	char mdate[6];
	time_t tim = time(NULL);
	
	if (!g_list_find(conversations, c))
		return FALSE;

	strftime(mdate, sizeof(mdate), "%H:%M", localtime(&tim));
	buf = g_strdup_printf("            %s", mdate);
	write_to_conv(c, buf, WFLAG_NOLOG, NULL, tim, -1);
	g_free(buf);
	return TRUE;
}

void timestamp_new_convo(char *name)
{
	struct conversation *c = find_conversation(name);
	do_timestamp(c);
	
	timestamp_timeouts = g_slist_append(timestamp_timeouts,
			GINT_TO_POINTER(gtk_timeout_add(TIMESTAMP_DELAY,
				(GtkFunction)do_timestamp, c)));

}
char *gaim_plugin_init(GModule *h) {
	GList *cnvs = conversations;
	struct conversation *c;
	handle = h;

	while (cnvs) {
		c = cnvs->data;
		timestamp_new_convo(c->name);
		cnvs = cnvs->next;
	}
	gaim_signal_connect(handle, event_new_conversation, timestamp_new_convo, NULL);

	return NULL;
}

void gaim_plugin_remove() {
	GSList *to;
	to = timestamp_timeouts;
	while (to) {
		gtk_timeout_remove(GPOINTER_TO_INT(to->data));
		to = to->next;
	}
	g_slist_free(timestamp_timeouts);
}

struct gaim_plugin_description desc; 
struct gaim_plugin_description *gaim_plugin_desc() {
	desc.api_version = PLUGIN_API_VERSION;
	desc.name = g_strdup(_("Timestamp"));
	desc.version = g_strdup(VERSION);
	desc.description = g_strdup(_("Adds iChat-style timestamps to conversations every 5 minutes."));
	desc.authors = g_strdup("Sean Egan &lt;bj91704@binghamton.edu>");
	desc.url = g_strdup(WEBSITE);
	return &desc;
}