Mercurial > pidgin.yaz
annotate plugins/history.c @ 9157:bd1ea0a717d7
[gaim-migrate @ 9941]
make deryni's removed placement option a plugin
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 01 Jun 2004 01:55:55 +0000 |
parents | 294ae6548d4e |
children | 4a15962c344a |
rev | line source |
---|---|
3598 | 1 /* Puts last 4k of log in new conversations a la Everybuddy (and then |
2 * stolen by Trillian "Pro") */ | |
3 | |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
4 #include "gtkinternal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
6 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
7 #include "debug.h" |
7433 | 8 #include "log.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
9 #include "prefs.h" |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
10 #include "signals.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
11 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
12 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
13 #include "gtkconv.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
14 #include "gtkimhtml.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
15 #include "gtkplugin.h" |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
16 |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
17 #define HISTORY_PLUGIN_ID "gtk-history" |
3598 | 18 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
19 #define HISTORY_SIZE (4 * 1024) |
3598 | 20 |
8913 | 21 static gboolean _scroll_imhtml_to_end(gpointer data) |
22 { | |
23 GtkIMHtml *imhtml = data; | |
24 gtk_imhtml_scroll_to_end(GTK_IMHTML(imhtml)); | |
25 g_object_unref(G_OBJECT(imhtml)); | |
26 return FALSE; | |
27 } | |
28 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
29 static void historize(GaimConversation *c) |
3598 | 30 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5599
diff
changeset
|
31 GaimGtkConversation *gtkconv; |
8898 | 32 GaimConversationType convtype; |
7433 | 33 char *history = NULL; |
7440 | 34 guint flags; |
3602 | 35 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
8898 | 36 GList *logs = NULL; |
37 | |
38 convtype = gaim_conversation_get_type(c); | |
39 if (convtype == GAIM_CONV_IM) | |
40 logs = gaim_log_get_logs(GAIM_LOG_IM, | |
41 gaim_conversation_get_name(c), gaim_conversation_get_account(c)); | |
42 else if (convtype == GAIM_CONV_CHAT) | |
43 logs = gaim_log_get_logs(GAIM_LOG_CHAT, | |
44 gaim_conversation_get_name(c), gaim_conversation_get_account(c)); | |
7440 | 45 |
7433 | 46 if (!logs) |
3598 | 47 return; |
8898 | 48 |
7433 | 49 history = gaim_log_read((GaimLog*)logs->data, &flags); |
50 gtkconv = GAIM_GTK_CONVERSATION(c); | |
51 if (flags & GAIM_LOG_READ_NO_NEWLINE) | |
3602 | 52 options |= GTK_IMHTML_NO_NEWLINE; |
7433 | 53 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options); |
54 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options); | |
8913 | 55 g_object_ref(G_OBJECT(gtkconv->imhtml)); |
56 g_idle_add(_scroll_imhtml_to_end, gtkconv->imhtml); | |
7433 | 57 g_free(history); |
8898 | 58 |
7535 | 59 while (logs) { |
7533 | 60 GaimLog *log = logs->data; |
7535 | 61 GList *logs2; |
7685 | 62 gaim_log_free(log); |
7535 | 63 logs2 = logs->next; |
64 g_list_free_1(logs); | |
65 logs = logs2; | |
7533 | 66 } |
3598 | 67 } |
68 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
69 static gboolean |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
70 plugin_load(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
71 { |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
72 gaim_signal_connect(gaim_conversations_get_handle(), |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
73 "conversation-created", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
74 plugin, GAIM_CALLBACK(historize), NULL); |
3598 | 75 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
76 return TRUE; |
3598 | 77 } |
78 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
79 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
80 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8729
diff
changeset
|
81 GAIM_PLUGIN_API_VERSION, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
82 GAIM_PLUGIN_STANDARD, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
83 GAIM_GTK_PLUGIN_TYPE, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
84 0, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
85 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
86 GAIM_PRIORITY_DEFAULT, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
87 HISTORY_PLUGIN_ID, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
88 N_("History"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
89 VERSION, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
90 N_("Shows recently logged conversations in new conversations."), |
7666 | 91 N_("When a new conversation is opened this plugin will insert the last conversation into the current conversation."), |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
92 "Sean Egan <bj91704@binghamton.edu>", |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
93 GAIM_WEBSITE, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
94 plugin_load, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
95 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
96 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
97 NULL, |
8993 | 98 NULL, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
99 NULL |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
100 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
101 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
102 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
103 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
104 { |
3598 | 105 } |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
106 |
6063 | 107 GAIM_INIT_PLUGIN(history, init_plugin, info) |