aboutsummaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-30 08:10:46 +1100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-30 08:31:53 +1100
commite3a8ed5183ed5a24e391395c9faeae03dc9e4a6a (patch)
tree6490fa5d2d135dd74b748f0fe31179411144f63f /statistics.c
parent468d3f28f9f1f2795960b8e8b79b9d02024e34ed (diff)
downloadsubsurface-e3a8ed5183ed5a24e391395c9faeae03dc9e4a6a.tar.gz
Massive cleanup
Mostly coding style and whitespace changes plus making lots of functions static that have no need to be extern. This also helped find a bit of code that is actually no longer used. This should have absolutely no functional impact - all changes should be purely cosmetic. But it removes a bunch of lines of code and makes the rest easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/statistics.c b/statistics.c
index c421b4051..14d83b686 100644
--- a/statistics.c
+++ b/statistics.c
@@ -3,19 +3,12 @@
* controlled through the following interfaces:
*
* void show_dive_stats(struct dive *dive)
- * void flush_dive_stats_changes(struct dive *dive)
*
* called from gtk-ui:
* GtkWidget *stats_widget(void)
*/
#include <glib/gi18n.h>
#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <time.h>
-#include <gdk/gdkkeysyms.h>
#include "dive.h"
#include "display.h"
@@ -106,7 +99,7 @@ enum {
N_COLUMNS
};
-static char * get_time_string(int seconds, int maxdays);
+static char *get_time_string(int seconds, int maxdays);
static void process_temperatures(struct dive *dp, stats_t *stats)
{
@@ -251,7 +244,7 @@ static void add_cell_to_tree(GtkTreeStore *store, char *value, int index, GtkTre
{
gtk_tree_store_set(store, parent, index, value, -1);
}
-static char * get_minutes(int seconds)
+static char *get_minutes(int seconds)
{
static char buf[80];
snprintf(buf, sizeof(buf), "%d:%.2d", FRACTION(seconds, 60));
@@ -335,7 +328,7 @@ static void process_interval_stats(stats_t stats_interval, GtkTreeIter *parent,
}
}
-void clear_statistics()
+static void clear_statistics()
{
GtkTreeStore *store;
@@ -360,7 +353,7 @@ static void key_press_event(GtkWidget *window, GdkEventKey *event, gpointer data
}
}
-void update_yearly_stats()
+static void update_yearly_stats()
{
int i, j, combined_months, month = 0;
GtkTreeIter year_iter, month_iter;
@@ -468,9 +461,9 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive)
if (current_year != tm.tm_year + 1900) {
current_year = tm.tm_year + 1900;
process_dive(dp, &(stats_yearly[++year_iter]));
- } else
+ } else {
process_dive(dp, &(stats_yearly[year_iter]));
-
+ }
stats_yearly[year_iter].selection_size++;
stats_yearly[year_iter].period = current_year;
@@ -483,7 +476,6 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive)
if (prev_month != current_month || prev_year != current_year)
month_iter++;
}
-
process_dive(dp, &(stats_monthly[month_iter]));
stats_monthly[month_iter].selection_size++;
stats_monthly[month_iter].period = current_month;
@@ -523,12 +515,12 @@ static void set_label(GtkWidget *w, const char *fmt, ...)
gtk_label_set_text(GTK_LABEL(w), buf);
}
-static char * get_time_string(int seconds, int maxdays)
+static char *get_time_string(int seconds, int maxdays)
{
static char buf[80];
- if (maxdays && seconds > 3600 * 24 * maxdays)
+ if (maxdays && seconds > 3600 * 24 * maxdays) {
snprintf(buf, sizeof(buf), _("more than %d days"), maxdays);
- else {
+ } else {
int days = seconds / 3600 / 24;
int hours = (seconds - days * 3600 * 24) / 3600;
int minutes = (seconds - days * 3600 * 24 - hours * 3600) / 60;
@@ -591,9 +583,9 @@ static void show_single_dive_stats(struct dive *dive)
set_label(single_w.air_press, _("unknown"));
}
value = get_volume_units(dive->sac, &decimals, &unit);
- if (value > 0) {
+ if (value > 0)
set_label(single_w.sac, _("%.*f %s/min"), decimals, value, unit);
- } else
+ else
set_label(single_w.sac, "");
set_label(single_w.otu, "%d", dive->otu);
offset = 0;
@@ -626,8 +618,9 @@ static void show_single_dive_stats(struct dive *dive)
if (gas_used) {
value = get_volume_units(gas_used, &decimals, &unit);
set_label(single_w.gas_used, "%.*f %s", decimals, value, unit);
- } else
+ } else {
set_label(single_w.gas_used, "");
+ }
}
/* this gets called when at least two but not all dives are selected */
@@ -753,11 +746,6 @@ void show_dive_stats(struct dive *dive)
show_total_dive_stats(dive);
}
-void flush_dive_stats_changes(struct dive *dive)
-{
- /* We do nothing: we require the "Ok" button press */
-}
-
static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label)
{
GtkWidget *label_widget;