summaryrefslogtreecommitdiff
path: root/src/trg-torrent-model.c
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-02-12 11:51:23 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-02-12 11:51:23 +0000
commit2d989e3e693f41f654f56972bc3c742828f409b6 (patch)
tree2c2124594342c47cf113e2bb40dfda5b85469516 /src/trg-torrent-model.c
parent78b168dbc30d9540b96254b77cfeaef3619b540c (diff)
torrent added notifications, make notifications configurable. unref id arrays if the user cancels an action.
Diffstat (limited to 'src/trg-torrent-model.c')
-rw-r--r--src/trg-torrent-model.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/trg-torrent-model.c b/src/trg-torrent-model.c
index cc58750..a3c9398 100644
--- a/src/trg-torrent-model.c
+++ b/src/trg-torrent-model.c
@@ -32,6 +32,7 @@
enum {
TMODEL_TORRENT_COMPLETED,
+ TMODEL_TORRENT_ADDED,
TMODEL_SIGNAL_COUNT
};
@@ -69,6 +70,14 @@ static void trg_torrent_model_class_init(TrgTorrentModelClass * klass)
NULL, g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1, G_TYPE_POINTER);
+ signals[TMODEL_TORRENT_ADDED] =
+ g_signal_new("torrent-added",
+ G_TYPE_FROM_CLASS(object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(TrgTorrentModelClass,
+ torrent_added), NULL,
+ NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
}
static void trg_torrent_model_count_peers(TrgTorrentModel * model,
@@ -316,10 +325,14 @@ void trg_torrent_model_update(TrgTorrentModel * model, trg_client * tc,
t = json_array_get_object_element(newTorrents, i);
if (first == TRUE
- || find_existing_torrent_item(model, t, &iter) == FALSE)
+ || find_existing_torrent_item(model, t, &iter) == FALSE) {
gtk_list_store_append(GTK_LIST_STORE(model), &iter);
-
- update_torrent_iter(tc->updateSerial, model, &iter, t, stats);
+ update_torrent_iter(tc->updateSerial, model, &iter, t, stats);
+ if (!first)
+ g_signal_emit(model, signals[TMODEL_TORRENT_ADDED], 0, &iter);
+ } else {
+ update_torrent_iter(tc->updateSerial, model, &iter, t, stats);
+ }
}
json_array_ref(newTorrents);