Added code to automatically fix date entries
This commit is contained in:
parent
1fa1a10a10
commit
ecf84fcd67
@ -99,7 +99,6 @@ static GDateTime *mainWindow_get_date_from_string(gchar *string)
|
|||||||
hour >= 0 && hour <= 23 &&
|
hour >= 0 && hour <= 23 &&
|
||||||
minute >= 0 && minute <= 59) {
|
minute >= 0 && minute <= 59) {
|
||||||
datetime = g_date_time_new_local(year, month, day, hour, minute, 0);
|
datetime = g_date_time_new_local(year, month, day, hour, minute, 0);
|
||||||
|
|
||||||
g_regex_unref(regex);
|
g_regex_unref(regex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -311,11 +310,19 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
|
|||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_dateChanged,
|
(GCallback) mainWindow_dateChanged,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
|
|
||||||
g_signal_connect(mainWindow->dateEnd,
|
g_signal_connect(mainWindow->dateEnd,
|
||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_dateChanged,
|
(GCallback) mainWindow_dateChanged,
|
||||||
mainWindow);
|
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()
|
struct mainWindow *mainWindow_new()
|
||||||
@ -439,3 +446,19 @@ void mainWindow_dateChanged(GtkWidget *widget, gpointer user_data)
|
|||||||
|
|
||||||
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
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(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);
|
||||||
|
}
|
||||||
|
@ -34,5 +34,6 @@ void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer u
|
|||||||
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
void mainWindow_calendarSelected(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
|
void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_dateChanged(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 */
|
#endif /* MAINWINDOW_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user