From 3bc36b0d370e91a4cbd3917fb8f89cd6e69af2e6 Mon Sep 17 00:00:00 2001 From: Todd Berman Date: Sat, 30 Oct 2004 02:40:00 +0000 Subject: [PATCH] 2004-10-29 Todd Berman * gtk/FileChooserDialog.custom: Add Filenames property to return the data as a string[] instead of a GSList. * gtk/FileChooserWidget.custom: Same as above. * gtk/Makefile.am: Add FileChooserWidget.custom svn path=/trunk/gtk-sharp/; revision=35492 --- ChangeLog | 7 +++++++ gtk/FileChooserDialog.custom | 21 +++++++++++++++++++++ gtk/FileChooserWidget.custom | 20 ++++++++++++++++++++ gtk/Gtk.metadata | 1 + gtk/Makefile.am | 1 + 5 files changed, 50 insertions(+) create mode 100644 gtk/FileChooserWidget.custom diff --git a/ChangeLog b/ChangeLog index 0eafd4721..fd1afb6ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-10-29 Todd Berman + + * gtk/FileChooserDialog.custom: Add Filenames property to return + the data as a string[] instead of a GSList. + * gtk/FileChooserWidget.custom: Same as above. + * gtk/Makefile.am: Add FileChooserWidget.custom + 2004-10-30 Jeroen Zwartepoorte * sources/gtk-sharp-sources.xml: Invalid XML due to unremoved --> diff --git a/gtk/FileChooserDialog.custom b/gtk/FileChooserDialog.custom index aaa438975..5369bee77 100644 --- a/gtk/FileChooserDialog.custom +++ b/gtk/FileChooserDialog.custom @@ -13,3 +13,24 @@ { Raw = gtk_file_chooser_dialog_new_with_backend (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, backend, IntPtr.Zero); } + + [DllImport ("libgtk-win32-2.0-0.dll")] + 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 { + get { + IntPtr strv = gtk_file_chooser_get_filenames (Handle); + System.Collections.ArrayList result = new System.Collections.ArrayList (); + int i = 0; + IntPtr strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); + while (strptr != IntPtr.Zero) { + result.Add (Marshal.PtrToStringAnsi (strptr)); + strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); + } + g_strfreev (strv); + return result.ToArray (typeof (string)) as string[]; + } + } diff --git a/gtk/FileChooserWidget.custom b/gtk/FileChooserWidget.custom new file mode 100644 index 000000000..faaf9becb --- /dev/null +++ b/gtk/FileChooserWidget.custom @@ -0,0 +1,20 @@ +[DllImport ("libgtk-win32-2.0-0.dll")] +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 { + get { + IntPtr strv = gtk_file_chooser_get_filenames (Handle); + System.Collections.ArrayList result = new System.Collections.ArrayList (); + int i = 0; + IntPtr strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); + while (strptr != IntPtr.Zero) { + result.Add (Marshal.PtrToStringAnsi (strptr)); + strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++); + } + g_strfreev (strv); + return result.ToArray (typeof (string)) as string[]; + } +} diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index cad3d9de8..01b469937 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -64,6 +64,7 @@ SetIsEditable TextDeleted TextInserted + 1 out 1 out diff --git a/gtk/Makefile.am b/gtk/Makefile.am index b8d6f2194..dfd80670e 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -46,6 +46,7 @@ customs = \ Dialog.custom \ Entry.custom \ FileChooserDialog.custom \ + FileChooserWidget.custom \ FileSelection.custom \ FileSystemModel.custom \ Frame.custom \