2004-11-03 Todd Berman <tberman@off.net>

* gtk/FileChooserDialog.custom:
        * gtk/FileChooserWidget.custom: Properly implement .Filenames. The old
        code was a really bad c&p job.

svn path=/trunk/gtk-sharp/; revision=35619
This commit is contained in:
Todd Berman 2004-11-04 04:06:07 +00:00
parent ad4b452f48
commit 131f2ed0d9
3 changed files with 22 additions and 27 deletions

View File

@ -1,3 +1,9 @@
2004-11-03 Todd Berman <tberman@off.net>
* gtk/FileChooserDialog.custom:
* gtk/FileChooserWidget.custom: Properly implement .Filenames. The old
code was a really bad c&p job.
2004-11-02 Jeroen Zwartepoorte <jeroen@xs4all.nl> 2004-11-02 Jeroen Zwartepoorte <jeroen@xs4all.nl>
* gnomevfs/AsyncDirectoryLoadCallback.cs: * gnomevfs/AsyncDirectoryLoadCallback.cs:

View File

@ -54,21 +54,15 @@
[DllImport ("libgtk-win32-2.0-0.dll")] [DllImport ("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_file_chooser_get_filenames (IntPtr raw); static extern IntPtr gtk_file_chooser_get_filenames (IntPtr raw);
[DllImport("libglib-2.0-0.dll")]
static extern void g_strfreev (IntPtr handle);
public string[] Filenames { public string[] Filenames {
get { get {
IntPtr strv = gtk_file_chooser_get_filenames (Handle); IntPtr raw_ret = gtk_file_chooser_get_filenames (Handle);
System.Collections.ArrayList result = new System.Collections.ArrayList (); if (raw_ret == IntPtr.Zero)
int i = 0; return new string[0];
IntPtr strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); GLib.SList list = new GLib.SList (raw_ret, typeof (string));
while (strptr != IntPtr.Zero) { string[] result = new string [list.Count];
result.Add (Marshal.PtrToStringAnsi (strptr)); for (int i = 0; i < list.Count; i++)
strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); result [i] = (string) list [i];
} return result;
g_strfreev (strv);
return result.ToArray (typeof (string)) as string[];
} }
} }

View File

@ -22,20 +22,15 @@
[DllImport ("libgtk-win32-2.0-0.dll")] [DllImport ("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_file_chooser_get_filenames (IntPtr raw); static extern IntPtr gtk_file_chooser_get_filenames (IntPtr raw);
[DllImport("libglib-2.0-0.dll")]
static extern void g_strfreev (IntPtr handle);
public string[] Filenames { public string[] Filenames {
get { get {
IntPtr strv = gtk_file_chooser_get_filenames (Handle); IntPtr raw_ret = gtk_file_chooser_get_filenames (Handle);
System.Collections.ArrayList result = new System.Collections.ArrayList (); if (raw_ret == IntPtr.Zero)
int i = 0; return new string[0];
IntPtr strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); GLib.SList list = new GLib.SList (raw_ret, typeof (string));
while (strptr != IntPtr.Zero) { string[] result = new string [list.Count];
result.Add (Marshal.PtrToStringAnsi (strptr)); for (int i = 0; i < list.Count; i++)
strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); result [i] = (string) list [i];
} return result;
g_strfreev (strv);
return result.ToArray (typeof (string)) as string[];
} }
} }