From e3bd75ef0dc6bf18fbf74cb9d3139fdfd8412446 Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 29 Sep 2014 23:40:44 +0200 Subject: [PATCH] Clear chart icon view before loading the list Fixes #94 --- src/ag-app.c | 2 +- src/ag-icon-view.c | 8 ++++++++ src/ag-icon-view.h | 2 ++ src/ag-window.c | 8 +++++--- src/ag-window.h | 2 +- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ag-app.c b/src/ag-app.c index 33bfd95..02b65e1 100644 --- a/src/ag-app.c +++ b/src/ag-app.c @@ -113,7 +113,7 @@ new_window_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data) { AgWindow *window = AG_WINDOW(ag_app_create_window(AG_APP(user_data))); - ag_window_load_chart_list(window); + ag_window_reload_chart_list(window); ag_window_change_tab(window, "list"); } diff --git a/src/ag-icon-view.c b/src/ag-icon-view.c index b6494a9..a867bcc 100644 --- a/src/ag-icon-view.c +++ b/src/ag-icon-view.c @@ -470,3 +470,11 @@ ag_icon_view_remove_selected(AgIconView *icon_view) ag_icon_view_selection_changed(icon_view); } + +void +ag_icon_view_remove_all(AgIconView *icon_view) +{ + AgIconViewPrivate *priv = ag_icon_view_get_instance_private(icon_view); + + gtk_list_store_clear(priv->model); +} diff --git a/src/ag-icon-view.h b/src/ag-icon-view.h index 9788577..3df334a 100644 --- a/src/ag-icon-view.h +++ b/src/ag-icon-view.h @@ -65,6 +65,8 @@ void ag_icon_view_unselect_all(AgIconView *icon_view); void ag_icon_view_remove_selected(AgIconView *icon_view); +void ag_icon_view_remove_all(AgIconView *icon_view); + G_END_DECLS #endif /* __AG_ICON_VIEW_H__ */ diff --git a/src/ag-window.c b/src/ag-window.c index 8482e19..9775c21 100644 --- a/src/ag-window.c +++ b/src/ag-window.c @@ -1666,7 +1666,7 @@ ag_window_back_action(GSimpleAction *action, ag_db_chart_save_unref(priv->saved_data); priv->saved_data = NULL; - ag_window_load_chart_list(window); + ag_window_reload_chart_list(window); gtk_stack_set_visible_child_name(GTK_STACK(priv->stack), "list"); gtk_header_bar_set_subtitle(GTK_HEADER_BAR(priv->header_bar), NULL); } @@ -1677,7 +1677,7 @@ ag_window_refresh_action(GSimpleAction *action, GVariant *parameter, gpointer user_data) { - ag_window_load_chart_list(AG_WINDOW(user_data)); + ag_window_reload_chart_list(AG_WINDOW(user_data)); } static void @@ -2862,7 +2862,7 @@ ag_window_cleanup_load_items(LoadIdleData *idle_data) } gboolean -ag_window_load_chart_list(AgWindow *window) +ag_window_reload_chart_list(AgWindow *window) { LoadIdleData *idle_data; AgDb *db = ag_db_get(); @@ -2870,6 +2870,8 @@ ag_window_load_chart_list(AgWindow *window) GList *chart_list = ag_db_chart_get_list(db, &err); AgWindowPrivate *priv = ag_window_get_instance_private(window); + ag_icon_view_remove_all(AG_ICON_VIEW(priv->chart_list)); + /* Lazy loading of charts with previews. Idea is from * http://blogs.gnome.org/ebassi/documentation/lazy-loading/ */ diff --git a/src/ag-window.h b/src/ag-window.h index 1f70c6c..ba3ba95 100644 --- a/src/ag-window.h +++ b/src/ag-window.h @@ -75,7 +75,7 @@ void ag_window_settings_save(GtkWindow *window, void ag_window_change_tab(AgWindow *window, const gchar *tab_name); -gboolean ag_window_load_chart_list(AgWindow *window); +gboolean ag_window_reload_chart_list(AgWindow *window); gboolean ag_window_is_usable(AgWindow *window);