From 8aacf43b3b4f21247a63b8301c952c6a8c98585e Mon Sep 17 00:00:00 2001 From: Alan Fitton Date: Fri, 18 Feb 2011 00:49:08 +0000 Subject: adding trackers now seems to work. change all tabs to whitespace. --- src/trg-stats-dialog.c | 201 ++++++++++++++++++++++++------------------------- 1 file changed, 100 insertions(+), 101 deletions(-) (limited to 'src/trg-stats-dialog.c') diff --git a/src/trg-stats-dialog.c b/src/trg-stats-dialog.c index 4c1d08c..c7d94b9 100644 --- a/src/trg-stats-dialog.c +++ b/src/trg-stats-dialog.c @@ -55,38 +55,38 @@ struct _TrgStatsDialogPrivate { GtkWidget *tv; GtkListStore *model; GtkTreeRowReference *rr_up, *rr_down, *rr_files_added, - *rr_session_count, *rr_active; + *rr_session_count, *rr_active; }; static GObject *instance = NULL; static gboolean trg_update_stats_timerfunc(gpointer data); static void on_stats_reply(JsonObject * response, int status, - gpointer data); + gpointer data); static void trg_stats_dialog_get_property(GObject * object, guint property_id, - GValue * value, GParamSpec * pspec) + GValue * value, GParamSpec * pspec) { switch (property_id) { default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } static void trg_stats_dialog_set_property(GObject * object, guint property_id, - const GValue * value, GParamSpec * pspec) + const GValue * value, GParamSpec * pspec) { TrgStatsDialogPrivate *priv = TRG_STATS_DIALOG_GET_PRIVATE(object); switch (property_id) { case PROP_CLIENT: - priv->client = g_value_get_pointer(value); - break; + priv->client = g_value_get_pointer(value); + break; case PROP_PARENT: - priv->parent = g_value_get_object(value); - break; + priv->parent = g_value_get_object(value); + break; default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } } @@ -100,14 +100,14 @@ trg_stats_dialog_dispose (GObject *object) static void trg_stats_response_cb(GtkDialog * dlg, gint res_id, - gpointer data G_GNUC_UNUSED) + gpointer data G_GNUC_UNUSED) { gtk_widget_destroy(GTK_WIDGET(dlg)); instance = NULL; } static GtkTreeRowReference *stats_dialog_add_statistic(GtkListStore * - model, gchar * name) + model, gchar * name) { GtkTreeIter iter; GtkTreePath *path; @@ -124,7 +124,7 @@ static GtkTreeRowReference *stats_dialog_add_statistic(GtkListStore * } static void update_statistic(GtkTreeRowReference * rr, gchar * session, - gchar * cumulat) + gchar * cumulat) { GtkTreePath *path = gtk_tree_row_reference_get_path(rr); GtkTreeModel *model = gtk_tree_row_reference_get_model(rr); @@ -133,7 +133,7 @@ static void update_statistic(GtkTreeRowReference * rr, gchar * session, gtk_tree_model_get_iter(model, &iter, path); gtk_list_store_set(GTK_LIST_STORE(model), &iter, STATCOL_SESSION, - session, STATCOL_CUMULAT, cumulat, -1); + session, STATCOL_CUMULAT, cumulat, -1); gtk_tree_path_free(path); } @@ -149,89 +149,88 @@ static JsonObject *get_cumulat_arg(JsonObject * args) } static void update_int_stat(JsonObject * args, GtkTreeRowReference * rr, - gchar * jsonKey) + gchar * jsonKey) { gchar session_val[32]; gchar cumulat_val[32]; g_snprintf(session_val, sizeof(session_val), "%ld", - json_object_get_int_member(get_session_arg(args), jsonKey)); + json_object_get_int_member(get_session_arg(args), jsonKey)); g_snprintf(cumulat_val, sizeof(cumulat_val), "%ld", - json_object_get_int_member(get_cumulat_arg(args), jsonKey)); + json_object_get_int_member(get_cumulat_arg(args), jsonKey)); update_statistic(rr, session_val, cumulat_val); } static void update_size_stat(JsonObject * args, GtkTreeRowReference * rr, - gchar * jsonKey) + gchar * jsonKey) { gchar session_val[32]; gchar cumulat_val[32]; trg_strlsize(cumulat_val, - json_object_get_int_member(get_cumulat_arg(args), - jsonKey)); + json_object_get_int_member(get_cumulat_arg(args), + jsonKey)); trg_strlsize(session_val, - json_object_get_int_member(get_session_arg(args), - jsonKey)); + json_object_get_int_member(get_session_arg(args), + jsonKey)); update_statistic(rr, session_val, cumulat_val); } static void update_time_stat(JsonObject * args, GtkTreeRowReference * rr, - gchar * jsonKey) + gchar * jsonKey) { gchar session_val[32]; gchar cumulat_val[32]; tr_strltime_long(session_val, - json_object_get_int_member(get_session_arg(args), - jsonKey), - sizeof(session_val)); + json_object_get_int_member(get_session_arg(args), + jsonKey), + sizeof(session_val)); tr_strltime_long(cumulat_val, - json_object_get_int_member(get_cumulat_arg(args), - jsonKey), - sizeof(cumulat_val)); + json_object_get_int_member(get_cumulat_arg(args), + jsonKey), + sizeof(cumulat_val)); update_statistic(rr, session_val, cumulat_val); } static void on_stats_reply(JsonObject * response, int status, - gpointer data) + gpointer data) { TrgStatsDialogPrivate *priv; JsonObject *args; - if (!TRG_IS_STATS_DIALOG(data)) - { - response_unref(response); - return; + if (!TRG_IS_STATS_DIALOG(data)) { + response_unref(response); + return; } priv = TRG_STATS_DIALOG_GET_PRIVATE(data); if (status == CURLE_OK) { - args = get_arguments(response); + args = get_arguments(response); - update_size_stat(args, priv->rr_up, "uploadedBytes"); - update_size_stat(args, priv->rr_down, "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"); + update_size_stat(args, priv->rr_up, "uploadedBytes"); + update_size_stat(args, priv->rr_down, "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"); - if (priv->client->session != NULL) - g_timeout_add_seconds(5, trg_update_stats_timerfunc, data); + if (priv->client->session != NULL) + g_timeout_add_seconds(5, trg_update_stats_timerfunc, data); } else { - const gchar *msg = make_error_message(response, status); - GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(data), - GTK_DIALOG_MODAL, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, "%s", - msg); - gtk_window_set_title(GTK_WINDOW(dialog), "Error"); - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); - g_free((gpointer) msg); + const gchar *msg = make_error_message(response, status); + GtkWidget *dialog = gtk_message_dialog_new(GTK_WINDOW(data), + GTK_DIALOG_MODAL, + GTK_MESSAGE_ERROR, + GTK_BUTTONS_OK, "%s", + msg); + gtk_window_set_title(GTK_WINDOW(dialog), "Error"); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); + g_free((gpointer) msg); } response_unref(response); @@ -242,21 +241,21 @@ static gboolean trg_update_stats_timerfunc(gpointer data) TrgStatsDialogPrivate *priv; if (TRG_IS_STATS_DIALOG(data)) { - priv = TRG_STATS_DIALOG_GET_PRIVATE(data); - dispatch_async(priv->client, session_stats(), on_stats_reply, - data); + priv = TRG_STATS_DIALOG_GET_PRIVATE(data); + dispatch_async(priv->client, session_stats(), on_stats_reply, + data); } return FALSE; } static void trg_stats_add_column(GtkTreeView * tv, gint index, - gchar * title, gint width) + gchar * title, gint width) { GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); GtkTreeViewColumn *column = - gtk_tree_view_column_new_with_attributes(title, renderer, - "text", index, NULL); + gtk_tree_view_column_new_with_attributes(title, renderer, + "text", index, NULL); gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_fixed_width(column, width); @@ -264,59 +263,59 @@ static void trg_stats_add_column(GtkTreeView * tv, gint index, } static GObject *trg_stats_dialog_constructor(GType type, - guint - n_construct_properties, - GObjectConstructParam - * construct_params) + guint + n_construct_properties, + GObjectConstructParam + * construct_params) { GtkWidget *tv; GObject *obj = G_OBJECT_CLASS - (trg_stats_dialog_parent_class)->constructor(type, - n_construct_properties, - construct_params); + (trg_stats_dialog_parent_class)->constructor(type, + n_construct_properties, + construct_params); TrgStatsDialogPrivate *priv = TRG_STATS_DIALOG_GET_PRIVATE(obj); gtk_window_set_title(GTK_WINDOW(obj), "Statistics"); gtk_window_set_transient_for(GTK_WINDOW(obj), - GTK_WINDOW(priv->parent)); + GTK_WINDOW(priv->parent)); gtk_window_set_destroy_with_parent(GTK_WINDOW(obj), TRUE); gtk_dialog_add_button(GTK_DIALOG(obj), GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE); + GTK_RESPONSE_CLOSE); gtk_container_set_border_width(GTK_CONTAINER(obj), GUI_PAD); gtk_dialog_set_default_response(GTK_DIALOG(obj), GTK_RESPONSE_CLOSE); g_signal_connect(G_OBJECT(obj), - "response", G_CALLBACK(trg_stats_response_cb), NULL); + "response", G_CALLBACK(trg_stats_response_cb), NULL); priv->model = - gtk_list_store_new(STATCOL_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING); + gtk_list_store_new(STATCOL_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING); priv->rr_down = - stats_dialog_add_statistic(priv->model, "Download Total"); + stats_dialog_add_statistic(priv->model, "Download Total"); priv->rr_up = stats_dialog_add_statistic(priv->model, "Upload Total"); priv->rr_files_added = - stats_dialog_add_statistic(priv->model, "Files Added"); + stats_dialog_add_statistic(priv->model, "Files Added"); priv->rr_session_count = - stats_dialog_add_statistic(priv->model, "Session Count"); + stats_dialog_add_statistic(priv->model, "Session Count"); priv->rr_active = - stats_dialog_add_statistic(priv->model, "Time Active"); + stats_dialog_add_statistic(priv->model, "Time Active"); tv = priv->tv = trg_tree_view_new(); gtk_widget_set_sensitive(tv, TRUE); trg_stats_add_column(GTK_TREE_VIEW(tv), STATCOL_STAT, "Statistic", - 170); + 170); trg_stats_add_column(GTK_TREE_VIEW(tv), STATCOL_SESSION, "Session", - 100); + 100); trg_stats_add_column(GTK_TREE_VIEW(tv), STATCOL_CUMULAT, "Cumulative", - 100); + 100); gtk_tree_view_set_model(GTK_TREE_VIEW(tv), - GTK_TREE_MODEL(priv->model)); + GTK_TREE_MODEL(priv->model)); gtk_container_set_border_width(GTK_CONTAINER(tv), GUI_PAD); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(obj)->vbox), tv, TRUE, TRUE, 0); @@ -338,27 +337,27 @@ static void trg_stats_dialog_class_init(TrgStatsDialogClass * klass) object_class->constructor = trg_stats_dialog_constructor; g_object_class_install_property(object_class, - PROP_PARENT, - g_param_spec_object - ("parent-window", "Parent window", - "Parent window", - TRG_TYPE_MAIN_WINDOW, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); + PROP_PARENT, + g_param_spec_object + ("parent-window", "Parent window", + "Parent window", + TRG_TYPE_MAIN_WINDOW, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); g_object_class_install_property(object_class, - PROP_CLIENT, - g_param_spec_pointer - ("trg-client", "TClient", - "Client", - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_NAME | - G_PARAM_STATIC_NICK | - G_PARAM_STATIC_BLURB)); + PROP_CLIENT, + g_param_spec_pointer + ("trg-client", "TClient", + "Client", + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_NAME | + G_PARAM_STATIC_NICK | + G_PARAM_STATIC_BLURB)); } static void trg_stats_dialog_init(TrgStatsDialog * self) @@ -366,12 +365,12 @@ static void trg_stats_dialog_init(TrgStatsDialog * self) } TrgStatsDialog *trg_stats_dialog_get_instance(TrgMainWindow * parent, - trg_client * client) + trg_client * client) { if (instance == NULL) { - instance = g_object_new(TRG_TYPE_STATS_DIALOG, - "trg-client", client, - "parent-window", parent, NULL); + instance = g_object_new(TRG_TYPE_STATS_DIALOG, + "trg-client", client, + "parent-window", parent, NULL); } return TRG_STATS_DIALOG(instance); -- cgit v1.2.3