changeset 215:6b258bdd9c49

added a feature of excluding reply to me from filter application.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 27 Aug 2008 07:20:04 +0900
parents 148fa8a8be8e
children 6dffa88a5905
files pidgin-twitter.c pidgin-twitter.h prefs.ui
diffstat 3 files changed, 153 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin-twitter.c	Tue Aug 26 18:56:06 2008 +0900
+++ b/pidgin-twitter.c	Wed Aug 27 07:20:04 2008 +0900
@@ -1529,6 +1529,7 @@
 {
     GMatchInfo *match_info;
     const gchar *list = NULL;
+    gchar *screen_name = NULL;
     gchar **candidates = NULL, **candidate = NULL;
 
     g_return_if_fail(*sender != NULL);
@@ -1539,18 +1540,31 @@
     switch(service) {
     case twitter_service:
         list = purple_prefs_get_string(OPT_FILTER_TWITTER);
+        screen_name = g_strdup_printf("@%s", purple_prefs_get_string(OPT_SCREEN_NAME_TWITTER));
         break;
     case wassr_service:
         list = purple_prefs_get_string(OPT_FILTER_WASSR);
+        screen_name = g_strdup_printf("@%s", purple_prefs_get_string(OPT_SCREEN_NAME_WASSR));
         break;
     case identica_service:
         list = purple_prefs_get_string(OPT_FILTER_IDENTICA);
+        screen_name = g_strdup_printf("@%s", purple_prefs_get_string(OPT_SCREEN_NAME_IDENTICA));
         break;
     }
     g_return_if_fail(list != NULL);
     if(strstr(list, DEFAULT_LIST))
         return;
 
+    /* find @myself */
+    if(purple_prefs_get_bool(OPT_FILTER_EXCLUDE_REPLY) &&
+       strstr(plain, screen_name)) {
+        g_free(plain);
+        g_free(screen_name);
+        return;
+    }
+    else
+        g_free(screen_name);
+
     candidates = g_strsplit_set(list, " ,:;", 0);
     g_return_if_fail(candidates != NULL);
 
@@ -1566,12 +1580,12 @@
             twitter_debug("candidate = %s\n", *candidate);
             if(!strcmp(user, *candidate)) {
                 twitter_debug("match. filter %s\n", user);
-//                *flags |= PURPLE_MESSAGE_INVISIBLE; /* pidgin should handle this flag properly --yaz */
-#if 1
+                /* pidgin should handle this flag properly --yaz */
+//                *flags |= PURPLE_MESSAGE_INVISIBLE; 
+
                 /* temporal workaround */
                 g_free(*sender); *sender = NULL;
                 g_free(*buffer); *buffer = NULL;
-#endif
                 break;
             }
         }
@@ -1579,6 +1593,7 @@
         g_free(user);
         g_match_info_next(match_info, NULL);
     }
+
     g_free(plain);
     g_strfreev(candidates);
     g_match_info_free(match_info);
@@ -2874,13 +2889,20 @@
     /***************/
     /* filter page */
     /***************/
-    e = GTK_WIDGET(gtk_builder_get_object (builder, "filter_check"));
+    e = GTK_WIDGET(gtk_builder_get_object (builder, "filter_filter_check"));
     g_object_set_data(G_OBJECT(e), "pref", OPT_FILTER);
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e),
                                  purple_prefs_get_bool(OPT_FILTER));
     g_signal_connect(e, "toggled",
                      G_CALLBACK(bool_toggled_cb), &e);
 
+    e = GTK_WIDGET(gtk_builder_get_object (builder, "filter_exclude_reply_check"));
+    g_object_set_data(G_OBJECT(e), "pref", OPT_FILTER_EXCLUDE_REPLY);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e),
+                                 purple_prefs_get_bool(OPT_FILTER_EXCLUDE_REPLY));
+    g_signal_connect(e, "toggled",
+                     G_CALLBACK(bool_toggled_cb), &e);
+
     e = GTK_WIDGET(gtk_builder_get_object (builder, "filter_twitter"));
     g_object_set_data(G_OBJECT(e), "pref", OPT_FILTER_TWITTER);
     text = purple_prefs_get_string(OPT_FILTER_TWITTER);
@@ -3166,6 +3188,7 @@
     purple_prefs_add_bool(OPT_LOG_OUTPUT, FALSE);
 
     purple_prefs_add_bool(OPT_FILTER, TRUE);
+    purple_prefs_add_bool(OPT_FILTER_EXCLUDE_REPLY, TRUE);
     purple_prefs_add_string(OPT_FILTER_TWITTER, DEFAULT_LIST);
     purple_prefs_add_string(OPT_FILTER_WASSR, DEFAULT_LIST);
     purple_prefs_add_string(OPT_FILTER_IDENTICA, DEFAULT_LIST);
--- a/pidgin-twitter.h	Tue Aug 26 18:56:06 2008 +0900
+++ b/pidgin-twitter.h	Wed Aug 27 07:20:04 2008 +0900
@@ -122,9 +122,11 @@
 #define OPT_API_BASE_GET_INTERVAL OPT_PIDGINTWITTER "/api_base_get_interval"
 #define OPT_LOG_OUTPUT          OPT_PIDGINTWITTER "/log_output"
 #define OPT_FILTER              OPT_PIDGINTWITTER "/filter"
+#define OPT_FILTER_EXCLUDE_REPLY OPT_PIDGINTWITTER "/filter_exclude_reply"
 #define OPT_FILTER_TWITTER      OPT_PIDGINTWITTER "/filter_twitter"
 #define OPT_FILTER_WASSR        OPT_PIDGINTWITTER "/filter_wassr"
 #define OPT_FILTER_IDENTICA     OPT_PIDGINTWITTER "/filter_identica"
+
 #ifdef _WIN32
 #define OPT_PIDGIN_BLINK_IM     PIDGIN_PREFS_ROOT "/win32/blink_im"
 #endif
--- a/prefs.ui	Tue Aug 26 18:56:06 2008 +0900
+++ b/prefs.ui	Wed Aug 27 07:20:04 2008 +0900
@@ -482,7 +482,7 @@
                 <property name="xalign">0</property>
                 <property name="left_padding">20</property>
                 <child>
-                  <object class="GtkCheckButton" id="filter_check">
+                  <object class="GtkCheckButton" id="filter_filter_check">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="label" translatable="yes">Apply filter</property>
@@ -499,6 +499,28 @@
               </packing>
             </child>
             <child>
+              <object class="GtkAlignment" id="alignment62">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="left_padding">20</property>
+                <child>
+                  <object class="GtkCheckButton" id="filter_exclude_reply_check">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="label" translatable="yes">Exclude reply to me from application</property>
+                    <property name="response_id">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">2</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkAlignment" id="alignment43">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
@@ -517,7 +539,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">2</property>
+                <property name="position">3</property>
               </packing>
             </child>
             <child>
@@ -561,7 +583,7 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="padding">2</property>
-                <property name="position">3</property>
+                <property name="position">4</property>
               </packing>
             </child>
             <child>
@@ -604,7 +626,7 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="padding">2</property>
-                <property name="position">4</property>
+                <property name="position">5</property>
               </packing>
             </child>
             <child>
@@ -648,7 +670,7 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="padding">2</property>
-                <property name="position">5</property>
+                <property name="position">6</property>
               </packing>
             </child>
           </object>
@@ -738,17 +760,46 @@
                   <placeholder/>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment40">
+                  <object class="GtkAlignment" id="alignment18">
                     <property name="visible">True</property>
-                    <property name="left_padding">40</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="x_options"></property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment16">
+                    <property name="visible">True</property>
                     <child>
-                      <object class="GtkLabel" id="label24">
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment45">
+                    <property name="visible">True</property>
+                    <property name="right_padding">20</property>
+                    <child>
+                      <object class="GtkLabel" id="label27">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">Icon size</property>
+                        <property name="label" translatable="yes">pixel</property>
                       </object>
                     </child>
                   </object>
                   <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
                     <property name="x_options"></property>
                     <property name="y_options"></property>
                   </packing>
@@ -775,46 +826,17 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment45">
+                  <object class="GtkAlignment" id="alignment40">
                     <property name="visible">True</property>
-                    <property name="right_padding">20</property>
+                    <property name="left_padding">40</property>
                     <child>
-                      <object class="GtkLabel" id="label27">
+                      <object class="GtkLabel" id="label24">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">pixel</property>
+                        <property name="label" translatable="yes">Icon size</property>
                       </object>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment16">
-                    <property name="visible">True</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment18">
-                    <property name="visible">True</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
                     <property name="x_options"></property>
                     <property name="y_options"></property>
                   </packing>
@@ -905,24 +927,72 @@
                   <placeholder/>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment52">
+                  <object class="GtkAlignment" id="alignment19">
                     <property name="visible">True</property>
-                    <property name="right_padding">20</property>
                     <child>
-                      <object class="GtkLabel" id="label18">
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment50">
+                    <property name="visible">True</property>
+                    <property name="left_padding">40</property>
+                    <child>
+                      <object class="GtkLabel" id="label25">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">days</property>
+                        <property name="label" translatable="yes">Update every</property>
                       </object>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">5</property>
-                    <property name="right_attach">6</property>
                     <property name="x_options"></property>
                     <property name="y_options"></property>
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkAlignment" id="alignment51">
+                    <property name="visible">True</property>
+                    <property name="left_padding">4</property>
+                    <child>
+                      <object class="GtkSpinButton" id="icon_max_count_spin">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="climb_rate">1</property>
+                        <property name="snap_to_ticks">True</property>
+                        <property name="numeric">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="x_options"></property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkAlignment" id="alignment53">
+                    <property name="visible">True</property>
+                    <child>
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">times  or</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">3</property>
+                    <property name="right_attach">4</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkAlignment" id="alignment54">
                     <property name="visible">True</property>
                     <property name="left_padding">4</property>
@@ -945,71 +1015,23 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkAlignment" id="alignment53">
+                  <object class="GtkAlignment" id="alignment52">
                     <property name="visible">True</property>
+                    <property name="right_padding">20</property>
                     <child>
-                      <object class="GtkLabel" id="label3">
+                      <object class="GtkLabel" id="label18">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">times  or</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">3</property>
-                    <property name="right_attach">4</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment51">
-                    <property name="visible">True</property>
-                    <property name="left_padding">4</property>
-                    <child>
-                      <object class="GtkSpinButton" id="icon_max_count_spin">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="climb_rate">1</property>
-                        <property name="snap_to_ticks">True</property>
-                        <property name="numeric">True</property>
+                        <property name="label" translatable="yes">days</property>
                       </object>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
+                    <property name="left_attach">5</property>
+                    <property name="right_attach">6</property>
                     <property name="x_options"></property>
                     <property name="y_options"></property>
                   </packing>
                 </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment50">
-                    <property name="visible">True</property>
-                    <property name="left_padding">40</property>
-                    <child>
-                      <object class="GtkLabel" id="label25">
-                        <property name="visible">True</property>
-                        <property name="label" translatable="yes">Update every</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="x_options"></property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkAlignment" id="alignment19">
-                    <property name="visible">True</property>
-                    <child>
-                      <placeholder/>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
-                    <property name="y_options"></property>
-                  </packing>
-                </child>
               </object>
               <packing>
                 <property name="expand">False</property>