plugins/timestamp.c

Mon, 11 Nov 2002 03:18:00 +0000

author
Robert McQueen <robot101@debian.org>
date
Mon, 11 Nov 2002 03:18:00 +0000
changeset 3939
27b0a88f2122
parent 3727
568444e48cb6
child 4113
e86a6c65c2b7
permissions
-rw-r--r--

[gaim-migrate @ 4115]
.todo file spelling fixes.

(22:11:39) Robot101: Fixes bug with multiple consecutive docklet clicks not
correctly showing and hiding the blist

(22:12:26) Robot101: Fixes compile warning in docklet.c the correct way
(without adding a default to the switch on an enum)

(22:12:53) Robot101: Avoids the blist being moved off-screen by the position
remembering code, and does the move before showing it instead of after

(22:13:50) Robot101: Fix evil behaviour with disappearing blists when you
switch desktop or minimise by removing the silly code

(22:14:24) Robot101: Replace it with nice code that raises the blist when you
click the docklet if it's fully obscured

committer: Luke Schierer <lschiere@pidgin.im>

/* 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;
}

mercurial