diff plugins/timestamp.c @ 6485:70d5122bc3ff

[gaim-migrate @ 6999] Removed the old event system and replaced it with a much better signal system. There will most likely be some bugs in this, but it seems to be working for now. Plugins can now generate their own signals, and other plugins can find those plugins and connect to them. This could give plugins a form of IPC. It's also useful for other things. It's rather flexible, except for the damn marshalling, but there's no way around that that I or the glib people can see. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 18 Aug 2003 01:03:43 +0000
parents 8f94cce8faa5
children 42fdf16f1dad
line wrap: on
line diff
--- a/plugins/timestamp.c	Sun Aug 17 17:55:46 2003 +0000
+++ b/plugins/timestamp.c	Mon Aug 18 01:03:43 2003 +0000
@@ -7,6 +7,7 @@
 
 #include "conversation.h"
 #include "debug.h"
+#include "signals.h"
 
 #include "gtkimhtml.h"
 #include "gtkplugin.h"
@@ -19,7 +20,7 @@
 
 static GSList *timestamp_timeouts;
 
-gboolean do_timestamp (gpointer data)
+static gboolean do_timestamp (gpointer data)
 {
 	GaimConversation *c = (GaimConversation *)data;
 	char *buf;
@@ -36,24 +37,23 @@
 	return TRUE;
 }
 
-void timestamp_new_convo(char *name)
+static void timestamp_new_convo(GaimConversation *conv)
 {
-	GaimConversation *c = gaim_find_conversation(name);
-	do_timestamp(c);
+	do_timestamp(conv);
 
 	timestamp_timeouts = g_slist_append(timestamp_timeouts,
-			GINT_TO_POINTER(g_timeout_add(timestamp, do_timestamp, c)));
+			GINT_TO_POINTER(g_timeout_add(timestamp, do_timestamp, conv)));
 
 }
 
 static void set_timestamp(GtkWidget *button, GtkWidget *spinner) {
 	int tm;
-       
+
 	tm = 0;
-	
+
 	tm = CLAMP(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner)), 1, G_MAXINT);
 	gaim_debug(GAIM_DEBUG_MISC, "timestamp", "setting  time to %d mins\n", tm);
-	
+
 	tm = tm * 60 * 1000;
 
 	timestamp = tm;
@@ -67,7 +67,7 @@
 	GtkWidget *vbox, *hbox;
 	GtkAdjustment *adj;
 	GtkWidget *spinner, *button;
-	
+
 	ret = gtk_vbox_new(FALSE, 18);
 	gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
 
@@ -80,21 +80,22 @@
 
 	label = gtk_label_new(_("Delay"));
 	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
-	
+
 	adj = (GtkAdjustment *)gtk_adjustment_new(timestamp/(60*1000), 1, G_MAXINT, 1, 0, 0);
 	spinner = gtk_spin_button_new(adj, 0, 0);
-        gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0);
 
-        label = gtk_label_new(_("minutes."));
-        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
+	label = gtk_label_new(_("minutes."));
+	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
 
-        hbox = gtk_hbox_new(TRUE, 5);
-        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
+	hbox = gtk_hbox_new(TRUE, 5);
+	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
 
-        button = gtk_button_new_with_mnemonic(_("_Apply"));
-        gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
-	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_timestamp), spinner);
-	
+	button = gtk_button_new_with_mnemonic(_("_Apply"));
+	gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5);
+	g_signal_connect(G_OBJECT(button), "clicked",
+					 G_CALLBACK(set_timestamp), spinner);
+
 	gtk_widget_show_all(ret);
 	return ret;
 }
@@ -108,11 +109,12 @@
 	timestamp_timeouts = NULL;
 	for (cnvs = gaim_get_conversations(); cnvs != NULL; cnvs = cnvs->next) {
 		c = cnvs->data;
-		timestamp_new_convo(c->name);
+		timestamp_new_convo(c);
 	}
 
-	gaim_signal_connect(plugin, event_new_conversation,
-						timestamp_new_convo, NULL);
+	gaim_signal_connect(gaim_conversations_get_handle(),
+						"conversation-created",
+						plugin, GAIM_CALLBACK(timestamp_new_convo), NULL);
 
 	return TRUE;
 }
@@ -152,7 +154,7 @@
 	                                                  /**  description    */
 	N_("Adds iChat-style timestamps to conversations every N minutes."),
 	"Sean Egan <bj91704@binghamton.edu>",             /**< author         */
-	GAIM_WEBSITE,                                          /**< homepage       */
+	GAIM_WEBSITE,                                     /**< homepage       */
 
 	plugin_load,                                      /**< load           */
 	plugin_unload,                                    /**< unload         */