[gtk+/gtk-2-90] Remove obsolete GtkTree test from testgtk



commit e67a41d1276a69990beed7eb2c2bb0e8fbf38f4a
Author: Christian Dywan <christian twotoasts de>
Date:   Wed Mar 31 15:20:03 2010 +0200

    Remove obsolete GtkTree test from testgtk

 tests/testgtk.c |  481 -------------------------------------------------------
 1 files changed, 0 insertions(+), 481 deletions(-)
---
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 16c69af..51b422f 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -1764,486 +1764,6 @@ create_statusbar (GtkWidget *widget)
 }
 
 /*
- * GtkTree
- */
-
-static void
-cb_tree_destroy_event(GtkWidget* w)
-{
-  sTreeButtons* tree_buttons;
-
-  /* free buttons structure associate at this tree */
-  tree_buttons = g_object_get_data (G_OBJECT (w), "user_data");
-  g_free (tree_buttons);
-}
-
-static void
-cb_add_new_item(GtkWidget* w, GtkTree* tree)
-{
-  sTreeButtons* tree_buttons;
-  GList* selected_list;
-  GtkWidget* selected_item;
-  GtkWidget* subtree;
-  GtkWidget* item_new;
-  char buffer[255];
-
-  tree_buttons = g_object_get_data (G_OBJECT (tree), "user_data");
-
-  selected_list = GTK_TREE_SELECTION_OLD(tree);
-
-  if(selected_list == NULL)
-    {
-      /* there is no item in tree */
-      subtree = GTK_WIDGET(tree);
-    }
-  else
-    {
-      /* list can have only one element */
-      selected_item = GTK_WIDGET(selected_list->data);
-      
-      subtree = GTK_TREE_ITEM_SUBTREE(selected_item);
-
-      if(subtree == NULL)
-	{
-	  /* current selected item have not subtree ... create it */
-	  subtree = gtk_tree_new();
-	  gtk_tree_item_set_subtree(GTK_TREE_ITEM(selected_item), 
-				    subtree);
-	}
-    }
-
-  /* at this point, we know which subtree will be used to add new item */
-  /* create a new item */
-  sprintf(buffer, "item add %d", tree_buttons->nb_item_add);
-  item_new = gtk_tree_item_new_with_label(buffer);
-  gtk_tree_append(GTK_TREE(subtree), item_new);
-  gtk_widget_show(item_new);
-
-  tree_buttons->nb_item_add++;
-}
-
-static void
-cb_remove_item(GtkWidget*w, GtkTree* tree)
-{
-  GList* selected_list;
-  GList* clear_list;
-  
-  selected_list = GTK_TREE_SELECTION_OLD(tree);
-
-  clear_list = NULL;
-    
-  while (selected_list) 
-    {
-      clear_list = g_list_prepend (clear_list, selected_list->data);
-      selected_list = selected_list->next;
-    }
-  
-  clear_list = g_list_reverse (clear_list);
-  gtk_tree_remove_items(tree, clear_list);
-
-  g_list_free (clear_list);
-}
-
-static void
-cb_remove_subtree(GtkWidget*w, GtkTree* tree)
-{
-  GList* selected_list;
-  GtkTreeItem *item;
-  
-  selected_list = GTK_TREE_SELECTION_OLD(tree);
-
-  if (selected_list)
-    {
-      item = GTK_TREE_ITEM (selected_list->data);
-      if (item->subtree)
-	gtk_tree_item_remove_subtree (item);
-    }
-}
-
-static void
-cb_tree_changed(GtkTree* tree)
-{
-  sTreeButtons* tree_buttons;
-  GList* selected_list;
-  guint nb_selected;
-
-  tree_buttons = g_object_get_data (G_OBJECT (tree), "user_data");
-
-  selected_list = GTK_TREE_SELECTION_OLD(tree);
-  nb_selected = g_list_length(selected_list);
-
-  if(nb_selected == 0) 
-    {
-      if(tree->children == NULL)
-	gtk_widget_set_sensitive(tree_buttons->add_button, TRUE);
-      else
-	gtk_widget_set_sensitive(tree_buttons->add_button, FALSE);
-      gtk_widget_set_sensitive(tree_buttons->remove_button, FALSE);
-      gtk_widget_set_sensitive(tree_buttons->subtree_button, FALSE);
-    } 
-  else 
-    {
-      gtk_widget_set_sensitive(tree_buttons->remove_button, TRUE);
-      gtk_widget_set_sensitive(tree_buttons->add_button, (nb_selected == 1));
-      gtk_widget_set_sensitive(tree_buttons->subtree_button, (nb_selected == 1));
-    }  
-}
-
-static void 
-create_subtree(GtkWidget* item, guint level, guint nb_item_max, guint recursion_level_max)
-{
-  GtkWidget* item_subtree;
-  GtkWidget* item_new;
-  guint nb_item;
-  char buffer[255];
-  int no_root_item;
-
-  if(level == recursion_level_max) return;
-
-  if(level == -1)
-    {
-      /* query with no root item */
-      level = 0;
-      item_subtree = item;
-      no_root_item = 1;
-    }
-  else
-    {
-      /* query with no root item */
-      /* create subtree and associate it with current item */
-      item_subtree = gtk_tree_new();
-      no_root_item = 0;
-    }
-  
-  for(nb_item = 0; nb_item < nb_item_max; nb_item++)
-    {
-      sprintf(buffer, "item %d-%d", level, nb_item);
-      item_new = gtk_tree_item_new_with_label(buffer);
-      gtk_tree_append(GTK_TREE(item_subtree), item_new);
-      create_subtree(item_new, level+1, nb_item_max, recursion_level_max);
-      gtk_widget_show(item_new);
-    }
-
-  if(!no_root_item)
-    gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), item_subtree);
-}
-
-static void
-create_tree_sample(GdkScreen *screen, guint selection_mode, 
-		   guint draw_line, guint view_line, guint no_root_item,
-		   guint nb_item_max, guint recursion_level_max) 
-{
-  GtkWidget* window;
-  GtkWidget* box1;
-  GtkWidget* box2;
-  GtkWidget* separator;
-  GtkWidget* button;
-  GtkWidget* scrolled_win;
-  GtkWidget* root_tree;
-  GtkWidget* root_item;
-  sTreeButtons* tree_buttons;
-
-  /* create tree buttons struct */
-  if ((tree_buttons = g_malloc (sizeof (sTreeButtons))) == NULL)
-    {
-      g_error("can't allocate memory for tree structure !\n");
-      return;
-    }
-  tree_buttons->nb_item_add = 0;
-
-  /* create top level window */
-  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-  gtk_window_set_screen (GTK_WINDOW (window), screen);
-  gtk_window_set_title(GTK_WINDOW(window), "Tree Sample");
-  g_signal_connect (window, "destroy",
-		    G_CALLBACK (cb_tree_destroy_event), NULL);
-  g_object_set_data (G_OBJECT (window), "user_data", tree_buttons);
-
-  box1 = gtk_vbox_new(FALSE, 0);
-  gtk_container_add(GTK_CONTAINER(window), box1);
-  gtk_widget_show(box1);
-
-  /* create tree box */
-  box2 = gtk_vbox_new(FALSE, 0);
-  gtk_box_pack_start(GTK_BOX(box1), box2, TRUE, TRUE, 0);
-  gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
-  gtk_widget_show(box2);
-
-  /* create scrolled window */
-  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
-				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  gtk_box_pack_start (GTK_BOX (box2), scrolled_win, TRUE, TRUE, 0);
-  gtk_widget_set_size_request (scrolled_win, 200, 200);
-  gtk_widget_show (scrolled_win);
-  
-  /* create root tree widget */
-  root_tree = gtk_tree_new();
-  g_signal_connect (root_tree, "selection_changed",
-		    G_CALLBACK (cb_tree_changed),
-		    NULL);
-  g_object_set_data (G_OBJECT (root_tree), "user_data", tree_buttons);
-  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_win), root_tree);
-  gtk_tree_set_selection_mode(GTK_TREE(root_tree), selection_mode);
-  gtk_tree_set_view_lines(GTK_TREE(root_tree), draw_line);
-  gtk_tree_set_view_mode(GTK_TREE(root_tree), !view_line);
-  gtk_widget_show(root_tree);
-
-  if ( no_root_item )
-    {
-      /* set root tree to subtree function with root item variable */
-      root_item = GTK_WIDGET(root_tree);
-    }
-  else
-    {
-      /* create root tree item widget */
-      root_item = gtk_tree_item_new_with_label("root item");
-      gtk_tree_append(GTK_TREE(root_tree), root_item);
-      gtk_widget_show(root_item);
-     }
-  create_subtree(root_item, -no_root_item, nb_item_max, recursion_level_max);
-
-  box2 = gtk_vbox_new(FALSE, 0);
-  gtk_box_pack_start(GTK_BOX(box1), box2, FALSE, FALSE, 0);
-  gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
-  gtk_widget_show(box2);
-
-  button = gtk_button_new_with_label("Add Item");
-  gtk_widget_set_sensitive(button, FALSE);
-  g_signal_connect (button, "clicked",
-		    G_CALLBACK (cb_add_new_item),
-		    root_tree);
-  gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
-  gtk_widget_show(button);
-  tree_buttons->add_button = button;
-
-  button = gtk_button_new_with_label("Remove Item(s)");
-  gtk_widget_set_sensitive(button, FALSE);
-  g_signal_connect (button, "clicked",
-		    G_CALLBACK (cb_remove_item),
-		    root_tree);
-  gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
-  gtk_widget_show(button);
-  tree_buttons->remove_button = button;
-
-  button = gtk_button_new_with_label("Remove Subtree");
-  gtk_widget_set_sensitive(button, FALSE);
-  g_signal_connect (button, "clicked",
-		    G_CALLBACK (cb_remove_subtree),
-		    root_tree);
-  gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
-  gtk_widget_show(button);
-  tree_buttons->subtree_button = button;
-
-  /* create separator */
-  separator = gtk_hseparator_new();
-  gtk_box_pack_start(GTK_BOX(box1), separator, FALSE, FALSE, 0);
-  gtk_widget_show(separator);
-
-  /* create button box */
-  box2 = gtk_vbox_new(FALSE, 0);
-  gtk_box_pack_start(GTK_BOX(box1), box2, FALSE, FALSE, 0);
-  gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
-  gtk_widget_show(box2);
-
-  button = gtk_button_new_with_label("Close");
-  gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
-  g_signal_connect_swapped (button, "clicked",
-			    G_CALLBACK (gtk_widget_destroy),
-			    window);
-  gtk_widget_show(button);
-
-  gtk_widget_show(window);
-}
-
-static void
-cb_create_tree(GtkWidget* w)
-{
-  guint selection_mode = GTK_SELECTION_SINGLE;
-  guint view_line;
-  guint draw_line;
-  guint no_root_item;
-  guint nb_item;
-  guint recursion_level;
-
-  /* get selection mode choice */
-  if(GTK_TOGGLE_BUTTON(sTreeSampleSelection.single_button)->active)
-    selection_mode = GTK_SELECTION_SINGLE;
-  else
-    if(GTK_TOGGLE_BUTTON(sTreeSampleSelection.browse_button)->active)
-      selection_mode = GTK_SELECTION_BROWSE;
-    else
-      selection_mode = GTK_SELECTION_MULTIPLE;
-
-  /* get options choice */
-  draw_line = GTK_TOGGLE_BUTTON(sTreeSampleSelection.draw_line_button)->active;
-  view_line = GTK_TOGGLE_BUTTON(sTreeSampleSelection.view_line_button)->active;
-  no_root_item = GTK_TOGGLE_BUTTON(sTreeSampleSelection.no_root_item_button)->active;
-    
-  /* get levels */
-  nb_item = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sTreeSampleSelection.nb_item_spinner));
-  recursion_level = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(sTreeSampleSelection.recursion_spinner));
-
-  if (pow (nb_item, recursion_level) > 10000)
-    {
-      g_print ("%g total items? That will take a very long time. Try less\n",
-	       pow (nb_item, recursion_level));
-      return;
-    }
-
-  create_tree_sample(gtk_widget_get_screen (w),
-		     selection_mode, draw_line, 
-		     view_line, no_root_item, nb_item, recursion_level);
-}
-
-void 
-create_tree_mode_window(GtkWidget *widget)
-{
-  static GtkWidget* window;
-  GtkWidget* box1;
-  GtkWidget* box2;
-  GtkWidget* box3;
-  GtkWidget* box4;
-  GtkWidget* box5;
-  GtkWidget* button;
-  GtkWidget* frame;
-  GtkWidget* separator;
-  GtkWidget* label;
-  GtkWidget* spinner;
-  GtkAdjustment *adj;
-
-  if (!window)
-    {
-      /* create toplevel window  */
-      window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-      gtk_window_set_screen (GTK_WINDOW (window),
-			     gtk_widget_get_screen (widget));
-      gtk_window_set_title(GTK_WINDOW(window), "Set Tree Parameters");
-      g_signal_connect (window, "destroy",
-			G_CALLBACK (gtk_widget_destroyed),
-			&window);
-      box1 = gtk_vbox_new(FALSE, 0);
-      gtk_container_add(GTK_CONTAINER(window), box1);
-
-      /* create upper box - selection box */
-      box2 = gtk_vbox_new(FALSE, 5);
-      gtk_box_pack_start(GTK_BOX(box1), box2, TRUE, TRUE, 0);
-      gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
-
-      box3 = gtk_hbox_new(FALSE, 5);
-      gtk_box_pack_start(GTK_BOX(box2), box3, TRUE, TRUE, 0);
-
-      /* create selection mode frame */
-      frame = gtk_frame_new("Selection Mode");
-      gtk_box_pack_start(GTK_BOX(box3), frame, TRUE, TRUE, 0);
-
-      box4 = gtk_vbox_new(FALSE, 0);
-      gtk_container_add(GTK_CONTAINER(frame), box4);
-      gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
-
-      /* create radio button */  
-      button = gtk_radio_button_new_with_label(NULL, "SINGLE");
-      gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      sTreeSampleSelection.single_button = button;
-
-      button = gtk_radio_button_new_with_label(gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
-					       "BROWSE");
-      gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      sTreeSampleSelection.browse_button = button;
-
-      button = gtk_radio_button_new_with_label(gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
-					       "MULTIPLE");
-      gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      sTreeSampleSelection.multiple_button = button;
-
-      sTreeSampleSelection.selection_mode_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
-
-      /* create option mode frame */
-      frame = gtk_frame_new("Options");
-      gtk_box_pack_start(GTK_BOX(box3), frame, TRUE, TRUE, 0);
-
-      box4 = gtk_vbox_new(FALSE, 0);
-      gtk_container_add(GTK_CONTAINER(frame), box4);
-      gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
-
-      /* create check button */
-      button = gtk_check_button_new_with_label("Draw line");
-      gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-      sTreeSampleSelection.draw_line_button = button;
-  
-      button = gtk_check_button_new_with_label("View Line mode");
-      gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), TRUE);
-      sTreeSampleSelection.view_line_button = button;
-  
-      button = gtk_check_button_new_with_label("Without Root item");
-      gtk_box_pack_start(GTK_BOX(box4), button, TRUE, TRUE, 0);
-      sTreeSampleSelection.no_root_item_button = button;
-
-      /* create recursion parameter */
-      frame = gtk_frame_new("Size Parameters");
-      gtk_box_pack_start(GTK_BOX(box2), frame, TRUE, TRUE, 0);
-
-      box4 = gtk_hbox_new(FALSE, 5);
-      gtk_container_add(GTK_CONTAINER(frame), box4);
-      gtk_container_set_border_width(GTK_CONTAINER(box4), 5);
-
-      /* create number of item spin button */
-      box5 = gtk_hbox_new(FALSE, 5);
-      gtk_box_pack_start(GTK_BOX(box4), box5, FALSE, FALSE, 0);
-
-      label = gtk_label_new("Number of items : ");
-      gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-      gtk_box_pack_start (GTK_BOX (box5), label, FALSE, TRUE, 0);
-
-      adj = (GtkAdjustment *) gtk_adjustment_new (DEFAULT_NUMBER_OF_ITEM, 1.0, 255.0, 1.0,
-						  5.0, 0.0);
-      spinner = gtk_spin_button_new (adj, 0, 0);
-      gtk_box_pack_start (GTK_BOX (box5), spinner, FALSE, TRUE, 0);
-      sTreeSampleSelection.nb_item_spinner = spinner;
-  
-      /* create recursion level spin button */
-      box5 = gtk_hbox_new(FALSE, 5);
-      gtk_box_pack_start(GTK_BOX(box4), box5, FALSE, FALSE, 0);
-
-      label = gtk_label_new("Depth : ");
-      gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
-      gtk_box_pack_start (GTK_BOX (box5), label, FALSE, TRUE, 0);
-
-      adj = (GtkAdjustment *) gtk_adjustment_new (DEFAULT_RECURSION_LEVEL, 0.0, 255.0, 1.0,
-						  5.0, 0.0);
-      spinner = gtk_spin_button_new (adj, 0, 0);
-      gtk_box_pack_start (GTK_BOX (box5), spinner, FALSE, TRUE, 0);
-      sTreeSampleSelection.recursion_spinner = spinner;
-  
-      /* create horizontal separator */
-      separator = gtk_hseparator_new();
-      gtk_box_pack_start(GTK_BOX(box1), separator, FALSE, FALSE, 0);
-
-      /* create bottom button box */
-      box2 = gtk_hbox_new(TRUE, 10);
-      gtk_box_pack_start(GTK_BOX(box1), box2, FALSE, FALSE, 0);
-      gtk_container_set_border_width(GTK_CONTAINER(box2), 5);
-
-      button = gtk_button_new_with_label("Create Tree");
-      gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
-      g_signal_connect (button, "clicked",
-			G_CALLBACK (cb_create_tree), NULL);
-
-      button = gtk_button_new_with_label("Close");
-      gtk_box_pack_start(GTK_BOX(box2), button, TRUE, TRUE, 0);
-      g_signal_connect_swapped (button, "clicked",
-			        G_CALLBACK (gtk_widget_destroy),
-				window);
-    }
-  if (!gtk_widget_get_visible (window))
-    gtk_widget_show_all (window);
-  else
-    gtk_widget_destroy (window);
-}
-
-/*
  * Gridded geometry
  */
 #define GRID_SIZE 20
@@ -11554,7 +11074,6 @@ struct {
   { "toggle buttons", create_toggle_buttons },
   { "toolbar", create_toolbar },
   { "tooltips", create_tooltips },
-  { "tree", create_tree_mode_window},
   { "WM hints", create_wmhints },
   { "window sizing", create_window_sizing },
   { "window states", create_window_states }



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