Compare commits

..

No commits in common. "0a5ba481bc085923b157ea98e44dd38433ff0d2a" and "1fa1a10a107a70795cfa92a22c444e24d47a0b58" have entirely different histories.

2 changed files with 6 additions and 30 deletions

View File

@ -99,6 +99,7 @@ static GDateTime *mainWindow_get_date_from_string(gchar *string)
hour >= 0 && hour <= 23 &&
minute >= 0 && minute <= 59) {
datetime = g_date_time_new_local(year, month, day, hour, minute, 0);
g_regex_unref(regex);
break;
}
@ -310,19 +311,11 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"changed",
(GCallback) mainWindow_dateChanged,
mainWindow);
g_signal_connect(mainWindow->dateEnd,
"changed",
(GCallback) mainWindow_dateChanged,
mainWindow);
g_signal_connect(mainWindow->dateStart,
"focus-out-event",
(GCallback) mainWindow_checkDate,
mainWindow);
g_signal_connect(mainWindow->dateEnd,
"focus-out-event",
(GCallback) mainWindow_checkDate,
mainWindow);
}
struct mainWindow *mainWindow_new()
@ -357,8 +350,8 @@ struct mainWindow *mainWindow_new()
/**
* 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), "2017-01-01");
gtk_entry_set_text(mainWindow->dateStart, "2016-01-01");
gtk_entry_set_text(mainWindow->dateEnd, "2017-01-01");
return mainWindow;
}
@ -433,12 +426,12 @@ void mainWindow_dateChanged(GtkWidget *widget, gpointer user_data)
GDateTime *datetime;
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
datetime = mainWindow_get_date_from_string((gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->dateStart)));
datetime = mainWindow_get_date_from_string(gtk_entry_get_text(GTK_ENTRY(mainWindow->dateStart)));
if (datetime) {
mainWindow->filterSettings.time_start = g_date_time_to_unix(datetime);
g_date_time_unref(datetime);
}
datetime = mainWindow_get_date_from_string((gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->dateEnd)));
datetime = mainWindow_get_date_from_string(gtk_entry_get_text(GTK_ENTRY(mainWindow->dateEnd)));
if (datetime) {
mainWindow->filterSettings.time_end = g_date_time_to_unix(datetime);
g_date_time_unref(datetime);
@ -446,19 +439,3 @@ void mainWindow_dateChanged(GtkWidget *widget, gpointer user_data)
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
}
void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data)
{
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
GDateTime *datetime;
datetime = mainWindow_get_date_from_string((char *)gtk_entry_get_text(GTK_ENTRY(widget)));
if (!datetime) {
datetime = g_date_time_new_from_unix_local(widget == mainWindow->dateStart
? mainWindow->filterSettings.time_start
: mainWindow->filterSettings.time_end);
gtk_entry_set_text(GTK_ENTRY(widget),
g_date_time_format(datetime, "%Y-%m-%d"));
}
g_date_time_unref(datetime);
}

View File

@ -34,6 +34,5 @@ void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer u
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
void mainWindow_dateChanged(GtkWidget *widget, gpointer user_data);
void mainWindow_checkDate(GtkWidget *widget, gint event, gpointer user_data);
#endif /* MAINWINDOW_H */