comparison plugins/statenotify.c @ 9583:91c9e060111b

[gaim-migrate @ 10426] " This patch provides a configuration page for the Buddy State Notification plugin, allowing you to select whether you want to be notified of buddy Away, Idle or both. The motivation for this is that clients such as Trillian report idle times of 1 minute, leading to lots of idle notifications, when only aways are really of any interest." --Alan Ford Date: 2004-06-06 00:03 Sender: deryni9 Logged In: YES user_id=516184 This should probably be made to use the new plugin pref stuff so that it doesn't add a dependency on gtk for no real reason. Date: 2004-06-27 13:24 Sender: ajf101 Logged In: YES user_id=1028264 Yes, you're quite right. I've got around to updating it now to use this new stuff, see the updated patch. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sat, 24 Jul 2004 15:14:43 +0000
parents 294ae6548d4e
children c001be3c330e
comparison
equal deleted inserted replaced
9582:fec83fb0b6a9 9583:91c9e060111b
2 2
3 #include "blist.h" 3 #include "blist.h"
4 #include "conversation.h" 4 #include "conversation.h"
5 #include "debug.h" 5 #include "debug.h"
6 #include "signals.h" 6 #include "signals.h"
7
8 #include "plugin.h"
9 #include "pluginpref.h"
10 #include "prefs.h"
11
12 #define STATENOTIFY_PLUGIN_ID "core-statenotify"
7 13
8 static void 14 static void
9 write_status(GaimBuddy *buddy, const char *message) 15 write_status(GaimBuddy *buddy, const char *message)
10 { 16 {
11 GaimConversation *conv; 17 GaimConversation *conv;
25 } 31 }
26 32
27 static void 33 static void
28 buddy_away_cb(GaimBuddy *buddy, void *data) 34 buddy_away_cb(GaimBuddy *buddy, void *data)
29 { 35 {
30 write_status(buddy, _("%s has gone away.")); 36 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away"))
37 write_status(buddy, _("%s has gone away."));
31 } 38 }
32 39
33 static void 40 static void
34 buddy_unaway_cb(GaimBuddy *buddy, void *data) 41 buddy_unaway_cb(GaimBuddy *buddy, void *data)
35 { 42 {
36 write_status(buddy, _("%s is no longer away.")); 43 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away"))
44 write_status(buddy, _("%s is no longer away."));
37 } 45 }
38 46
39 static void 47 static void
40 buddy_idle_cb(GaimBuddy *buddy, void *data) 48 buddy_idle_cb(GaimBuddy *buddy, void *data)
41 { 49 {
42 write_status(buddy, _("%s has become idle.")); 50 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle"))
51 write_status(buddy, _("%s has become idle."));
43 } 52 }
44 53
45 static void 54 static void
46 buddy_unidle_cb(GaimBuddy *buddy, void *data) 55 buddy_unidle_cb(GaimBuddy *buddy, void *data)
47 { 56 {
48 write_status(buddy, _("%s is no longer idle.")); 57 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle"))
58 write_status(buddy, _("%s is no longer idle."));
59 }
60
61 static GaimPluginPrefFrame *
62 get_plugin_pref_frame(GaimPlugin *plugin)
63 {
64 GaimPluginPrefFrame *frame;
65 GaimPluginPref *ppref;
66
67 frame = gaim_plugin_pref_frame_new();
68
69 ppref = gaim_plugin_pref_new_with_label("Notify When");
70 gaim_plugin_pref_frame_add(frame, ppref);
71
72 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", "Buddy Goes _Away");
73 gaim_plugin_pref_frame_add(frame, ppref);
74
75 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", "Buddy Goes _Idle");
76 gaim_plugin_pref_frame_add(frame, ppref);
77
78 return frame;
49 } 79 }
50 80
51 static gboolean 81 static gboolean
52 plugin_load(GaimPlugin *plugin) 82 plugin_load(GaimPlugin *plugin)
53 { 83 {
63 plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); 93 plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL);
64 94
65 return TRUE; 95 return TRUE;
66 } 96 }
67 97
98 static GaimPluginUiInfo prefs_info =
99 {
100 get_plugin_pref_frame
101 };
102
68 static GaimPluginInfo info = 103 static GaimPluginInfo info =
69 { 104 {
70 GAIM_PLUGIN_API_VERSION, /**< api_version */ 105 GAIM_PLUGIN_API_VERSION, /**< api_version */
71 GAIM_PLUGIN_STANDARD, /**< type */ 106 GAIM_PLUGIN_STANDARD, /**< type */
72 NULL, /**< ui_requirement */ 107 NULL, /**< ui_requirement */
73 0, /**< flags */ 108 0, /**< flags */
74 NULL, /**< dependencies */ 109 NULL, /**< dependencies */
75 GAIM_PRIORITY_DEFAULT, /**< priority */ 110 GAIM_PRIORITY_DEFAULT, /**< priority */
76 111
77 NULL, /**< id */ 112 STATENOTIFY_PLUGIN_ID, /**< id */
78 N_("Buddy State Notification"), /**< name */ 113 N_("Buddy State Notification"), /**< name */
79 VERSION, /**< version */ 114 VERSION, /**< version */
80 /** summary */ 115 /** summary */
81 N_("Notifies in a conversation window when a buddy goes or returns from " 116 N_("Notifies in a conversation window when a buddy goes or returns from "
82 "away or idle."), 117 "away or idle."),
90 NULL, /**< unload */ 125 NULL, /**< unload */
91 NULL, /**< destroy */ 126 NULL, /**< destroy */
92 127
93 NULL, /**< ui_info */ 128 NULL, /**< ui_info */
94 NULL, /**< extra_info */ 129 NULL, /**< extra_info */
95 NULL, 130 &prefs_info, /**< prefs_info */
96 NULL 131 NULL
97 }; 132 };
98 133
99 static void 134 static void
100 init_plugin(GaimPlugin *plugin) 135 init_plugin(GaimPlugin *plugin)
101 { 136 {
137 gaim_prefs_add_none("/plugins/core/statenotify");
138 gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE);
139 gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE);
102 } 140 }
103 141
104 GAIM_INIT_PLUGIN(statenotify, init_plugin, info) 142 GAIM_INIT_PLUGIN(statenotify, init_plugin, info)