← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 378: Added a case-insensitive substring search for nick list

 

------------------------------------------------------------
revno: 378
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-08-08 22:11:55 -0500
message:
  Added a case-insensitive substring search for nick list
modified:
  Changelog.txt
  linux/hub.cc
  linux/hub.hh


--
lp:linuxdcpp
https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk

Your team LinuxDC++ Team is subscribed to branch lp:linuxdcpp.
To unsubscribe from this branch go to https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk/+edit-subscription
=== modified file 'Changelog.txt'
--- Changelog.txt	2010-08-05 05:31:49 +0000
+++ Changelog.txt	2010-08-09 03:11:55 +0000
@@ -53,6 +53,7 @@
 [2010-05-22] lp#317346: Favorite Users tab merged from freedcpp. 
 [2010-06-06] lp#590359: Fix crash with two simultaneous Socket::resolve calls (Razzloss)
 [2010-08-05] lp#337576: Don't show partial finished downloads. (thanks Bart Vullings)
+[2010-08-08] Added a case-insensitive substring search for nick list.
 
 *** 1.0.3 2009-02-01 ***
 [2008-08-10] lp#256236: Fixed a crash on startup when using auto-open options.

=== modified file 'linux/hub.cc'
--- linux/hub.cc	2010-05-22 14:23:56 +0000
+++ linux/hub.cc	2010-08-09 03:11:55 +0000
@@ -71,6 +71,7 @@
 	gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(nickStore), nickView.col("Nick Order"), GTK_SORT_ASCENDING);
 	gtk_tree_view_column_set_sort_indicator(gtk_tree_view_get_column(nickView.get(), nickView.col("Nick")), TRUE);
 	gtk_tree_view_set_fixed_height_mode(nickView.get(), TRUE);
+	gtk_tree_view_set_search_equal_func(nickView.get(), onNickListSearch_gui, 0,0);
 
 	// Initialize the chat window
 	if (BOOLSETTING(USE_OEM_MONOFONT))
@@ -600,6 +601,29 @@
 	return FALSE;
 }
 
+/*
+ * Implements a case-insensitive substring search for UTF-8 strings.
+ */
+gboolean Hub::onNickListSearch_gui(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer data)
+{
+	gboolean result = TRUE;
+	gchar *nick;
+	gtk_tree_model_get(model, iter, column, &nick, -1);
+
+	gchar *keyCasefold = g_utf8_casefold(key, -1);
+	gchar *nickCasefold = g_utf8_casefold(nick, -1);
+
+	// Return false per search equal func API if the key is contained within the nick
+	if (g_strstr_len(nickCasefold, -1, keyCasefold) != NULL)
+		result = FALSE;
+
+	g_free(nick);
+	g_free(keyCasefold);
+	g_free(nickCasefold);
+
+	return result;
+}
+
 gboolean Hub::onEntryKeyPress_gui(GtkWidget *entry, GdkEventKey *event, gpointer data)
 {
 	Hub *hub = (Hub *)data;

=== modified file 'linux/hub.hh'
--- linux/hub.hh	2010-05-22 14:23:56 +0000
+++ linux/hub.hh	2010-08-09 03:11:55 +0000
@@ -66,6 +66,7 @@
 		static gboolean onNickListButtonPress_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
 		static gboolean onNickListButtonRelease_gui(GtkWidget *widget, GdkEventButton *event, gpointer data);
 		static gboolean onNickListKeyRelease_gui(GtkWidget *widget, GdkEventKey *event, gpointer data);
+		static gboolean onNickListSearch_gui(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer data);
 		static gboolean onEntryKeyPress_gui(GtkWidget *widget, GdkEventKey *event, gpointer data);
 		static gboolean onNickTagEvent_gui(GtkTextTag *tag, GObject *textView, GdkEvent *event, GtkTextIter *iter, gpointer data);
 		static gboolean onLinkTagEvent_gui(GtkTextTag *tag, GObject *textView, GdkEvent *event, GtkTextIter *iter, gpointer data);