Optimized filter parameter parsing code
This commit is contained in:
parent
7f296855d5
commit
6a8cbccbfe
@ -261,7 +261,6 @@ static void mainWindow_configure_treeView(struct mainWindow *mainWindow)
|
|||||||
/*
|
/*
|
||||||
* Test entries for debugging only
|
* Test entries for debugging only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GDateTime *dt;
|
GDateTime *dt;
|
||||||
GList *list = NULL;
|
GList *list = NULL;
|
||||||
|
|
||||||
@ -308,11 +307,11 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
|
|||||||
|
|
||||||
g_signal_connect(mainWindow->dateStart,
|
g_signal_connect(mainWindow->dateStart,
|
||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_dateChanged,
|
(GCallback) mainWindow_filterChanged,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
g_signal_connect(mainWindow->dateEnd,
|
g_signal_connect(mainWindow->dateEnd,
|
||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_dateChanged,
|
(GCallback) mainWindow_filterChanged,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
|
|
||||||
g_signal_connect(mainWindow->dateStart,
|
g_signal_connect(mainWindow->dateStart,
|
||||||
@ -323,6 +322,11 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
|
|||||||
"focus-out-event",
|
"focus-out-event",
|
||||||
(GCallback) mainWindow_checkDate,
|
(GCallback) mainWindow_checkDate,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
|
|
||||||
|
g_signal_connect(mainWindow->searchEntry,
|
||||||
|
"changed",
|
||||||
|
(GCallback) mainWindow_filterChanged,
|
||||||
|
mainWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mainWindow *mainWindow_new()
|
struct mainWindow *mainWindow_new()
|
||||||
@ -429,21 +433,35 @@ void mainWindow_entrySelected(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mainWindow_dateChanged(GtkWidget *widget, gpointer user_data)
|
/**
|
||||||
|
* @brief mainWindow_filterChanged updates the filter backend values
|
||||||
|
* @param widget The widget that caused the update request. Can be NULL to update all.
|
||||||
|
* @param user_data struct mainWindow *
|
||||||
|
*/
|
||||||
|
void mainWindow_filterChanged(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((gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->dateStart)));
|
if (!widget || widget == 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((gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->dateEnd)));
|
}
|
||||||
|
if (!widget || widget == 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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!widget || widget == mainWindow->searchEntry) {
|
||||||
|
NULL;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ void mainWindow_showPopover(GtkWidget *widget, GdkEvent *event, gpointer user_da
|
|||||||
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data);
|
void mainWindow_chooseWorkspaceClicked(GtkWidget *widget, gint event, gpointer user_data);
|
||||||
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_filterChanged(GtkWidget *widget, gpointer user_data);
|
||||||
void mainWindow_checkDate(GtkWidget *widget, gint event, 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