aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2009-04-24 00:54:21 +0800
committerXavier Claessens <xclaesse@gmail.com>2009-04-25 03:21:28 +0800
commit063625395264373ce915fac0ac03562527c7bf51 (patch)
treea74015a59c10cee83bf636e4b2ca00fde4c1a5f6 /src
parent207f9d47f2630cf9c8919d41bd2a246103520c14 (diff)
downloadgsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.tar
gsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.tar.gz
gsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.tar.bz2
gsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.tar.lz
gsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.tar.xz
gsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.tar.zst
gsoc2013-empathy-063625395264373ce915fac0ac03562527c7bf51.zip
Display the file transfer speed and calculate remaining time more dynamically.
Diffstat (limited to 'src')
-rw-r--r--src/empathy-ft-manager.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/empathy-ft-manager.c b/src/empathy-ft-manager.c
index 98e58d4f3..d3d22fbd8 100644
--- a/src/empathy-ft-manager.c
+++ b/src/empathy-ft-manager.c
@@ -200,6 +200,7 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager,
TpFileTransferState state;
TpFileTransferStateChangeReason reason;
gboolean incoming;
+ gdouble speed;
row_ref = ft_manager_get_row_from_tp_file (ft_manager, tp_file);
g_return_if_fail (row_ref != NULL);
@@ -210,6 +211,7 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager,
total_size = empathy_tp_file_get_size (tp_file);
state = empathy_tp_file_get_state (tp_file, &reason);
incoming = empathy_tp_file_is_incoming (tp_file);
+ speed = empathy_tp_file_get_speed (tp_file);
switch (state)
{
@@ -234,6 +236,7 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager,
{
gchar *total_size_str;
gchar *transferred_bytes_str;
+ gchar *speed_str;
if (total_size == EMPATHY_TP_FILE_UNKNOWN_SIZE)
total_size_str = g_strdup (C_("file size", "Unknown"));
@@ -241,13 +244,15 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager,
total_size_str = g_format_size_for_display (total_size);
transferred_bytes_str = g_format_size_for_display (transferred_bytes);
+ speed_str = g_format_size_for_display (speed);
/* translators: first %s is the transferred size, second %s is
* the total file size */
- second_line = g_strdup_printf (_("%s of %s"), transferred_bytes_str,
- total_size_str);
+ second_line = g_strdup_printf (_("%s of %s at %s/s"),
+ transferred_bytes_str, total_size_str, speed_str);
g_free (transferred_bytes_str);
g_free (total_size_str);
+ g_free (speed_str);
}
else
@@ -301,8 +306,10 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager,
if (remaining < 0)
{
- if (state != TP_FILE_TRANSFER_STATE_COMPLETED &&
- state != TP_FILE_TRANSFER_STATE_CANCELLED)
+ if (state == TP_FILE_TRANSFER_STATE_OPEN)
+ remaining_str = g_strdup (C_("remaining time", "Stalled"));
+ else if (state != TP_FILE_TRANSFER_STATE_COMPLETED &&
+ state != TP_FILE_TRANSFER_STATE_CANCELLED)
remaining_str = g_strdup (C_("remaining time", "Unknown"));
}
else
@@ -334,9 +341,8 @@ ft_manager_update_ft_row (EmpathyFTManager *ft_manager,
}
static void
-ft_manager_transferred_bytes_changed_cb (EmpathyTpFile *tp_file,
- GParamSpec *pspec,
- EmpathyFTManager *ft_manager)
+ft_manager_refresh_cb (EmpathyTpFile *tp_file,
+ EmpathyFTManager *ft_manager)
{
ft_manager_update_ft_row (ft_manager, tp_file);
}
@@ -840,8 +846,8 @@ ft_manager_add_tp_file_to_list (EmpathyFTManager *ft_manager,
ft_manager_update_ft_row (ft_manager, tp_file);
g_signal_connect (tp_file, "notify::state",
G_CALLBACK (ft_manager_state_changed_cb), ft_manager);
- g_signal_connect (tp_file, "notify::transferred-bytes",
- G_CALLBACK (ft_manager_transferred_bytes_changed_cb), ft_manager);
+ g_signal_connect (tp_file, "refresh",
+ G_CALLBACK (ft_manager_refresh_cb), ft_manager);
gtk_window_present (GTK_WINDOW (ft_manager->priv->window));
}