diff options
author | Vitaly Minko <vitaly.minko@gmail.com> | 2010-11-12 22:47:51 +0800 |
---|---|---|
committer | Vitaly Minko <vitaly.minko@gmail.com> | 2010-11-12 22:47:51 +0800 |
commit | 875bf697d54f1c4ca98478ded849bc733828f758 (patch) | |
tree | e623330e91d22c72a3293baabde6d2cfe4b5450a /libempathy-gtk/empathy-account-chooser.c | |
parent | 18d649cbfd8eda7678957a3d2a76b9bb8681a981 (diff) | |
download | gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.tar gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.tar.gz gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.tar.bz2 gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.tar.lz gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.tar.xz gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.tar.zst gsoc2013-empathy-875bf697d54f1c4ca98478ded849bc733828f758.zip |
Make AccountChooser-related code simpler and clearer (re #633481).
Diffstat (limited to 'libempathy-gtk/empathy-account-chooser.c')
-rw-r--r-- | libempathy-gtk/empathy-account-chooser.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index f077827fb..f1c0ec6b4 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -80,6 +80,30 @@ typedef struct { GtkTreeIter *iter; } FilterResultCallbackData; +static FilterResultCallbackData * +filter_result_callback_data_new (EmpathyAccountChooser *chooser, + TpAccount *account, + GtkTreeIter *iter) +{ + FilterResultCallbackData *data; + + data = g_slice_new0 (FilterResultCallbackData); + data->chooser = g_object_ref (chooser); + data->account = g_object_ref (account); + data->iter = gtk_tree_iter_copy (iter); + + return data; +} + +static void +filter_result_callback_data_free (FilterResultCallbackData *data) +{ + g_object_unref (data->chooser); + g_object_unref (data->account); + gtk_tree_iter_free (data->iter); + g_slice_free (FilterResultCallbackData, data); +} + /* Distinguishes between store entries which are actually accounts, and special * items like the "All" entry and the separator below it, so they can be sorted * correctly. Higher-numbered entries will sort earlier. @@ -765,8 +789,7 @@ account_chooser_filter_ready_cb (gboolean is_enabled, } g_object_unref (account); - g_free (iter); - g_slice_free (FilterResultCallbackData, fr_data); + filter_result_callback_data_free (fr_data); } static void @@ -792,10 +815,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, if (account == NULL) return; - data = g_slice_new0 (FilterResultCallbackData); - data->chooser = chooser; - data->account = account; - data->iter = g_memdup (iter, sizeof (GtkTreeIter)); + data = filter_result_callback_data_new (chooser, account, iter); if (priv->filter) priv->filter (account, account_chooser_filter_ready_cb, |