[empathy] live-search: move from Empathy to tp-account-widgets



commit 406dc1041ff2d0575e43bb0c320a072d29e4af79
Author: Marco Barisione <marco barisione collabora co uk>
Date:   Thu May 9 13:44:04 2013 +0100

    live-search: move from Empathy to tp-account-widgets
    
    https://bugzilla.gnome.org/show_bug.cgi?id=699492

 libempathy-gtk/Makefile.am                         |    2 -
 libempathy-gtk/empathy-contact-chooser.c           |    2 +-
 libempathy-gtk/empathy-individual-view.c           |   14 +-
 libempathy-gtk/empathy-individual-view.h           |    4 +-
 libempathy-gtk/empathy-live-search.h               |   79 -----------
 libempathy-gtk/empathy-roster-view.c               |   10 +-
 libempathy-gtk/empathy-roster-view.h               |    5 +-
 libempathy-gtk/empathy-ui-utils.c                  |    8 +-
 src/empathy-roster-window.c                        |    4 +-
 tests/empathy-live-search-test.c                   |    4 +-
 tests/interactive/Makefile.am                      |    1 +
 tests/interactive/test-empathy-dual-roster-view.c  |    4 +-
 .../test-empathy-roster-model-aggregator.c         |    4 +-
 tests/interactive/test-empathy-roster-view.c       |    4 +-
 tp-account-widgets/Makefile.am                     |    2 +
 .../tpaw-irc-network-chooser-dialog.c              |   12 +-
 .../tpaw-live-search.c                             |  140 ++++++++++----------
 tp-account-widgets/tpaw-live-search.h              |   79 +++++++++++
 18 files changed, 190 insertions(+), 188 deletions(-)
---
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 3605eea..43e7689 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -42,7 +42,6 @@ libempathy_gtk_handwritten_source =                   \
        empathy-contact-blocking-dialog.c       \
        empathy-contact-chooser.c               \
        empathy-contactinfo-utils.c             \
-       empathy-live-search.c                   \
        empathy-contact-search-dialog.c         \
        empathy-contact-widget.c                \
        empathy-dialpad-widget.c                \
@@ -106,7 +105,6 @@ libempathy_gtk_headers =                    \
        empathy-chat.h                          \
        empathy-contact-blocking-dialog.h       \
        empathy-contact-chooser.h               \
-       empathy-live-search.h                   \
        empathy-contact-search-dialog.h         \
        empathy-contact-widget.h                \
        empathy-contactinfo-utils.h             \
diff --git a/libempathy-gtk/empathy-contact-chooser.c b/libempathy-gtk/empathy-contact-chooser.c
index dd81dde..e31b22f 100644
--- a/libempathy-gtk/empathy-contact-chooser.c
+++ b/libempathy-gtk/empathy-contact-chooser.c
@@ -312,7 +312,7 @@ search_text_changed (GtkEntry *entry,
 
   id = gtk_entry_get_text (entry);
 
-  self->priv->search_words = empathy_live_search_strip_utf8_string (id);
+  self->priv->search_words = tpaw_live_search_strip_utf8_string (id);
   self->priv->search_str = g_strdup (id);
 
   add_temporary_individuals (self, id);
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index d0a367d..8fe7af7 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -1327,7 +1327,7 @@ individual_view_start_search_cb (EmpathyIndividualView *view,
 }
 
 static void
-individual_view_search_text_notify_cb (EmpathyLiveSearch *search,
+individual_view_search_text_notify_cb (TpawLiveSearch *search,
     GParamSpec *pspec,
     EmpathyIndividualView *view)
 {
@@ -1420,7 +1420,7 @@ individual_view_search_key_navigation_cb (GtkWidget *search,
 }
 
 static void
-individual_view_search_hide_cb (EmpathyLiveSearch *search,
+individual_view_search_hide_cb (TpawLiveSearch *search,
     EmpathyIndividualView *view)
 {
   EmpathyIndividualViewPriv *priv = GET_PRIV (view);
@@ -1489,7 +1489,7 @@ individual_view_search_hide_cb (EmpathyLiveSearch *search,
 }
 
 static void
-individual_view_search_show_cb (EmpathyLiveSearch *search,
+individual_view_search_show_cb (TpawLiveSearch *search,
     EmpathyIndividualView *view)
 {
   /* block expand or collapse handlers during expand all, they would
@@ -1639,7 +1639,7 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
     guint event_count)
 {
   EmpathyIndividualViewPriv *priv = GET_PRIV (self);
-  EmpathyLiveSearch *live = EMPATHY_LIVE_SEARCH (priv->search_widget);
+  TpawLiveSearch *live = TPAW_LIVE_SEARCH (priv->search_widget);
   GeeSet *personas;
   GeeIterator *iter;
   gboolean is_favorite;
@@ -1691,8 +1691,8 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
   }
 
   return empathy_individual_match_string (individual,
-      empathy_live_search_get_text (live),
-      empathy_live_search_get_words (live));
+      tpaw_live_search_get_text (live),
+      tpaw_live_search_get_words (live));
 }
 
 static gchar *
@@ -2483,7 +2483,7 @@ out:
 
 void
 empathy_individual_view_set_live_search (EmpathyIndividualView *view,
-    EmpathyLiveSearch *search)
+    TpawLiveSearch *search)
 {
   EmpathyIndividualViewPriv *priv = GET_PRIV (view);
 
diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h
index e942a42..2fd0bce 100644
--- a/libempathy-gtk/empathy-individual-view.h
+++ b/libempathy-gtk/empathy-individual-view.h
@@ -29,10 +29,10 @@
 
 #include <gtk/gtk.h>
 #include <folks/folks.h>
+#include <tp-account-widgets/tpaw-live-search.h>
 
 #include "empathy-individual-menu.h"
 #include "empathy-individual-store.h"
-#include "empathy-live-search.h"
 
 G_BEGIN_DECLS
 #define EMPATHY_TYPE_INDIVIDUAL_VIEW         (empathy_individual_view_get_type ())
@@ -100,7 +100,7 @@ GtkWidget *empathy_individual_view_get_individual_menu (
 GtkWidget *empathy_individual_view_get_group_menu (EmpathyIndividualView *view);
 
 void empathy_individual_view_set_live_search (EmpathyIndividualView *view,
-    EmpathyLiveSearch *search);
+    TpawLiveSearch *search);
 
 gboolean empathy_individual_view_get_show_offline (
     EmpathyIndividualView *view);
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c
index a6b6ffe..4413510 100644
--- a/libempathy-gtk/empathy-roster-view.c
+++ b/libempathy-gtk/empathy-roster-view.c
@@ -67,7 +67,7 @@ struct _EmpathyRosterViewPriv
   gboolean show_groups;
   gboolean empty;
 
-  EmpathyLiveSearch *search;
+  TpawLiveSearch *search;
 
   EmpathyRosterModel *model;
 };
@@ -864,8 +864,8 @@ contact_should_be_displayed (EmpathyRosterView *self,
       individual = empathy_roster_contact_get_individual (contact);
 
       return empathy_individual_match_string (individual,
-          empathy_live_search_get_text (self->priv->search),
-          empathy_live_search_get_words (self->priv->search));
+          tpaw_live_search_get_text (self->priv->search),
+          tpaw_live_search_get_words (self->priv->search));
     }
 
   if (self->priv->show_offline)
@@ -1473,7 +1473,7 @@ search_timeout_cb (EmpathyRosterView *self)
 }
 
 static void
-search_text_notify_cb (EmpathyLiveSearch *search,
+search_text_notify_cb (TpawLiveSearch *search,
     GParamSpec *pspec,
     EmpathyRosterView *self)
 {
@@ -1500,7 +1500,7 @@ search_activate_cb (GtkWidget *search,
 
 void
 empathy_roster_view_set_live_search (EmpathyRosterView *self,
-    EmpathyLiveSearch *search)
+    TpawLiveSearch *search)
 {
   if (self->priv->search != NULL)
     {
diff --git a/libempathy-gtk/empathy-roster-view.h b/libempathy-gtk/empathy-roster-view.h
index c09d09c..586d75b 100644
--- a/libempathy-gtk/empathy-roster-view.h
+++ b/libempathy-gtk/empathy-roster-view.h
@@ -2,8 +2,9 @@
 #ifndef __EMPATHY_ROSTER_VIEW_H__
 #define __EMPATHY_ROSTER_VIEW_H__
 
+#include <tp-account-widgets/tpaw-live-search.h>
+
 #include "egg-list-box/egg-list-box.h"
-#include "empathy-live-search.h"
 #include "empathy-roster-model.h"
 
 G_BEGIN_DECLS
@@ -58,7 +59,7 @@ void empathy_roster_view_show_groups (EmpathyRosterView *self,
     gboolean show);
 
 void empathy_roster_view_set_live_search (EmpathyRosterView *self,
-    EmpathyLiveSearch *search);
+    TpawLiveSearch *search);
 
 gboolean empathy_roster_view_is_empty (EmpathyRosterView *self);
 
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 86edb3b..ec868a3 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -36,10 +36,10 @@
 #include <gdk/gdkx.h>
 #include <glib/gi18n-lib.h>
 #include <gio/gdesktopappinfo.h>
+#include <tp-account-widgets/tpaw-live-search.h>
 
 #include "empathy-ft-factory.h"
 #include "empathy-images.h"
-#include "empathy-live-search.h"
 #include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_OTHER
@@ -1406,7 +1406,7 @@ empathy_get_current_action_time (void)
   return (tp_user_action_time_from_x11 (gtk_get_current_event_time ()));
 }
 
-/* @words = empathy_live_search_strip_utf8_string (@text);
+/* @words = tpaw_live_search_strip_utf8_string (@text);
  *
  * User has to pass both so we don't have to compute @words ourself each time
  * this function is called. */
@@ -1423,7 +1423,7 @@ empathy_individual_match_string (FolksIndividual *individual,
   /* check alias name */
   str = folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual));
 
-  if (empathy_live_search_match_words (str, words))
+  if (tpaw_live_search_match_words (str, words))
     return TRUE;
 
   personas = folks_individual_get_personas (individual);
@@ -1454,7 +1454,7 @@ empathy_individual_match_string (FolksIndividual *individual,
               if (p != NULL)
                 str = dup_str = g_strndup (str, p - str);
 
-              visible = empathy_live_search_match_words (str, words);
+              visible = tpaw_live_search_match_words (str, words);
               g_free (dup_str);
               if (visible)
                 retval = TRUE;
diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c
index 0fb2d83..1a30f71 100644
--- a/src/empathy-roster-window.c
+++ b/src/empathy-roster-window.c
@@ -2371,10 +2371,10 @@ empathy_roster_window_init (EmpathyRosterWindow *self)
   gtk_widget_set_has_tooltip (GTK_WIDGET (self->priv->view), TRUE);
 
   /* Set up search bar */
-  self->priv->search_bar = empathy_live_search_new (
+  self->priv->search_bar = tpaw_live_search_new (
       GTK_WIDGET (self->priv->view));
   empathy_roster_view_set_live_search (self->priv->view,
-      EMPATHY_LIVE_SEARCH (self->priv->search_bar));
+      TPAW_LIVE_SEARCH (self->priv->search_bar));
   gtk_box_pack_start (GTK_BOX (search_vbox), self->priv->search_bar,
       FALSE, TRUE, 0);
 
diff --git a/tests/empathy-live-search-test.c b/tests/empathy-live-search-test.c
index 10f0346..2fb3e48 100644
--- a/tests/empathy-live-search-test.c
+++ b/tests/empathy-live-search-test.c
@@ -3,8 +3,8 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <tp-account-widgets/tpaw-live-search.h>
 
-#include "empathy-live-search.h"
 #include "test-helper.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_TESTS
@@ -57,7 +57,7 @@ test_live_search (void)
       gboolean match;
       gboolean ok;
 
-      match = empathy_live_search_match_string (tests[i].string, tests[i].prefix);
+      match = tpaw_live_search_match_string (tests[i].string, tests[i].prefix);
       ok = (match == tests[i].should_match);
 
       DEBUG ("'%s' - '%s' %s: %s", tests[i].string, tests[i].prefix,
diff --git a/tests/interactive/Makefile.am b/tests/interactive/Makefile.am
index 397536b..86d8fe1 100644
--- a/tests/interactive/Makefile.am
+++ b/tests/interactive/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS =                                           \
        $(DISABLE_DEPRECATED)
 
 LDADD =                                                                \
+       $(top_builddir)/tp-account-widgets/libtp-account-widgets.la     \
        $(top_builddir)/libempathy-gtk/libempathy-gtk.la        \
        $(top_builddir)/libempathy/libempathy.la                \
        $(EMPATHY_LIBS)
diff --git a/tests/interactive/test-empathy-dual-roster-view.c 
b/tests/interactive/test-empathy-dual-roster-view.c
index 74bb59f..5d2dfdc 100644
--- a/tests/interactive/test-empathy-dual-roster-view.c
+++ b/tests/interactive/test-empathy-dual-roster-view.c
@@ -93,9 +93,9 @@ create_view_box (EmpathyRosterModel *model,
   empathy_roster_view_show_offline (EMPATHY_ROSTER_VIEW (view), show_offline);
   empathy_roster_view_show_groups (EMPATHY_ROSTER_VIEW (view), show_groups);
 
-  search = empathy_live_search_new (view);
+  search = tpaw_live_search_new (view);
   empathy_roster_view_set_live_search (EMPATHY_ROSTER_VIEW (view),
-      EMPATHY_LIVE_SEARCH (search));
+      TPAW_LIVE_SEARCH (search));
 
   scrolled = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
diff --git a/tests/interactive/test-empathy-roster-model-aggregator.c 
b/tests/interactive/test-empathy-roster-model-aggregator.c
index 478b4e6..b558431 100644
--- a/tests/interactive/test-empathy-roster-model-aggregator.c
+++ b/tests/interactive/test-empathy-roster-model-aggregator.c
@@ -136,9 +136,9 @@ main (int argc,
   empathy_roster_view_show_offline (EMPATHY_ROSTER_VIEW (view), show_offline);
   empathy_roster_view_show_groups (EMPATHY_ROSTER_VIEW (view), show_groups);
 
-  search = empathy_live_search_new (view);
+  search = tpaw_live_search_new (view);
   empathy_roster_view_set_live_search (EMPATHY_ROSTER_VIEW (view),
-      EMPATHY_LIVE_SEARCH (search));
+      TPAW_LIVE_SEARCH (search));
 
   scrolled = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
diff --git a/tests/interactive/test-empathy-roster-view.c b/tests/interactive/test-empathy-roster-view.c
index f814d96..eb5cf6c 100644
--- a/tests/interactive/test-empathy-roster-view.c
+++ b/tests/interactive/test-empathy-roster-view.c
@@ -128,9 +128,9 @@ main (int argc,
 
   g_object_unref (mgr);
 
-  search = empathy_live_search_new (view);
+  search = tpaw_live_search_new (view);
   empathy_roster_view_set_live_search (EMPATHY_ROSTER_VIEW (view),
-      EMPATHY_LIVE_SEARCH (search));
+      TPAW_LIVE_SEARCH (search));
 
   scrolled = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
diff --git a/tp-account-widgets/Makefile.am b/tp-account-widgets/Makefile.am
index 29a8ed7..3ff5531 100644
--- a/tp-account-widgets/Makefile.am
+++ b/tp-account-widgets/Makefile.am
@@ -29,6 +29,7 @@ libtp_account_widgets_sources =               \
        tpaw-irc-network-manager.c              \
        tpaw-irc-network.c                      \
        tpaw-irc-server.c                       \
+       tpaw-live-search.c                      \
        tpaw-utils.c                            \
        totem-subtitle-encoding.c               \
        $(NULL)
@@ -46,6 +47,7 @@ libtp_account_widgets_headers =                       \
        tpaw-irc-network-manager.h              \
        tpaw-irc-network.h                      \
        tpaw-irc-server.h                       \
+       tpaw-live-search.h                      \
        tpaw-utils.h                            \
        totem-subtitle-encoding.h               \
        $(NULL)
diff --git a/tp-account-widgets/tpaw-irc-network-chooser-dialog.c 
b/tp-account-widgets/tpaw-irc-network-chooser-dialog.c
index c7995a5..daf35a0 100644
--- a/tp-account-widgets/tpaw-irc-network-chooser-dialog.c
+++ b/tp-account-widgets/tpaw-irc-network-chooser-dialog.c
@@ -26,7 +26,7 @@
 
 #include "tpaw-irc-network-dialog.h"
 #include "tpaw-irc-network-manager.h"
-#include "empathy-live-search.h"
+#include "tpaw-live-search.h"
 #include "empathy-utils.h"
 
 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT | EMPATHY_DEBUG_IRC
@@ -436,7 +436,7 @@ filter_visible_func (GtkTreeModel *model,
 
   gtk_tree_model_get (model, iter, COL_NETWORK_OBJ, &network, -1);
 
-  visible = empathy_live_search_match (EMPATHY_LIVE_SEARCH (priv->search),
+  visible = tpaw_live_search_match (TPAW_LIVE_SEARCH (priv->search),
       tpaw_irc_network_get_name (network));
 
   g_object_unref (network);
@@ -452,7 +452,7 @@ search_activate_cb (GtkWidget *search,
 }
 
 static void
-search_text_notify_cb (EmpathyLiveSearch *search,
+search_text_notify_cb (TpawLiveSearch *search,
     GParamSpec *pspec,
     TpawIrcNetworkChooserDialog *self)
 {
@@ -468,7 +468,7 @@ search_text_notify_cb (EmpathyLiveSearch *search,
     {
       const gchar *text;
 
-      text = empathy_live_search_get_text (EMPATHY_LIVE_SEARCH (priv->search));
+      text = tpaw_live_search_get_text (TPAW_LIVE_SEARCH (priv->search));
       if (!EMP_STR_EMPTY (text))
         {
           /* We are doing a search, select the first matching network */
@@ -592,7 +592,7 @@ tpaw_irc_network_chooser_dialog_constructed (GObject *object)
   gtk_style_context_set_junction_sides (context, GTK_JUNCTION_TOP);
 
   /* Live search */
-  priv->search = empathy_live_search_new (priv->treeview);
+  priv->search = tpaw_live_search_new (priv->treeview);
 
   gtk_box_pack_start (GTK_BOX (vbox), priv->search, FALSE, TRUE, 0);
 
@@ -653,7 +653,7 @@ tpaw_irc_network_chooser_dialog_dispose (GObject *object)
 
   if (priv->search != NULL)
     {
-      empathy_live_search_set_hook_widget (EMPATHY_LIVE_SEARCH (priv->search),
+      tpaw_live_search_set_hook_widget (TPAW_LIVE_SEARCH (priv->search),
           NULL);
 
       priv->search = NULL;
diff --git a/libempathy-gtk/empathy-live-search.c b/tp-account-widgets/tpaw-live-search.c
similarity index 80%
rename from libempathy-gtk/empathy-live-search.c
rename to tp-account-widgets/tpaw-live-search.c
index 51f6a2e..1547a4b 100644
--- a/libempathy-gtk/empathy-live-search.c
+++ b/tp-account-widgets/tpaw-live-search.c
@@ -22,13 +22,13 @@
  */
 
 #include "config.h"
-#include "empathy-live-search.h"
+#include "tpaw-live-search.h"
 
 #include "empathy-utils.h"
 
-G_DEFINE_TYPE (EmpathyLiveSearch, empathy_live_search, GTK_TYPE_HBOX)
+G_DEFINE_TYPE (TpawLiveSearch, tpaw_live_search, GTK_TYPE_HBOX)
 
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyLiveSearch)
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, TpawLiveSearch)
 
 typedef struct
 {
@@ -36,7 +36,7 @@ typedef struct
   GtkWidget *hook_widget;
 
   GPtrArray *stripped_words;
-} EmpathyLiveSearchPriv;
+} TpawLiveSearchPriv;
 
 enum
 {
@@ -127,7 +127,7 @@ append_word (GPtrArray **word_array,
 }
 
 GPtrArray *
-empathy_live_search_strip_utf8_string (const gchar *string)
+tpaw_live_search_strip_utf8_string (const gchar *string)
 {
   GPtrArray *word_array = NULL;
   GString *word = NULL;
@@ -218,7 +218,7 @@ live_search_match_prefix (const gchar *string,
 }
 
 gboolean
-empathy_live_search_match_words (const gchar *string,
+tpaw_live_search_match_words (const gchar *string,
     GPtrArray *words)
 {
   guint i;
@@ -234,7 +234,7 @@ empathy_live_search_match_words (const gchar *string,
 }
 
 static gboolean
-fire_key_navigation_sig (EmpathyLiveSearch *self,
+fire_key_navigation_sig (TpawLiveSearch *self,
     GdkEventKey *event)
 {
   gboolean ret;
@@ -248,7 +248,7 @@ live_search_entry_key_pressed_cb (GtkEntry *entry,
     GdkEventKey *event,
     gpointer user_data)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (user_data);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data);
 
   /* if esc key pressed, hide the search */
   if (event->keyval == GDK_KEY_Escape)
@@ -283,8 +283,8 @@ static void
 live_search_text_changed (GtkEntry *entry,
     gpointer user_data)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (user_data);
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
   const gchar *text;
 
   text = gtk_entry_get_text (entry);
@@ -297,7 +297,7 @@ live_search_text_changed (GtkEntry *entry,
   if (priv->stripped_words != NULL)
     g_ptr_array_unref (priv->stripped_words);
 
-  priv->stripped_words = empathy_live_search_strip_utf8_string (text);
+  priv->stripped_words = tpaw_live_search_strip_utf8_string (text);
 
   g_object_notify (G_OBJECT (self), "text");
 }
@@ -308,7 +308,7 @@ live_search_close_pressed (GtkEntry *entry,
     GdkEvent *event,
     gpointer user_data)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (user_data);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data);
 
   gtk_widget_hide (GTK_WIDGET (self));
 }
@@ -318,8 +318,8 @@ live_search_key_press_event_cb (GtkWidget *widget,
     GdkEventKey *event,
     gpointer user_data)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (user_data);
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
   GdkEvent *new_event;
   gboolean ret;
 
@@ -380,15 +380,15 @@ live_search_key_press_event_cb (GtkWidget *widget,
 
 static void
 live_search_entry_activate_cb (GtkEntry *entry,
-    EmpathyLiveSearch *self)
+    TpawLiveSearch *self)
 {
   g_signal_emit (self, signals[ACTIVATE], 0);
 }
 
 static void
-live_search_release_hook_widget (EmpathyLiveSearch *self)
+live_search_release_hook_widget (TpawLiveSearch *self)
 {
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
   /* remove old handlers if old source was not null */
   if (priv->hook_widget != NULL)
@@ -406,7 +406,7 @@ static void
 live_search_hook_widget_destroy_cb (GtkWidget *object,
     gpointer user_data)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (user_data);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (user_data);
 
   /* unref the hook widget and hide search */
   gtk_widget_hide (GTK_WIDGET (self));
@@ -416,25 +416,25 @@ live_search_hook_widget_destroy_cb (GtkWidget *object,
 static void
 live_search_dispose (GObject *obj)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (obj);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (obj);
 
   live_search_release_hook_widget (self);
 
-  if (G_OBJECT_CLASS (empathy_live_search_parent_class)->dispose != NULL)
-    G_OBJECT_CLASS (empathy_live_search_parent_class)->dispose (obj);
+  if (G_OBJECT_CLASS (tpaw_live_search_parent_class)->dispose != NULL)
+    G_OBJECT_CLASS (tpaw_live_search_parent_class)->dispose (obj);
 }
 
 static void
 live_search_finalize (GObject *obj)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (obj);
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (obj);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
   if (priv->stripped_words != NULL)
     g_ptr_array_unref (priv->stripped_words);
 
-  if (G_OBJECT_CLASS (empathy_live_search_parent_class)->finalize != NULL)
-    G_OBJECT_CLASS (empathy_live_search_parent_class)->finalize (obj);
+  if (G_OBJECT_CLASS (tpaw_live_search_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (tpaw_live_search_parent_class)->finalize (obj);
 }
 
 static void
@@ -443,15 +443,15 @@ live_search_get_property (GObject *object,
     GValue *value,
     GParamSpec *pspec)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (object);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (object);
 
   switch (param_id)
     {
     case PROP_HOOK_WIDGET:
-      g_value_set_object (value, empathy_live_search_get_hook_widget (self));
+      g_value_set_object (value, tpaw_live_search_get_hook_widget (self));
       break;
     case PROP_TEXT:
-      g_value_set_string (value, empathy_live_search_get_text (self));
+      g_value_set_string (value, tpaw_live_search_get_text (self));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -465,14 +465,14 @@ live_search_set_property (GObject *object,
     const GValue *value,
     GParamSpec *pspec)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (object);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (object);
 
   switch (param_id) {
   case PROP_HOOK_WIDGET:
-    empathy_live_search_set_hook_widget (self, g_value_get_object (value));
+    tpaw_live_search_set_hook_widget (self, g_value_get_object (value));
     break;
   case PROP_TEXT:
-    empathy_live_search_set_text (self, g_value_get_string (value));
+    tpaw_live_search_set_text (self, g_value_get_string (value));
     break;
   default:
     G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -483,10 +483,10 @@ live_search_set_property (GObject *object,
 static void
 live_search_unmap (GtkWidget *widget)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (widget);
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
-  GTK_WIDGET_CLASS (empathy_live_search_parent_class)->unmap (widget);
+  GTK_WIDGET_CLASS (tpaw_live_search_parent_class)->unmap (widget);
 
   /* unmap can happen if a parent gets hidden, in that case we want to hide
    * the live search as well, so when it gets mapped again, the live search
@@ -502,20 +502,20 @@ live_search_unmap (GtkWidget *widget)
 static void
 live_search_show (GtkWidget *widget)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (widget);
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
   if (!gtk_widget_has_focus (priv->search_entry))
     gtk_widget_grab_focus (priv->search_entry);
 
-  GTK_WIDGET_CLASS (empathy_live_search_parent_class)->show (widget);
+  GTK_WIDGET_CLASS (tpaw_live_search_parent_class)->show (widget);
 }
 
 static void
 live_search_grab_focus (GtkWidget *widget)
 {
-  EmpathyLiveSearch *self = EMPATHY_LIVE_SEARCH (widget);
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearch *self = TPAW_LIVE_SEARCH (widget);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
   if (!gtk_widget_has_focus (priv->search_entry))
     {
@@ -525,7 +525,7 @@ live_search_grab_focus (GtkWidget *widget)
 }
 
 static void
-empathy_live_search_class_init (EmpathyLiveSearchClass *klass)
+tpaw_live_search_class_init (TpawLiveSearchClass *klass)
 {
   GObjectClass *object_class = (GObjectClass *) klass;
   GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
@@ -567,15 +567,15 @@ empathy_live_search_class_init (EmpathyLiveSearchClass *klass)
       "", G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
   g_object_class_install_property (object_class, PROP_TEXT, param_spec);
 
-  g_type_class_add_private (klass, sizeof (EmpathyLiveSearchPriv));
+  g_type_class_add_private (klass, sizeof (TpawLiveSearchPriv));
 }
 
 static void
-empathy_live_search_init (EmpathyLiveSearch *self)
+tpaw_live_search_init (TpawLiveSearch *self)
 {
-  EmpathyLiveSearchPriv *priv =
-    G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_LIVE_SEARCH,
-        EmpathyLiveSearchPriv);
+  TpawLiveSearchPriv *priv =
+    G_TYPE_INSTANCE_GET_PRIVATE ((self), TPAW_TYPE_LIVE_SEARCH,
+        TpawLiveSearchPriv);
 
   gtk_widget_set_no_show_all (GTK_WIDGET (self), TRUE);
 
@@ -605,11 +605,11 @@ empathy_live_search_init (EmpathyLiveSearch *self)
 }
 
 GtkWidget *
-empathy_live_search_new (GtkWidget *hook)
+tpaw_live_search_new (GtkWidget *hook)
 {
   g_return_val_if_fail (hook == NULL || GTK_IS_WIDGET (hook), NULL);
 
-  return g_object_new (EMPATHY_TYPE_LIVE_SEARCH,
+  return g_object_new (TPAW_TYPE_LIVE_SEARCH,
       "hook-widget", hook,
       NULL);
 }
@@ -617,22 +617,22 @@ empathy_live_search_new (GtkWidget *hook)
 /* public methods */
 
 GtkWidget *
-empathy_live_search_get_hook_widget (EmpathyLiveSearch *self)
+tpaw_live_search_get_hook_widget (TpawLiveSearch *self)
 {
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
-  g_return_val_if_fail (EMPATHY_IS_LIVE_SEARCH (self), NULL);
+  g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), NULL);
 
   return priv->hook_widget;
 }
 
 void
-empathy_live_search_set_hook_widget (EmpathyLiveSearch *self,
+tpaw_live_search_set_hook_widget (TpawLiveSearch *self,
     GtkWidget *hook)
 {
-  EmpathyLiveSearchPriv *priv;
+  TpawLiveSearchPriv *priv;
 
-  g_return_if_fail (EMPATHY_IS_LIVE_SEARCH (self));
+  g_return_if_fail (TPAW_IS_LIVE_SEARCH (self));
   g_return_if_fail (hook == NULL || GTK_IS_WIDGET (hook));
 
   priv = GET_PRIV (self);
@@ -654,30 +654,30 @@ empathy_live_search_set_hook_widget (EmpathyLiveSearch *self,
 }
 
 const gchar *
-empathy_live_search_get_text (EmpathyLiveSearch *self)
+tpaw_live_search_get_text (TpawLiveSearch *self)
 {
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
-  g_return_val_if_fail (EMPATHY_IS_LIVE_SEARCH (self), NULL);
+  g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), NULL);
 
   return gtk_entry_get_text (GTK_ENTRY (priv->search_entry));
 }
 
 void
-empathy_live_search_set_text (EmpathyLiveSearch *self,
+tpaw_live_search_set_text (TpawLiveSearch *self,
     const gchar *text)
 {
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
-  g_return_if_fail (EMPATHY_IS_LIVE_SEARCH (self));
+  g_return_if_fail (TPAW_IS_LIVE_SEARCH (self));
   g_return_if_fail (text != NULL);
 
   gtk_entry_set_text (GTK_ENTRY (priv->search_entry), text);
 }
 
 /**
- * empathy_live_search_match:
- * @self: a #EmpathyLiveSearch
+ * tpaw_live_search_match:
+ * @self: a #TpawLiveSearch
  * @string: a string where to search, must be valid UTF-8.
  *
  * Search if one of the words in @string string starts with the current text
@@ -692,27 +692,27 @@ empathy_live_search_set_text (EmpathyLiveSearch *self,
  *
  **/
 gboolean
-empathy_live_search_match (EmpathyLiveSearch *self,
+tpaw_live_search_match (TpawLiveSearch *self,
     const gchar *string)
 {
-  EmpathyLiveSearchPriv *priv;
+  TpawLiveSearchPriv *priv;
 
-  g_return_val_if_fail (EMPATHY_IS_LIVE_SEARCH (self), FALSE);
+  g_return_val_if_fail (TPAW_IS_LIVE_SEARCH (self), FALSE);
 
   priv = GET_PRIV (self);
 
-  return empathy_live_search_match_words (string, priv->stripped_words);
+  return tpaw_live_search_match_words (string, priv->stripped_words);
 }
 
 gboolean
-empathy_live_search_match_string (const gchar *string,
+tpaw_live_search_match_string (const gchar *string,
     const gchar *prefix)
 {
   GPtrArray *words;
   gboolean match;
 
-  words = empathy_live_search_strip_utf8_string (prefix);
-  match = empathy_live_search_match_words (string, words);
+  words = tpaw_live_search_strip_utf8_string (prefix);
+  match = tpaw_live_search_match_words (string, words);
   if (words != NULL)
     g_ptr_array_unref (words);
 
@@ -720,9 +720,9 @@ empathy_live_search_match_string (const gchar *string,
 }
 
 GPtrArray *
-empathy_live_search_get_words (EmpathyLiveSearch *self)
+tpaw_live_search_get_words (TpawLiveSearch *self)
 {
-  EmpathyLiveSearchPriv *priv = GET_PRIV (self);
+  TpawLiveSearchPriv *priv = GET_PRIV (self);
 
   return priv->stripped_words;
 }
diff --git a/tp-account-widgets/tpaw-live-search.h b/tp-account-widgets/tpaw-live-search.h
new file mode 100644
index 0000000..50aad92
--- /dev/null
+++ b/tp-account-widgets/tpaw-live-search.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ * Copyright (C) 2007-2010 Nokia Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Authors: Felix Kaser <felix kaser collabora co uk>
+ *          Xavier Claessens <xavier claessens collabora co uk>
+ *          Claudio Saavedra <csaavedra igalia com>
+ */
+
+#ifndef __TPAW_LIVE_SEARCH_H__
+#define __TPAW_LIVE_SEARCH_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define TPAW_TYPE_LIVE_SEARCH         (tpaw_live_search_get_type ())
+#define TPAW_LIVE_SEARCH(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TPAW_TYPE_LIVE_SEARCH, 
TpawLiveSearch))
+#define TPAW_LIVE_SEARCH_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), TPAW_TYPE_LIVE_SEARCH, 
TpawLiveSearchClass))
+#define TPAW_IS_LIVE_SEARCH(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TPAW_TYPE_LIVE_SEARCH))
+#define TPAW_IS_LIVE_SEARCH_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TPAW_TYPE_LIVE_SEARCH))
+#define TPAW_LIVE_SEARCH_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TPAW_TYPE_LIVE_SEARCH, 
TpawLiveSearchClass))
+
+typedef struct _TpawLiveSearch      TpawLiveSearch;
+typedef struct _TpawLiveSearchClass TpawLiveSearchClass;
+
+struct _TpawLiveSearch {
+  GtkHBox parent;
+
+  /*<private>*/
+  gpointer priv;
+};
+
+struct _TpawLiveSearchClass {
+  GtkHBoxClass parent_class;
+};
+
+GType tpaw_live_search_get_type (void) G_GNUC_CONST;
+GtkWidget *tpaw_live_search_new (GtkWidget *hook);
+
+GtkWidget *tpaw_live_search_get_hook_widget (TpawLiveSearch *self);
+void tpaw_live_search_set_hook_widget (TpawLiveSearch *self,
+    GtkWidget *hook);
+
+const gchar *tpaw_live_search_get_text (TpawLiveSearch *self);
+void tpaw_live_search_set_text (TpawLiveSearch *self,
+    const gchar *text);
+
+gboolean tpaw_live_search_match (TpawLiveSearch *self,
+    const gchar *string);
+
+GPtrArray * tpaw_live_search_strip_utf8_string (const gchar *string);
+
+gboolean tpaw_live_search_match_words (const gchar *string,
+    GPtrArray *words);
+
+GPtrArray * tpaw_live_search_get_words (TpawLiveSearch *self);
+
+/* Made public for unit tests */
+gboolean tpaw_live_search_match_string (const gchar *string,
+   const gchar *prefix);
+
+G_END_DECLS
+
+#endif /* __TPAW_LIVE_SEARCH_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]