Added field selection to search
This commit is contained in:
parent
5686bdb834
commit
9bac55c4ce
@ -41,6 +41,82 @@
|
|||||||
<property name="position">0</property>
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkBox" id="searchInBox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="label" translatable="yes">search in: </property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="checkSearchTitle">
|
||||||
|
<property name="label" translatable="yes">Title</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="checkSearchTags">
|
||||||
|
<property name="label" translatable="yes">Tags</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCheckButton" id="checkSearchText">
|
||||||
|
<property name="label" translatable="yes">Text</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkSeparator">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkBox" id="boxDateEntry">
|
<object class="GtkBox" id="boxDateEntry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -88,7 +164,7 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -194,21 +194,29 @@ static gboolean mainWindow_list_entry_visible(GtkTreeModel *model, GtkTreeIter *
|
|||||||
|
|
||||||
/* Check text search */
|
/* Check text search */
|
||||||
searchString = (gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->searchEntry));
|
searchString = (gchar *)gtk_entry_get_text(GTK_ENTRY(mainWindow->searchEntry));
|
||||||
if (searchString[0] != 0) {
|
if (searchString[0] != 0 && (
|
||||||
|
mainWindow->filterSettings.search_title ||
|
||||||
|
mainWindow->filterSettings.search_tags ||
|
||||||
|
mainWindow->filterSettings.search_text)) {
|
||||||
regex = g_regex_new(searchString, G_REGEX_CASELESS, 0, NULL);
|
regex = g_regex_new(searchString, G_REGEX_CASELESS, 0, NULL);
|
||||||
|
|
||||||
gtk_tree_model_get(model, iter, COL_TITLE, &temp, -1);
|
gtk_tree_model_get(model, iter, COL_TITLE, &temp, -1);
|
||||||
if (g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
|
if (mainWindow->filterSettings.search_title &&
|
||||||
search_matched = 1;
|
g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
|
||||||
g_free(temp);
|
|
||||||
|
|
||||||
gtk_tree_model_get(model, iter, COL_TEXT, &temp, -1);
|
|
||||||
if (!search_matched && g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
|
|
||||||
search_matched = 1;
|
search_matched = 1;
|
||||||
g_free(temp);
|
g_free(temp);
|
||||||
|
|
||||||
gtk_tree_model_get(model, iter, COL_TAGS_TEXT, &temp, -1);
|
gtk_tree_model_get(model, iter, COL_TAGS_TEXT, &temp, -1);
|
||||||
if (!search_matched && g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
|
if (!search_matched &&
|
||||||
|
mainWindow->filterSettings.search_tags &&
|
||||||
|
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);
|
||||||
|
if (!search_matched &&
|
||||||
|
mainWindow->filterSettings.search_text &&
|
||||||
|
g_regex_match(regex, temp, 0, &match_info) && g_match_info_matches(match_info))
|
||||||
search_matched = 1;
|
search_matched = 1;
|
||||||
g_free(temp);
|
g_free(temp);
|
||||||
|
|
||||||
@ -390,6 +398,19 @@ static void mainWindow_connect_signals(struct mainWindow *mainWindow)
|
|||||||
"changed",
|
"changed",
|
||||||
(GCallback) mainWindow_filterChanged,
|
(GCallback) mainWindow_filterChanged,
|
||||||
mainWindow);
|
mainWindow);
|
||||||
|
|
||||||
|
g_signal_connect(mainWindow->checkSearchTitle,
|
||||||
|
"toggled",
|
||||||
|
(GCallback) mainWindow_filterChanged,
|
||||||
|
mainWindow);
|
||||||
|
g_signal_connect(mainWindow->checkSearchTags,
|
||||||
|
"toggled",
|
||||||
|
(GCallback) mainWindow_filterChanged,
|
||||||
|
mainWindow);
|
||||||
|
g_signal_connect(mainWindow->checkSearchText,
|
||||||
|
"toggled",
|
||||||
|
(GCallback) mainWindow_filterChanged,
|
||||||
|
mainWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -412,6 +433,9 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow->entryText = GTK_WIDGET(gtk_builder_get_object(builder, "entryText"));
|
mainWindow->entryText = GTK_WIDGET(gtk_builder_get_object(builder, "entryText"));
|
||||||
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->checkSearchTags = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchTags"));
|
||||||
|
mainWindow->checkSearchText = GTK_WIDGET(gtk_builder_get_object(builder, "checkSearchText"));
|
||||||
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
mainWindow->entryListView = GTK_TREE_VIEW(gtk_builder_get_object(builder, "entryListView"));
|
||||||
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
|
mainWindow->entryListSelection = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "entryListSelection"));
|
||||||
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
|
mainWindow->textBuffer = GTK_TEXT_BUFFER(gtk_builder_get_object(builder, "entryTextBuffer"));
|
||||||
@ -426,6 +450,10 @@ struct mainWindow *mainWindow_new()
|
|||||||
mainWindow_configure_treeView(mainWindow);
|
mainWindow_configure_treeView(mainWindow);
|
||||||
mainWindow_connect_signals(mainWindow);
|
mainWindow_connect_signals(mainWindow);
|
||||||
|
|
||||||
|
gtk_toggle_button_set_active(mainWindow->checkSearchTitle, 1);
|
||||||
|
gtk_toggle_button_set_active(mainWindow->checkSearchTags, 1);
|
||||||
|
gtk_toggle_button_set_active(mainWindow->checkSearchText, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These need to be set to oldest and newest after indexing date
|
* These need to be set to oldest and newest after indexing date
|
||||||
*/
|
*/
|
||||||
@ -548,6 +576,13 @@ void mainWindow_filterChanged(GtkWidget *widget, gpointer user_data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mainWindow->filterSettings.search_title = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
||||||
|
mainWindow->checkSearchTitle));
|
||||||
|
mainWindow->filterSettings.search_tags = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
||||||
|
mainWindow->checkSearchTags));
|
||||||
|
mainWindow->filterSettings.search_text = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
|
||||||
|
mainWindow->checkSearchText));
|
||||||
|
|
||||||
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
gtk_tree_model_filter_refilter(mainWindow->entryListFiltered);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ struct mainWindow {
|
|||||||
GtkWidget *entryText;
|
GtkWidget *entryText;
|
||||||
GtkWidget *popoverDate;
|
GtkWidget *popoverDate;
|
||||||
GtkWidget *calendarRange;
|
GtkWidget *calendarRange;
|
||||||
|
GtkWidget *checkSearchTitle;
|
||||||
|
GtkWidget *checkSearchTags;
|
||||||
|
GtkWidget *checkSearchText;
|
||||||
GtkTreeView *entryListView;
|
GtkTreeView *entryListView;
|
||||||
GtkTreeSelection *entryListSelection;
|
GtkTreeSelection *entryListSelection;
|
||||||
GtkTextBuffer *textBuffer;
|
GtkTextBuffer *textBuffer;
|
||||||
@ -24,6 +27,9 @@ struct mainWindow {
|
|||||||
struct filterSettings {
|
struct filterSettings {
|
||||||
guint time_start;
|
guint time_start;
|
||||||
guint time_end;
|
guint time_end;
|
||||||
|
gboolean search_title;
|
||||||
|
gboolean search_tags;
|
||||||
|
gboolean search_text;
|
||||||
} filterSettings;
|
} filterSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user