 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
hungerfish
Joined: 20 Apr 2007 Posts: 4
|
Posted: Sun Jul 15, 2007 1:30 am Post subject: Displaying only certain files with a listView |
|
|
Hello,
I'm writing an app. in which I want to display the contents of a folder (selected via filechooserdiag) in a listView. However I only want 'certain' filetypes to be displayed.
Now while I can do this using standard c-functions to analyise the filename and select only those files with the correct type(ending), I wonder if there is a way of doing this through GTK or GDK?
Also, on a side note, how can I include subfolders when 'opening' a directory with ' g_dir_open' & 'g_dir_read_name'?
ThanX |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 386 Location: Fairfax, Virginia
|
Posted: Sun Jul 15, 2007 5:29 pm Post subject: |
|
|
To display sub folders, you need to use g_file_test() to check whether the current file is a file or folder. Create a recursive parsing function.
As for file types, GVFS is coming in the next few releases of GLib, which checks mime types. For now, you can either check the file extension by searching the filename string, or using GnomeVFS. |
|
| Back to top |
|
 |
hungerfish
Joined: 20 Apr 2007 Posts: 4
|
Posted: Sun Jul 15, 2007 11:29 pm Post subject: |
|
|
Thank you for your help. I'll look into using GnomeVFS, however I want to keep dependencies low, so I'll probably stick with checking strings.
| Quote: | | To display sub folders, you need to use g_file_test() to check whether the current file is a file or folder. |
How obvious, now why didn't I realise this... :oops: |
|
| Back to top |
|
 |
forward83
Joined: 09 Mar 2008 Posts: 2
|
Posted: Sun Mar 09, 2008 4:44 pm Post subject: |
|
|
Hi, I'm looking to implement something similar but is a total noob.
Do you have some code/sample to share? Thanks. |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|