Re: Problem with GtkTreeSelection



Hey John,

Yes, setting the focus to the GtkTreeView will indeed make the blue selection 
cursor appear, and I am able to do that the same way you do in your 
example... the problem is that the search I am doing is with a dynamic search 
image being entered into a GtkEntry widget by the user.. so changing the 
focus to the GtkTreeView in order to make the blue cursor appear is not a 
viable option, because as in your example, it requires the user to click on 
something to regain focus for the GtkEntry widget where the search image 
entry was occuring.

The other information about themes is probably more useful.  I was not aware 
that the selection cursor appeared as a grey color and I probably need to 
investigate that situation. 

Thank you so much for all the effort you put into answering my question.  

Best regards,
Bob Caryl

On Wednesday 22 December 2004 06:22, you wrote:
Hi again, I added a click to select button to the gtkdemo treestore
and it seems to work for me. As a poster said on gtklist, maybe it's a
theme problem? I'm using gtk+-2.4.13 on linux with the default theme,
if that's any help.

I pasted this near the end of do_tree_store()
(gtk+-2.4.x/demos/gtk-demo/tree_store.c) to add a 'go to groundhog
day' button:

{
        GtkWidget *button;

        button = gtk_button_new_with_label( "Again!" );
        g_signal_connect( button, "clicked",
                G_CALLBACK( groundhog_cb ), treeview );
        gtk_box_pack_start( GTK_BOX( vbox ), button, FALSE, FALSE, 0 );
}

then earlier in the code I have:

static gboolean
groundhog_lookup( GtkTreeModel *model,
        GtkTreePath *path, GtkTreeIter *iter,  GtkTreeIter *iter_return )
{
        char *name;
        gboolean found = FALSE;

        /* Yuk! Very inefficient search.
         */
        gtk_tree_model_get( model, iter, HOLIDAY_NAME_COLUMN, &name, -1 );
        if( strcmp( name, "Groundhog Day" ) == 0 ) {
                *iter_return = *iter;
                found = TRUE;
        }
        g_free( name );

        return( found );
}

void
groundhog_cb( GtkWidget *button, GtkWidget *view )
{
        GtkTreeModel *model = gtk_tree_view_get_model( GTK_TREE_VIEW( view
) ); GtkTreeIter iter;
        GtkTreePath *path;

        gtk_tree_model_foreach( model,
                (GtkTreeModelForeachFunc) groundhog_lookup, &iter );

        /* Should check that the search suceeded, oh well.
         */

        /* Expand the tree to show the row we want, move the selection to
         * that point.
         */

        path = gtk_tree_model_get_path( model, &iter );
        gtk_tree_view_expand_to_path( GTK_TREE_VIEW( view ), path );
        gtk_tree_view_set_cursor( GTK_TREE_VIEW( view ), path, NULL, FALSE
); gtk_tree_path_free( path );

        /* After the button click the keyboard focus will be on the button
         * (obviously). The selected row in the treeview will display with
         * white text on a grey background (like all unfocussed
selections). * This call will warp the kb focus to the treeview, lighting
up the * selected row in the usual white-text-on-blue style.
         */
        gtk_widget_grab_focus( view );
}




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