mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add some more dive info - and actually update it
It's still the ugliest application ever, but now it at least gives you some basic dive info. I'd love to add a way to edit the dives to add new data (name, buddies, location etc), but that would also require the ability to save the end result. Maybe some day. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c7e2906372
commit
a39b2ee220
3 changed files with 41 additions and 2 deletions
|
@ -9,6 +9,9 @@ extern int selected_dive;
|
||||||
extern GtkWidget *dive_profile_frame(void);
|
extern GtkWidget *dive_profile_frame(void);
|
||||||
extern GtkWidget *dive_info_frame(void);
|
extern GtkWidget *dive_info_frame(void);
|
||||||
extern GtkWidget *create_dive_list(void);
|
extern GtkWidget *create_dive_list(void);
|
||||||
|
extern void update_dive_info(struct dive *dive);
|
||||||
extern void repaint_dive(void);
|
extern void repaint_dive(void);
|
||||||
|
|
||||||
|
#define current_dive (dive_table.dives[selected_dive])
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
39
info.c
39
info.c
|
@ -5,11 +5,36 @@
|
||||||
#include "dive.h"
|
#include "dive.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
static GtkWidget *datetime, *depth, *duration;
|
||||||
|
|
||||||
|
void update_dive_info(struct dive *dive)
|
||||||
|
{
|
||||||
|
struct tm *tm;
|
||||||
|
char buffer[80];
|
||||||
|
|
||||||
|
tm = gmtime(&dive->when);
|
||||||
|
snprintf(buffer, sizeof(buffer),
|
||||||
|
"%04d-%02d-%02d "
|
||||||
|
"%02d:%02d:%02d",
|
||||||
|
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
||||||
|
tm->tm_hour, tm->tm_min, tm->tm_sec);
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(datetime), buffer);
|
||||||
|
|
||||||
|
snprintf(buffer, sizeof(buffer),
|
||||||
|
"%d ft",
|
||||||
|
to_feet(dive->maxdepth));
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(depth), buffer);
|
||||||
|
|
||||||
|
snprintf(buffer, sizeof(buffer),
|
||||||
|
"%d min",
|
||||||
|
dive->duration.seconds / 60);
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(duration), buffer);
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *dive_info_frame(void)
|
GtkWidget *dive_info_frame(void)
|
||||||
{
|
{
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *depth;
|
|
||||||
|
|
||||||
frame = gtk_frame_new("Dive info");
|
frame = gtk_frame_new("Dive info");
|
||||||
gtk_widget_show(frame);
|
gtk_widget_show(frame);
|
||||||
|
@ -17,11 +42,21 @@ GtkWidget *dive_info_frame(void)
|
||||||
hbox = gtk_hbox_new(FALSE, 5);
|
hbox = gtk_hbox_new(FALSE, 5);
|
||||||
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
||||||
|
|
||||||
|
datetime = gtk_entry_new();
|
||||||
|
gtk_editable_set_editable(GTK_EDITABLE(datetime), FALSE);
|
||||||
|
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), datetime, FALSE, FALSE, 0);
|
||||||
|
|
||||||
depth = gtk_entry_new();
|
depth = gtk_entry_new();
|
||||||
gtk_entry_set_text(GTK_ENTRY(depth), "54 ft");
|
|
||||||
gtk_editable_set_editable(GTK_EDITABLE(depth), FALSE);
|
gtk_editable_set_editable(GTK_EDITABLE(depth), FALSE);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), depth, FALSE, FALSE, 0);
|
gtk_box_pack_start(GTK_BOX(hbox), depth, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
duration = gtk_entry_new();
|
||||||
|
gtk_editable_set_editable(GTK_EDITABLE(duration), FALSE);
|
||||||
|
|
||||||
|
gtk_box_pack_start(GTK_BOX(hbox), duration, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
update_dive_info(current_dive);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
1
main.c
1
main.c
|
@ -51,6 +51,7 @@ static GtkWidget *dive_profile;
|
||||||
|
|
||||||
void repaint_dive(void)
|
void repaint_dive(void)
|
||||||
{
|
{
|
||||||
|
update_dive_info(current_dive);
|
||||||
gtk_widget_queue_draw(dive_profile);
|
gtk_widget_queue_draw(dive_profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue