diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2009-08-05 02:00:54 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-08-22 21:20:44 +0800 |
commit | bc7cb0959c31644d271fc9945d17cd961dece03d (patch) | |
tree | 653ece0b28dfaa11f76f0e11f3f0de444865f771 /libempathy-gtk/empathy-protocol-chooser.c | |
parent | caa57e8e5e3fbbad790e3825597a5b3ddd2f3175 (diff) | |
download | gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.tar gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.tar.gz gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.tar.bz2 gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.tar.lz gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.tar.xz gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.tar.zst gsoc2013-empathy-bc7cb0959c31644d271fc9945d17cd961dece03d.zip |
Support changing the filter func on the fly
Diffstat (limited to 'libempathy-gtk/empathy-protocol-chooser.c')
-rw-r--r-- | libempathy-gtk/empathy-protocol-chooser.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c index 9ba28baf6..70ba60b06 100644 --- a/libempathy-gtk/empathy-protocol-chooser.c +++ b/libempathy-gtk/empathy-protocol-chooser.c @@ -59,7 +59,7 @@ typedef struct { GtkListStore *store; - GtkTreeModel *filter_model; + gboolean dispose_run; EmpathyConnectionManagers *cms; @@ -232,9 +232,6 @@ protocol_chooser_constructed (GObject *object) G_TYPE_OBJECT, /* CM */ G_TYPE_POINTER); /* protocol */ - priv->filter_model = gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->store), - NULL); - /* Set the protocol sort function */ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->store), COL_PROTOCOL, @@ -245,7 +242,7 @@ protocol_chooser_constructed (GObject *object) GTK_SORT_ASCENDING); gtk_combo_box_set_model (GTK_COMBO_BOX (object), - GTK_TREE_MODEL (priv->filter_model)); + GTK_TREE_MODEL (priv->store)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, FALSE); @@ -295,12 +292,6 @@ protocol_chooser_dispose (GObject *object) priv->dispose_run = TRUE; - if (priv->filter_model) - { - g_object_unref (priv->filter_model); - priv->filter_model = NULL; - } - if (priv->store) { g_object_unref (priv->store); @@ -365,20 +356,25 @@ empathy_protocol_chooser_dup_selected ( EmpathyProtocolChooser *protocol_chooser, TpConnectionManagerProtocol **protocol) { - EmpathyProtocolChooserPriv *priv = GET_PRIV (protocol_chooser); GtkTreeIter iter; TpConnectionManager *cm = NULL; + GtkTreeModel *cur_model; g_return_val_if_fail (EMPATHY_IS_PROTOCOL_CHOOSER (protocol_chooser), NULL); + /* get the current model from the chooser, as we could either be filtering + * or not. + */ + cur_model = gtk_combo_box_get_model (GTK_COMBO_BOX (protocol_chooser)); + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (protocol_chooser), &iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (priv->filter_model), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (cur_model), &iter, COL_CM, &cm, -1); if (protocol != NULL) - gtk_tree_model_get (GTK_TREE_MODEL (priv->filter_model), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (cur_model), &iter, COL_PROTOCOL, protocol, -1); } @@ -406,6 +402,7 @@ empathy_protocol_chooser_set_visible (EmpathyProtocolChooser *protocol_chooser, gpointer user_data) { EmpathyProtocolChooserPriv *priv; + GtkTreeModel *filter_model; g_return_if_fail (EMPATHY_IS_PROTOCOL_CHOOSER (protocol_chooser)); @@ -413,9 +410,16 @@ empathy_protocol_chooser_set_visible (EmpathyProtocolChooser *protocol_chooser, priv->filter_func = func; priv->filter_user_data = user_data; + filter_model = gtk_tree_model_filter_new (GTK_TREE_MODEL (priv->store), + NULL); + gtk_combo_box_set_model (GTK_COMBO_BOX (protocol_chooser), filter_model); + g_object_unref (filter_model); + gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER - (priv->filter_model), protocol_chooser_filter_visible_func, + (filter_model), protocol_chooser_filter_visible_func, protocol_chooser, NULL); - gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model)); + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model)); + + gtk_combo_box_set_active (GTK_COMBO_BOX (protocol_chooser), 0); } |