annotate plugins/history.c @ 11016:6417b2f5de4e

[gaim-migrate @ 12885] Wherever possible, allow users to act on objects and data directly, rather than through dialogs or explicit commands. For example, it is more intuitive to drag a circle object around in a diagram rather than selecting a "Move" command from a menu while the circle is selected. Simlarly, in an email application, allow the user to attach files by dragging them from the file manager and dropping them onto the message composition window if they wish. -- GNOME HIG This allows direct manipulation of buddy aliases and group names, by moving the features from dialogs to GtkTreeView's inline editing. I think this is a great change, but it seems like the type of thing that might stir up controversy. If so, take it to the mailing list for discussion. If not, I'll go ahead and perfect this sometime later. -s. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 21 Jun 2005 04:40:34 +0000
parents c3b709d6d1e7
children 5290afac047c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* Puts last 4k of log in new conversations a la Everybuddy (and then
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * stolen by Trillian "Pro") */
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 8993
diff changeset
4 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 8993
diff changeset
5 #include "gtkgaim.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
6
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
7 #include "conversation.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
8 #include "debug.h"
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
9 #include "log.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
10 #include "prefs.h"
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
11 #include "signals.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
12 #include "util.h"
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9791
diff changeset
13 #include "version.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
14
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
15 #include "gtkconv.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
16 #include "gtkimhtml.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5676
diff changeset
17 #include "gtkplugin.h"
4202
59751fe608c5 [gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents: 4113
diff changeset
18
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6063
diff changeset
19 #define HISTORY_PLUGIN_ID "gtk-history"
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
21 #define HISTORY_SIZE (4 * 1024)
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
23 static gboolean _scroll_imhtml_to_end(gpointer data)
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
24 {
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
25 GtkIMHtml *imhtml = data;
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
26 gtk_imhtml_scroll_to_end(GTK_IMHTML(imhtml));
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
27 g_object_unref(G_OBJECT(imhtml));
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
28 return FALSE;
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
29 }
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
30
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
31 static void historize(GaimConversation *c)
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 {
5676
dae79aefac8d [gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents: 5599
diff changeset
33 GaimGtkConversation *gtkconv;
8898
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
34 GaimConversationType convtype;
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
35 char *history = NULL;
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7433
diff changeset
36 guint flags;
3602
a9cf9903bd74 [gaim-migrate @ 3713]
Luke Schierer <lschiere@pidgin.im>
parents: 3598
diff changeset
37 GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS;
8898
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
38 GList *logs = NULL;
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
39
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
40 convtype = gaim_conversation_get_type(c);
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
41 if (convtype == GAIM_CONV_IM)
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
42 logs = gaim_log_get_logs(GAIM_LOG_IM,
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
43 gaim_conversation_get_name(c), gaim_conversation_get_account(c));
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
44 else if (convtype == GAIM_CONV_CHAT)
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
45 logs = gaim_log_get_logs(GAIM_LOG_CHAT,
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
46 gaim_conversation_get_name(c), gaim_conversation_get_account(c));
7440
8c0527c91a92 [gaim-migrate @ 8045]
Nathan Walp <nwalp@pidgin.im>
parents: 7433
diff changeset
47
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
48 if (!logs)
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 return;
8898
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
50
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
51 history = gaim_log_read((GaimLog*)logs->data, &flags);
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
52 gtkconv = GAIM_GTK_CONVERSATION(c);
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
53 if (flags & GAIM_LOG_READ_NO_NEWLINE)
3602
a9cf9903bd74 [gaim-migrate @ 3713]
Luke Schierer <lschiere@pidgin.im>
parents: 3598
diff changeset
54 options |= GTK_IMHTML_NO_NEWLINE;
10764
c3b709d6d1e7 [gaim-migrate @ 12369]
Sean Egan <seanegan@gmail.com>
parents: 10763
diff changeset
55 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<br>", options);
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
56 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options);
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
57 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options);
8913
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
58 g_object_ref(G_OBJECT(gtkconv->imhtml));
d729311f6352 [gaim-migrate @ 9683]
Luke Schierer <lschiere@pidgin.im>
parents: 8898
diff changeset
59 g_idle_add(_scroll_imhtml_to_end, gtkconv->imhtml);
7433
6fdc55dd636a [gaim-migrate @ 8038]
Sean Egan <seanegan@gmail.com>
parents: 7261
diff changeset
60 g_free(history);
8898
de87e510ff9a [gaim-migrate @ 9667]
Mark Doliner <mark@kingant.net>
parents: 8749
diff changeset
61
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
62 while (logs) {
7533
66d6f5c4a14a [gaim-migrate @ 8146]
Sean Egan <seanegan@gmail.com>
parents: 7440
diff changeset
63 GaimLog *log = logs->data;
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
64 GList *logs2;
7685
9e122b8f564f [gaim-migrate @ 8329]
Ethan Blanton <elb@pidgin.im>
parents: 7666
diff changeset
65 gaim_log_free(log);
7535
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
66 logs2 = logs->next;
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
67 g_list_free_1(logs);
f771759739c1 [gaim-migrate @ 8148]
Sean Egan <seanegan@gmail.com>
parents: 7533
diff changeset
68 logs = logs2;
7533
66d6f5c4a14a [gaim-migrate @ 8146]
Sean Egan <seanegan@gmail.com>
parents: 7440
diff changeset
69 }
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 }
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
72 static gboolean
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
73 plugin_load(GaimPlugin *plugin)
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
74 {
6485
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
75 gaim_signal_connect(gaim_conversations_get_handle(),
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
76 "conversation-created",
70d5122bc3ff [gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
77 plugin, GAIM_CALLBACK(historize), NULL);
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
79 return TRUE;
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 }
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
82 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
83 {
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9791
diff changeset
84 GAIM_PLUGIN_MAGIC,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9791
diff changeset
85 GAIM_MAJOR_VERSION,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9791
diff changeset
86 GAIM_MINOR_VERSION,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
87 GAIM_PLUGIN_STANDARD,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
88 GAIM_GTK_PLUGIN_TYPE,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
89 0,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
90 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
91 GAIM_PRIORITY_DEFAULT,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
92 HISTORY_PLUGIN_ID,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
93 N_("History"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
94 VERSION,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
95 N_("Shows recently logged conversations in new conversations."),
7666
25488bd0d461 [gaim-migrate @ 8310]
Luke Schierer <lschiere@pidgin.im>
parents: 7535
diff changeset
96 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
97 "Sean Egan <bj91704@binghamton.edu>",
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6063
diff changeset
98 GAIM_WEBSITE,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
99 plugin_load,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
100 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
101 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
102 NULL,
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8913
diff changeset
103 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
104 NULL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
105 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
106
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
107 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5873
diff changeset
108 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
109 {
3598
c6f92ece3097 [gaim-migrate @ 3700]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 }
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5114
diff changeset
111
6063
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 5920
diff changeset
112 GAIM_INIT_PLUGIN(history, init_plugin, info)