Compare commits
2 Commits
1fa1a10a10
...
0a5ba481bc
Author | SHA1 | Date | |
---|---|---|---|
0a5ba481bc | |||
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()
|
||||||
@ -350,8 +357,8 @@ struct mainWindow *mainWindow_new()
|
|||||||
/**
|
/**
|
||||||
* These need to be set to oldest and newest after indexing date
|
* These need to be set to oldest and newest after indexing date
|
||||||
*/
|
*/
|
||||||
gtk_entry_set_text(mainWindow->dateStart, "2016-01-01");
|
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateStart), "2016-01-01");
|
||||||
gtk_entry_set_text(mainWindow->dateEnd, "2017-01-01");
|
gtk_entry_set_text(GTK_ENTRY(mainWindow->dateEnd), "2017-01-01");
|
||||||
|
|
||||||
return mainWindow;
|
return mainWindow;
|
||||||
}
|
}
|
||||||
@ -426,12 +433,12 @@ void mainWindow_dateChanged(GtkWidget *widget, gpointer user_data)
|
|||||||
GDateTime *datetime;
|
GDateTime *datetime;
|
||||||
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
struct mainWindow *mainWindow = (struct mainWindow *)user_data;
|
||||||
|
|
||||||
datetime = mainWindow_get_date_from_string(gtk_entry_get_text(GTK_ENTRY(mainWindow->dateStart)));
|
datetime = mainWindow_get_date_from_string((gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->dateStart)));
|
||||||
if (datetime) {
|
if (datetime) {
|
||||||
mainWindow->filterSettings.time_start = g_date_time_to_unix(datetime);
|
mainWindow->filterSettings.time_start = g_date_time_to_unix(datetime);
|
||||||
g_date_time_unref(datetime);
|
g_date_time_unref(datetime);
|
||||||
}
|
}
|
||||||
datetime = mainWindow_get_date_from_string(gtk_entry_get_text(GTK_ENTRY(mainWindow->dateEnd)));
|
datetime = mainWindow_get_date_from_string((gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->dateEnd)));
|
||||||
if (datetime) {
|
if (datetime) {
|
||||||
mainWindow->filterSettings.time_end = g_date_time_to_unix(datetime);
|
mainWindow->filterSettings.time_end = g_date_time_to_unix(datetime);
|
||||||
g_date_time_unref(datetime);
|
g_date_time_unref(datetime);
|
||||||
@ -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((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);
|
||||||
|
}
|
||||||
|
@ -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