Added function to clear the listStore
This commit is contained in:
parent
7a9a5af65b
commit
ba3d68c507
@ -16,6 +16,9 @@ int main(int argc, char *argv[])
|
||||
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(), TRUE);
|
||||
mdiary_reset_store(mainWindow->entryListStore, mainWindow->completionListStore);
|
||||
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
|
@ -475,7 +475,7 @@ void mainWindow_set_meta_information(struct mainWindow *mainWindow,
|
||||
mainWindow->time_earliest = time_earliest;
|
||||
mainWindow->time_latest = time_latest;
|
||||
mainWindow->filterSettings.hide_all = hide_all;
|
||||
|
||||
gtk_widget_set_sensitive(mainWindow->mainPane, !hide_all);
|
||||
mainWindow_clearSearch(NULL, mainWindow);
|
||||
}
|
||||
|
||||
|
34
src/mdiary.c
34
src/mdiary.c
@ -500,3 +500,37 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
|
||||
-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);
|
||||
}
|
||||
|
@ -28,5 +28,6 @@ GDateTime *mdiary_get_date_from_string_ext(gchar *string, gchar *prefix, gchar *
|
||||
GDateTime *mdiary_get_date_from_string(gchar *string);
|
||||
gint64 mdiary_get_time_earliest(void);
|
||||
gint64 mdiary_get_time_latest(void);
|
||||
void mdiary_reset_store(GtkListStore *entryListStore, GtkListStore *autoCompletion);
|
||||
|
||||
#endif /* MDIARY_H */
|
||||
|
Loading…
Reference in New Issue
Block a user