From 8e49f0c56e5e5de4952521719003a9dc77a94063 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Sun, 21 Oct 2012 15:26:34 +0200 Subject: [PATCH] Remember filter after closing edit window * src/eom-main-window.c (eom_main_window_new): Set the `state' variable to 0 the first time around. (eom_main_window_load): Remove the `manga' parameter. Get incomplete collections when `state' is `0'. (eom_main_window_on_filter): Don't fetch any manga, just set the window's `state'. (eom_main_window_on_new): (eom_main_window_on_edit_closed): No more `manga' parameter for `eom_main_window_load'. * src/eom-main-window.h (struct _EomMainWindow): Add `state' property. * src/interface.c (interface_show_main_window): No more `manga' parameter for `eom_main_window_load'. --- src/eom-main-window.c | 24 ++++++++++-------------- src/eom-main-window.h | 4 +++- src/interface.c | 2 +- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/eom-main-window.c b/src/eom-main-window.c index b80e6cb..fa1253e 100644 --- a/src/eom-main-window.c +++ b/src/eom-main-window.c @@ -42,18 +42,20 @@ static void eom_main_window_on_row_activated(GtkWidget *treeview, GtkWidget *eom_main_window_new(void) { - return g_object_new(EOM_TYPE_MAIN_WINDOW, NULL); + return g_object_new(EOM_TYPE_MAIN_WINDOW, + "state", 0, + NULL); } -void eom_main_window_load(EomMainWindow *self, GList *manga) +void eom_main_window_load(EomMainWindow *self) { GList *list; int i; gtk_list_store_clear(self->store); - if (manga) - list = manga; + if (self->state) + list = data_get_incomplete_manga(); else list = data_get_manga(); @@ -216,14 +218,8 @@ static void eom_main_window_add_menu(EomMainWindow *window) static void eom_main_window_on_filter(GtkWidget *widget, struct filter_args *arg) { - GList *manga; - - if (arg->state) - manga = data_get_incomplete_manga(); - else - manga = data_get_manga(); - - eom_main_window_load(arg->window, manga); + arg->window->state = arg->state; + eom_main_window_load(arg->window); } static void eom_main_window_on_new(GtkWidget *widget, GtkWindow *window) @@ -252,7 +248,7 @@ static void eom_main_window_on_new(GtkWidget *widget, GtkWindow *window) if (name != NULL) { if (data_add_manga(name, total_qty)) - eom_main_window_load(EOM_MAIN_WINDOW(window), NULL); + eom_main_window_load(EOM_MAIN_WINDOW(window)); } } @@ -262,7 +258,7 @@ static gboolean eom_main_window_on_edit_closed(GtkWidget *widget, { EomMainWindow *self = user_data; - eom_main_window_load(self, NULL); + eom_main_window_load(self); return FALSE; } diff --git a/src/eom-main-window.h b/src/eom-main-window.h index 4cecb50..d4ff74e 100644 --- a/src/eom-main-window.h +++ b/src/eom-main-window.h @@ -45,13 +45,15 @@ struct _EomMainWindow GtkTreeIter iter; GtkListStore *store; + + int state; }; GType eom_main_window_get_type(void); GtkWidget *eom_main_window_new(void); -void eom_main_window_load(EomMainWindow *self, GList *manga); +void eom_main_window_load(EomMainWindow *self); void eom_main_window_add_line(EomMainWindow *window, gint id, const gchar *name, diff --git a/src/interface.c b/src/interface.c index a897f29..02b8ff4 100644 --- a/src/interface.c +++ b/src/interface.c @@ -12,7 +12,7 @@ void interface_show_main_window(void) window = eom_main_window_new(); gtk_widget_show_all(window); - eom_main_window_load(EOM_MAIN_WINDOW(window), NULL); + eom_main_window_load(EOM_MAIN_WINDOW(window)); } GtkWidget *interface_show_edit_window(gint manga_id)