Added summary filter option

This commit is contained in:
Markus Koch 2017-02-04 18:40:51 +01:00
parent d42a0ffc2e
commit fe1e6b8f35
3 changed files with 30 additions and 11 deletions

View File

@ -48,10 +48,12 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child> <child>
<object class="GtkLabel"> <object class="GtkCheckButton" id="checkSearchTitle">
<property name="label" translatable="yes">Title</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">search in: </property> <property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -60,8 +62,8 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkCheckButton" id="checkSearchTitle"> <object class="GtkCheckButton" id="checkSearchSummary">
<property name="label" translatable="yes">Title</property> <property name="label" translatable="yes">Summary</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="receives_default">False</property> <property name="receives_default">False</property>

View File

@ -41,6 +41,13 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GtkTreeIter *
search_matched = 1; search_matched = 1;
g_free(temp); g_free(temp);
gtk_tree_model_get(model, iter, COL_SUMMARY, &temp, -1);
if (!search_matched &&
mainWindow->filterSettings.search_summary &&
g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
search_matched = 1;
g_free(temp);
gtk_tree_model_get(model, iter, COL_TEXT, &temp, -1); gtk_tree_model_get(model, iter, COL_TEXT, &temp, -1);
if (!search_matched && if (!search_matched &&
mainWindow->filterSettings.search_text && mainWindow->filterSettings.search_text &&
@ -218,6 +225,10 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
"toggled", "toggled",
(GCallback) mainWindow_filterChanged, (GCallback) mainWindow_filterChanged,
mainWindow); mainWindow);
g_signal_connect(mainWindow->checkSearchSummary,
"toggled",
(GCallback) mainWindow_filterChanged,
mainWindow);
} }
/** /**
@ -241,6 +252,7 @@ struct mainWindow *mainWindow_new()
mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate")); mainWindow->popoverDate = GTK_WIDGET(gtk_builder_get_object(builder, "popoverDate"));
mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange")); mainWindow->calendarRange = GTK_WIDGET(gtk_builder_get_object(builder, "calendarRange"));
mainWindow->checkSearchTitle = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTitle")); mainWindow->checkSearchTitle = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTitle"));
mainWindow->checkSearchSummary = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchSummary"));
mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags")); mainWindow->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags"));
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText")); mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary")); mainWindow->labelSummary = GTK_WIDGET(gtk_builder_get_object(builder, "labelSummary"));
@ -259,6 +271,7 @@ struct mainWindow *mainWindow_new()
mainWindow_connect_signals(mainWindow); mainWindow_connect_signals(mainWindow);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle), 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags), 1); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags), 1);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchText), 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mainWindow->checkSearchText), 0);
@ -397,12 +410,14 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
} }
} }
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(
mainWindow->checkSearchTitle)); GTK_TOGGLE_BUTTON(mainWindow->checkSearchTitle));
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(
mainWindow->checkSearchTags)); GTK_TOGGLE_BUTTON(mainWindow->checkSearchTags));
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(
mainWindow->checkSearchText)); GTK_TOGGLE_BUTTON(mainWindow->checkSearchText));
mainWindow->filterSettings.search_summary = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(mainWindow->checkSearchSummary));
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered); gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
} }

View File

@ -15,6 +15,7 @@ struct mainWindow {
GtkWidget *popoverDate; GtkWidget *popoverDate;
GtkWidget *calendarRange; GtkWidget *calendarRange;
GtkWidget *checkSearchTitle; GtkWidget *checkSearchTitle;
GtkWidget *checkSearchSummary;
GtkWidget *checkSearchTags; GtkWidget *checkSearchTags;
GtkWidget *checkSearchText; GtkWidget *checkSearchText;
GtkWidget *labelSummary; GtkWidget *labelSummary;
@ -31,6 +32,7 @@ struct mainWindow {
guint time_end; guint time_end;
gboolean search_title; gboolean search_title;
gboolean search_tags; gboolean search_tags;
gboolean search_summary;
gboolean search_text; gboolean search_text;
} filterSettings; } filterSettings;
}; };