Tue, 14 Feb 2006 05:43:43 +0000
[gaim-migrate @ 15646]
Always show a vertical scrollbar on conversations imhtmls. This will solve the shrinking conversation window bug. I chose this approach instead of saving the size of the window (as I had previous talked about), as this prevents the contents of the scrollback from rewrapping when the scrollbars appear or disappear. It also just seems to feel like the right thing to do, but maybe that's me being lazy.
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3 | #include "blist.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
4 | #include "conversation.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5 | #include "debug.h" |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
6 | #include "signals.h" |
| 9943 | 7 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
8 | |
| 9583 | 9 | #include "plugin.h" |
| 10 | #include "pluginpref.h" | |
| 11 | #include "prefs.h" | |
| 12 | ||
| 13 | #define STATENOTIFY_PLUGIN_ID "core-statenotify" | |
| 14 | ||
| 5267 | 15 | static void |
| 6695 | 16 | write_status(GaimBuddy *buddy, const char *message) |
| 5267 | 17 | { |
|
5676
d3c2fdaf4821
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5587
diff
changeset
|
18 | GaimConversation *conv; |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
19 | const char *who; |
| 5267 | 20 | char buf[256]; |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
21 | char *escaped; |
| 5267 | 22 | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
10246
diff
changeset
|
23 | conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
24 | buddy->name, buddy->account); |
| 5267 | 25 | |
| 26 | if (conv == NULL) | |
| 27 | return; | |
| 28 | ||
|
9620
fe99fcea5c1c
[gaim-migrate @ 10464]
Christopher O'Brien <siege@pidgin.im>
parents:
9583
diff
changeset
|
29 | who = gaim_buddy_get_alias(buddy); |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
30 | escaped = g_markup_escape_text(who, -1); |
| 5267 | 31 | |
|
10167
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
32 | g_snprintf(buf, sizeof(buf), message, escaped); |
|
3f4db9c54e04
[gaim-migrate @ 11254]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9943
diff
changeset
|
33 | g_free(escaped); |
| 5267 | 34 | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6695
diff
changeset
|
35 | gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 5267 | 36 | } |
| 37 | ||
| 38 | static void | |
| 11935 | 39 | buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, |
| 40 | GaimStatus *status, void *data) | |
| 5267 | 41 | { |
| 11935 | 42 | gboolean available, old_available; |
| 43 | ||
| 44 | available = gaim_status_is_available(status); | |
| 45 | old_available = gaim_status_is_available(old_status); | |
| 46 | ||
| 47 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) { | |
| 48 | if (available && !old_available) | |
| 49 | write_status(buddy, _("%s is no longer away.")); | |
| 50 | else if (!available && old_available) | |
| 51 | write_status(buddy, _("%s has gone away.")); | |
| 52 | } | |
| 5267 | 53 | } |
| 54 | ||
| 55 | static void | |
| 11935 | 56 | buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle, |
| 57 | void *data) | |
| 5267 | 58 | { |
| 11935 | 59 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { |
| 60 | if (idle) { | |
| 61 | write_status(buddy, _("%s has become idle.")); | |
| 62 | } else { | |
| 63 | write_status(buddy, _("%s is no longer idle.")); | |
| 64 | } | |
| 65 | } | |
| 9583 | 66 | } |
| 67 | ||
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
68 | static void |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
69 | buddy_signon_cb(GaimBuddy *buddy, void *data) |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
70 | { |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
71 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
72 | write_status(buddy, _("%s has signed on.")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
73 | } |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
74 | |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
75 | static void |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
76 | buddy_signoff_cb(GaimBuddy *buddy, void *data) |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
77 | { |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
78 | if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_signon")) |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
79 | write_status(buddy, _("%s has signed off.")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
80 | } |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
81 | |
| 9583 | 82 | static GaimPluginPrefFrame * |
| 83 | get_plugin_pref_frame(GaimPlugin *plugin) | |
| 84 | { | |
| 85 | GaimPluginPrefFrame *frame; | |
| 86 | GaimPluginPref *ppref; | |
| 87 | ||
| 88 | frame = gaim_plugin_pref_frame_new(); | |
| 89 | ||
|
9648
34a457599c78
[gaim-migrate @ 10496]
Mark Doliner <markdoliner@pidgin.im>
parents:
9620
diff
changeset
|
90 | ppref = gaim_plugin_pref_new_with_label(_("Notify When")); |
| 9583 | 91 | gaim_plugin_pref_frame_add(frame, ppref); |
| 92 | ||
|
9648
34a457599c78
[gaim-migrate @ 10496]
Mark Doliner <markdoliner@pidgin.im>
parents:
9620
diff
changeset
|
93 | ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", _("Buddy Goes _Away")); |
| 9583 | 94 | gaim_plugin_pref_frame_add(frame, ppref); |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
95 | |
|
9648
34a457599c78
[gaim-migrate @ 10496]
Mark Doliner <markdoliner@pidgin.im>
parents:
9620
diff
changeset
|
96 | ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", _("Buddy Goes _Idle")); |
| 9583 | 97 | gaim_plugin_pref_frame_add(frame, ppref); |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10167
diff
changeset
|
98 | |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
99 | ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_signon", _("Buddy _Signs On/Off")); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
100 | gaim_plugin_pref_frame_add(frame, ppref); |
|
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
101 | |
| 9583 | 102 | return frame; |
| 5267 | 103 | } |
| 104 | ||
| 105 | static gboolean | |
| 106 | plugin_load(GaimPlugin *plugin) | |
| 107 | { | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
108 | void *blist_handle = gaim_blist_get_handle(); |
|
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
109 | |
| 11935 | 110 | gaim_signal_connect(blist_handle, "buddy-status-changed", plugin, |
| 111 | GAIM_CALLBACK(buddy_status_changed_cb), NULL); | |
| 112 | gaim_signal_connect(blist_handle, "buddy-idle-changed", plugin, | |
| 113 | GAIM_CALLBACK(buddy_idle_changed_cb), NULL); | |
| 114 | gaim_signal_connect(blist_handle, "buddy-signed-on", plugin, | |
| 115 | GAIM_CALLBACK(buddy_signon_cb), NULL); | |
| 116 | gaim_signal_connect(blist_handle, "buddy-signed-off", plugin, | |
| 117 | GAIM_CALLBACK(buddy_signoff_cb), NULL); | |
| 5267 | 118 | |
| 119 | return TRUE; | |
| 120 | } | |
| 121 | ||
| 9583 | 122 | static GaimPluginUiInfo prefs_info = |
| 123 | { | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
11935
diff
changeset
|
124 | get_plugin_pref_frame, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
11935
diff
changeset
|
125 | 0, /* page_num (Reserved) */ |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
11935
diff
changeset
|
126 | NULL /* frame (Reserved) */ |
| 9583 | 127 | }; |
| 128 | ||
| 5267 | 129 | static GaimPluginInfo info = |
| 130 | { | |
| 9943 | 131 | GAIM_PLUGIN_MAGIC, |
| 132 | GAIM_MAJOR_VERSION, | |
| 133 | GAIM_MINOR_VERSION, | |
| 5267 | 134 | GAIM_PLUGIN_STANDARD, /**< type */ |
| 135 | NULL, /**< ui_requirement */ | |
| 136 | 0, /**< flags */ | |
| 137 | NULL, /**< dependencies */ | |
| 138 | GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 139 | ||
| 9583 | 140 | STATENOTIFY_PLUGIN_ID, /**< id */ |
| 5267 | 141 | N_("Buddy State Notification"), /**< name */ |
| 142 | VERSION, /**< version */ | |
| 143 | /** summary */ | |
| 144 | N_("Notifies in a conversation window when a buddy goes or returns from " | |
| 145 | "away or idle."), | |
| 146 | /** description */ | |
| 147 | N_("Notifies in a conversation window when a buddy goes or returns from " | |
| 148 | "away or idle."), | |
| 149 | "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
|
6485
3c7ba18e32f1
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6441
diff
changeset
|
150 | GAIM_WEBSITE, /**< homepage */ |
| 5267 | 151 | |
| 152 | plugin_load, /**< load */ | |
| 153 | NULL, /**< unload */ | |
| 154 | NULL, /**< destroy */ | |
| 155 | ||
| 156 | NULL, /**< ui_info */ | |
| 8993 | 157 | NULL, /**< extra_info */ |
| 9583 | 158 | &prefs_info, /**< prefs_info */ |
| 8993 | 159 | NULL |
| 5267 | 160 | }; |
| 161 | ||
| 162 | static void | |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
163 | init_plugin(GaimPlugin *plugin) |
| 5267 | 164 | { |
| 9583 | 165 | gaim_prefs_add_none("/plugins/core/statenotify"); |
| 166 | gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE); | |
| 167 | gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE); | |
|
11901
34394921fe76
[gaim-migrate @ 14192]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11338
diff
changeset
|
168 | gaim_prefs_add_bool("/plugins/core/statenotify/notify_signon", TRUE); |
| 5267 | 169 | } |
| 170 | ||
| 6063 | 171 | GAIM_INIT_PLUGIN(statenotify, init_plugin, info) |