1 /* iChat-like timestamps by Sean Egan.
3 * Modified by: Chris J. Friesen <Darth_Sebulba04@yahoo.com> Jan 05, 2003.
14 #include "gtkimhtml.h"
16 //Set the default to 5 minutes.
17 int timestamp
= 5 * 60 * 1000;
20 GSList
*timestamp_timeouts
;
22 gboolean
do_timestamp (gpointer data
)
24 struct gaim_conversation
*c
= (struct gaim_conversation
*)data
;
27 time_t tim
= time(NULL
);
29 if (!g_list_find(conversations
, c
))
32 strftime(mdate
, sizeof(mdate
), "%H:%M", localtime(&tim
));
33 buf
= g_strdup_printf(" %s", mdate
);
34 gaim_conversation_write(c
, NULL
, buf
, WFLAG_NOLOG
, tim
, -1);
39 void timestamp_new_convo(char *name
)
41 struct gaim_conversation
*c
= gaim_find_conversation(name
);
44 timestamp_timeouts
= g_slist_append(timestamp_timeouts
,
45 GINT_TO_POINTER(g_timeout_add(timestamp
, do_timestamp
, c
)));
49 static void set_timestamp(GtkWidget
*button
, GtkWidget
*spinner
) {
54 tm
= CLAMP(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner
)), 1, G_MAXINT
);
55 debug_printf("setting time to %d mins\n", tm
);
62 GtkWidget
*gaim_plugin_config_gtk() {
64 GtkWidget
*frame
, *label
;
65 GtkWidget
*vbox
, *hbox
;
67 GtkWidget
*spinner
, *button
;
69 ret
= gtk_vbox_new(FALSE
, 18);
70 gtk_container_set_border_width (GTK_CONTAINER (ret
), 12);
72 frame
= make_frame(ret
, _("iChat Timestamp"));
73 vbox
= gtk_vbox_new(FALSE
, 5);
74 gtk_container_add(GTK_CONTAINER(frame
), vbox
);
76 hbox
= gtk_hbox_new(FALSE
, 5);
77 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 5);
79 label
= gtk_label_new("Delay");
80 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 5);
82 adj
= (GtkAdjustment
*)gtk_adjustment_new(timestamp
/(60*1000), 1, G_MAXINT
, 1, 0, 0);
83 spinner
= gtk_spin_button_new(adj
, 0, 0);
84 gtk_box_pack_start(GTK_BOX(hbox
), spinner
, TRUE
, TRUE
, 0);
86 label
= gtk_label_new("minutes.");
87 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 5);
89 hbox
= gtk_hbox_new(TRUE
, 5);
90 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 5);
92 button
= gtk_button_new_with_mnemonic(_("_Apply"));
93 gtk_box_pack_start(GTK_BOX(hbox
), button
, FALSE
, FALSE
, 5);
94 g_signal_connect(GTK_OBJECT(button
), "clicked", G_CALLBACK(set_timestamp
), spinner
);
96 gtk_widget_show_all(ret
);
101 char *gaim_plugin_init(GModule
*h
) {
102 GList
*cnvs
= conversations
;
103 struct gaim_conversation
*c
;
108 timestamp_new_convo(c
->name
);
111 gaim_signal_connect(handle
, event_new_conversation
, timestamp_new_convo
, NULL
);
116 void gaim_plugin_remove() {
118 to
= timestamp_timeouts
;
120 g_source_remove(GPOINTER_TO_INT(to
->data
));
123 g_slist_free(timestamp_timeouts
);
126 struct gaim_plugin_description desc
;
127 struct gaim_plugin_description
*gaim_plugin_desc() {
128 desc
.api_version
= PLUGIN_API_VERSION
;
129 desc
.name
= g_strdup(_("Timestamp"));
130 desc
.version
= g_strdup(VERSION
);
131 desc
.description
= g_strdup(_("Adds iChat-style timestamps to conversations every N minutes."));
132 desc
.authors
= g_strdup("Sean Egan <bj91704@binghamton.edu>");
133 desc
.url
= g_strdup(WEBSITE
);