[PATCH] Display yearly/monthly statistics

Miika Turkia miika.turkia at gmail.com
Fri Jun 15 05:15:19 PDT 2012


On 6/3/12, Dirk Hohndel <dirk at hohndel.org> wrote:
>
> Hi Miika,
>
> Sorry for ignoring this patch for so long. I was traveling when it came
> in and completely forgot about it...

no worries, I am currently returning from 3 weeks of diving without
Internet or phones - just the way I like 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?

I did consider having this as a feature of the dive list but I decided
this to be beyond my GUI skills. In short term, triggering the stats
window from the statistics notebook page would probably be more
intuitive than the log menu.

> 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?

Having different view modes for the dive list view sounds good to me.
That really is the place where all this information should be
displayed.

Stats based on dive trips is an option I would also like to see. In
general, currently the information about dive trips is quite painful
to insert as all the information on all the dives must be added
individually for each dive. It would be nice to be able to e.g. add
the tank size, weight and country information to a bunch of newly
imported dives in a batch..but I guess this is quite of the topic.

> 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...

True.

> 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?

I like the idea but most likely I won't be able to work on the code
within the next 2 months. So applying it for now and modifying later
sounds good to me. (I'll give a ping if it turns out I have a change
on working on the suggested changes to avoid both of us hacking it at
the same time.)

miika


More information about the subsurface mailing list