[PATCH 2/2] Modifications to core files for detail dialog
John Van Ostrand
john at netdirect.ca
Fri Nov 11 05:07:35 PST 2011
Added files missed in the dive detail dialog commit.
Signed-off-by: John Van Ostrand <john at netdirect.ca>
---
Makefile | 5 ++++-
dive.c | 15 +++++++++++++++
dive.h | 27 +++++++++++++++++++++++++++
divelist.c | 12 ++++++++++++
divelist.h | 1 +
gtk-gui.c | 10 ++++++++++
6 files changed, 69 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 1b1a31a..51d951c 100644
--- a/Makefile
+++ b/Makefile
@@ -84,7 +84,7 @@ LIBS = $(LIBXML2) $(LIBXSLT) $(LIBGTK) $(LIBDIVECOMPUTER) -lpthread
OBJS = main.o dive.o profile.o info.o equipment.o divelist.o \
parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o \
- gtk-gui.o statistics.o $(RESFILE)
+ gtk-gui.o statistics.o detail.o $(RESFILE)
$(NAME): $(OBJS)
$(CC) $(LDFLAGS) -o $(NAME) $(OBJS) $(LIBS)
@@ -156,6 +156,9 @@ equipment.o: equipment.c dive.h display.h divelist.h
statistics.o: statistics.c dive.h display.h divelist.h
$(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c statistics.c
+detail.o: detail.c detail.h dive.h display.h divelist.h display-gtk.h
+ $(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c detail.c
+
divelist.o: divelist.c dive.h display.h divelist.h
$(CC) $(CFLAGS) $(GTK2CFLAGS) $(GLIB2CFLAGS) -c divelist.c
diff --git a/dive.c b/dive.c
index dad0e23..679b634 100644
--- a/dive.c
+++ b/dive.c
@@ -135,6 +135,21 @@ struct dive *alloc_dive(void)
return dive;
}
+void free_dive(struct dive *dive)
+{
+ free(dive);
+}
+
+/* Delete a dive from the list */
+void delete_dive(int dive_no)
+{
+ for (; dive_no < dive_table.nr; dive_no++)
+ {
+ dive_table.dives[dive_no] = dive_table.dives[dive_no + 1];
+ }
+ dive_table.nr--;
+}
+
struct sample *prepare_sample(struct dive **divep)
{
struct dive *dive = *divep;
diff --git a/dive.h b/dive.h
index 0116a1c..4005245 100644
--- a/dive.h
+++ b/dive.h
@@ -107,6 +107,11 @@ static inline double mm_to_feet(int mm)
return mm * 0.00328084;
}
+static inline int feet_to_mm(double feet)
+{
+ return feet / 0.00328084 + 0.5;
+}
+
static inline int to_feet(depth_t depth)
{
return mm_to_feet(depth.mm) + 0.5;
@@ -122,6 +127,16 @@ static double mkelvin_to_F(int mkelvin)
return mkelvin * 9 / 5000.0 - 459.670;
}
+static inline int F_to_mkelvin(double f)
+{
+ return (f + 459.670) / 9 * 5000.0 + 0.5;
+}
+
+static inline int C_to_mkelvin(double c)
+{
+ return c * 1000 + 273150 + 0.5;
+}
+
static inline int to_C(temperature_t temp)
{
if (!temp.mkelvin)
@@ -157,6 +172,16 @@ static inline double bar_to_atm(double bar)
return bar / 1.01325;
}
+static inline int PSI_to_mbar(int PSI)
+{
+ return PSI / 0.0145037738;
+}
+
+static inline int ATM_to_mbar(double ATM)
+{
+ return ATM * 1013.25;
+}
+
static inline double to_ATM(pressure_t pressure)
{
return pressure.mbar / 1013.25;
@@ -277,6 +302,8 @@ static inline unsigned int dive_size(int samples)
extern time_t utc_mktime(struct tm *tm);
extern struct dive *alloc_dive(void);
+extern void free_dive(struct dive *dive);
+extern void delete_dive(int dive_no);
extern void record_dive(struct dive *dive);
extern struct sample *prepare_sample(struct dive **divep);
diff --git a/divelist.c b/divelist.c
index eb8f231..f13f9c9 100644
--- a/divelist.c
+++ b/divelist.c
@@ -564,3 +564,15 @@ int unsaved_changes()
{
return dive_list.changed;
}
+
+void set_dive_list_cursor(int index)
+{
+ GtkTreeIter iter;
+
+ /* Set active row in divelist */
+ if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(dive_list.model), &iter, NULL, index))
+ {
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(dive_list.tree_view), gtk_tree_model_get_path(GTK_TREE_MODEL(dive_list.model), &iter), NULL, FALSE);
+ }
+}
+
diff --git a/divelist.h b/divelist.h
index 2635b75..a7bcab6 100644
--- a/divelist.h
+++ b/divelist.h
@@ -10,4 +10,5 @@ extern void flush_divelist(struct dive *);
extern void mark_divelist_changed(int);
extern int unsaved_changes(void);
+extern void set_dive_list_cursor(int index);
#endif
diff --git a/gtk-gui.c b/gtk-gui.c
index c78d7e6..230dcb0 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -18,6 +18,7 @@
#include "divelist.h"
#include "display.h"
#include "display-gtk.h"
+#include "detail.h"
#include "libdivecomputer.h"
@@ -578,6 +579,7 @@ static void about_dialog(GtkWidget *w, gpointer data)
static GtkActionEntry menu_items[] = {
{ "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
+ { "EditMenuAction", GTK_STOCK_EDIT, "Edit", NULL, NULL, NULL},
{ "LogMenuAction", GTK_STOCK_FILE, "Log", NULL, NULL, NULL},
{ "FilterMenuAction", GTK_STOCK_FILE, "Filter", NULL, NULL, NULL},
{ "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL},
@@ -589,6 +591,9 @@ static GtkActionEntry menu_items[] = {
{ "Renumber", NULL, "Renumber", NULL, NULL, G_CALLBACK(renumber_dialog) },
{ "SelectEvents", NULL, "SelectEvents", NULL, NULL, G_CALLBACK(selectevents_dialog) },
{ "Quit", GTK_STOCK_QUIT, NULL, "<control>Q", NULL, G_CALLBACK(quit) },
+ { "EditDive", NULL, "Edit dive", NULL, NULL, G_CALLBACK(edit_dive_detail_dialog) },
+ { "AddDive", NULL, "Add dive", NULL, NULL, G_CALLBACK(add_dive_detail_dialog) },
+ { "DeleteDive", NULL, "Delete dive", NULL, NULL, G_CALLBACK(delete_dive_detail_dialog) },
{ "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) },
};
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
@@ -607,6 +612,11 @@ static const gchar* ui_string = " \
<separator name=\"Separator3\"/> \
<menuitem name=\"Quit\" action=\"Quit\" /> \
</menu> \
+ <menu name=\"EditMenu\" action=\"EditMenuAction\"> \
+ <menuitem name=\"Edit dive\" action=\"EditDive\" /> \
+ <menuitem name=\"Add dive\" action=\"AddDive\" /> \
+ <menuitem name=\"Delete dive\" action=\"DeleteDive\" /> \
+ </menu> \
<menu name=\"LogMenu\" action=\"LogMenuAction\"> \
<menuitem name=\"Renumber\" action=\"Renumber\" /> \
</menu> \
--
1.7.3.4
More information about the subsurface
mailing list