]> git.tdb.fi Git - ext/subsurface.git/blobdiff - info.c
Make handling of empty airconsumption string consistent
[ext/subsurface.git] / info.c
diff --git a/info.c b/info.c
index 66233e32ab19c97d9ed109ac5e471b28c9e77f1d..6834b1645c81174001453fb849d6f818efed80c0 100644 (file)
--- a/info.c
+++ b/info.c
@@ -8,12 +8,15 @@
 #include "divelist.h"
 
 static GtkWidget *info_frame;
-static GtkWidget *depth, *duration, *temperature;
+static GtkWidget *depth, *duration, *temperature, *airconsumption;
 static GtkEntry *location, *buddy, *divemaster;
 static GtkTextBuffer *notes;
 static int location_changed = 1, notes_changed = 1;
 static int divemaster_changed = 1, buddy_changed = 1;
 
+#define EMPTY_AIRCONSUMPTION " \n "
+#define AIRCON_WIDTH 20
+
 static const char *weekday(int wday)
 {
        static const char wday_array[7][4] = {
@@ -67,6 +70,8 @@ void show_dive_info(struct dive *dive)
        if (!dive) {
                gtk_label_set_text(GTK_LABEL(depth), "");
                gtk_label_set_text(GTK_LABEL(duration), "");
+               gtk_label_set_text(GTK_LABEL(airconsumption), EMPTY_AIRCONSUMPTION);
+               gtk_label_set_width_chars(GTK_LABEL(airconsumption), AIRCON_WIDTH);
                return;
        }
        /* dive number and location (or lacking that, the date) go in the window title */
@@ -86,7 +91,7 @@ void show_dive_info(struct dive *dive)
        }
        text = buffer;
        if (!dive->number)
-               text += 9;      /* Skip the "Dive 0 - " part */
+               text += 10;     /* Skip the "Dive #0 - " part */
        gtk_window_set_title(GTK_WINDOW(main_window), text);
 
        /* the date goes in the frame label */
@@ -181,10 +186,23 @@ GtkWidget *dive_info_frame(void)
        depth = info_label(hbox, "depth", GTK_JUSTIFY_RIGHT);
        duration = info_label(hbox, "duration", GTK_JUSTIFY_RIGHT);
        temperature = info_label(hbox, "temperature", GTK_JUSTIFY_RIGHT);
+       airconsumption = info_label(hbox, "air", GTK_JUSTIFY_RIGHT);
+       gtk_misc_set_alignment(GTK_MISC(airconsumption), 1.0, 0.5);
+       gtk_label_set_width_chars(GTK_LABEL(airconsumption), AIRCON_WIDTH);
 
        return frame;
 }
 
+void update_air_info(char *buffer)
+{
+       char markup[120];
+       
+       if (! buffer)
+               buffer = EMPTY_AIRCONSUMPTION;
+       snprintf(markup, sizeof(markup), "<span font=\"8\">%s</span>",buffer);
+       gtk_label_set_markup(GTK_LABEL(airconsumption), markup);
+}
+
 static GtkEntry *text_entry(GtkWidget *box, const char *label)
 {
        GtkWidget *entry;