From 337a0ba2d28f837138aeebda5eda6fb566f3c39b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 25 Oct 2012 00:25:24 +0200 Subject: [PATCH] Show an "infinite" list when total is unknown * src/eom-detail-window.c (eom_detail_window_load): If the currently selected manga's `total_qty' is `0', take, for viewing/editing purposes, the manga's `current_qty' + `1' instead. (on_volume_toggled): If the current manga's `total_qty' is `0' reload the screen after toggling a manga as collected. --- src/eom-detail-window.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/eom-detail-window.c b/src/eom-detail-window.c index 5f3de4a..00c7453 100644 --- a/src/eom-detail-window.c +++ b/src/eom-detail-window.c @@ -36,13 +36,19 @@ void eom_detail_window_load(EomDetailWindow *self) { gint i, j = 0, row = 0, col = 0; - int rows = (int)floor(self->manga->total_qty / COLUMNS); + int total_qty = self->manga->total_qty; + int rows; + + if (!total_qty) + total_qty = self->manga->current_qty + 1; + + rows = (int)floor(total_qty / COLUMNS); gtk_window_set_title(GTK_WINDOW(self), self->manga->name); gtk_table_resize(GTK_TABLE(self->ctable), rows, COLUMNS); gtk_table_resize(GTK_TABLE(self->rtable), rows, COLUMNS); - for (i = 0; i < self->manga->total_qty; i++) { + for (i = 0; i < total_qty; i++) { GtkWidget *cbtn, *rbtn; gchar *txt; @@ -275,6 +281,9 @@ on_volume_toggled(GtkToggleButton *togglebutton, gpointer user_data) } self->manga->current_qty--; } + + if (!self->manga->total_qty) + eom_detail_window_load(self); } static void