List view : no scroll bar and maximum length ?
Adrien <[email protected]>
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I've written a small mp3 player during the week-end, mainly in order
to check whether it was possible to write a light and fast one with
lablgtk (I miss foobar2000's interface under linux).
I've encountered some problems, especially with list view (which the
biggest difference between a foobar ui and a winamp one :
http://foobar2000.org/screenshots/img/main-simple.png.html )
My interface looks like : http://ocaml.yaxm.org/files/blatere/pr11n.png
(1000 times the same file in order to see how it scaled)
First, I don't have any scroll bar though my playlist is 1000 elements
long. I know there is the GRange module but I can't believe these
scroll bars are not automatic.
Second, if I create a 2000 elements-long playlist, my program crashes
with the following message:
The program 'blatère' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
(Details: serial 462 error_code 11 request_code 53 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
I can't manage to get anything more useful. However I guess this has
to do something with the way I add rows :
let playlist=new GTree.column_list
let rank_column=playlist#add Gobject.Data.string
let fileinfo_column=playlist#add Gobject.Data.string
let playlist_view=GTree.view ~packing:vbox#pack ()
let _=playlist_view#append_column (GTree.view_column ~title:"Rank"
~renderer:(GTree.cell_renderer_text [], ["text", rank_column]) ())
let _=playlist_view#append_column (GTree.view_column ~title:"File
Info" ~renderer:(GTree.cell_renderer_text [], ["text",
fileinfo_column]) ())
let playlist_store=GTree.list_store playlist
let rec fill_playlist n pl=
match pl with
|[]->()
|t::q->let this_playlist_entry=playlist_store#append () in
let _=playlist_store#set ~row:this_playlist_entry
~column:rank_column ("["^(string_of_int n)^"]") in
let _=playlist_store#set ~row:this_playlist_entry
~column:fileinfo_column t in
fill_playlist (n+1) q
let _=fill_playlist 1 pl
let _=playlist_view#set_model (Some playlist_store#coerce)
The source can be found at http://ocaml.yaxm.org/files/blatere/second_try.ml
(remember this is the first time I get serious at using lablgtk)
Thanks.
---
Adrien Nader