mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Rename 'cylinder.c' as 'equipment.c'
Make it about general equipment management, and start hooking up functions to show new equipment information when changing dives (and to flush changes to equipment information for the previously active dive). Nothing is hooked up yet, and it's now showing just one (really big) cylinder choice, so this is all broken. But it should make it possible to at least get somewhere some day. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
41bce9e5f4
commit
067506038a
7 changed files with 47 additions and 31 deletions
6
Makefile
6
Makefile
|
@ -1,7 +1,7 @@
|
|||
CC=gcc
|
||||
CFLAGS=-Wall -Wno-pointer-sign -g
|
||||
|
||||
OBJS=main.o dive.o profile.o info.o cylinders.o divelist.o parse-xml.o save-xml.o
|
||||
OBJS=main.o dive.o profile.o info.o equipment.o divelist.o parse-xml.o save-xml.o
|
||||
|
||||
divelog: $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o divelog $(OBJS) \
|
||||
|
@ -27,8 +27,8 @@ profile.o: profile.c dive.h display.h divelist.h
|
|||
info.o: info.c dive.h display.h divelist.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c info.c
|
||||
|
||||
cylinders.o: cylinders.c dive.h display.h divelist.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c cylinders.c
|
||||
equipment.o: equipment.c dive.h display.h divelist.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c equipment.c
|
||||
|
||||
divelist.o: divelist.c dive.h display.h divelist.h
|
||||
$(CC) $(CFLAGS) `pkg-config --cflags gtk+-2.0 glib-2.0` -c divelist.c
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
extern GtkWidget *dive_profile_widget(void);
|
||||
extern GtkWidget *dive_info_frame(void);
|
||||
extern GtkWidget *extended_dive_info_widget(void);
|
||||
extern GtkWidget *cylinder_management_widget(void);
|
||||
extern void update_dive_info(struct dive *dive);
|
||||
extern GtkWidget *equipment_widget(void);
|
||||
|
||||
extern void repaint_dive(void);
|
||||
|
||||
#endif
|
||||
|
|
7
dive.h
7
dive.h
|
@ -175,7 +175,12 @@ static inline struct dive *get_dive(unsigned int nr)
|
|||
extern void parse_xml_init(void);
|
||||
extern void parse_xml_file(const char *filename, GError **error);
|
||||
|
||||
extern void flush_dive_info_changes(void);
|
||||
extern void show_dive_info(struct dive *);
|
||||
extern void flush_dive_info_changes(struct dive *);
|
||||
|
||||
extern void show_dive_equipment(struct dive *);
|
||||
extern void flush_dive_equipment_changes(struct dive *);
|
||||
|
||||
extern void save_dives(const char *filename);
|
||||
|
||||
static inline unsigned int dive_size(int samples)
|
||||
|
|
|
@ -8,6 +8,14 @@
|
|||
#include "display.h"
|
||||
#include "divelist.h"
|
||||
|
||||
void show_dive_equipment(struct dive *dive)
|
||||
{
|
||||
}
|
||||
|
||||
void flush_dive_equipment_changes(struct dive *dive)
|
||||
{
|
||||
}
|
||||
|
||||
static struct tank_info {
|
||||
const char *name;
|
||||
int size; /* cuft or mliter depending on psi */
|
||||
|
@ -59,7 +67,6 @@ static void fill_tank_list(GtkListStore *store)
|
|||
static void cylinder_widget(GtkWidget *box, int nr, GtkListStore *model)
|
||||
{
|
||||
GtkWidget *frame, *hbox, *size;
|
||||
GtkCellRenderer *cell;
|
||||
char buffer[80];
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "Cylinder %d", nr);
|
||||
|
@ -69,11 +76,7 @@ static void cylinder_widget(GtkWidget *box, int nr, GtkListStore *model)
|
|||
hbox = gtk_hbox_new(TRUE, 3);
|
||||
gtk_container_add(GTK_CONTAINER(frame), hbox);
|
||||
|
||||
size = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
|
||||
cell = gtk_cell_renderer_text_new();
|
||||
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(size), cell, TRUE);
|
||||
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(size), cell, "text", 0, NULL );
|
||||
|
||||
size = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), size, FALSE, FALSE, 0);
|
||||
}
|
||||
|
||||
|
@ -91,17 +94,15 @@ static GtkListStore *create_tank_size_model(void)
|
|||
return model;
|
||||
}
|
||||
|
||||
GtkWidget *cylinder_management_widget(void)
|
||||
GtkWidget *equipment_widget(void)
|
||||
{
|
||||
int i;
|
||||
GtkWidget *vbox;
|
||||
GtkListStore *model;
|
||||
|
||||
vbox = gtk_vbox_new(TRUE, 3);
|
||||
|
||||
model = create_tank_size_model();
|
||||
for (i = 0; i < MAX_CYLINDERS; i++)
|
||||
cylinder_widget(vbox, i, model);
|
||||
cylinder_widget(vbox, 0, model);
|
||||
|
||||
return vbox;
|
||||
}
|
12
info.c
12
info.c
|
@ -11,7 +11,6 @@ static GtkWidget *divedate, *divetime, *depth, *duration, *temperature, *locatio
|
|||
static GtkEntry *location;
|
||||
static GtkTextBuffer *notes;
|
||||
static int location_changed = 1, notes_changed = 1;
|
||||
static struct dive *buffered_dive;
|
||||
|
||||
static const char *weekday(int wday)
|
||||
{
|
||||
|
@ -31,10 +30,8 @@ static char *get_text(GtkTextBuffer *buffer)
|
|||
return gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
|
||||
}
|
||||
|
||||
void flush_dive_info_changes(void)
|
||||
void flush_dive_info_changes(struct dive *dive)
|
||||
{
|
||||
struct dive *dive = buffered_dive;
|
||||
|
||||
if (!dive)
|
||||
return;
|
||||
|
||||
|
@ -49,15 +46,12 @@ void flush_dive_info_changes(void)
|
|||
}
|
||||
}
|
||||
|
||||
void update_dive_info(struct dive *dive)
|
||||
void show_dive_info(struct dive *dive)
|
||||
{
|
||||
struct tm *tm;
|
||||
char buffer[80];
|
||||
char *text;
|
||||
|
||||
flush_dive_info_changes();
|
||||
buffered_dive = dive;
|
||||
|
||||
if (!dive) {
|
||||
gtk_label_set_text(GTK_LABEL(divedate), "no dive");
|
||||
gtk_label_set_text(GTK_LABEL(divetime), "");
|
||||
|
@ -217,6 +211,6 @@ GtkWidget *extended_dive_info_widget(void)
|
|||
notes = text_view(vbox, "Notes", TRUE);
|
||||
|
||||
/* Add extended info here: name, description, yadda yadda */
|
||||
update_dive_info(current_dive);
|
||||
show_dive_info(current_dive);
|
||||
return vbox;
|
||||
}
|
||||
|
|
26
main.c
26
main.c
|
@ -90,9 +90,25 @@ static void on_destroy(GtkWidget* w, gpointer data)
|
|||
|
||||
static GtkWidget *dive_profile;
|
||||
|
||||
void update_dive(struct dive *new_dive)
|
||||
{
|
||||
static struct dive *buffered_dive;
|
||||
struct dive *old_dive = buffered_dive;
|
||||
|
||||
if (old_dive) {
|
||||
flush_dive_info_changes(old_dive);
|
||||
flush_dive_equipment_changes(old_dive);
|
||||
}
|
||||
if (new_dive) {
|
||||
buffered_dive = new_dive;
|
||||
show_dive_info(new_dive);
|
||||
show_dive_equipment(new_dive);
|
||||
}
|
||||
}
|
||||
|
||||
void repaint_dive(void)
|
||||
{
|
||||
update_dive_info(current_dive);
|
||||
update_dive(current_dive);
|
||||
gtk_widget_queue_draw(dive_profile);
|
||||
}
|
||||
|
||||
|
@ -356,7 +372,7 @@ int main(int argc, char **argv)
|
|||
GtkWidget *notebook;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *dive_info;
|
||||
GtkWidget *cylinder_management;
|
||||
GtkWidget *equipment;
|
||||
GtkWidget *menubar;
|
||||
GtkWidget *vbox;
|
||||
|
||||
|
@ -417,9 +433,9 @@ int main(int argc, char **argv)
|
|||
dive_info = extended_dive_info_widget();
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dive_info, gtk_label_new("Dive Notes"));
|
||||
|
||||
/* Frame for extended dive info */
|
||||
cylinder_management = cylinder_management_widget();
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), cylinder_management, gtk_label_new("Cylinders"));
|
||||
/* Frame for dive equipment */
|
||||
equipment = equipment_widget();
|
||||
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), equipment, gtk_label_new("Equipment"));
|
||||
|
||||
gtk_widget_set_app_paintable(win, TRUE);
|
||||
gtk_widget_show_all(win);
|
||||
|
|
|
@ -226,7 +226,7 @@ void save_dives(const char *filename)
|
|||
return;
|
||||
|
||||
/* Flush any edits of current dives back to the dives! */
|
||||
flush_dive_info_changes();
|
||||
update_dive(NULL);
|
||||
|
||||
fprintf(f, "<dives>\n<program name='diveclog' version='%d'></program>\n", VERSION);
|
||||
for (i = 0; i < dive_table.nr; i++)
|
||||
|
|
Loading…
Reference in a new issue