[PATCH 2/3] Added a quick method to update dive ratings from the dive list

Dirk Hohndel dirk at hohndel.org
Fri Jan 25 07:28:59 PST 2013


Umm. Why would we want that? That's yet another odd user interface that
no one will be able to figure out and that has no consistency. What we
need is the ability to edit things in place. What we need is an actual
star rating widget where you click on the stars and they light up. We
don't need random one-off user interfaces that make no sense.

Sorry, Lubomir: NACK

/D

"Lubomir I. Ivanov" <neolit123 at gmail.com> writes:

> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
>
> When hovering over dives in the dive list, it is now possible
> to hold the CTRL key and use the mouse wheel to quickly
> set the hovered dive rating.
>
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
> ---
>
> i was first looking at using ALT (GDK_MOD1_MASK), but it had odd behaviour
> on Ubuntu 12.04 in a VM. also, i'm not sure if ctrl + mouse wheel is confortable
> (or even possible) on the Mac.
>
> ---
>  divelist.c | 37 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 37 insertions(+)
>
> diff --git a/divelist.c b/divelist.c
> index 8b86c53..c5f4c10 100644
> --- a/divelist.c
> +++ b/divelist.c
> @@ -1698,6 +1698,41 @@ static void show_gps_location_cb(GtkWidget *menuitem, struct dive *dive)
>  }
>  #endif
>  
> +gboolean rating_scroll_cb(GtkWidget *w, GdkEventScroll *event, gpointer data)
> +{
> +	GtkTreePath *path = NULL;
> +	GtkTreeIter iter;
> +	GtkTreeViewColumn *col;
> +	int idx;
> +	struct dive *dive;
> +
> +	if ((event->state & GDK_CONTROL_MASK) != 0 &&
> +	    gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(dive_list.tree_view), event->x, event->y, &path, &col, NULL, NULL)) {
> +		if (col == data) {
> +			gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
> +			gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
> +			dive = get_dive(idx);
> +			if (dive) {
> +				if (event->direction == GDK_SCROLL_UP) {
> +					dive->rating--;
> +					if (dive->rating < 0)
> +						dive->rating = 0;
> +				} else if (event->direction == GDK_SCROLL_DOWN) {
> +					dive->rating++;
> +					if (dive->rating > 5)
> +						dive->rating = 5;
> +				}
> +				mark_divelist_changed(TRUE);
> +				flush_divelist(dive);
> +			}
> +		}
> +		if (path)
> +			gtk_tree_path_free(path);
> +		return TRUE;
> +	}
> +	return FALSE;
> +}
> +
>  gboolean icon_click_cb(GtkWidget *w, GdkEventButton *event, gpointer data)
>  {
>  #if HAVE_OSM_GPS_MAP
> @@ -2769,6 +2804,8 @@ GtkWidget *dive_list_create(void)
>  	dive_list.otu = divelist_column(&dive_list, dl_column + DIVE_OTU);
>  	dive_list.maxcns = divelist_column(&dive_list, dl_column + DIVE_MAXCNS);
>  	dive_list.location = divelist_column(&dive_list, dl_column + DIVE_LOCATION);
> +	/* update dive rating */
> +	g_signal_connect(dive_list.tree_view, "scroll-event", G_CALLBACK(rating_scroll_cb), dive_list.stars);
>  	/* now add the GPS icon to the location column */
>  	tree_view_column_add_pixbuf(dive_list.tree_view, gpsicon_data_func, dive_list.location);
>  
> -- 
> 1.7.11.msysgit.0
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

-- 
Dirk Hohndel
Intel Open Source Technology Center


More information about the subsurface mailing list