Re: How to suppress text on GtkCellRendererToggle
- From: Tadej BorovÅak <tadeboro gmail com>
- To: rpoe <randall c poe lmco com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: How to suppress text on GtkCellRendererToggle
- Date: Thu, 24 Sep 2009 22:16:03 +0200
Hi.
The problem I'm having is with display. I'd like it only to show the
checkbox. I can write a cell data display function to read the value
from the model and set the checkbox appropriately. That works fine. But
if I make the underlying value a G_TYPE_INTEGER then the column displays
1's and 0's along with the checkbox. If I make it a G_TYPE_BOOLEAN I get
the word "TRUE" or "FALSE". There doesn't seem to be a "text" property
connected to the renderer, or anything else that controls the displayed
text.
I cannot replicate your problem. Below you'll find minimalistic
application that works as it should.
---- CODE ----
#include <gtk/gtk.h>
int
main( int    argc,
      char **argv )
{
    GtkWidget *window,
              *tree;
    GtkListStore *store;
    GtkCellRenderer *cell;
    gint i;
    gtk_init( &argc, &argv );
    window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
    g_signal_connect( G_OBJECT( window ), "destroy",
                      G_CALLBACK( gtk_main_quit ), NULL );
    store = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
    for( i = 0; i < 10; i++ )
    {
        GtkTreeIter iter;
        gchar       string[] = " ";
        string[0] = '0' + i;
        gtk_list_store_append( store, &iter );
        gtk_list_store_set( store, &iter, 0, string, 1, i % 2, -1 );
    }
    tree = gtk_tree_view_new_with_model( GTK_TREE_MODEL( store ) );
    gtk_container_add( GTK_CONTAINER( window ), tree );
    cell = gtk_cell_renderer_text_new();
    gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( tree ),
                                                 -1, "Label", cell,
                                                 "text", 0,
                                                 NULL );
    cell = gtk_cell_renderer_toggle_new();
    gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( tree ),
                                                 -1, "Check", cell,
                                                 "active", 1,
                                                 NULL );
    gtk_widget_show_all( window );
    gtk_main();
    return( 0 );
}
---- CODE ----
-- 
Tadej BorovÅak
tadeboro.blogspot.com
tadeboro gmail com
tadej borovsak gmail com
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]