diff options
-rw-r--r-- | src/trg-client.c | 12 | ||||
-rw-r--r-- | src/trg-client.h | 1 | ||||
-rw-r--r-- | src/trg-torrent-model.c | 17 | ||||
-rw-r--r-- | src/trg-torrent-model.h | 1 | ||||
-rw-r--r-- | src/trg-torrent-tree-view.c | 4 |
5 files changed, 29 insertions, 6 deletions
diff --git a/src/trg-client.c b/src/trg-client.c index 3dbcea1..1a566fd 100644 --- a/src/trg-client.c +++ b/src/trg-client.c @@ -73,6 +73,7 @@ struct _TrgClientPrivate { GPrivate *tlsKey; gint configSerial; GMutex *configMutex; + GDateTime *updateTime; }; static void @@ -332,9 +333,20 @@ void trg_client_thread_pool_push(TrgClient *tc, gpointer data, GError **err) void trg_client_inc_serial(TrgClient *tc) { TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc); + + if (priv->updateTime) + g_date_time_unref(priv->updateTime); + + priv->updateTime = g_date_time_new_now_local (); priv->updateSerial++; } +gint64 trg_client_get_last_update_unix_time(TrgClient *tc) +{ + TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc); + return priv->updateTime ? g_date_time_to_unix(priv->updateTime) : -1; +} + gint64 trg_client_get_serial(TrgClient *tc) { TrgClientPrivate *priv = TRG_CLIENT_GET_PRIVATE(tc); diff --git a/src/trg-client.h b/src/trg-client.h index a35b9cb..bd596ab 100644 --- a/src/trg-client.h +++ b/src/trg-client.h @@ -119,6 +119,7 @@ gchar *trg_client_get_username(TrgClient *tc); gchar *trg_client_get_url(TrgClient *tc); gchar *trg_client_get_session_id(TrgClient *tc); void trg_client_set_session_id(TrgClient *tc, gchar *session_id); +gint64 trg_client_get_last_update_unix_time(TrgClient *tc); #ifndef CURL_NO_SSL gboolean trg_client_get_ssl(TrgClient *tc); #endif diff --git a/src/trg-torrent-model.c b/src/trg-torrent-model.c index 39aa65d..4cd6cd0 100644 --- a/src/trg-torrent-model.c +++ b/src/trg-torrent-model.c @@ -58,7 +58,7 @@ static void trg_torrent_model_dispose(GObject * object) } static void -update_torrent_iter(TrgTorrentModel * model, gint64 rpcv, gint64 serial, +update_torrent_iter(TrgClient *tc, TrgTorrentModel * model, gint64 rpcv, GtkTreeIter * iter, JsonObject * t, trg_torrent_model_update_stats * stats); @@ -178,6 +178,7 @@ static void trg_torrent_model_init(TrgTorrentModel * self) column_types[TORRENT_COLUMN_PEERS_TO_US] = G_TYPE_INT64; column_types[TORRENT_COLUMN_TRACKERHOST] = G_TYPE_STRING; column_types[TORRENT_COLUMN_QUEUE_POSITION] = G_TYPE_INT64; + column_types[TORRENT_COLUMN_LASTACTIVE] = G_TYPE_INT64; gtk_list_store_set_column_types(GTK_LIST_STORE(self), TORRENT_COLUMN_COLUMNS, column_types); @@ -228,7 +229,7 @@ void trg_torrent_model_remove_all(TrgTorrentModel *model) } static void -update_torrent_iter(TrgTorrentModel * model, gint64 rpcv, gint64 serial, +update_torrent_iter(TrgClient *tc, TrgTorrentModel * model, gint64 rpcv, GtkTreeIter * iter, JsonObject * t, trg_torrent_model_update_stats * stats) { @@ -294,7 +295,7 @@ update_torrent_iter(TrgTorrentModel * model, gint64 rpcv, gint64 serial, -1); gtk_list_store_set(ls, iter, TORRENT_COLUMN_ID, id, -1); gtk_list_store_set(ls, iter, TORRENT_COLUMN_JSON, t, -1); - gtk_list_store_set(ls, iter, TORRENT_COLUMN_UPDATESERIAL, serial, -1); + gtk_list_store_set(ls, iter, TORRENT_COLUMN_UPDATESERIAL, trg_client_get_serial(tc), -1); gtk_list_store_set(ls, iter, TORRENT_COLUMN_ADDED, torrent_get_added_date(t), -1); @@ -352,9 +353,13 @@ update_torrent_iter(TrgTorrentModel * model, gint64 rpcv, gint64 serial, TORRENT_COLUMN_ID, id, TORRENT_COLUMN_JSON, t, TORRENT_COLUMN_TRACKERHOST, firstTracker ? tracker_stats_get_host(firstTracker) : "", - TORRENT_COLUMN_UPDATESERIAL, serial, -1); + TORRENT_COLUMN_UPDATESERIAL, trg_client_get_serial(tc), -1); #endif + if (newFlags & TORRENT_FLAG_ACTIVE) + gtk_list_store_set(ls, iter, TORRENT_COLUMN_LASTACTIVE, + trg_client_get_last_update_unix_time(tc), -1); + if (lastJson) json_object_unref(lastJson); @@ -477,7 +482,7 @@ void trg_torrent_model_update(TrgTorrentModel * model, TrgClient * tc, if (!result) { gtk_list_store_append(GTK_LIST_STORE(model), &iter); - update_torrent_iter(model, rpcv, trg_client_get_serial(tc), &iter, t, stats); + update_torrent_iter(tc, model, rpcv, &iter, t, stats); path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &iter); rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(model), path); @@ -495,7 +500,7 @@ void trg_torrent_model_update(TrgTorrentModel * model, TrgClient * tc, if (path) { if (gtk_tree_model_get_iter (GTK_TREE_MODEL(model), &iter, path)) { - update_torrent_iter(model, rpcv, trg_client_get_serial(tc), &iter, t, + update_torrent_iter(tc, model, rpcv, &iter, t, stats); } gtk_tree_path_free(path); diff --git a/src/trg-torrent-model.h b/src/trg-torrent-model.h index 8d192a9..a71b0e2 100644 --- a/src/trg-torrent-model.h +++ b/src/trg-torrent-model.h @@ -112,6 +112,7 @@ enum { TORRENT_COLUMN_FROMDHT, TORRENT_COLUMN_TRACKERHOST, TORRENT_COLUMN_QUEUE_POSITION, + TORRENT_COLUMN_LASTACTIVE, TORRENT_COLUMN_COLUMNS }; diff --git a/src/trg-torrent-tree-view.c b/src/trg-torrent-tree-view.c index f426c26..8056632 100644 --- a/src/trg-torrent-tree-view.c +++ b/src/trg-torrent-tree-view.c @@ -107,6 +107,10 @@ static void trg_torrent_tree_view_init(TrgTorrentTreeView * tttv) trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, TORRENT_COLUMN_DONE_DATE, _("Completed"), "done-date", TRG_COLUMN_EXTRA); + trg_tree_view_reg_column(ttv, TRG_COLTYPE_EPOCH, + TORRENT_COLUMN_LASTACTIVE, _("Last Active"), + "last-active", TRG_COLUMN_EXTRA); + gtk_tree_view_set_search_column(GTK_TREE_VIEW(tttv), TORRENT_COLUMN_NAME); |