]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-roster-view.c
GNOME Goal: Update icon names
[empathy.git] / libempathy-gtk / empathy-roster-view.c
index a5d145943803aa7408ba2eb50389a82308b9b70f..657deaa96c3c5e06c29716622f0b247943796c28 100644 (file)
@@ -1,22 +1,22 @@
 #include "config.h"
-
 #include "empathy-roster-view.h"
 
 #include <glib/gi18n-lib.h>
 
-#include <libempathy/empathy-contact-groups.h>
-
-#include <libempathy-gtk/empathy-roster-contact.h>
-#include <libempathy-gtk/empathy-roster-group.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
-
-#include <libempathy/empathy-utils.h>
+#include "empathy-contact-groups.h"
+#include "empathy-roster-contact.h"
+#include "empathy-roster-group.h"
+#include "empathy-ui-utils.h"
 
 G_DEFINE_TYPE (EmpathyRosterView, empathy_roster_view, EGG_TYPE_LIST_BOX)
 
 /* Flashing delay for icons (milliseconds). */
 #define FLASH_TIMEOUT 500
 
+/* Delay in milliseconds between the last stroke on the keyboard and the start
+ * of the live search. */
+#define SEARCH_TIMEOUT 500
+
 enum
 {
   PROP_MODEL = 1,
@@ -61,6 +61,8 @@ struct _EmpathyRosterViewPriv
   guint flash_id;
   gboolean display_flash_event;
 
+  guint search_id;
+
   gboolean show_offline;
   gboolean show_groups;
   gboolean empty;
@@ -393,7 +395,7 @@ individual_added (EmpathyRosterView *self,
     {
       GList *groups, *l;
 
-      groups = empathy_roster_model_get_groups_for_individual (self->priv->model,
+      groups = empathy_roster_model_dup_groups_for_individual (self->priv->model,
           individual);
 
       if (g_list_length (groups) > 0)
@@ -409,7 +411,7 @@ individual_added (EmpathyRosterView *self,
           add_to_group (self, individual, EMPATHY_ROSTER_MODEL_GROUP_UNGROUPED);
         }
 
-      g_list_free (groups);
+      g_list_free_full (groups, g_free);
     }
 
   tp_g_signal_connect_object (individual, "notify::is-favourite",
@@ -588,14 +590,14 @@ contact_in_top (EmpathyRosterView *self,
 
       individual = empathy_roster_contact_get_individual (contact);
 
-      groups = empathy_roster_model_get_groups_for_individual (
+      groups = empathy_roster_model_dup_groups_for_individual (
           self->priv->model, individual);
 
       if (g_list_find_custom (groups, EMPATHY_ROSTER_MODEL_GROUP_TOP_GROUP,
             (GCompareFunc) g_strcmp0) != NULL)
         result = TRUE;
 
-      g_list_free (groups);
+      g_list_free_full (groups, g_free);
 
       return result;
     }
@@ -907,6 +909,7 @@ filter_group (EmpathyRosterView *self,
     EmpathyRosterGroup *group)
 {
   GList *widgets, *l;
+  gboolean result = FALSE;
 
   /* Display the group if it contains at least one displayed contact */
   widgets = empathy_roster_group_get_widgets (group);
@@ -915,10 +918,15 @@ filter_group (EmpathyRosterView *self,
       EmpathyRosterContact *contact = l->data;
 
       if (contact_should_be_displayed (self, contact))
-        return TRUE;
+        {
+          result = TRUE;
+          break;
+        }
     }
 
-  return FALSE;
+  g_list_free (widgets);
+
+  return result;
 }
 
 static gboolean
@@ -1072,6 +1080,12 @@ empathy_roster_view_dispose (GObject *object)
   empathy_roster_view_set_live_search (self, NULL);
   g_clear_object (&self->priv->model);
 
+  if (self->priv->search_id != 0)
+    {
+      g_source_remove (self->priv->search_id);
+      self->priv->search_id = 0;
+    }
+
   if (chain_up != NULL)
     chain_up (object);
 }
@@ -1431,14 +1445,27 @@ select_first_contact (EmpathyRosterView *self)
   g_list_free (children);
 }
 
+static gboolean
+search_timeout_cb (EmpathyRosterView *self)
+{
+  egg_list_box_refilter (EGG_LIST_BOX (self));
+
+  select_first_contact (self);
+
+  self->priv->search_id = 0;
+  return G_SOURCE_REMOVE;
+}
+
 static void
 search_text_notify_cb (EmpathyLiveSearch *search,
     GParamSpec *pspec,
     EmpathyRosterView *self)
 {
-  egg_list_box_refilter (EGG_LIST_BOX (self));
+  if (self->priv->search_id != 0)
+    g_source_remove (self->priv->search_id);
 
-  select_first_contact (self);
+  self->priv->search_id = g_timeout_add (SEARCH_TIMEOUT,
+      (GSourceFunc) search_timeout_cb, self);
 }
 
 static void