Added function to clear the listStore

This commit is contained in:
Markus Koch 2017-02-07 19:03:05 +01:00
parent 7a9a5af65b
commit ba3d68c507
4 changed files with 39 additions and 1 deletions

View File

@ -16,6 +16,9 @@ int main(int argc, char *argv[])
mdiary_scan_to_store(argv[1], mainWindow->entryListStore, mainWindow->completionListStore); mdiary_scan_to_store(argv[1], mainWindow->entryListStore, mainWindow->completionListStore);
mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest(), FALSE); mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest(), FALSE);
mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest(), TRUE);
mdiary_reset_store(mainWindow->entryListStore, mainWindow->completionListStore);
gtk_main(); gtk_main();
return 0; return 0;

View File

@ -475,7 +475,7 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow,
mainWindow->time_earliest = time_earliest; mainWindow->time_earliest = time_earliest;
mainWindow->time_latest = time_latest; mainWindow->time_latest = time_latest;
mainWindow->filterSettings.hide_all = hide_all; mainWindow->filterSettings.hide_all = hide_all;
gtk_widget_set_sensitive(mainWindow->mainPane, !hide_all);
mainWindow_clearSearch(NULL, mainWindow); mainWindow_clearSearch(NULL, mainWindow);
} }

View File

@ -500,3 +500,37 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
-1); -1);
} }
} }
/**
* @brief mdiary_free_entry_elements frees all non-GtkListView-managed parts of the mdiary entry
* @param model
* @param path
* @param iter
* @param data
* @return FALSE
*/
gboolean mdiary_free_entry_elements(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) {
gpointer ptr;
gtk_tree_model_get(model, iter, COL_TAGLIST, &ptr, -1);
g_list_free_full((GList *)ptr, g_free);
gtk_tree_model_get(model, iter, COL_TIMESTAMP, &ptr, -1);
g_date_time_unref((GDateTime *)ptr);
return FALSE;
}
/**
* @brief mdiary_reset_store clears the two GtkListStores and frees all of their respective elements. (Make sure that
* no other part of the program tries to access the elements of the store while executing this function.)
* @param entryListStore
* @param autoCompletion
*/
void mdiary_reset_store(GtkListStore *entryListStore, GtkListStore *autoCompletion)
{
gtk_tree_model_foreach(GTK_TREE_MODEL(entryListStore), mdiary_free_entry_elements, NULL);
gtk_list_store_clear(entryListStore);
gtk_list_store_clear(autoCompletion);
}

View File

@ -28,5 +28,6 @@ GDateTime *mdiary_get_date_from_string_ext(gchar *string, gchar *prefix, gchar *
GDateTime *mdiary_get_date_from_string(gchar *string); GDateTime *mdiary_get_date_from_string(gchar *string);
gint64 mdiary_get_time_earliest(void); gint64 mdiary_get_time_earliest(void);
gint64 mdiary_get_time_latest(void); gint64 mdiary_get_time_latest(void);
void mdiary_reset_store(GtkListStore *entryListStore, GtkListStore *autoCompletion);
#endif /* MDIARY_H */ #endif /* MDIARY_H */