]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-live-search.c
local-xmpp-assistant-widget: increase row-spacing
[empathy.git] / libempathy-gtk / empathy-live-search.c
index bc7cfb10fd2a38410e2814309e0dac6a4195121b..3dc77998c39d7d24d9f644a5098ea8f0cfe45db7 100644 (file)
@@ -30,7 +30,6 @@
 #include <libempathy/empathy-utils.h>
 
 #include "empathy-live-search.h"
-#include "empathy-gtk-marshal.h"
 
 G_DEFINE_TYPE (EmpathyLiveSearch, empathy_live_search, GTK_TYPE_HBOX)
 
@@ -74,8 +73,6 @@ stripped_char (gunichar ch)
 {
   gunichar retval = 0;
   GUnicodeType utype;
-  gunichar *decomp;
-  gsize dlen;
 
   utype = g_unichar_type (ch);
 
@@ -115,12 +112,7 @@ stripped_char (gunichar ch)
     case G_UNICODE_SPACE_SEPARATOR:
     default:
       ch = g_unichar_tolower (ch);
-      decomp = g_unicode_canonical_decomposition (ch, &dlen);
-      if (decomp != NULL)
-        {
-          retval = decomp[0];
-          g_free (decomp);
-        }
+      g_unichar_fully_decompose (ch, FALSE, &retval, 1);
     }
 
   return retval;
@@ -139,8 +131,8 @@ append_word (GPtrArray **word_array,
     }
 }
 
-static GPtrArray *
-strip_utf8_string (const gchar *string)
+GPtrArray *
+empathy_live_search_strip_utf8_string (const gchar *string)
 {
   GPtrArray *word_array = NULL;
   GString *word = NULL;
@@ -230,8 +222,8 @@ live_search_match_prefix (const gchar *string,
   return FALSE;
 }
 
-static gboolean
-live_search_match_words (const gchar *string,
+gboolean
+empathy_live_search_match_words (const gchar *string,
     GPtrArray *words)
 {
   guint i;
@@ -309,7 +301,7 @@ live_search_text_changed (GtkEntry *entry,
   if (priv->stripped_words != NULL)
     g_ptr_array_unref (priv->stripped_words);
 
-  priv->stripped_words = strip_utf8_string (text);
+  priv->stripped_words = empathy_live_search_strip_utf8_string (text);
 
   g_object_notify (G_OBJECT (self), "text");
 }
@@ -546,7 +538,7 @@ empathy_live_search_class_init (EmpathyLiveSearchClass *klass)
       G_SIGNAL_RUN_LAST,
       0,
       NULL, NULL,
-      g_cclosure_marshal_VOID__VOID,
+      g_cclosure_marshal_generic,
       G_TYPE_NONE, 0);
 
   signals[KEYNAV] = g_signal_new ("key-navigation",
@@ -554,7 +546,7 @@ empathy_live_search_class_init (EmpathyLiveSearchClass *klass)
       G_SIGNAL_RUN_LAST,
       0,
       g_signal_accumulator_true_handled, NULL,
-      _empathy_gtk_marshal_BOOLEAN__BOXED,
+      g_cclosure_marshal_generic,
       G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
 
   param_spec = g_param_spec_object ("hook-widget", "Live Search Hook Widget",
@@ -702,7 +694,7 @@ empathy_live_search_match (EmpathyLiveSearch *self,
 
   priv = GET_PRIV (self);
 
-  return live_search_match_words (string, priv->stripped_words);
+  return empathy_live_search_match_words (string, priv->stripped_words);
 }
 
 gboolean
@@ -712,11 +704,18 @@ empathy_live_search_match_string (const gchar *string,
   GPtrArray *words;
   gboolean match;
 
-  words = strip_utf8_string (prefix);
-  match = live_search_match_words (string, words);
+  words = empathy_live_search_strip_utf8_string (prefix);
+  match = empathy_live_search_match_words (string, words);
   if (words != NULL)
     g_ptr_array_unref (words);
 
   return match;
 }
 
+GPtrArray *
+empathy_live_search_get_words (EmpathyLiveSearch *self)
+{
+  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+
+  return priv->stripped_words;
+}