comparison plugins/timestamp.c @ 7237:5b94ddd51aa1

[gaim-migrate @ 7812] Committing this before I break it... It saves/reads the timestamp plugin's preference. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 12 Oct 2003 04:10:31 +0000
parents 083d1e4a9c78
children 60aa7d4ebfba
comparison
equal deleted inserted replaced
7236:7346c92b01c7 7237:5b94ddd51aa1
1 /* iChat-like timestamps by Sean Egan. 1 /*
2 * Gaim - iChat-like timestamps
2 * 3 *
3 * Modified by: Chris J. Friesen <Darth_Sebulba04@yahoo.com> Jan 05, 2003. 4 * Copyright (C) 2002-2003, Sean Egan
4 * <INSERT GPL HERE> */ 5 * Copyright (C) 2003, Chris J. Friesen <Darth_Sebulba04@yahoo.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23
5 24
6 #include "internal.h" 25 #include "internal.h"
7 26
8 #include "conversation.h" 27 #include "conversation.h"
9 #include "debug.h" 28 #include "debug.h"
29 #include "prefs.h"
10 #include "signals.h" 30 #include "signals.h"
11 31
12 #include "gtkimhtml.h" 32 #include "gtkimhtml.h"
13 #include "gtkplugin.h" 33 #include "gtkplugin.h"
14 #include "gtkutils.h" 34 #include "gtkutils.h"
15 35
16 #define TIMESTAMP_PLUGIN_ID "gtk-timestamp" 36 #define TIMESTAMP_PLUGIN_ID "gtk-timestamp"
17 37
18 /* Set the default to 5 minutes. */ 38 /* Set the default to 5 minutes. */
19 static int timestamp = 5 * 60 * 1000; 39 static int interval = 5 * 60 * 1000;
20 40
21 static GSList *timestamp_timeouts; 41 static GSList *timestamp_timeouts;
22 42
23 static gboolean do_timestamp (gpointer data) 43 static gboolean do_timestamp (gpointer data)
24 { 44 {
40 static void timestamp_new_convo(GaimConversation *conv) 60 static void timestamp_new_convo(GaimConversation *conv)
41 { 61 {
42 do_timestamp(conv); 62 do_timestamp(conv);
43 63
44 timestamp_timeouts = g_slist_append(timestamp_timeouts, 64 timestamp_timeouts = g_slist_append(timestamp_timeouts,
45 GINT_TO_POINTER(g_timeout_add(timestamp, do_timestamp, conv))); 65 GINT_TO_POINTER(g_timeout_add(interval, do_timestamp, conv)));
46 66
47 } 67 }
48 68
49 static void set_timestamp(GtkWidget *button, GtkWidget *spinner) { 69 static void set_timestamp(GtkWidget *button, GtkWidget *spinner) {
50 int tm; 70 int tm;
51 71
52 tm = 0; 72 tm = 0;
53 73
54 tm = CLAMP(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner)), 1, G_MAXINT); 74 tm = CLAMP(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner)), 1, G_MAXINT);
55 gaim_debug(GAIM_DEBUG_MISC, "timestamp", "setting time to %d mins\n", tm); 75 gaim_debug(GAIM_DEBUG_MISC, "timestamp", "setting time to %d mins\n", tm);
56 76
57 tm = tm * 60 * 1000; 77 tm = tm * 60 * 1000;
58 78
59 timestamp = tm; 79 interval = tm;
80 gaim_prefs_set_int("/plugins/gtk/timestamp/interval", interval);
60 } 81 }
61 82
62 static GtkWidget * 83 static GtkWidget *
63 get_config_frame(GaimPlugin *plugin) 84 get_config_frame(GaimPlugin *plugin)
64 { 85 {
79 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); 100 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
80 101
81 label = gtk_label_new(_("Delay")); 102 label = gtk_label_new(_("Delay"));
82 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); 103 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
83 104
84 adj = (GtkAdjustment *)gtk_adjustment_new(timestamp/(60*1000), 1, G_MAXINT, 1, 0, 0); 105 adj = (GtkAdjustment *)gtk_adjustment_new(interval/(60*1000), 1, G_MAXINT, 1, 0, 0);
85 spinner = gtk_spin_button_new(adj, 0, 0); 106 spinner = gtk_spin_button_new(adj, 0, 0);
86 gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0); 107 gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0);
87 108
88 label = gtk_label_new(_("minutes.")); 109 label = gtk_label_new(_("minutes."));
89 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); 110 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
113 } 134 }
114 135
115 gaim_signal_connect(gaim_conversations_get_handle(), 136 gaim_signal_connect(gaim_conversations_get_handle(),
116 "conversation-created", 137 "conversation-created",
117 plugin, GAIM_CALLBACK(timestamp_new_convo), NULL); 138 plugin, GAIM_CALLBACK(timestamp_new_convo), NULL);
139
140 interval = gaim_prefs_get_int("/plugins/gtk/timestamp/interval");
141 gaim_debug(GAIM_DEBUG_ERROR, "XXX", "Got interval from prefs: %d\n", interval);
118 142
119 return TRUE; 143 return TRUE;
120 } 144 }
121 145
122 static gboolean 146 static gboolean
165 }; 189 };
166 190
167 static void 191 static void
168 init_plugin(GaimPlugin *plugin) 192 init_plugin(GaimPlugin *plugin)
169 { 193 {
194 gaim_prefs_add_none("/plugins/gtk/timestamp");
195 gaim_prefs_add_int("/plugins/gtk/timestamp/interval", interval);
170 } 196 }
171 197
172 GAIM_INIT_PLUGIN(timestamp, init_plugin, info) 198 GAIM_INIT_PLUGIN(interval, init_plugin, info)