summaryrefslogtreecommitdiff
path: root/src/trg-stats-dialog.c
diff options
context:
space:
mode:
authorGravatar Alan F <ajf8@users.noreply.github.com>2016-05-13 14:44:24 +0100
committerGravatar Alan F <ajf8@users.noreply.github.com>2016-05-13 14:44:24 +0100
commit3689dda548af18b43c65892b2520a9943bd0dbd7 (patch)
tree9bb3c9499080a9452713f48cbc2616c1211e53c7 /src/trg-stats-dialog.c
parent8fab1a38681901c3e38ca96d5b3f7ff1516e0c0e (diff)
parentdf494abb4f46db333808b39c2651fbfee5e78cbb (diff)
Merge pull request #24 from DriverXX/master
GUI improvements
Diffstat (limited to 'src/trg-stats-dialog.c')
-rw-r--r--src/trg-stats-dialog.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/trg-stats-dialog.c b/src/trg-stats-dialog.c
index 920b36c..c23628d 100644
--- a/src/trg-stats-dialog.c
+++ b/src/trg-stats-dialog.c
@@ -60,7 +60,7 @@ struct _TrgStatsDialogPrivate {
TrgMainWindow *parent;
GtkWidget *tv;
GtkListStore *model;
- GtkTreeRowReference *rr_up, *rr_down, *rr_files_added,
+ GtkTreeRowReference *rr_down, *rr_up, *rr_ratio, *rr_files_added,
*rr_session_count, *rr_active, *rr_version;
};
@@ -160,8 +160,7 @@ update_int_stat(JsonObject * args, GtkTreeRowReference * rr,
}
static void
-update_size_stat(JsonObject * args, GtkTreeRowReference * rr,
- gchar * jsonKey)
+update_size_stat(JsonObject * args, GtkTreeRowReference * rr, gchar * jsonKey)
{
gchar session_val[32];
gchar cumulat_val[32];
@@ -177,6 +176,23 @@ update_size_stat(JsonObject * args, GtkTreeRowReference * rr,
}
static void
+update_ratio_stat(JsonObject * args, GtkTreeRowReference * rr, gchar * jsonKeyA, gchar * jsonKeyB)
+{
+ gchar session_val[32];
+ gchar cumulat_val[32];
+
+ trg_strlratio(session_val,
+ json_object_get_double_member(get_session_arg(args), jsonKeyA) /
+ json_object_get_double_member(get_session_arg(args), jsonKeyB) );
+
+ trg_strlratio(cumulat_val,
+ json_object_get_double_member(get_cumulat_arg(args), jsonKeyA) /
+ json_object_get_double_member(get_cumulat_arg(args), jsonKeyB) );
+
+ update_statistic(rr, session_val, cumulat_val);
+}
+
+static void
update_time_stat(JsonObject * args, GtkTreeRowReference * rr,
gchar * jsonKey)
{
@@ -218,6 +234,7 @@ static gboolean on_stats_reply(gpointer data)
update_size_stat(args, priv->rr_up, "uploadedBytes");
update_size_stat(args, priv->rr_down, "downloadedBytes");
+ update_ratio_stat(args, priv->rr_ratio, "uploadedBytes", "downloadedBytes");
update_int_stat(args, priv->rr_files_added, "filesAdded");
update_int_stat(args, priv->rr_session_count, "sessionCount");
update_time_stat(args, priv->rr_active, "secondsActive");
@@ -300,6 +317,8 @@ static GObject *trg_stats_dialog_constructor(GType type,
stats_dialog_add_statistic(priv->model, _("Download Total"));
priv->rr_up =
stats_dialog_add_statistic(priv->model, _("Upload Total"));
+ priv->rr_ratio =
+ stats_dialog_add_statistic(priv->model, _("Ratio"));
priv->rr_files_added =
stats_dialog_add_statistic(priv->model, _("Files Added"));
priv->rr_session_count =