Compare commits

..

No commits in common. "3c00112efab4521647c4380ee2c9a7b3cbce1848" and "57623e464e707ebbc3a8de506a2b03a7975091b2" have entirely different histories.

5 changed files with 8 additions and 73 deletions

View File

@ -14,7 +14,6 @@ int main(int argc, char *argv[])
gtk_widget_show(mainWindow->mainWindow); gtk_widget_show(mainWindow->mainWindow);
mdiary_scan_to_store(argv[1], mainWindow->entryListStore); mdiary_scan_to_store(argv[1], mainWindow->entryListStore);
mainWindow_set_meta_information(mainWindow, mdiary_get_time_earliest(), mdiary_get_time_latest());
gtk_main(); gtk_main();

View File

@ -63,9 +63,7 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GtkTreeIter *
gtk_tree_model_get(model, iter, COL_TIMESTAMP, &datetime, -1); gtk_tree_model_get(model, iter, COL_TIMESTAMP, &datetime, -1);
if (datetime) { if (datetime) {
time = g_date_time_to_unix(datetime); time = g_date_time_to_unix(datetime);
/* The addition/subtraction in braces allows for the whole day instead of just its first second. */ return time >= mainWindow->filterSettings.time_start && time <= mainWindow->filterSettings.time_end;
return time >= (mainWindow->filterSettings.time_start - (60 * 60 * 23 + 60 * 59 + 59)) &&
time <= mainWindow->filterSettings.time_end + (60 * 60 * 23 + 60 * 59 + 59);
} else { } else {
return 0; return 0;
} }
@ -282,8 +280,6 @@ struct mainWindow *mainWindow_new()
mainWindow->filterSettings.time_start = 0; mainWindow->filterSettings.time_start = 0;
mainWindow->filterSettings.time_end = -1; mainWindow->filterSettings.time_end = -1;
mainWindow->time_earliest = 0;
mainWindow->time_latest = 0;
gtk_builder_connect_signals(builder, NULL); gtk_builder_connect_signals(builder, NULL);
@ -299,20 +295,6 @@ struct mainWindow *mainWindow_new()
return mainWindow; return mainWindow;
} }
/**
* @brief mainWindow_set_meta_information sets some meta info for a nice GUI. It also resets the search.
* @param mainWindow
* @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)
{
mainWindow->time_earliest = time_earliest;
mainWindow->time_latest = time_latest;
mainWindow_clearSearch(NULL, mainWindow);
}
/** /**
* @brief mainWindow_chooseWorkspaceClicked is called when the user clicks the Choose Workspace button. * @brief mainWindow_chooseWorkspaceClicked is called when the user clicks the Choose Workspace button.
* @param widget N/A * @param widget N/A
@ -482,20 +464,12 @@ void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data)
void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data) void mainWindow_clearSearch(GtkWidget *widget, gpointer user_data)
{ {
struct mainWindow *mainWindow = (struct mainWindow *)user_data; struct mainWindow *mainWindow = (struct mainWindow *)user_data;
GDateTime *datetime;
gchar *temp;
gtk_entry_set_text(GTK_ENTRY(mainWindow->searchEntry), ""); gtk_entry_set_text(GTK_ENTRY(mainWindow->searchEntry), "");
datetime = g_date_time_new_from_unix_local(mainWindow->time_earliest); /**
temp = g_date_time_format(datetime, "%Y-%m-%d"); * These need to be set to oldest and newest after indexing date
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), temp); */
g_date_time_unref(datetime); gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), "2016-01-01");
g_free(temp); gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), "2018-01-01");
datetime = g_date_time_new_from_unix_local(mainWindow->time_latest);
temp = g_date_time_format(datetime, "%Y-%m-%d");
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), temp);
g_date_time_unref(datetime);
g_free(temp);
} }

View File

@ -28,9 +28,6 @@ struct mainWindow {
GtkWidget *selectedDateEntry; GtkWidget *selectedDateEntry;
GtkTreeModelFilter *entryListFiltered; GtkTreeModelFilter *entryListFiltered;
guint time_earliest;
guint time_latest;
struct filterSettings { struct filterSettings {
guint time_start; guint time_start;
guint time_end; guint time_end;
@ -42,7 +39,6 @@ struct mainWindow {
}; };
struct mainWindow *mainWindow_new(); struct mainWindow *mainWindow_new();
void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_earliest, guint time_latest);
/* Slots */ /* Slots */
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data); void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);

View File

@ -1,8 +1,5 @@
#include "mdiary.h" #include "mdiary.h"
static gint64 time_earliest;
static gint64 time_latest;
/** /**
* @brief The dateFormats struct contains regex/date-info pairs to parse different date formats. * @brief The dateFormats struct contains regex/date-info pairs to parse different date formats.
*/ */
@ -157,7 +154,7 @@ static gboolean mdiary_is_empty_line(gchar *string)
{ {
GRegex *regex; GRegex *regex;
GMatchInfo *match_info; GMatchInfo *match_info;
gboolean ret = 0; gchar *ret = 0;
regex = g_regex_new("^\\s*$", G_REGEX_RAW, 0, NULL); regex = g_regex_new("^\\s*$", G_REGEX_RAW, 0, NULL);
if (g_regex_match(regex, string, 0, &match_info) && if (g_regex_match(regex, string, 0, &match_info) &&
@ -191,7 +188,7 @@ static GList *mdiary_add_tags_from_string(gchar *string)
*/ */
ptr = beg_ptr = orig_ptr = g_strdup(g_match_info_fetch(match_info, 1)); ptr = beg_ptr = orig_ptr = g_strdup(g_match_info_fetch(match_info, 1));
do { do {
if (*ptr == ',' || *ptr == '\0') { if (*ptr == ',' || *ptr == ' ' || *ptr == '\0') {
bak = *ptr; bak = *ptr;
if (collected) { if (collected) {
collected = 0; collected = 0;
@ -202,9 +199,6 @@ static GList *mdiary_add_tags_from_string(gchar *string)
} else { } else {
beg_ptr = ptr + 1; beg_ptr = ptr + 1;
} }
} else if (*ptr == ' ') {
if (!collected)
beg_ptr = ptr + 1;
} else { } else {
collected = 1; collected = 1;
} }
@ -308,11 +302,6 @@ static void mdiary_add_file_to_store(gchar *filename, GtkListStore *entryListSto
summary, summary,
text->str); text->str);
if (g_date_time_to_unix(datetime) > time_latest)
time_latest = g_date_time_to_unix(datetime);
if (g_date_time_to_unix(datetime) < time_earliest)
time_earliest = g_date_time_to_unix(datetime);
g_input_stream_close(G_INPUT_STREAM(dstream), NULL, NULL); g_input_stream_close(G_INPUT_STREAM(dstream), NULL, NULL);
g_input_stream_close(G_INPUT_STREAM(stream), NULL, NULL); g_input_stream_close(G_INPUT_STREAM(stream), NULL, NULL);
g_string_free(text, 0); g_string_free(text, 0);
@ -358,30 +347,9 @@ static void mdiary_recurse_and_collect(gchar *base_dir, GtkListStore *entryListS
*/ */
void mdiary_scan_to_store(gchar *base_dir, GtkListStore *entryListStore) void mdiary_scan_to_store(gchar *base_dir, GtkListStore *entryListStore)
{ {
time_earliest = G_MAXINT64;
time_latest = 0;
mdiary_recurse_and_collect(base_dir, entryListStore, 5); mdiary_recurse_and_collect(base_dir, entryListStore, 5);
} }
/**
* @brief mdiary_get_time_earliest getter function for time_earliest. Call mdiary_scan_to_store before using.
* @return time_earliest
*/
guint mdiary_get_time_earliest(void)
{
return time_earliest;
}
/**
* @brief mdiary_get_time_earliest getter function for time_latest. Call mdiary_scan_to_store before using.
* @return time_latest
*/
guint mdiary_get_time_latest(void)
{
return time_latest;
}
/** /**
* @brief mainWindow_taglist_to_string concatenates a list with commas * @brief mainWindow_taglist_to_string concatenates a list with commas
* @param list is a GList of strings to concatenate * @param list is a GList of strings to concatenate

View File

@ -26,7 +26,5 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
gchar *text); gchar *text);
GDateTime *mdiary_get_date_from_string_ext(gchar *string, gchar *prefix, gchar *suffix); GDateTime *mdiary_get_date_from_string_ext(gchar *string, gchar *prefix, gchar *suffix);
GDateTime *mdiary_get_date_from_string(gchar *string); GDateTime *mdiary_get_date_from_string(gchar *string);
guint mdiary_get_time_earliest(void);
guint mdiary_get_time_latest(void);
#endif /* MDIARY_H */ #endif /* MDIARY_H */