GTK weirdness

Discussion in 'Ruby' started by Joe Laughlin, Aug 13, 2004.

  1. Joe Laughlin

    Joe Laughlin Guest

    I'm creating a Gtk::TreeViewColumn and attaching its model to a
    Gtk::ListStore. The liststore is created to have one column of type Object.
    I then create a bunch of columns and renderers and and call
    set_cell_data_func() on each column, setting the renderer.text attribute to
    equal some atribute in an object that's contained in the Gtk::ListStore.

    (hope that makes sense!)

    So when I run the application, I get a bunch of these warnings when I move
    my mouse over the treeview:

    GLib-GObject-WARNING **: unable to set property `text' of type `gchararray'
    from value of type `VALUE'

    Ideas?

    Thanks,
    Joe
    Joe Laughlin, Aug 13, 2004
    #1
    1. Advertising

  2. Joe Laughlin

    Joao Pedrosa Guest

    Hi,

    --- Joe Laughlin <> wrote:

    > I'm creating a Gtk::TreeViewColumn and attaching its
    > model to a
    > Gtk::ListStore. The liststore is created to have
    > one column of type Object.
    > I then create a bunch of columns and renderers and
    > and call
    > set_cell_data_func() on each column, setting the
    > renderer.text attribute to
    > equal some atribute in an object that's contained in
    > the Gtk::ListStore.
    >
    > (hope that makes sense!)
    >
    > So when I run the application, I get a bunch of
    > these warnings when I move
    > my mouse over the treeview:
    >
    > GLib-GObject-WARNING **: unable to set property
    > `text' of type `gchararray'
    > from value of type `VALUE'
    >
    > Ideas?


    On Windows 2000, ruby 1.8.2 (2004-06-29)
    [i386-mswin32], with the "One Click Ruby Install"
    (OCRI), GTK 2.4.3 by Tor, Ruby/GTK from the CVS, I was
    able to create the following example, which seemed to
    work fine. By the way, great Idea. :)

    ---->--- cut ---->-----
    require 'gtk2'
    include Gtk

    def create_treeview
    model = ListStore.new(Object)
    treeview = TreeView.new(model)
    3.times{|n|
    column = TreeViewColumn.new
    column.set_title("Etc#{n}")
    text_renderer = CellRendererText.new
    column.pack_start(text_renderer, true)
    text_renderer.signal_connect('edited'){|cell,
    path, value| }
    column.set_cell_data_func(text_renderer){|column,
    cell, model, iter|
    cell.text = iter[0][n].to_s
    }
    treeview.append_column(column)
    }
    fill_random_data model
    treeview
    end

    def fill_random_data model
    10.times{|i|
    iter = model.append
    iter[0] = ["one#{i}", 2 + i, "three#{i}"]
    }
    end

    Gtk.init
    w = Window.new
    w.signal_connect('destroy'){ Gtk.main_quit }
    w.title = 'A Test'
    w.set_default_size 500,400
    w.add(create_treeview)
    w.show_all
    Gtk.main
    ---->--- cut ---->-----

    Cheers,
    Joao



    __________________________________
    Do you Yahoo!?
    Yahoo! Mail - You care about security. So do we.
    http://promotions.yahoo.com/new_mail
    Joao Pedrosa, Aug 13, 2004
    #2
    1. Advertising

  3. Joe Laughlin

    Joe Laughlin Guest

    Joao Pedrosa wrote:
    > Hi,
    >
    > --- Joe Laughlin <> wrote:
    >
    >> I'm creating a Gtk::TreeViewColumn and attaching its
    >> model to a
    >> Gtk::ListStore. The liststore is created to have
    >> one column of type Object.
    >> I then create a bunch of columns and renderers and
    >> and call
    >> set_cell_data_func() on each column, setting the
    >> renderer.text attribute to
    >> equal some atribute in an object that's contained in
    >> the Gtk::ListStore.
    >>
    >> (hope that makes sense!)
    >>
    >> So when I run the application, I get a bunch of
    >> these warnings when I move
    >> my mouse over the treeview:
    >>
    >> GLib-GObject-WARNING **: unable to set property
    >> `text' of type `gchararray'
    >> from value of type `VALUE'
    >>
    >> Ideas?

    >
    > On Windows 2000, ruby 1.8.2 (2004-06-29)
    > [i386-mswin32], with the "One Click Ruby Install"
    > (OCRI), GTK 2.4.3 by Tor, Ruby/GTK from the CVS, I was
    > able to create the following example, which seemed to
    > work fine. By the way, great Idea. :)
    >
    > ---->--- cut ---->-----
    > require 'gtk2'
    > include Gtk
    >
    > def create_treeview
    > model = ListStore.new(Object)
    > treeview = TreeView.new(model)
    > 3.times{|n|
    > column = TreeViewColumn.new
    > column.set_title("Etc#{n}")
    > text_renderer = CellRendererText.new
    > column.pack_start(text_renderer, true)
    > text_renderer.signal_connect('edited'){|cell,
    > path, value| }
    > column.set_cell_data_func(text_renderer){|column,
    > cell, model, iter|
    > cell.text = iter[0][n].to_s
    > }
    > treeview.append_column(column)
    > }
    > fill_random_data model
    > treeview
    > end
    >
    > def fill_random_data model
    > 10.times{|i|
    > iter = model.append
    > iter[0] = ["one#{i}", 2 + i, "three#{i}"]
    > }
    > end
    >
    > Gtk.init
    > w = Window.new
    > w.signal_connect('destroy'){ Gtk.main_quit }
    > w.title = 'A Test'
    > w.set_default_size 500,400
    > w.add(create_treeview)
    > w.show_all
    > Gtk.main
    > ---->--- cut ---->-----
    >
    > Cheers,
    > Joao
    >
    >
    >
    > __________________________________
    > Do you Yahoo!?
    > Yahoo! Mail - You care about security. So do we.
    > http://promotions.yahoo.com/new_mail


    Thanks for the information.

    I tracked it down to how I created the TreeViewColumn. I was setting :text
    equal to 0 when creating the TreeViewColumn, which tells the TreeViewColumn
    to try to find the text for the column in the first column of the model,
    which is an Object. So when I removed ":text = 0", it worked.

    Joe
    Joe Laughlin, Aug 16, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wayne Myers

    POK Flag Weirdness wth binary files

    Wayne Myers, May 26, 2004, in forum: Perl
    Replies:
    1
    Views:
    466
    ! aaa
    May 27, 2004
  2. steve
    Replies:
    4
    Views:
    509
    Brian van den Broek
    Mar 13, 2005
  3. Replies:
    2
    Views:
    506
  4. Gergely Kontra
    Replies:
    2
    Views:
    239
    Joao Pedrosa
    Jun 18, 2004
  5. Alex Shulgin
    Replies:
    1
    Views:
    168
    thefed
    Nov 21, 2007
Loading...

Share This Page