diff options
author | Tom Willemsen | 2012-10-25 21:15:50 +0200 |
---|---|---|
committer | Tom Willemsen | 2012-10-25 21:15:50 +0200 |
commit | 7ffc87d99d0435146358c6ea1dd90ddaae294f51 (patch) | |
tree | 2c058fb61cad48e5a3f40d1d2926608382ec82b6 /src/data.c | |
parent | 337a0ba2d28f837138aeebda5eda6fb566f3c39b (diff) | |
download | eye-on-manga-7ffc87d99d0435146358c6ea1dd90ddaae294f51.tar.gz eye-on-manga-7ffc87d99d0435146358c6ea1dd90ddaae294f51.zip |
Correctly show changes when total goes down
* src/data.c (data_update_manga): When updating, set `current_qty' to
the lesser of `current_qty' and `total_qty' so that current will
never exceed total. If the update went well remove any volumes that
have numbers greater than the `total_qty'.
* src/eom-detail-window.c (eom_detail_window_load): Get to upper bound
of rows, if I need 1.5 rows I actually need 2 rows, what was I
thinking? Clear both tables of children before filling them up
again.
(cb_destroy): New function. Just calls destroy in `widget', but
`gtk_widget_destroy' doesn't seem like a valid `GtkCallback'.
(on_volume_toggled): When adding a volume fails, revert one from
`current_qty'. Don't mess with `self->manga->current_qty', just
reset the manga id, otherwise we will know that there should be one
more or less volume, but won't show it in the manga's volumes
collection.
Diffstat (limited to 'src/data.c')
-rw-r--r-- | src/data.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -239,12 +239,24 @@ gboolean data_update_manga(gint manga_id, const gchar *name, gint total_qty) { gchar *sql = - g_strdup_printf("UPDATE manga SET name = '%s', total_qty = %d " - "WHERE id = %d", name, total_qty, manga_id); + g_strdup_printf("UPDATE manga SET " + " name = '%s', " + " total_qty = %d, " + " current_qty = MIN(current_qty, %d) " + "WHERE id = %d", name, total_qty, total_qty, + manga_id); gboolean ret = execute_non_query(sql); g_free(sql); + if (ret) { + sql = g_strdup_printf("DELETE FROM volume " + "WHERE manga_id = %d " + "AND id > %d", + manga_id, total_qty); + ret = execute_non_query(sql); + } + return ret; } |