X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=equipment.c;h=da758a9d42b24bbe4c483d89b263c9cfdabc5f75;hb=cbcfcddfb167ac242b27d253b9d8f36e78255865;hp=7e52f980a4852baf8439d149f4c1471cf8761b39;hpb=c7b9387d4bf624230ca2e317e7ac8cf5b4b81f0c;p=ext%2Fsubsurface.git diff --git a/equipment.c b/equipment.c index 7e52f98..da758a9 100644 --- a/equipment.c +++ b/equipment.c @@ -1,3 +1,13 @@ +/* equipment.c */ +/* creates the UI for the equipment page - + * controlled through the following interfaces: + * + * void show_dive_equipment(struct dive *dive) + * void flush_dive_equipment_changes(struct dive *dive) + * + * called from gtk-ui: + * GtkWidget *equipment_widget(void) + */ #include #include #include @@ -6,6 +16,7 @@ #include "dive.h" #include "display.h" +#include "display-gtk.h" #include "divelist.h" struct cylinder_widget { @@ -224,11 +235,32 @@ static void record_cylinder_changes(cylinder_t *cyl, struct cylinder_widget *cyl } void flush_dive_equipment_changes(struct dive *dive) +{ + /* We do nothing: we require the "Ok" button press */ +} + +static void apply_cb(GtkButton *button, gpointer data) { int i; + struct dive *dive = current_dive; + + if (!dive) + return; for (i = 0; i < MAX_CYLINDERS; i++) record_cylinder_changes(dive->cylinder+i, gtk_cylinder+i); + mark_divelist_changed(TRUE); + flush_divelist(dive); +} + +static void cancel_cb(GtkButton *button, gpointer data) +{ + struct dive *dive = current_dive; + + if (!dive) + return; + + show_dive_equipment(current_dive); } /* @@ -337,7 +369,7 @@ static void cylinder_widget(int nr, GtkListStore *model) cylinder->description = GTK_COMBO_BOX(widget); g_signal_connect(widget, "changed", G_CALLBACK(cylinder_cb), cylinder); - widget = create_spinbutton(hbox, "Size", 0, 200, 0.1); + widget = create_spinbutton(hbox, "Size", 0, 300, 0.1); cylinder->size = GTK_SPIN_BUTTON(widget); widget = create_spinbutton(hbox, "Pressure", 0, 5000, 1); @@ -370,7 +402,8 @@ static GtkListStore *create_tank_size_model(void) GtkWidget *equipment_widget(void) { int i; - GtkWidget *vbox; + GtkWidget *vbox, *hbox; + GtkWidget *apply, *cancel; GtkListStore *model; vbox = gtk_vbox_new(FALSE, 3); @@ -387,5 +420,16 @@ GtkWidget *equipment_widget(void) gtk_box_pack_start(GTK_BOX(vbox), cylinder->hbox, FALSE, TRUE, 0); } + hbox = gtk_hbox_new(TRUE, 3); + gtk_box_pack_end(GTK_BOX(vbox), hbox, TRUE, FALSE, 0); + + apply = gtk_button_new_from_stock(GTK_STOCK_APPLY); + cancel = gtk_button_new_from_stock(GTK_STOCK_CANCEL); + gtk_box_pack_start(GTK_BOX(hbox), apply, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), cancel, FALSE, FALSE, 0); + + g_signal_connect(apply, "clicked", G_CALLBACK(apply_cb), NULL); + g_signal_connect(cancel, "clicked", G_CALLBACK(cancel_cb), NULL); + return vbox; }