diff options
author | Alan Fitton <ajf@eth0.org.uk> | 2011-09-18 16:21:04 +0000 |
---|---|---|
committer | Alan Fitton <ajf@eth0.org.uk> | 2011-09-18 16:21:04 +0000 |
commit | 79cd86dbfd5b2ea0963c84b48088ec189acfc795 (patch) | |
tree | 535769200823fdaa1fec9795fe986668cb33bdee /src/trg-stats-dialog.c | |
parent | 63763bb00502e3c235e478ec50e097904c774696 (diff) |
Big changeset, may break stuff. Unfortunately you can't magically jump into the UI thread using gdk_threads_enter/leave() on Windows, the only way is to schedule a callback using g_idle_add. This required a lot of reworking. Good news, Windows support actually works now \o/
Diffstat (limited to 'src/trg-stats-dialog.c')
-rw-r--r-- | src/trg-stats-dialog.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/trg-stats-dialog.c b/src/trg-stats-dialog.c index 9ecbc28..5688083 100644 --- a/src/trg-stats-dialog.c +++ b/src/trg-stats-dialog.c @@ -23,7 +23,6 @@ #include <curl/curl.h> #include "hig.h" -#include "dispatch.h" #include "requests.h" #include "json.h" #include "util.h" @@ -63,8 +62,7 @@ struct _TrgStatsDialogPrivate { static GObject *instance = NULL; static gboolean trg_update_stats_timerfunc(gpointer data); -static void on_stats_reply(JsonObject * response, int status, - gpointer data); +static gboolean on_stats_reply(gpointer data); static void trg_stats_dialog_get_property(GObject * object, guint property_id, @@ -87,6 +85,7 @@ trg_stats_dialog_set_property(GObject * object, guint property_id, break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + break; } } @@ -188,23 +187,21 @@ static void update_time_stat(JsonObject * args, GtkTreeRowReference * rr, update_statistic(rr, session_val, cumulat_val); } -static void on_stats_reply(JsonObject * response, int status, - gpointer data) +static gboolean on_stats_reply(gpointer data) { + trg_response *response = (trg_response*)data; TrgStatsDialogPrivate *priv; JsonObject *args; - if (!TRG_IS_STATS_DIALOG(data)) { - response_unref(response); - return; + if (!TRG_IS_STATS_DIALOG(response->cb_data)) { + trg_response_free(response); + return FALSE; } - gdk_threads_enter(); - - priv = TRG_STATS_DIALOG_GET_PRIVATE(data); + priv = TRG_STATS_DIALOG_GET_PRIVATE(response->cb_data); - if (status == CURLE_OK) { - args = get_arguments(response); + if (response->status == CURLE_OK) { + args = get_arguments(response->obj); update_size_stat(args, priv->rr_up, "uploadedBytes"); update_size_stat(args, priv->rr_down, "downloadedBytes"); @@ -215,12 +212,11 @@ static void on_stats_reply(JsonObject * response, int status, if (trg_client_is_connected(priv->client)) g_timeout_add_seconds(STATS_UPDATE_INTERVAL, trg_update_stats_timerfunc, data); } else { - trg_error_dialog(GTK_WINDOW(data), status, response); + trg_error_dialog(GTK_WINDOW(data), response); } - gdk_threads_leave(); - - response_unref(response); + trg_response_free(response); + return FALSE; } static gboolean trg_update_stats_timerfunc(gpointer data) |