Ejemplo n.º 1
0
static gboolean
filter_model_visible_func (GtkTreeModel *model, GtkTreeIter *iter, PraghaFilterDialog *fdialog)
{
	gchar *haystack = NULL, *haystackd = NULL, *needle = NULL;
	gboolean approximate, visible = FALSE;

	if(!fdialog->filter_string)
		return TRUE;

	gtk_tree_model_get(model, iter, 1, &haystack, -1);

	needle = fdialog->filter_string;

	haystackd = g_utf8_strdown (haystack, -1);

	approximate = pragha_preferences_get_approximate_search(fdialog->preferences);

	if(g_strstr_lv(haystackd, needle, approximate ? 1 : 0))
		visible = TRUE;

	g_free(haystack);
	g_free(haystackd);

	return visible;
}
Ejemplo n.º 2
0
gchar *
pragha_strstr_lv(gchar *haystack, gchar *needle, PraghaPreferences *preferences)
{
	gboolean aproximate_search;
	aproximate_search = pragha_preferences_get_approximate_search(preferences);

	return g_strstr_lv(haystack, needle,
			   aproximate_search ? 1 : 0);
}
Ejemplo n.º 3
0
static void
seach_entry_populate_popup (GtkEntry *entry, PraghaPreferences *preferences)
{
	GtkWidget *popup_menu, *item;
	gboolean instant_search, approximate_search;

	popup_menu = gtk_menu_new ();

	/* Instant search. */

	item = gtk_check_menu_item_new_with_label (_("Refine the search while writing"));
	gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);

	instant_search = pragha_preferences_get_instant_search(preferences);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), instant_search);
	g_signal_connect (G_OBJECT (item), "toggled",
				G_CALLBACK (search_entry_instant_option_toggled), preferences);
	gtk_widget_show (item);

	/* Aproximate search. */

	item = gtk_check_menu_item_new_with_label (_("Search approximate words"));
	gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), item);

	approximate_search = pragha_preferences_get_approximate_search(preferences);
	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), approximate_search);
	g_signal_connect (G_OBJECT (item), "toggled",
				G_CALLBACK (search_entry_approximate_option_toggled), preferences);
	gtk_widget_show (item);

	gtk_menu_attach_to_widget(GTK_MENU(popup_menu), GTK_WIDGET(entry), NULL);

	gtk_menu_popup(GTK_MENU(popup_menu), NULL, NULL,
			(GtkMenuPositionFunc) menu_position, entry,
			0, gtk_get_current_event_time());
}