Sun, 17 Oct 2004 23:55:49 +0000
[gaim-migrate @ 11141]
Two things:
a. Added Enter as a gtk_binding to GtkIMHtml. This fixes everything.
Input methods now work. The "Enter sends" and "Ctrl-Enter sends" preferences
were removed and defaulted to yes and no respectively, BUT, in a very super-cool
turn of events, you can now add your own bindings to .gtkrc to make WHATEVER
YOU WANT send. Awesome. Someone should use g_signal_accumulator_true_handled
or something to make profiles and away messages able to insert newlines.
b. Removed "Use multi-colored screennames in chats," defaulted to yes, and
wrote a nifty algorithm to automatically adjust the colors to accomodate the
background (see http://gaim.sf.net/sean/porn-chat.png). People should play
around and tweak it a bit. The algorithm takes into consideration the
luminosity of the current background and the base hue to use for the screenname
in generating the new colors. Note that it does this while maintaining the hues.
Someone should optimize this so it skips over the floating point arithmatic when
the background color is white.
| 3598 | 1 | /* Puts last 4k of log in new conversations a la Everybuddy (and then |
| 2 | * stolen by Trillian "Pro") */ | |
| 3 | ||
| 9791 | 4 | #include "internal.h" |
| 5 | #include "gtkgaim.h" | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
6 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
7 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
8 | #include "debug.h" |
| 7433 | 9 | #include "log.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
10 | #include "prefs.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
11 | #include "signals.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
12 | #include "util.h" |
| 9943 | 13 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
14 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
15 | #include "gtkconv.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
16 | #include "gtkimhtml.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
17 | #include "gtkplugin.h" |
|
4202
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4113
diff
changeset
|
18 | |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
19 | #define HISTORY_PLUGIN_ID "gtk-history" |
| 3598 | 20 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
21 | #define HISTORY_SIZE (4 * 1024) |
| 3598 | 22 | |
| 8913 | 23 | static gboolean _scroll_imhtml_to_end(gpointer data) |
| 24 | { | |
| 25 | GtkIMHtml *imhtml = data; | |
| 26 | gtk_imhtml_scroll_to_end(GTK_IMHTML(imhtml)); | |
| 27 | g_object_unref(G_OBJECT(imhtml)); | |
| 28 | return FALSE; | |
| 29 | } | |
| 30 | ||
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
31 | static void historize(GaimConversation *c) |
| 3598 | 32 | { |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5599
diff
changeset
|
33 | GaimGtkConversation *gtkconv; |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
34 | GaimConversationType convtype; |
| 7433 | 35 | char *history = NULL; |
| 7440 | 36 | guint flags; |
| 3602 | 37 | GtkIMHtmlOptions options = GTK_IMHTML_NO_COLOURS; |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
38 | GList *logs = NULL; |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
39 | |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
40 | convtype = gaim_conversation_get_type(c); |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
41 | if (convtype == GAIM_CONV_IM) |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
42 | logs = gaim_log_get_logs(GAIM_LOG_IM, |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
43 | gaim_conversation_get_name(c), gaim_conversation_get_account(c)); |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
44 | else if (convtype == GAIM_CONV_CHAT) |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
45 | logs = gaim_log_get_logs(GAIM_LOG_CHAT, |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
46 | gaim_conversation_get_name(c), gaim_conversation_get_account(c)); |
| 7440 | 47 | |
| 7433 | 48 | if (!logs) |
| 3598 | 49 | return; |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
50 | |
| 7433 | 51 | history = gaim_log_read((GaimLog*)logs->data, &flags); |
| 52 | gtkconv = GAIM_GTK_CONVERSATION(c); | |
| 53 | if (flags & GAIM_LOG_READ_NO_NEWLINE) | |
| 3602 | 54 | options |= GTK_IMHTML_NO_NEWLINE; |
| 7433 | 55 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), history, options); |
| 56 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<hr>", options); | |
| 8913 | 57 | g_object_ref(G_OBJECT(gtkconv->imhtml)); |
| 58 | g_idle_add(_scroll_imhtml_to_end, gtkconv->imhtml); | |
| 7433 | 59 | g_free(history); |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8749
diff
changeset
|
60 | |
| 7535 | 61 | while (logs) { |
| 7533 | 62 | GaimLog *log = logs->data; |
| 7535 | 63 | GList *logs2; |
| 7685 | 64 | gaim_log_free(log); |
| 7535 | 65 | logs2 = logs->next; |
| 66 | g_list_free_1(logs); | |
| 67 | logs = logs2; | |
| 7533 | 68 | } |
| 3598 | 69 | } |
| 70 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
71 | static gboolean |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
72 | plugin_load(GaimPlugin *plugin) |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
73 | { |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
74 | gaim_signal_connect(gaim_conversations_get_handle(), |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
75 | "conversation-created", |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
76 | plugin, GAIM_CALLBACK(historize), NULL); |
| 3598 | 77 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
78 | return TRUE; |
| 3598 | 79 | } |
| 80 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
81 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
82 | { |
| 9943 | 83 | GAIM_PLUGIN_MAGIC, |
| 84 | GAIM_MAJOR_VERSION, | |
| 85 | GAIM_MINOR_VERSION, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
86 | GAIM_PLUGIN_STANDARD, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
87 | GAIM_GTK_PLUGIN_TYPE, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
88 | 0, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
89 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
90 | GAIM_PRIORITY_DEFAULT, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
91 | HISTORY_PLUGIN_ID, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
92 | N_("History"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
93 | VERSION, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
94 | N_("Shows recently logged conversations in new conversations."), |
| 7666 | 95 | N_("When a new conversation is opened this plugin will insert the last conversation into the current conversation."), |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
96 | "Sean Egan <bj91704@binghamton.edu>", |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6063
diff
changeset
|
97 | GAIM_WEBSITE, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
98 | plugin_load, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
99 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
100 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
101 | NULL, |
| 8993 | 102 | NULL, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
103 | NULL |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
104 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
105 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
106 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
107 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
108 | { |
| 3598 | 109 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5114
diff
changeset
|
110 | |
| 6063 | 111 | GAIM_INIT_PLUGIN(history, init_plugin, info) |