changeset 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 fec83fb0b6a9
children fe35f55ee984
files plugins/statenotify.c
diffstat 1 files changed, 44 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/statenotify.c	Fri Jul 23 19:56:27 2004 +0000
+++ b/plugins/statenotify.c	Sat Jul 24 15:14:43 2004 +0000
@@ -5,6 +5,12 @@
 #include "debug.h"
 #include "signals.h"
 
+#include "plugin.h"
+#include "pluginpref.h"
+#include "prefs.h"
+
+#define STATENOTIFY_PLUGIN_ID "core-statenotify"
+
 static void
 write_status(GaimBuddy *buddy, const char *message)
 {
@@ -27,25 +33,49 @@
 static void
 buddy_away_cb(GaimBuddy *buddy, void *data)
 {
-	write_status(buddy, _("%s has gone away."));
+	if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away"))
+		write_status(buddy, _("%s has gone away."));
 }
 
 static void
 buddy_unaway_cb(GaimBuddy *buddy, void *data)
 {
-	write_status(buddy, _("%s is no longer away."));
+	if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away"))
+		write_status(buddy, _("%s is no longer away."));
 }
 
 static void
 buddy_idle_cb(GaimBuddy *buddy, void *data)
 {
-	write_status(buddy, _("%s has become idle."));
+	if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle"))
+		write_status(buddy, _("%s has become idle."));
 }
 
 static void
 buddy_unidle_cb(GaimBuddy *buddy, void *data)
 {
-	write_status(buddy, _("%s is no longer idle."));
+	if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle"))
+		write_status(buddy, _("%s is no longer idle."));
+}
+
+static GaimPluginPrefFrame *
+get_plugin_pref_frame(GaimPlugin *plugin)
+{
+	GaimPluginPrefFrame *frame;
+	GaimPluginPref *ppref;
+
+	frame = gaim_plugin_pref_frame_new();
+
+	ppref = gaim_plugin_pref_new_with_label("Notify When");
+	gaim_plugin_pref_frame_add(frame, ppref);
+
+	ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_away", "Buddy Goes _Away");
+	gaim_plugin_pref_frame_add(frame, ppref);
+	
+	ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/core/statenotify/notify_idle", "Buddy Goes _Idle");
+	gaim_plugin_pref_frame_add(frame, ppref);
+	
+	return frame;
 }
 
 static gboolean
@@ -65,6 +95,11 @@
 	return TRUE;
 }
 
+static GaimPluginUiInfo prefs_info =
+{
+	get_plugin_pref_frame
+};
+
 static GaimPluginInfo info =
 {
 	GAIM_PLUGIN_API_VERSION,                          /**< api_version    */
@@ -74,7 +109,7 @@
 	NULL,                                             /**< dependencies   */
 	GAIM_PRIORITY_DEFAULT,                            /**< priority       */
 
-	NULL,                                             /**< id             */
+	STATENOTIFY_PLUGIN_ID,                            /**< id             */
 	N_("Buddy State Notification"),                   /**< name           */
 	VERSION,                                          /**< version        */
 	                                                  /**  summary        */
@@ -92,13 +127,16 @@
 
 	NULL,                                             /**< ui_info        */
 	NULL,                                             /**< extra_info     */
-	NULL,
+	&prefs_info,                                      /**< prefs_info     */
 	NULL
 };
 
 static void
 init_plugin(GaimPlugin *plugin)
 {
+	gaim_prefs_add_none("/plugins/core/statenotify");
+	gaim_prefs_add_bool("/plugins/core/statenotify/notify_away", TRUE);
+	gaim_prefs_add_bool("/plugins/core/statenotify/notify_idle", TRUE);
 }
 
 GAIM_INIT_PLUGIN(statenotify, init_plugin, info)