From b3e84cf14a6eec63c0e7cf8d11e8279f22c56b56 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sun, 5 Feb 2017 17:38:36 +0100 Subject: [PATCH] Some filtering fixes --- src/main.c | 2 +- src/mainwindow.c | 13 +++++++++++-- src/mainwindow.h | 14 +++++++++----- src/mdiary.c | 3 +-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index dbbf5fb..af61136 100644 --- a/src/main.c +++ b/src/main.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) gtk_widget_show(mainWindow->mainWindow); mdiary_scan_to_store(argv[1], mainWindow->entryListStore); - mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest()); + mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest(), FALSE); gtk_main(); diff --git a/src/mainwindow.c b/src/mainwindow.c index 977f0b9..891f8e3 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -17,7 +17,7 @@ static gboolean mainWindow_workspace_entry_visible(GtkTreeModel *model, gchar *temp; gboolean ret = FALSE; - searchString = gtk_entry_get_text(GTK_ENTRY(mainWindow->workspaceSearch)); + searchString = (gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->workspaceSearch)); if (g_strcmp0(searchString, "")) { regex = g_regex_new(searchString, G_REGEX_CASELESS, 0, NULL); @@ -61,6 +61,9 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GDateTime *datetime; guint time; + if (mainWindow->filterSettings.hide_all) + return FALSE; + /* Check text search */ searchString = (gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->searchEntry)); if (searchString[0] != 0 && ( @@ -132,6 +135,7 @@ static gint mainWindow_sort_date_compare_func(GtkTreeModel *model, gtk_tree_model_get(model, a, COL_TIMESTAMP, &datetime1, -1); gtk_tree_model_get(model, b, COL_TIMESTAMP, &datetime2, -1); + time1 = g_date_time_to_unix(datetime1); time2 = g_date_time_to_unix(datetime2); @@ -411,6 +415,7 @@ struct mainWindow *mainWindow_new() mainWindow->filterSettings.time_start = 0; mainWindow->filterSettings.time_end = -1; + mainWindow->filterSettings.hide_all = TRUE; mainWindow->time_earliest = 0; mainWindow->time_latest = 0; @@ -433,10 +438,14 @@ struct mainWindow *mainWindow_new() * @param time_earliest is the reset value for the filter start date * @param time_latest is the reset value for the filter end date */ -void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_earliest, guint time_latest) +void mainWindow_set_meta_information(struct mainWindow *mainWindow, + guint time_earliest, + guint time_latest, + gboolean hide_all) { mainWindow->time_earliest = time_earliest; mainWindow->time_latest = time_latest; + mainWindow->filterSettings.hide_all = hide_all; mainWindow_clearSearch(NULL, mainWindow); } diff --git a/src/mainwindow.h b/src/mainwindow.h index fd5df81..443c08a 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -28,16 +28,17 @@ struct mainWindow { GtkWidget *selectedDateEntry; GtkTreeModelFilter *entryListFiltered; - guint time_earliest; - guint time_latest; + gint64 time_earliest; + gint64 time_latest; struct filterSettings { - guint time_start; - guint time_end; + gint64 time_start; + gint64 time_end; gboolean search_title; gboolean search_tags; gboolean search_summary; gboolean search_text; + gboolean hide_all; } filterSettings; GtkWidget *buttonOtherWorkspace; @@ -50,7 +51,10 @@ struct mainWindow { }; struct mainWindow *mainWindow_new(); -void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_earliest, guint time_latest); +void mainWindow_set_meta_information(struct mainWindow *mainWindow, + guint time_earliest, + guint time_latest, + gboolean hide_all); /* Slots */ void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data); diff --git a/src/mdiary.c b/src/mdiary.c index e36773a..0628691 100644 --- a/src/mdiary.c +++ b/src/mdiary.c @@ -232,7 +232,7 @@ static void mdiary_add_file_to_store(gchar *filename, GtkListStore *entryListSto GString *text = NULL; guint header_state = 0; - g_print("Add file: %s\n", filename); + g_message("Add file: %s\n", filename); file = g_file_new_for_path(filename); stream = g_file_read(file, NULL, &err); @@ -433,7 +433,6 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore, taglist_copy = g_list_copy_deep(tags, (GCopyFunc) g_strdup, NULL); taglistString = mdiary_taglist_to_string(taglist_copy); - gtk_list_store_append(entryListStore, &iter); gtk_list_store_set(entryListStore, &iter, COL_TITLE, title,