[PATCH] Display yearly/monthly statistics

Dirk Hohndel dirk at hohndel.org
Sat Jun 2 21:13:20 PDT 2012

Hi Miika,

Sorry for ignoring this patch for so long. I was traveling when it came
in and completely forgot about it...

On Sun, 13 May 2012 18:27:22 +0300, Miika Turkia <miika.turkia at gmail.com> wrote:
> Display yearly statistics on a statistics window with option to expand
> the viewing on monthly level. The amount of dives along with basic
> information like duration, depth, water temperature and air consumption
> is displayed in yearly and monthly level. Thus you are able to compare
> e.g. development of air consumption or diving activity from year to
> year.

I really like the idea of this patch. It's something that I've thought
about for a while and at some point even started to work on, but
conceptually I thought about this differently.

What your patch does is that it adds a new entry to the "Log" menu entry
which opens a new window which then has the statistical data.

For one thing that seems really unintuitive - why would this be in the
"Log" menu? And given what it does (basically group dives by year and
month and provide statistics for them), I wonder why this isn't either
triggered from within the statistics notebook page, or, even better, why
this doesn't simply become a feature of the dive list?

Here's the design idea I have been playing with but haven't found the
time to implement:

I want to be able to create groups and super-groups of dives in the
divelist window. One default way to create these groups and super groups
would be to automatically create them by month and year - but another
option should be to create "dive trips" and then group those by year
(and allow a "trip" that straddles New Year's Eve to be assigned to
either the previous or the next year). Then these trips and years would
fold in the dive list (very similar to what you are doing in the extra
window right now) and display some of the statistical information in the
dive list tree view.

Doesn't this seem like a more natural user interface?

I'm not married to this specific idea - I'm open to arguments others
might have, but I think this would make more sense than what you have
implemented in this patch.

> +void show_yearly_stats()
> +{
> +	int i, j, combined_months, month_iter = 0;
> +	GtkWidget *window;
> +	GtkWidget *tree, *sw;
> +	GtkTreeIter parent_iter;
> +
> +	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
> +	sw = gtk_scrolled_window_new (NULL, NULL);
> +	tree = gtk_tree_view_new ();
> +
> +	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
> +	gtk_window_set_default_size(GTK_WINDOW(window), 640, 480);
> +	gtk_window_set_title(GTK_WINDOW(window), "Yearly Statistics");
> +	gtk_container_set_border_width(GTK_CONTAINER(window), 5);
> +	GTK_WINDOW(window)->allow_shrink = TRUE;
> +	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
> +	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_ETCHED_IN);
> +
> +	gtk_container_add (GTK_CONTAINER (sw), tree);
> +	gtk_container_add (GTK_CONTAINER (window), sw);
> +
> +	/* Display the yearly statistics on top level
> +	 * Monthly statistics are available by expanding a year */
> +	init_tree(tree);
> +	for (i = 0; stats_yearly[i].period; ++i) {

BTW: You may want to make sure that you have stats_yearly initialized
before dereferencing it. When you call subsurface without any dives
loaded, this crashes right here...

Anyway, here's my question:

Do you like my idea? Would you like to rework your code to take it in
this direction? Or should I apply it as is and modify it afterwards to
implement what I describe above?


More information about the subsurface mailing list