RE: Weird behaviour of GtkCTree



GtkCTree is listed as deprecated for GTK 1.3. Should you and Louise be using 
GtkTreeView?

Padraig

> Delivered-To: gtk-devel-list gnome org
> X-Accept-Language: en
> MIME-Version: 1.0
> To: gtk-devel-list gnome org
> Subject: RE: Weird behaviour of GtkCTree
> Content-Transfer-Encoding: 7bit
> X-BeenThere: gtk-devel-list gnome org
> X-Loop: gtk-devel-list gnome org
> X-Mailman-Version: 2.0.5
> List-Help: <mailto:gtk-devel-list-request gnome org?subject=help>
> List-Post: <mailto:gtk-devel-list gnome org>
> List-Subscribe: <http://mail.gnome.org/mailman/listinfo/gtk-devel-list>, 
<mailto:gtk-devel-list-request gnome org?subject=subscribe>
> List-Id: Development of GTK+ <gtk-devel-list.gnome.org>
> List-Unsubscribe: <http://mail.gnome.org/mailman/listinfo/gtk-devel-list>, 
<mailto:gtk-devel-list-request gnome org?subject=unsubscribe>
> List-Archive: <http://mail.gnome.org/archives/gtk-devel-list/>
> 
> 
> On September 25th 2001, Louise Miller wrote:
> 
> > What I want the GtkCTree to do is :
> > When a parent node is selected, all the children of that node should also 
> > be selected, i.e turn blue etc.
> >
> > If I select nodes using the up/down arrow keys - works
> > If I single-click a collapsed parent node and then expand it - works
> > If I single-click an expanded parent node, the child node doesnt turn blue.
> > If I double-click a collapsed parent node, causing it to expand, child node 
> > isnt blue
> 
> Can somebody please hurry up and help out Louise, because otherwise I'm
> going to have to redesign the whole new Nautilus help sidebar GUI and
> I've got no idea how anything other than the proposed design could
> work...  :o)
> 
> Cheeri,
> Calum.
> 
> 
> 
> > I edited a ctree example i found to illustrate the problem, its attached if 
> > anyone wants to try it out.
> > 
> > Is there something I am missing out or is this a problem with GtkCTree?
> > Would really appreciate the help
> > Thanks
> > Louise
> > 
> > #include <gtk/gtk.h>
> > 
> > /* User clicked the "Add List" button. */
> > void button_add_clicked( gpointer data )
> > {
> >     int indx;
> >  
> >     /* Something silly to add to the list. 4 rows of 2 columns each */
> >     gchar *drink[4][2] = { { "Milk",    "3 Oz" },
> >                            { "Water",   "6 l" },
> >                            { "Carrots", "2" },
> >                            { "Snakes",  "55" } };
> >     gchar *food[4][2] = { { "sweet",    "3 Oz" },
> >                            { "more sweet",   "6 l" },
> >                            { "cake", "2" },
> >                            { "more cakes",  "55" } };
> > 
> >     /* Here we do the actual adding of the text. It's done once for
> >      * each row.
> >      */
> >     for ( indx=0 ; indx < 4 ; indx++ ) {
> >         GtkCTreeNode *node =    gtk_ctree_insert_node((GtkCTree *) data, 
NULL, NULL, drink[indx],0,NULL, NULL,NULL,NULL, FALSE, TRUE);
> >         gtk_ctree_insert_node((GtkCTree *) data, node,   NULL, 
food[indx],0,NULL, NULL,NULL,NULL, FALSE, TRUE);
> >         }
> > 
> >     return;
> > }
> > 
> > /* User clicked the "Clear List" button. */
> > void button_clear_clicked( gpointer data )
> > {
> >     /* Clear the list using gtk_clist_clear. This is much faster than
> >      * calling gtk_clist_remove once for each row.
> >      */
> >     gtk_clist_clear( (GtkCList *) data);
> > 
> >     return;
> > }
> > 
> > /* If we come here, then the user has selected a row in the list. */
> > void selection_made( GtkCTree      *ctree,
> > GtkCTreeNode            *node,
> > gint            column,
> >                       gpointer        data )
> >  {
> >         gtk_signal_handler_block_by_func(GTK_OBJECT(ctree), selection_made, 
data);      
> >         gtk_ctree_select_recursive(GTK_CTREE(ctree),node);
> >         gtk_signal_handler_unblock_by_func(GTK_OBJECT(ctree), 
selection_made, data);    
> > 
> >      return;
> >  }
> > 
> >  int main( int    argc,
> >            gchar *argv[] )
> >  {                                  
> >      GtkWidget *window;
> >      GtkWidget *vbox, *hbox;
> >      GtkWidget *scrolled_window, *ctree;
> >      GtkWidget *button_add, *button_clear;    
> >      gchar *titles[2] = { "Ingredients", "Amount" };
> > 
> >      gtk_init(&argc, &argv);
> >      
> >      window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
> >      gtk_widget_set_usize(GTK_WIDGET(window), 300, 150);
> > 
> >      gtk_window_set_title(GTK_WINDOW(window), "GtkCList Example");
> >      gtk_signal_connect(GTK_OBJECT(window),
> >                         "destroy",
> >                         GTK_SIGNAL_FUNC(gtk_main_quit),
> >                         NULL);
> >      
> >      vbox=gtk_vbox_new(FALSE, 5);
> >      gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
> >      gtk_container_add(GTK_CONTAINER(window), vbox);
> >      gtk_widget_show(vbox);
> >      
> >      /* Create a scrolled window to pack the CList widget into */
> >      scrolled_window = gtk_scrolled_window_new (NULL, NULL);
> >      gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
> >                                      GTK_POLICY_AUTOMATIC, 
GTK_POLICY_ALWAYS);
> > 
> >      gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);
> >      gtk_widget_show (scrolled_window);
> > 
> >      /* Create the CList. For this example we use 2 columns */
> >      ctree = gtk_ctree_new( 2, 0);
> > 
> >      /* When a selection is made, we want to know about it. The callback
> >       * used is selection_made, and its code can be found further down */
> >      gtk_signal_connect(GTK_OBJECT(ctree), "tree_select_row",
> >                         GTK_SIGNAL_FUNC(selection_made),
> >                         NULL);
> > 
> >      /* It isn't necessary to shadow the border, but it looks nice :) */
> >      gtk_clist_set_shadow_type (GTK_CLIST(ctree), GTK_SHADOW_OUT);
> > 
> >      /* What however is important, is that we set the column widths as
> >       * they will never be right otherwise. Note that the columns are
> >       * numbered from 0 and up (to 1 in this case).
> >       */
> >      gtk_clist_set_column_width (GTK_CLIST(ctree), 0, 150);
> >      gtk_clist_set_selection_mode (GTK_CLIST(ctree),GTK_SELECTION_EXTENDED);
> > 
> >      /* Add the CList widget to the vertical box and show it. */
> >      gtk_container_add(GTK_CONTAINER(scrolled_window), ctree);
> >      gtk_widget_show(ctree);
> > 
> >      /* Create the buttons and add them to the window. See the button
> >       * tutorial for more examples and comments on this.
> >       */
> >      hbox = gtk_hbox_new(FALSE, 0);
> >      gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
> >      gtk_widget_show(hbox);
> > 
> >      button_add = gtk_button_new_with_label("Add List");
> >      button_clear = gtk_button_new_with_label("Clear List");
> > 
> >      gtk_box_pack_start(GTK_BOX(hbox), button_add, TRUE, TRUE, 0);
> >      gtk_box_pack_start(GTK_BOX(hbox), button_clear, TRUE, TRUE, 0);
> > 
> >      /* Connect our callbacks to the three buttons */
> >      gtk_signal_connect_object(GTK_OBJECT(button_add), "clicked",
> >                                GTK_SIGNAL_FUNC(button_add_clicked),
> >                                (gpointer) ctree);
> >      gtk_signal_connect_object(GTK_OBJECT(button_clear), "clicked",
> >                                GTK_SIGNAL_FUNC(button_clear_clicked),
> >                                (gpointer) ctree);
> > 
> >      gtk_widget_show(button_add);
> >      gtk_widget_show(button_clear);
> > 
> >      /* The interface is completely set up so we show the window and
> >       * enter the gtk_main loop.
> >       */
> >      gtk_widget_show(window);
> >      gtk_main();
> >      
> >      return(0);
> >  }
> > 
> 
> -- 
> CALUM BENSON, Usability Engineer       Sun Microsystems Ireland
> mailto:calum benson ireland sun com    Desktop Engineering Group
> http://www.sun.ie                      +353 1 819 9771
> 
> Any opinions are personal and not necessarily those of Sun Microsystems
> 
> _______________________________________________
> gtk-devel-list mailing list
> gtk-devel-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-devel-list





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