summaryrefslogtreecommitdiffstats
path: root/info.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-06 12:44:55 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-09-06 12:44:55 -0700
commit252c28f8f28614383167a20105ef68f4e5b4eb4c (patch)
tree196d323233855984209e206019e600737c25f1e1 /info.c
parentd20428973acbd9dd052ae5213098f5ff59df924a (diff)
parent4679f4fbbc1f303b963b4eabebbbc9c684299619 (diff)
downloadsubsurface-252c28f8f28614383167a20105ef68f4e5b4eb4c.tar.gz
Merge branch 'trip3' of git://git.hohndel.org/subsurface
Pull trip manipulation branch from Dirk Hohndel: "I have added yet more of the requested features. I am not aware of any outstanding bugs or crashes (except for the Gtk problem that causes the import to crash for some people on Ubuntu and MacOS - but as I mentioned earlier, that bug has been around as long as the import file selector box)." * 'trip3' of git://git.hohndel.org/subsurface: Avoid duplicate dive_trip entries More trip manipulations: remove selected dives from trip Add ability to merge trip with trip below Use the infrastructure for moving dives in more places Correct the trip related test dives Fix crash when removing the first dive of a trip Correctly initialize the toggle state of the autogroup menu entry Fix copy_tree_node to no longer overwrite dive duration Add autogen menu command Fix a crash when changing sort column Use truth values with gboolean Allow modification and edits of trips Clean up macros and auxiliary functions Store time_t as long value
Diffstat (limited to 'info.c')
-rw-r--r--info.c62
1 files changed, 61 insertions, 1 deletions
diff --git a/info.c b/info.c
index d9379ac68..3efb40cf8 100644
--- a/info.c
+++ b/info.c
@@ -415,6 +415,24 @@ static void save_dive_info_changes(struct dive *dive, struct dive *master, struc
}
}
+static void dive_trip_widget(GtkWidget *box, struct dive *trip, struct dive_info *info)
+{
+ GtkWidget *hbox, *label;
+ char buffer[80] = "Edit trip summary";
+
+ label = gtk_label_new(buffer);
+ gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0);
+
+ info->location = text_entry(box, "Location", location_list, trip->location);
+
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, TRUE, 0);
+
+ info->notes = text_view(box, "Notes", READ_WRITE);
+ if (trip->notes && *trip->notes)
+ gtk_text_buffer_set_text(gtk_text_view_get_buffer(info->notes), trip->notes, -1);
+}
+
static void dive_info_widget(GtkWidget *box, struct dive *dive, struct dive_info *info, gboolean multi)
{
GtkWidget *hbox, *label, *frame, *equipment;
@@ -489,7 +507,49 @@ void update_equipment_data(struct dive *dive, struct dive *master)
memcpy(dive->weightsystem, master->weightsystem, WS_BYTES);
}
-/* A negative index means "all selected" */
+gboolean edit_trip(struct dive *trip)
+{
+ GtkWidget *dialog, *vbox;
+ int success;
+ gboolean changed = FALSE;
+ char *old_text, *new_text;
+ struct dive_info info;
+
+ memset(&info, 0, sizeof(struct dive_info));
+ dialog = gtk_dialog_new_with_buttons("Edit Trip Info",
+ GTK_WINDOW(main_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ NULL);
+ vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ dive_trip_widget(vbox, trip, &info);
+ gtk_widget_show_all(dialog);
+ success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
+ if (success) {
+ /* we need to store the edited location and notes */
+ new_text = get_combo_box_entry_text(info.location, &trip->location, trip->location);
+ if (new_text) {
+ add_location(new_text);
+ changed = TRUE;
+ }
+ if (info.notes) {
+ old_text = trip->notes;
+ trip->notes = get_text(info.notes);
+ if (text_changed(old_text, trip->notes))
+ changed = TRUE;
+ if (old_text)
+ g_free(old_text);
+ }
+ if (changed) {
+ mark_divelist_changed(TRUE);
+ flush_divelist(trip);
+ }
+ }
+ gtk_widget_destroy(dialog);
+ return changed;
+}
+
int edit_multi_dive_info(struct dive *single_dive)
{
int success;