]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Add location to divelist too
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 19 Sep 2011 22:52:42 +0000 (15:52 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 19 Sep 2011 22:52:42 +0000 (15:52 -0700)
Sure, it's visible elsewhere, but this way you can search and sort for
it, and see several entries at once.  So again, having it visible in the
dive list is a good thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
divelist.c
divelist.h

index dc0e256a557c51b341fb9f22a7ef70e264868b87..2559c367eccdb173eec2898cb8b6a4616aa9a0fd 100644 (file)
@@ -19,6 +19,7 @@ enum {
        DIVE_DEPTH,             /* int: dive->maxdepth in mm */
        DIVE_DURATIONSTR,       /* "47" in minutes */
        DIVE_DURATION,          /* int: in seconds */
+       DIVE_LOCATION,          /* "47" in minutes */
        DIVE_TEMPSTR,           /* "78" in fahrenheit or whatever */
        DIVE_TEMP,              /* int: in mkelvin */
        DIVE_NITROXSTR,         /* "32.5" in percent */
@@ -123,6 +124,14 @@ static void get_duration(struct dive *dive, int *val, char **str)
        *str = strdup(buffer);
 }
 
+static void get_location(struct dive *dive, char **str)
+{
+       char buffer[16];
+
+       snprintf(buffer, sizeof(buffer), "%s", dive->location);
+       *str = strdup(buffer);
+}
+
 static void get_temp(struct dive *dive, int *val, char **str)
 {
        int value = dive->watertemp.mkelvin;
@@ -175,6 +184,7 @@ static gboolean set_one_dive(GtkTreeModel *model,
        struct dive *dive;
        int date, depth, duration, temp, nitrox, sac;
        char *datestr, *depthstr, *durationstr, *tempstr, *nitroxstr, *sacstr;
+       char *location;
 
        /* Get the dive number */
        gtk_tree_model_get_value(model, iter, DIVE_INDEX, &value);
@@ -185,6 +195,7 @@ static gboolean set_one_dive(GtkTreeModel *model,
        get_date(dive, &date, &datestr);
        get_depth(dive, &depth, &depthstr);
        get_duration(dive, &duration, &durationstr);
+       get_location(dive, &location);
        get_temp(dive, &temp, &tempstr);
        get_nitrox(dive, &nitrox, &nitroxstr);
        get_sac(dive, &sac, &sacstr);
@@ -197,6 +208,7 @@ static gboolean set_one_dive(GtkTreeModel *model,
                DIVE_DATESTR, datestr,
                DIVE_DEPTHSTR, depthstr,
                DIVE_DURATIONSTR, durationstr,
+               DIVE_LOCATION, location,
                DIVE_TEMPSTR, tempstr,
                DIVE_TEMP, temp,
                DIVE_NITROXSTR, nitroxstr,
@@ -246,6 +258,7 @@ static void fill_dive_list(struct DiveList *dive_list)
                        DIVE_DEPTH, dive->maxdepth,
                        DIVE_DURATIONSTR, "duration",
                        DIVE_DURATION, dive->duration.seconds,
+                       DIVE_LOCATION, "location",
                        DIVE_TEMPSTR, "temp",
                        DIVE_TEMP, dive->watertemp.mkelvin,
                        DIVE_NITROXSTR, "21.0",
@@ -277,6 +290,7 @@ struct DiveList dive_list_create(void)
                                G_TYPE_STRING, G_TYPE_INT,      /* Date */
                                G_TYPE_STRING, G_TYPE_INT,      /* Depth */
                                G_TYPE_STRING, G_TYPE_INT,      /* Duration */
+                               G_TYPE_STRING,                  /* Location */
                                G_TYPE_STRING, G_TYPE_INT,      /* Temperature */
                                G_TYPE_STRING, G_TYPE_INT,      /* Nitrox */
                                G_TYPE_STRING, G_TYPE_INT       /* SAC */
@@ -316,6 +330,14 @@ struct DiveList dive_list_create(void)
        gtk_object_set(GTK_OBJECT(renderer), "alignment", PANGO_ALIGN_RIGHT, NULL);
        gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), 1.0, 0.5);
 
+       renderer = gtk_cell_renderer_text_new();
+       dive_list.location = col = gtk_tree_view_column_new();
+       gtk_tree_view_column_set_title(col, "Location");
+       gtk_tree_view_column_set_sort_column_id(col, DIVE_LOCATION);
+       gtk_tree_view_column_pack_start(col, renderer, FALSE);
+       gtk_tree_view_column_add_attribute(col, renderer, "text", DIVE_LOCATION);
+       gtk_tree_view_append_column(GTK_TREE_VIEW(dive_list.tree_view), col);
+
        renderer = gtk_cell_renderer_text_new();
        dive_list.temperature = col = gtk_tree_view_column_new();
        gtk_tree_view_column_set_title(col, "deg");
index c8bc5ff722c17f2a352f1b646d0278bbbad05a94..e0ab1137cc105627b681a28df57f62a4eb71581d 100644 (file)
@@ -7,7 +7,7 @@ struct DiveList {
        GtkWidget    *tree_view;
        GtkWidget    *container_widget;
        GtkListStore *model;
-       GtkTreeViewColumn *date, *depth, *duration;
+       GtkTreeViewColumn *date, *depth, *duration, *location;
        GtkTreeViewColumn *temperature, *nitrox, *sac;
 };