comparison plugins/timestamp.c @ 4220:0cff8ec38935

[gaim-migrate @ 4464] Chris (darth_sebulba04) writes: "I made it so the timestamp.c iChat plugin can be configured from the gaim configuration menu to set the delay for when each stamp is shown." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 07 Jan 2003 14:21:43 +0000
parents 59751fe608c5
children 5fb47ec9bfe4
comparison
equal deleted inserted replaced
4219:1c57051bf64b 4220:0cff8ec38935
1 /* iChat-like timestamps by Sean Egan. 1 /* iChat-like timestamps by Sean Egan.
2 *
3 * Modified by: Chris J. Friesen <Darth_Sebulba04@yahoo.com> Jan 05, 2003.
2 * <INSERT GPL HERE> */ 4 * <INSERT GPL HERE> */
3 5
4 #include "config.h" 6 #include "config.h"
5 7
6 #ifndef GAIM_PLUGINS 8 #ifndef GAIM_PLUGINS
9 11
10 #include <time.h> 12 #include <time.h>
11 #include "gaim.h" 13 #include "gaim.h"
12 #include "gtkimhtml.h" 14 #include "gtkimhtml.h"
13 15
14 #define TIMESTAMP_DELAY (5 * 60 * 1000) 16 //Set the default to 5 minutes.
17 int timestamp = 5 * 60 * 1000;
15 18
16 GModule *handle; 19 GModule *handle;
17 GSList *timestamp_timeouts; 20 GSList *timestamp_timeouts;
18 21
19 gboolean do_timestamp (gpointer data) 22 gboolean do_timestamp (gpointer data)
37 { 40 {
38 struct conversation *c = find_conversation(name); 41 struct conversation *c = find_conversation(name);
39 do_timestamp(c); 42 do_timestamp(c);
40 43
41 timestamp_timeouts = g_slist_append(timestamp_timeouts, 44 timestamp_timeouts = g_slist_append(timestamp_timeouts,
42 GINT_TO_POINTER(g_timeout_add(TIMESTAMP_DELAY, do_timestamp, c))); 45 GINT_TO_POINTER(g_timeout_add(timestamp, do_timestamp, c)));
43 46
44 } 47 }
48
49 static void set_timestamp(GtkWidget *button, GtkWidget *spinner) {
50 int tm;
51
52 tm = 0;
53
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);
56
57 tm = tm * 60 * 1000;
58
59 timestamp = tm;
60 }
61
62 GtkWidget *gaim_plugin_config_gtk() {
63 GtkWidget *ret;
64 GtkWidget *frame, *label;
65 GtkWidget *vbox, *hbox;
66 GtkAdjustment *adj;
67 GtkWidget *spinner, *button;
68
69 ret = gtk_vbox_new(FALSE, 18);
70 gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
71
72 frame = make_frame(ret, _("iChat Timestamp"));
73 vbox = gtk_vbox_new(FALSE, 5);
74 gtk_container_add(GTK_CONTAINER(frame), vbox);
75
76 hbox = gtk_hbox_new(FALSE, 5);
77 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
78
79 label = gtk_label_new("Delay");
80 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
81
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);
85
86 label = gtk_label_new("minutes.");
87 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
88
89 hbox = gtk_hbox_new(TRUE, 5);
90 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
91
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);
95
96 gtk_widget_show_all(ret);
97 return ret;
98 }
99
100
45 char *gaim_plugin_init(GModule *h) { 101 char *gaim_plugin_init(GModule *h) {
46 GList *cnvs = conversations; 102 GList *cnvs = conversations;
47 struct conversation *c; 103 struct conversation *c;
48 handle = h; 104 handle = h;
49 105
70 struct gaim_plugin_description desc; 126 struct gaim_plugin_description desc;
71 struct gaim_plugin_description *gaim_plugin_desc() { 127 struct gaim_plugin_description *gaim_plugin_desc() {
72 desc.api_version = PLUGIN_API_VERSION; 128 desc.api_version = PLUGIN_API_VERSION;
73 desc.name = g_strdup(_("Timestamp")); 129 desc.name = g_strdup(_("Timestamp"));
74 desc.version = g_strdup(VERSION); 130 desc.version = g_strdup(VERSION);
75 desc.description = g_strdup(_("Adds iChat-style timestamps to conversations every 5 minutes.")); 131 desc.description = g_strdup(_("Adds iChat-style timestamps to conversations every N minutes."));
76 desc.authors = g_strdup("Sean Egan &lt;bj91704@binghamton.edu>"); 132 desc.authors = g_strdup("Sean Egan &lt;bj91704@binghamton.edu>");
77 desc.url = g_strdup(WEBSITE); 133 desc.url = g_strdup(WEBSITE);
78 return &desc; 134 return &desc;
79 } 135 }