Compare commits
No commits in common. "3c00112efab4521647c4380ee2c9a7b3cbce1848" and "57623e464e707ebbc3a8de506a2b03a7975091b2" have entirely different histories.
3c00112efa
...
57623e464e
@ -14,7 +14,6 @@ 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());
|
||||
|
||||
gtk_main();
|
||||
|
||||
|
@ -63,9 +63,7 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GtkTreeIter *
|
||||
gtk_tree_model_get(model, iter, COL_TIMESTAMP, &datetime, -1);
|
||||
if (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 - (60 * 60 * 23 + 60 * 59 + 59)) &&
|
||||
time <= mainWindow->filterSettings.time_end + (60 * 60 * 23 + 60 * 59 + 59);
|
||||
return time >= mainWindow->filterSettings.time_start && time <= mainWindow->filterSettings.time_end;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -282,8 +280,6 @@ struct mainWindow *mainWindow_new()
|
||||
|
||||
mainWindow->filterSettings.time_start = 0;
|
||||
mainWindow->filterSettings.time_end = -1;
|
||||
mainWindow->time_earliest = 0;
|
||||
mainWindow->time_latest = 0;
|
||||
|
||||
gtk_builder_connect_signals(builder, NULL);
|
||||
|
||||
@ -299,20 +295,6 @@ struct mainWindow *mainWindow_new()
|
||||
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.
|
||||
* @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)
|
||||
{
|
||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
||||
GDateTime *datetime;
|
||||
gchar *temp;
|
||||
|
||||
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");
|
||||
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), temp);
|
||||
g_date_time_unref(datetime);
|
||||
g_free(temp);
|
||||
|
||||
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);
|
||||
/**
|
||||
* These need to be set to oldest and newest after indexing date
|
||||
*/
|
||||
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), "2016-01-01");
|
||||
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), "2018-01-01");
|
||||
}
|
||||
|
@ -28,9 +28,6 @@ struct mainWindow {
|
||||
GtkWidget *selectedDateEntry;
|
||||
GtkTreeModelFilter *entryListFiltered;
|
||||
|
||||
guint time_earliest;
|
||||
guint time_latest;
|
||||
|
||||
struct filterSettings {
|
||||
guint time_start;
|
||||
guint time_end;
|
||||
@ -42,7 +39,6 @@ struct mainWindow {
|
||||
};
|
||||
|
||||
struct mainWindow *mainWindow_new();
|
||||
void mainWindow_set_meta_information(struct mainWindow *mainWindow, guint time_earliest, guint time_latest);
|
||||
|
||||
/* Slots */
|
||||
void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_data);
|
||||
|
36
src/mdiary.c
36
src/mdiary.c
@ -1,8 +1,5 @@
|
||||
#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.
|
||||
*/
|
||||
@ -157,7 +154,7 @@ static gboolean mdiary_is_empty_line(gchar *string)
|
||||
{
|
||||
GRegex *regex;
|
||||
GMatchInfo *match_info;
|
||||
gboolean ret = 0;
|
||||
gchar *ret = 0;
|
||||
|
||||
regex = g_regex_new("^\\s*$", G_REGEX_RAW, 0, NULL);
|
||||
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));
|
||||
do {
|
||||
if (*ptr == ',' || *ptr == '\0') {
|
||||
if (*ptr == ',' || *ptr == ' ' || *ptr == '\0') {
|
||||
bak = *ptr;
|
||||
if (collected) {
|
||||
collected = 0;
|
||||
@ -202,9 +199,6 @@ static GList *mdiary_add_tags_from_string(gchar *string)
|
||||
} else {
|
||||
beg_ptr = ptr + 1;
|
||||
}
|
||||
} else if (*ptr == ' ') {
|
||||
if (!collected)
|
||||
beg_ptr = ptr + 1;
|
||||
} else {
|
||||
collected = 1;
|
||||
}
|
||||
@ -308,11 +302,6 @@ static void mdiary_add_file_to_store(gchar *filename, GtkListStore *entryListSto
|
||||
summary,
|
||||
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(stream), NULL, NULL);
|
||||
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)
|
||||
{
|
||||
time_earliest = G_MAXINT64;
|
||||
time_latest = 0;
|
||||
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
|
||||
* @param list is a GList of strings to concatenate
|
||||
|
@ -26,7 +26,5 @@ void mdiary_add_entry_to_store(GtkListStore *entryListStore,
|
||||
gchar *text);
|
||||
GDateTime *mdiary_get_date_from_string_ext(gchar *string, gchar *prefix, gchar *suffix);
|
||||
GDateTime *mdiary_get_date_from_string(gchar *string);
|
||||
guint mdiary_get_time_earliest(void);
|
||||
guint mdiary_get_time_latest(void);
|
||||
|
||||
#endif /* MDIARY_H */
|
||||
|
Loading…
Reference in New Issue
Block a user