changeset 11:7ea2a717af42

now sender list and sender sound can be set in independent of recipient settings.
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Thu, 01 May 2008 14:16:14 +0900
parents 4bd8c89b4749
children 0d102bbb40bb
files pidgin-twitter.c
diffstat 1 files changed, 53 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Thu May 01 13:37:49 2008 +0900
+++ b/pidgin-twitter.c	Thu May 01 14:16:14 2008 +0900
@@ -39,8 +39,10 @@
 #define OPT_TRANSLATE_SENDER    OPT_PIDGINTWITTER "/translate_sender"
 #define OPT_PLAYSOUND_RECIPIENT OPT_PIDGINTWITTER "/playsound_recipient"
 #define OPT_PLAYSOUND_SENDER    OPT_PIDGINTWITTER "/playsound_sender"
-#define OPT_SOUNDID             OPT_PIDGINTWITTER "/soundid"
-#define OPT_USERLIST            OPT_PIDGINTWITTER "/userlist"
+#define OPT_SOUNDID_RECIPIENT   OPT_PIDGINTWITTER "/soundid_recipient"
+#define OPT_SOUNDID_SENDER      OPT_PIDGINTWITTER "/soundid_sender"
+#define OPT_USERLIST_RECIPIENT  OPT_PIDGINTWITTER "/userlist_recipient"
+#define OPT_USERLIST_SENDER     OPT_PIDGINTWITTER "/userlist_sender"
 #define RECIPIENT_FORMAT        "@<a href='http://twitter.com/%s'>%s</a>"
 #define SENDER_FORMAT           "<a href='http://twitter.com/%s'>%s</a> :"
 #define DEFAULT_LIST             "(list of users: separated with ' ,:;')"
@@ -97,7 +99,7 @@
     const gchar *list;
     gchar **candidates = NULL, **candidate = NULL;
 
-    list = purple_prefs_get_string(OPT_USERLIST);
+    list = purple_prefs_get_string(which ? OPT_USERLIST_SENDER : OPT_USERLIST_RECIPIENT);
     g_return_if_fail(list != NULL);
     if(!strcmp(list, DEFAULT_LIST))
         return;
@@ -118,7 +120,7 @@
             if(!strcmp(user, *candidate)) {
                 twitter_debug("match. play sound\n");
                 purple_sound_play_event(
-                    purple_prefs_get_int(OPT_SOUNDID), NULL);
+                    purple_prefs_get_int(which ? OPT_SOUNDID_SENDER : OPT_SOUNDID_RECIPIENT), NULL);
                 break;
             }
         }
@@ -185,35 +187,42 @@
 static PurplePluginPrefFrame *
 get_plugin_pref_frame(PurplePlugin * plugin)
 {
+    /* create gtk elements for the plugin preferences */
+
     PurplePluginPref *pref;
     PurplePluginPrefFrame *frame = purple_plugin_pref_frame_new();
 
-    /* create gtk elements for the plugin preferences */
+    /* frame title */
     pref = purple_plugin_pref_new_with_label("Pidgin-Twitter Configuration");
     purple_plugin_pref_frame_add(frame, pref);
 
+
+    /* translation settings */
     pref = purple_plugin_pref_new_with_name_and_label(
         OPT_TRANSLATE_RECIPIENT,
-        "Translate @username to the link to the user");
+        "Translate @username to link to the user");
     purple_plugin_pref_frame_add(frame, pref);
 
     pref = purple_plugin_pref_new_with_name_and_label(
         OPT_TRANSLATE_SENDER,
-        "Translate sender name to the link");
+        "Translate sender name to link");
     purple_plugin_pref_frame_add(frame, pref);
 
+
+    /* sound settings for recipient */
     pref = purple_plugin_pref_new_with_name_and_label(
         OPT_PLAYSOUND_RECIPIENT,
-        "Play a sound on an arrival of reply to the user in the Userlist");
+        "Play a sound on reply to the user in the recipient list");
     purple_plugin_pref_frame_add(frame, pref);
 
+    /* recipient list */
     pref = purple_plugin_pref_new_with_name_and_label(
-        OPT_PLAYSOUND_SENDER,
-        "Play a sound if sender of a message is in the Userlist");
+        OPT_USERLIST_RECIPIENT,
+        "Recipient List");
     purple_plugin_pref_frame_add(frame, pref);
 
     /* sound id selector */
-	pref = purple_plugin_pref_new_with_name_and_label(OPT_SOUNDID, "Sound");
+	pref = purple_plugin_pref_new_with_name_and_label(OPT_SOUNDID_RECIPIENT, "Recipient Sound");
 
 	purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE);
 	purple_plugin_pref_add_choice(pref, "Arrive", GINT_TO_POINTER(0));
@@ -230,12 +239,37 @@
 
 	purple_plugin_pref_frame_add(frame, pref);
 
-    /* user list */
+
+    /* sound settings for sender */
+    pref = purple_plugin_pref_new_with_name_and_label(
+        OPT_PLAYSOUND_SENDER,
+        "Play a sound if sender of a message is in the sender list");
+    purple_plugin_pref_frame_add(frame, pref);
+
+    /* sender list */
     pref = purple_plugin_pref_new_with_name_and_label(
-        OPT_USERLIST,
-        "Userlist");
+        OPT_USERLIST_SENDER,
+        "Sender List");
     purple_plugin_pref_frame_add(frame, pref);
 
+    /* sound id selector */
+	pref = purple_plugin_pref_new_with_name_and_label(OPT_SOUNDID_SENDER, "Sender 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);
+
     return frame;
 }
 
@@ -254,7 +288,7 @@
     PURPLE_PRIORITY_DEFAULT,    /**< priority	*/
     PIDGINTWITTER_PLUGIN_ID,    /**< id		*/
     "Pidgin-Twitter",           /**< name	*/
-    "0.3.1",                    /**< version	*/
+    "0.4.0",                    /**< version	*/
     "replaces @username to a link and play sound", /**  summary	*/
     "replaces @username in a link and play sound", /**  desc	*/
     "Yoshiki Yazawa (yaz@honeyplanet.jp)",     /**< author	*/
@@ -280,8 +314,10 @@
 
     purple_prefs_add_bool(OPT_PLAYSOUND_RECIPIENT, TRUE);
     purple_prefs_add_bool(OPT_PLAYSOUND_SENDER, FALSE);
-    purple_prefs_add_int(OPT_SOUNDID, PURPLE_SOUND_POUNCE_DEFAULT);
-    purple_prefs_add_string(OPT_USERLIST, DEFAULT_LIST);
+    purple_prefs_add_int(OPT_SOUNDID_RECIPIENT, PURPLE_SOUND_POUNCE_DEFAULT);
+    purple_prefs_add_string(OPT_USERLIST_RECIPIENT, DEFAULT_LIST);
+    purple_prefs_add_int(OPT_SOUNDID_SENDER, PURPLE_SOUND_RECEIVE);
+    purple_prefs_add_string(OPT_USERLIST_SENDER, DEFAULT_LIST);
 
     /* compile regex */
     regp[RECIPIENT] = g_regex_new("@([A-Za-z0-9_]+)", 0, 0, NULL);