changeset 8:2c7c9eb4cdda

added soundid selector
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 01 May 2008 02:00:45 +0900
parents 44a66c52b190
children c6b80f47d4df
files pidgin-twitter.c
diffstat 1 files changed, 38 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Wed Apr 30 18:49:49 2008 +0900
+++ b/pidgin-twitter.c	Thu May 01 02:00:45 2008 +0900
@@ -35,8 +35,9 @@
 
 #define PIDGINTWITTER_PLUGIN_ID	"pidgin_twitter"
 #define OPT_PIDGINTWITTER 		"/plugins/pidgin_twitter"
-#define OPT_TRANSLATE	OPT_PIDGINTWITTER "/translate"
-#define OPT_PLAYSOUND	OPT_PIDGINTWITTER "/playsound"
+#define OPT_TRANSLATE   OPT_PIDGINTWITTER "/translate"
+#define OPT_PLAYSOUND   OPT_PIDGINTWITTER "/playsound"
+#define OPT_SOUNDID     OPT_PIDGINTWITTER "/soundid"
 #define OPT_USERLIST	OPT_PIDGINTWITTER "/userlist"
 #define TWITTER_FORMAT  "@<a href='http://twitter.com/%s'>%s</a>"
 #define DEFAULT_LIST    "(list of users: separated with ' ,:;')"
@@ -64,7 +65,8 @@
     return FALSE;
 }
 
-static void translate(gchar **str)
+static void
+translate(gchar **str)
 {
     gchar *newstr;
 
@@ -85,7 +87,8 @@
     *str = newstr;
 }
 
-static void playsound(gchar **str)
+static void
+playsound(gchar **str)
 {
     GMatchInfo *match_info;
     const gchar *list;
@@ -112,7 +115,8 @@
             if(!strcmp(user, *candidate) ||
                !strcmp(user + 1, *candidate)) {
                 twitter_debug("match. play sound\n");
-                purple_sound_play_event(PURPLE_SOUND_POUNCE_DEFAULT, NULL);
+                purple_sound_play_event(
+                    purple_prefs_get_int(OPT_SOUNDID), NULL);
                 break;
             }
         }
@@ -148,7 +152,8 @@
     return FALSE;
 }
 
-static gboolean load_plugin(PurplePlugin * plugin)
+static gboolean
+load_plugin(PurplePlugin * plugin)
 {
     /* connect to signal */
     purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg",
@@ -157,7 +162,8 @@
     return TRUE;
 }
 
-static gboolean unload_plugin(PurplePlugin * plugin)
+static gboolean
+unload_plugin(PurplePlugin * plugin)
 {
     twitter_debug("pidgin-twitter unload called\n");
 
@@ -166,7 +172,8 @@
     return TRUE;
 }
 
-static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin * plugin)
+static PurplePluginPrefFrame *
+get_plugin_pref_frame(PurplePlugin * plugin)
 {
     PurplePluginPref *pref;
     PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new();
@@ -185,6 +192,25 @@
         "Play a sound on a reply to the user in the Userlist");
     purple_plugin_pref_frame_add(frame, pref);
 
+    /* sound id selector */
+	pref = purple_plugin_pref_new_with_name_and_label(
+        OPT_SOUNDID,
+        "Sound");
+	purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE);
+	purple_plugin_pref_add_choice(pref, "Arrive", GINT_TO_POINTER(0));
+	purple_plugin_pref_add_choice(pref, "Leave", GINT_TO_POINTER(1));
+	purple_plugin_pref_add_choice(pref, "Receive", GINT_TO_POINTER(2));
+	purple_plugin_pref_add_choice(pref, "Fist Receive", GINT_TO_POINTER(3));
+	purple_plugin_pref_add_choice(pref, "Send", GINT_TO_POINTER(4));
+	purple_plugin_pref_add_choice(pref, "Chat Join", GINT_TO_POINTER(5));
+	purple_plugin_pref_add_choice(pref, "Chat Leave", GINT_TO_POINTER(6));
+	purple_plugin_pref_add_choice(pref, "Chat You Say", GINT_TO_POINTER(7));
+	purple_plugin_pref_add_choice(pref, "Chat Someone Say", GINT_TO_POINTER(8));
+	purple_plugin_pref_add_choice(pref, "Pounce Default", GINT_TO_POINTER(9));
+	purple_plugin_pref_add_choice(pref, "Chat Nick Said", GINT_TO_POINTER(10));
+	purple_plugin_pref_frame_add(frame, pref);
+
+    /* user list */
     pref = purple_plugin_pref_new_with_name_and_label(
         OPT_USERLIST,
         "Userlist");
@@ -208,7 +234,7 @@
     PURPLE_PRIORITY_DEFAULT,    /**< priority	*/
     PIDGINTWITTER_PLUGIN_ID,    /**< id		*/
     "Pidgin-Twitter",           /**< name	*/
-    "0.1.0",                    /**< version	*/
+    "0.2.0",                    /**< version	*/
     "replaces @username in a message with link to the user", /**  summary	*/
     "replaces @username in a message with link to the user", /**  desc	*/
     "Yoshiki Yazawa (yaz@honeyplanet.jp)",     /**< author	*/
@@ -222,7 +248,8 @@
     NULL
 };
 
-static void init_plugin(PurplePlugin * plugin)
+static void
+init_plugin(PurplePlugin * plugin)
 {
     g_type_init();
 
@@ -230,6 +257,7 @@
     purple_prefs_add_none(OPT_PIDGINTWITTER);
     purple_prefs_add_bool(OPT_TRANSLATE, TRUE);
     purple_prefs_add_bool(OPT_PLAYSOUND, TRUE);
+    purple_prefs_add_int(OPT_SOUNDID, PURPLE_SOUND_POUNCE_DEFAULT);
     purple_prefs_add_string(OPT_USERLIST, DEFAULT_LIST);
 
     /* compile regex */