[Glade-devel] glade: populating table/list with headers



On Sat, 2012-01-14 at 20:54 +0100, Saku Masukita wrote:

Hi,

Sorry for the late reply...

On Sun, Nov 13, 2011 at 1:13 AM, Tristan Van Berkom
<tristanvb at openismus.com> wrote:
        On Sat, 2011-11-12 at 20:29 +0100, Saku Masukita wrote:
        >
        > Hello,
        >
        > I need to populate a list/table in glade with some headers
        > which label the columns. Could anyone point me in the
        > right direction. Do I need to use a GtkTreeView? Is the
        > old CList no longer supported for this? Do I have to
        > build my own custom widget and import it into glade?
        
        
        Hi Saku,
          If you are displaying dynamic content, and that content
        might be larger than say, 5 or 10 rows of data... then you
        should definitely use a GtkTreeView.
        
        Note that the ultimate problem with the old clist widgets
        was that they use an unreasonable amount of resources to
        display a list of dynamic data, so you do not want to relive
        that by creating widgets for each row yourself (once you have
        around 100 rows it can start to take a long time just to
        create
        those widgets).
        
        To do this in Glade,
         o Create a GtkTreeView
         o Create a GtkListStore (it may be an option while creating
        the view)
         o Then select the "Edit" toolbar item with the treeview
        selected

, I have tried clicking on a GtkTreeView
and placing it down. A popup window shows up asking me to
enter a GtkTreeView TreeView Model. I create a new object
called liststore1. I then right click the Tree View and select
Edit and get the following errors which crash glade altogether
(I see no way on the Edit toolbar to assign datatypes). How
should I proceed???

(glade:9725): Gtk-CRITICAL **: gtk_cell_view_set_displayed_row:
assertion `GTK_IS_TREE_MODEL (cell_view->priv->model)' failed

(glade:9725): Gtk-WARNING **: /build/buildd/gtk
+3.0-3.2.0/./gtk/gtktreeview.c:1944: invalid property id 14 for
"ubuntu-almost-fixed-height-mode" of type `GParamBoolean' in
`GtkTreeView'

(glade:9725): Gtk-WARNING **: GtkContainerClass::add not implemented
for `GtkTreeView'

Gtk-ERROR **: GtkBox child GladeEditorTable minimum height: -4 < 0
Trace/breakpoint trap

This is a very well known GTK+ bug which was in fact fixed almost
two full months ago in GTK+ git master.

I don't know why but it seems most distributions of GTK+ still
have this bug (because I hear a lot about it), to track the progress
of this you can follow:
    https://bugzilla.gnome.org/show_bug.cgi?id=660139

It seems the fix should be available in an upcoming 3.2 release
(as per Benjamin's (Company's) comment that the fix has been
backported to the 3.2 branch).

If you can't get your hands on a recent version of GTK+ that
contains the fix, I can give you a quick pointer on how
to hack around that with Glade sources:

  o cd ~/path/to/glade/sources/
  o grep -r gtk_grid_set_column_spacing .
  o grep -r gtk_grid_set_row_spacing
  o edit any of column/row spacing assigned to a GtkGrid
    in Glade, you can simply remove these lines or change
    the set value to '0'
  o recompile and install Glade

That will avoid the crash for the time being.

Sorry for the inconvenience.

Cheers,
        -Tristan


Thanks,

Saku
 
         o In the main page... assign data types to your list store,
           for instance you might have a column named 'name' which is
           of type 'gchararray' (GType-speak for a string)
         o Then go to the 'Hierarchy' tab of the editor
         o Press the 'Add' button on the bottom left, this will add
           a GtkTreeViewColumn to your view
         o Right Click on the newly created treeview column which
        appears
           in the treeview editor window
         o In this context menu you can create GtkCellRenderers to
        show
           data in your view... Add some renderers, a text renderer to
           render text, etc.
         o Now that you have a renderer selected, on the right hand
        you
           will have a list of properties... only here instead of
        strict
           values (which are still possible), you can attribute the
        cell
           renderer properties to be set from specific values in the
           GtkTreeStore which you defined earlier
        
           So in this final step, you say that the
        GtkCellRendererText:text
           property should be driven by the 'name' column which you
        defined
           in your GtkTreeStore as a 'gchararray' (string).
        
        After that, in code you generally have a loop where you call
        apis like gtk_list_store_append() to add the data you need.
        
        Cheers,
                -Tristan
        
        







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