Mercurial > pidgin.yaz
annotate plugins/timestamp.c @ 4359:5fb47ec9bfe4
[gaim-migrate @ 4625]
Wow, okay, where to begin with this one ;)
I rewrote the whole conversation backend. It is now core/UI split. Here's
how it works..
Every conversation is represented by a gaim_conversation structure. This
branches out into gaim_im and gaim_chat structures. Every conversation
lives in (well, normally, but it doesn't have to) a gaim_window structure.
This is a _CORE_ representation of a window. There can be multiple
gaim_window structures around.
The gaim_window and gaim_conversation structures have UI-specific operation
structures associated with them. At the moment, the only UI is GTK+, and
this will be for some time. Don't start thinking you can write a QT UI now.
It's just not going to happen.
Everything that is done on a conversation is done through the core API.
This API does core processing and then calls the UI operations for the
rendering and anything else.
Now, what does this give the user?
- Multiple windows.
- Multiple tabs per window.
- Draggable tabs.
- Send As menu is moved to the menubar.
- Menubar for chats.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
For developers:
- Fully documented API
- Core/UI split
- Variable checking and mostly sane handling of incorrect variables.
- Logical structure to conversations, both core and UI.
- Some very cool stuff in the future, like replacing, say, IRC chat windows
with an X-Chat interface, or whatever.
- Later on, customizable window/conversation positioning.
- Oh yeah, and the beginning of a stock icon system.
Now, there are things that aren't there yet. You will see tabs even if you
have them turned off. This will be fixed in time. Also, the preferences
will change to work with the new structure. I'm starting school in 2 days,
so it may not be done immediately, but hopefully in the next week.
Enjoy!
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Mon, 20 Jan 2003 09:10:23 +0000 |
parents | 0cff8ec38935 |
children | 2c985a9e994c |
rev | line source |
---|---|
3598 | 1 /* iChat-like timestamps by Sean Egan. |
4220 | 2 * |
3 * Modified by: Chris J. Friesen <Darth_Sebulba04@yahoo.com> Jan 05, 2003. | |
3598 | 4 * <INSERT GPL HERE> */ |
5 | |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
6 #include "config.h" |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
7 |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
8 #ifndef GAIM_PLUGINS |
3598 | 9 #define GAIM_PLUGINS |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
10 #endif |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4201
diff
changeset
|
11 |
3598 | 12 #include <time.h> |
13 #include "gaim.h" | |
14 #include "gtkimhtml.h" | |
15 | |
4220 | 16 //Set the default to 5 minutes. |
17 int timestamp = 5 * 60 * 1000; | |
3598 | 18 |
19 GModule *handle; | |
20 GSList *timestamp_timeouts; | |
21 | |
4201
511c2b63caa4
[gaim-migrate @ 4432]
Christian Hammond <chipx86@chipx86.com>
parents:
4168
diff
changeset
|
22 gboolean do_timestamp (gpointer data) |
3598 | 23 { |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4220
diff
changeset
|
24 struct gaim_conversation *c = (struct gaim_conversation *)data; |
3598 | 25 char *buf; |
26 char mdate[6]; | |
27 time_t tim = time(NULL); | |
28 | |
29 if (!g_list_find(conversations, c)) | |
30 return FALSE; | |
31 | |
32 strftime(mdate, sizeof(mdate), "%H:%M", localtime(&tim)); | |
33 buf = g_strdup_printf(" %s", mdate); | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4220
diff
changeset
|
34 gaim_conversation_write(c, NULL, buf, WFLAG_NOLOG, tim, -1); |
3598 | 35 g_free(buf); |
36 return TRUE; | |
37 } | |
38 | |
39 void timestamp_new_convo(char *name) | |
40 { | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4220
diff
changeset
|
41 struct gaim_conversation *c = gaim_find_conversation(name); |
3598 | 42 do_timestamp(c); |
4168 | 43 |
3727 | 44 timestamp_timeouts = g_slist_append(timestamp_timeouts, |
4220 | 45 GINT_TO_POINTER(g_timeout_add(timestamp, do_timestamp, c))); |
3598 | 46 |
47 } | |
4220 | 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 | |
3598 | 101 char *gaim_plugin_init(GModule *h) { |
102 GList *cnvs = conversations; | |
4359
5fb47ec9bfe4
[gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents:
4220
diff
changeset
|
103 struct gaim_conversation *c; |
3598 | 104 handle = h; |
105 | |
106 while (cnvs) { | |
107 c = cnvs->data; | |
108 timestamp_new_convo(c->name); | |
109 cnvs = cnvs->next; | |
110 } | |
111 gaim_signal_connect(handle, event_new_conversation, timestamp_new_convo, NULL); | |
112 | |
113 return NULL; | |
114 } | |
115 | |
116 void gaim_plugin_remove() { | |
117 GSList *to; | |
118 to = timestamp_timeouts; | |
119 while (to) { | |
4168 | 120 g_source_remove(GPOINTER_TO_INT(to->data)); |
3598 | 121 to = to->next; |
122 } | |
123 g_slist_free(timestamp_timeouts); | |
124 } | |
125 | |
126 struct gaim_plugin_description desc; | |
127 struct gaim_plugin_description *gaim_plugin_desc() { | |
128 desc.api_version = PLUGIN_API_VERSION; | |
4113 | 129 desc.name = g_strdup(_("Timestamp")); |
3598 | 130 desc.version = g_strdup(VERSION); |
4220 | 131 desc.description = g_strdup(_("Adds iChat-style timestamps to conversations every N minutes.")); |
3598 | 132 desc.authors = g_strdup("Sean Egan <bj91704@binghamton.edu>"); |
133 desc.url = g_strdup(WEBSITE); | |
134 return &desc; | |
135 } |