]> Pileus Git - ~andy/gtk/blobdiff - tests/testtreesort.c
reftests: Add test for recent fix
[~andy/gtk] / tests / testtreesort.c
index 622f678fb1c123b6817f6584fd7aa7a3de7cefe2..b45ede02dcf08d9ed3627da7a7da4100b0162219 100644 (file)
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <config.h>
+#include "config.h"
 #include <gtk/gtk.h>
 
-#include "../gtk/gtktreedatalist.h"
-
 
 typedef struct _ListSort ListSort;
 struct _ListSort
@@ -84,6 +80,19 @@ select_func (GtkTreeSelection  *selection,
   return FALSE;
 }
 
+static void
+switch_search_method (GtkWidget *button,
+                     gpointer   tree_view)
+{
+  if (!gtk_tree_view_get_search_entry (GTK_TREE_VIEW (tree_view)))
+    {
+      gpointer data = g_object_get_data (tree_view, "my-search-entry");
+      gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), GTK_ENTRY (data));
+    }
+  else
+    gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), NULL);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -99,6 +108,7 @@ main (int argc, char *argv[])
   GtkTreeIter iter;
   gint i;
 
+  GtkWidget *entry, *button;
   GtkWidget *window2, *vbox2, *scrolled_window2, *tree_view2;
   GtkWidget *window3, *vbox3, *scrolled_window3, *tree_view3;
 
@@ -111,11 +121,17 @@ main (int argc, char *argv[])
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (GTK_WINDOW (window), "Words, words, words - Window 1");
   g_signal_connect (window, "destroy", gtk_main_quit, NULL);
-  vbox = gtk_vbox_new (FALSE, 8);
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
   gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
   gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new ("Jonathan and Kristian's list of cool words. (And Anders' cool list of numbers) \n\nThis is just a GtkTreeStore"), FALSE, FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), vbox);
 
+  entry = gtk_entry_new ();
+  gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
+
+  button = gtk_button_new_with_label ("Switch search method");
+  gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -128,7 +144,14 @@ main (int argc, char *argv[])
   ssmodel = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (smodel));
 */
   tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
-  gtk_tree_selection_set_select_function (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), select_func, NULL, NULL);
+
+  gtk_tree_view_set_search_entry (GTK_TREE_VIEW (tree_view), GTK_ENTRY (entry));
+  g_object_set_data (G_OBJECT (tree_view), "my-search-entry", entry);
+  g_signal_connect (button, "clicked",
+                   G_CALLBACK (switch_search_method), tree_view);
+
+ /* gtk_tree_selection_set_select_function (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), select_func, NULL, NULL);*/
+
   /* 12 iters now, 12 later... */
   for (i = 0; data[i].word_1 != NULL; i++)
     {
@@ -228,7 +251,7 @@ main (int argc, char *argv[])
       gtk_window_set_title (GTK_WINDOW (window2), 
                            "Words, words, words - window 2");
       g_signal_connect (window2, "destroy", gtk_main_quit, NULL);
-      vbox2 = gtk_vbox_new (FALSE, 8);
+      vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
       gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8);
       gtk_box_pack_start (GTK_BOX (vbox2), 
                          gtk_label_new ("Jonathan and Kristian's list of words.\n\nA GtkTreeModelSort wrapping the GtkTreeStore of window 1"),
@@ -300,7 +323,7 @@ main (int argc, char *argv[])
       gtk_window_set_title (GTK_WINDOW (window3), 
                            "Words, words, words - Window 3");
       g_signal_connect (window3, "destroy", gtk_main_quit, NULL);
-      vbox3 = gtk_vbox_new (FALSE, 8);
+      vbox3 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
       gtk_container_set_border_width (GTK_CONTAINER (vbox3), 8);
       gtk_box_pack_start (GTK_BOX (vbox3), 
                          gtk_label_new ("Jonathan and Kristian's list of words.\n\nA GtkTreeModelSort wrapping the GtkTreeModelSort of window 2"),