empathy r1863 - trunk/libempathy-gtk
- From: xclaesse svn gnome org
- To: svn-commits-list gnome org
- Subject: empathy r1863 - trunk/libempathy-gtk
- Date: Fri, 21 Nov 2008 16:21:52 +0000 (UTC)
Author: xclaesse
Date: Fri Nov 21 16:21:51 2008
New Revision: 1863
URL: http://svn.gnome.org/viewvc/empathy?rev=1863&view=rev
Log:
ft-manager: ft_manager_clear: use a GHashTableIter instead of creating a temporary GSList
Modified:
trunk/libempathy-gtk/empathy-ft-manager.c
Modified: trunk/libempathy-gtk/empathy-ft-manager.c
==============================================================================
--- trunk/libempathy-gtk/empathy-ft-manager.c (original)
+++ trunk/libempathy-gtk/empathy-ft-manager.c Fri Nov 21 16:21:51 2008
@@ -496,7 +496,6 @@
/* Removal */
gtk_list_store_remove (GTK_LIST_STORE (ft_manager->priv->model), &iter2);
- g_hash_table_remove (ft_manager->priv->tp_file_to_row_ref, tp_file);
g_object_unref (tp_file);
/* Actual selection */
@@ -516,41 +515,27 @@
}
static void
-ft_manager_clear_foreach_cb (gpointer key,
- gpointer value,
- gpointer user_data)
-{
- GSList **list = user_data;
- EmpathyTpFile *tp_file = key;
-
- switch (empathy_tp_file_get_state (tp_file))
- {
- case EMP_FILE_TRANSFER_STATE_COMPLETED:
- case EMP_FILE_TRANSFER_STATE_CANCELLED:
- *list = g_slist_append (*list, tp_file);
- break;
- default:
- break;
- }
-}
-
-static void
ft_manager_clear (EmpathyFTManager *ft_manager)
{
- GSList *closed_files = NULL;
- GSList *l;
+ GHashTableIter iter;
+ gpointer key, value;
DEBUG ("Clearing file transfer list");
- g_hash_table_foreach (ft_manager->priv->tp_file_to_row_ref,
- ft_manager_clear_foreach_cb, &closed_files);
-
- for (l = closed_files; l; l = l->next)
- {
- ft_manager_remove_file_from_list (ft_manager, l->data);
+ /* Remove completed and cancelled transfers */
+ g_hash_table_iter_init (&iter, ft_manager->priv->tp_file_to_row_ref);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ EmpathyTpFile *tp_file = EMPATHY_TP_FILE (key);
+ EmpFileTransferState state;
+
+ state = empathy_tp_file_get_state (tp_file);
+ if (state == EMP_FILE_TRANSFER_STATE_COMPLETED ||
+ state == EMP_FILE_TRANSFER_STATE_CANCELLED)
+ {
+ ft_manager_remove_file_from_list (ft_manager, tp_file);
+ }
}
-
- g_slist_free (closed_files);
}
static void
@@ -587,9 +572,14 @@
}
if (remove)
- ft_manager_remove_file_from_list (ft_manager, tp_file);
+ {
+ ft_manager_remove_file_from_list (ft_manager, tp_file);
+ g_hash_table_remove (ft_manager->priv->tp_file_to_row_ref, tp_file);
+ }
else
- ft_manager_update_ft_row (ft_manager, tp_file);
+ {
+ ft_manager_update_ft_row (ft_manager, tp_file);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]