aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-19 21:44:22 +0800
committerPhilip Withnall <philip.withnall@collabora.co.uk>2010-08-20 17:32:28 +0800
commit7906c05973b29175938775fa5fabc3e3f347b372 (patch)
tree9acfd9388a06dabf72bed821d4b955c075bc61e7 /libempathy-gtk
parent4a38890ece9f9e0ef045c689d79d13e00515d98c (diff)
downloadgsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.tar
gsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.tar.gz
gsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.tar.bz2
gsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.tar.lz
gsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.tar.xz
gsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.tar.zst
gsoc2013-empathy-7906c05973b29175938775fa5fabc3e3f347b372.zip
Bug 627219 — Link dialog search doesn't work
Allow the store of an EmpathyIndividualView to be changed after construction, and cope with recreating the filter when this happens. Closes: bgo#627219
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-individual-linker.c6
-rw-r--r--libempathy-gtk/empathy-individual-view.c95
-rw-r--r--libempathy-gtk/empathy-individual-view.h5
3 files changed, 81 insertions, 25 deletions
diff --git a/libempathy-gtk/empathy-individual-linker.c b/libempathy-gtk/empathy-individual-linker.c
index d4bad83b7..8ca6c4a3a 100644
--- a/libempathy-gtk/empathy-individual-linker.c
+++ b/libempathy-gtk/empathy-individual-linker.c
@@ -557,8 +557,8 @@ empathy_individual_linker_set_start_individual (EmpathyIndividualLinker *self,
priv->start_individual = g_object_ref (individual);
priv->new_individual = folks_individual_new (
folks_individual_get_personas (individual));
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->individual_view),
- GTK_TREE_MODEL (priv->individual_store));
+ empathy_individual_view_set_store (priv->individual_view,
+ priv->individual_store);
}
else
{
@@ -567,7 +567,7 @@ empathy_individual_linker_set_start_individual (EmpathyIndividualLinker *self,
/* We only display Individuals in the individual view if we have a
* new_individual to link them into */
- gtk_tree_view_set_model (GTK_TREE_VIEW (priv->individual_view), NULL);
+ empathy_individual_view_set_store (priv->individual_view, NULL);
}
empathy_individual_widget_set_individual (
diff --git a/libempathy-gtk/empathy-individual-view.c b/libempathy-gtk/empathy-individual-view.c
index 28c3069ab..d2562fcb8 100644
--- a/libempathy-gtk/empathy-individual-view.c
+++ b/libempathy-gtk/empathy-individual-view.c
@@ -32,10 +32,12 @@
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
-#include <folks/folks.h>
#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
+#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
+
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-individual-manager.h>
#include <libempathy/empathy-contact-groups.h>
@@ -1482,6 +1484,7 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
/* check alias name */
str = folks_individual_get_alias (individual);
+
if (empathy_live_search_match (live, str))
return TRUE;
@@ -1493,7 +1496,10 @@ individual_view_is_visible_individual (EmpathyIndividualView *self,
gchar *dup_str = NULL;
gboolean visible;
- str = folks_persona_get_uid (l->data);
+ if (!TPF_IS_PERSONA (l->data))
+ continue;
+
+ str = folks_persona_get_display_id (l->data);
p = strstr (str, "@");
if (p != NULL)
str = dup_str = g_strndup (str, p - str);
@@ -1588,28 +1594,10 @@ static void
individual_view_constructed (GObject *object)
{
EmpathyIndividualView *view = EMPATHY_INDIVIDUAL_VIEW (object);
- EmpathyIndividualViewPriv *priv = GET_PRIV (view);
GtkCellRenderer *cell;
GtkTreeViewColumn *col;
guint i;
- priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (
- GTK_TREE_MODEL (priv->store), NULL));
- gtk_tree_model_filter_set_visible_func (priv->filter,
- individual_view_filter_visible_func, view, NULL);
-
- g_signal_connect (priv->filter, "row-has-child-toggled",
- G_CALLBACK (individual_view_row_has_child_toggled_cb), view);
- gtk_tree_view_set_model (GTK_TREE_VIEW (view),
- GTK_TREE_MODEL (priv->filter));
-
- tp_g_signal_connect_object (priv->store, "row-changed",
- G_CALLBACK (individual_view_store_row_changed_cb), view, 0);
- tp_g_signal_connect_object (priv->store, "row-inserted",
- G_CALLBACK (individual_view_store_row_changed_cb), view, 0);
- tp_g_signal_connect_object (priv->store, "row-deleted",
- G_CALLBACK (individual_view_store_row_deleted_cb), view, 0);
-
/* Setup view */
g_object_set (view,
"headers-visible", FALSE,
@@ -1837,7 +1825,7 @@ individual_view_set_property (GObject *object,
switch (param_id)
{
case PROP_STORE:
- priv->store = g_value_dup_object (value);
+ empathy_individual_view_set_store (view, g_value_get_object (value));
break;
case PROP_VIEW_FEATURES:
individual_view_set_view_features (view, g_value_get_flags (value));
@@ -1895,7 +1883,7 @@ empathy_individual_view_class_init (EmpathyIndividualViewClass *klass)
"The store of the view",
"The store of the view",
EMPATHY_TYPE_INDIVIDUAL_STORE,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_VIEW_FEATURES,
g_param_spec_flags ("view-features",
@@ -2332,3 +2320,66 @@ empathy_individual_view_set_show_offline (EmpathyIndividualView *self,
g_object_notify (G_OBJECT (self), "show-offline");
gtk_tree_model_filter_refilter (priv->filter);
}
+
+EmpathyIndividualStore *
+empathy_individual_view_get_store (EmpathyIndividualView *self)
+{
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (self), NULL);
+
+ return GET_PRIV (self)->store;
+}
+
+void
+empathy_individual_view_set_store (EmpathyIndividualView *self,
+ EmpathyIndividualStore *store)
+{
+ EmpathyIndividualViewPriv *priv;
+
+ g_return_if_fail (EMPATHY_IS_INDIVIDUAL_VIEW (self));
+ g_return_if_fail (store == NULL || EMPATHY_IS_INDIVIDUAL_STORE (store));
+
+ priv = GET_PRIV (self);
+
+ /* Destroy the old filter and remove the old store */
+ if (priv->store != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (priv->store,
+ individual_view_store_row_changed_cb, self);
+ g_signal_handlers_disconnect_by_func (priv->store,
+ individual_view_store_row_deleted_cb, self);
+
+ g_signal_handlers_disconnect_by_func (priv->filter,
+ individual_view_row_has_child_toggled_cb, self);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self), NULL);
+ }
+
+ tp_clear_object (&priv->filter);
+ tp_clear_object (&priv->store);
+
+ /* Set the new store */
+ priv->store = store;
+
+ if (store != NULL)
+ {
+ g_object_ref (store);
+
+ /* Create a new filter */
+ priv->filter = GTK_TREE_MODEL_FILTER (gtk_tree_model_filter_new (
+ GTK_TREE_MODEL (priv->store), NULL));
+ gtk_tree_model_filter_set_visible_func (priv->filter,
+ individual_view_filter_visible_func, self, NULL);
+
+ g_signal_connect (priv->filter, "row-has-child-toggled",
+ G_CALLBACK (individual_view_row_has_child_toggled_cb), self);
+ gtk_tree_view_set_model (GTK_TREE_VIEW (self),
+ GTK_TREE_MODEL (priv->filter));
+
+ tp_g_signal_connect_object (priv->store, "row-changed",
+ G_CALLBACK (individual_view_store_row_changed_cb), self, 0);
+ tp_g_signal_connect_object (priv->store, "row-inserted",
+ G_CALLBACK (individual_view_store_row_changed_cb), self, 0);
+ tp_g_signal_connect_object (priv->store, "row-deleted",
+ G_CALLBACK (individual_view_store_row_deleted_cb), self, 0);
+ }
+}
diff --git a/libempathy-gtk/empathy-individual-view.h b/libempathy-gtk/empathy-individual-view.h
index 9d6cec0fe..003ff2ab3 100644
--- a/libempathy-gtk/empathy-individual-view.h
+++ b/libempathy-gtk/empathy-individual-view.h
@@ -105,5 +105,10 @@ void empathy_individual_view_set_show_offline (
gboolean empathy_individual_view_is_searching (
EmpathyIndividualView *view);
+EmpathyIndividualStore *empathy_individual_view_get_store (
+ EmpathyIndividualView *self);
+void empathy_individual_view_set_store (EmpathyIndividualView *self,
+ EmpathyIndividualStore *store);
+
G_END_DECLS
#endif /* __EMPATHY_INDIVIDUAL_VIEW_H__ */