[patch] add ability to typeahead in print view



Hi,

This patch fixes this bug:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=136865
inline text search doesn't work for printer names

Should this go on before we branch libgnomeprintui or after?

--- libgnomeprintui/gpaui/gpa-printer-selector.c.~1.29.~	2004-09-01 14:09:38.000000000 -0400
+++ libgnomeprintui/gpaui/gpa-printer-selector.c	2004-10-26 14:34:30.393732480 -0400
@@ -48,6 +48,11 @@
 					       GPAPrinter   *printer);
 static void selection_changed_cb (GtkTreeSelection *selection, 
 				  gpointer          data);
+gboolean interactive_search_func (GtkTreeModel *model,
+				  gint          column,
+				  const gchar  *key,
+				  GtkTreeIter  *iter,
+				  gpointer search_data);
 static void set_printer_icon (GtkCellLayout   *layout, 
 			      GtkCellRenderer *rend,
 			      GtkTreeModel    *model, 
@@ -163,6 +168,11 @@
 						 (GtkTreeCellDataFunc)set_printer_name, 
 						 NULL, NULL);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (ps->treeview), col);
+	gtk_tree_view_set_search_column (ps->treeview, 0);
+	gtk_tree_view_set_search_equal_func (ps->treeview,
+					     interactive_search_func,
+					     NULL,
+					     NULL);
 
 	rend = gtk_cell_renderer_text_new ();
 	col = gtk_tree_view_column_new_with_attributes (_("State"), rend, NULL);	
@@ -263,6 +273,26 @@
 	}
 }
 
+gboolean
+interactive_search_func (GtkTreeModel *model,
+			 gint column,
+			 const gchar *key,
+			 GtkTreeIter *iter,
+			 gpointer search_data)
+{
+	char *name;
+	GPANode *printer;
+	gboolean ret;
+
+	gtk_tree_model_get (model, iter, 0, &printer, -1);	
+	name = gpa_node_get_value (printer);
+	
+	ret = strncmp (key, name, strlen (key));
+	g_free (name);
+
+	return ret;
+}
+
 void
 gpa_printer_selector_printer_state_changed (GPAPrinterSelector *selector,
 					    GPANode *printer)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]