mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add dive tags and support invalid dives
This started out as a way to keep dives in the dive list but being able to mark them as 'invalid' so they wouldn't be visible (with an option to disable that feature). Now it supports an (at this point, fixed) set of tags that can be assigned to a dive with 'invalid' being just one of them (but one that is special as it gets some additional support for hiding such dive and marking dives as (in)valid from the divelist). [Dirk Hohndel: merged with the latest code and minor changes for coding style and consistency. Ensure divelist is marked as modified when changing 'invalid' tag] Signed-Off-By: Jozef Ivanecký (dodo.sk@gmail.com) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
68545465ba
commit
ed3f67bc33
9 changed files with 198 additions and 5 deletions
|
@ -715,7 +715,10 @@ static void fill_dive_list(void)
|
|||
i = dive_table.nr;
|
||||
while (--i >= 0) {
|
||||
struct dive *dive = get_dive(i);
|
||||
dive_trip_t *trip = dive->divetrip;
|
||||
dive_trip_t *trip;
|
||||
if ((dive->dive_tags & DTYPE_INVALID) && !prefs.display_invalid_dives)
|
||||
continue;
|
||||
trip = dive->divetrip;
|
||||
|
||||
if (!trip) {
|
||||
parent_ptr = NULL;
|
||||
|
@ -1061,6 +1064,42 @@ static void save_as_cb(GtkWidget *menuitem, struct dive *dive)
|
|||
}
|
||||
}
|
||||
|
||||
static void invalid_dives_cb(GtkWidget *menuitem, GtkTreePath *path)
|
||||
{
|
||||
int i;
|
||||
int changed = 0;
|
||||
struct dive *dive;
|
||||
|
||||
if (!amount_selected)
|
||||
return;
|
||||
/* walk the dive list in chronological order */
|
||||
for_each_dive(i, dive) {
|
||||
dive = get_dive(i);
|
||||
if (!dive)
|
||||
continue;
|
||||
if (!dive->selected)
|
||||
continue;
|
||||
/* now swap the invalid tag if just 1 dive was selected
|
||||
* otherwise set all to invalid */
|
||||
if(amount_selected == 1) {
|
||||
if (dive->dive_tags & DTYPE_INVALID)
|
||||
dive->dive_tags &= ~DTYPE_INVALID;
|
||||
else
|
||||
dive->dive_tags |= DTYPE_INVALID;
|
||||
changed = 1;
|
||||
} else {
|
||||
if (! dive->dive_tags & DTYPE_INVALID) {
|
||||
dive->dive_tags |= DTYPE_INVALID;
|
||||
changed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
dive_list_update_dives();
|
||||
mark_divelist_changed(TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void expand_all_cb(GtkWidget *menuitem, GtkTreeView *tree_view)
|
||||
{
|
||||
gtk_tree_view_expand_all(tree_view);
|
||||
|
@ -1626,7 +1665,7 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
|
|||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
} else {
|
||||
dive = get_dive(idx);
|
||||
/* if we right click on selected dive(s), edit or delete those */
|
||||
/* if we right click on selected dive(s), edit, delete or tag them as invalid */
|
||||
if (dive->selected) {
|
||||
if (amount_selected == 1) {
|
||||
deletelabel = _(deletesinglelabel);
|
||||
|
@ -1642,6 +1681,17 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int
|
|||
g_signal_connect(menuitem, "activate", G_CALLBACK(save_as_cb), dive);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
|
||||
if (amount_selected == 1) {
|
||||
if (dive->dive_tags & DTYPE_INVALID)
|
||||
menuitem = gtk_menu_item_new_with_label(_("Mark valid"));
|
||||
else
|
||||
menuitem = gtk_menu_item_new_with_label(_("Mark invalid"));
|
||||
} else {
|
||||
menuitem = gtk_menu_item_new_with_label(_("Mark invalid"));
|
||||
}
|
||||
g_signal_connect(menuitem, "activate", G_CALLBACK(invalid_dives_cb), path);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
|
||||
menuitem = gtk_menu_item_new_with_label(deletelabel);
|
||||
g_signal_connect(menuitem, "activate", G_CALLBACK(delete_selected_dives_cb), path);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue