[Gtk-sharp-list] Patch to make Gtk.FileChooserDialog somewhat useable
Rafael Teixeira
Rafael Teixeira <monoman@gmail.com>
Mon, 24 Jan 2005 19:40:18 -0200
------=_Part_4940_5219300.1106602818956
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
With this patch in place this snippet runs:
using (FileChooserDialog chooser =
new FileChooserDialog("Choose new picture file", Gtk.Stock.Open,
this.MainWindow, FileChooserAction.Open)) {
chooser.SelectMultiple = false;
ResponseType response = (ResponseType) chooser.Run();
if (response == ResponseType.Accept) {
Console.WriteLine("FileChooserDialog filename = '{0}'", chooser.Filename);
myLife.PathToPhoto = chooser.Filename;
} else {
Console.WriteLine("FileChooserDialog response = '{0}'", response);
}
chooser.Destroy();
}
Hope it can be accepted,
--
Rafael "Monoman" Teixeira
---------------------------------------
I'm trying to become a "Rosh Gadol" before my own eyes.
See http://www.joelonsoftware.com/items/2004/12/06.html for enlightment.
------=_Part_4940_5219300.1106602818956
Content-Type: text/x-patch; name="FileChooserDialog.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename="FileChooserDialog.diff"
Index: FileChooserDialog.custom
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- FileChooserDialog.custom=09(revision 39432)
+++ FileChooserDialog.custom=09(working copy)
@@ -21,6 +21,29 @@
=20
=20
=09=09[DllImport("libgtk-win32-2.0-0.dll")]
+=09=09static extern IntPtr gtk_file_chooser_dialog_new(string title, IntPt=
r parent, int action,=20
+=09=09=09string firstButtonText, int firstButtonResponse,=20
+=09=09=09string secondButtonText, int secondButtonResponse, IntPtr nil);
+
+=09=09public FileChooserDialog (string title, string acceptButtonText, Win=
dow parent, FileChooserAction action)
+=09=09{
+=09=09=09if (GetType () !=3D typeof (FileChooserDialog)) {
+=09=09=09=09CreateNativeObject (new string[0], new GLib.Value[0]);
+=09=09=09=09Title =3D title;
+=09=09=09=09if (parent !=3D null)
+=09=09=09=09=09TransientFor =3D parent;
+=09=09=09=09Action =3D action;
+=09=09=09=09return;
+=09=09=09}
+=09=09=09Raw =3D gtk_file_chooser_dialog_new (title, parent =3D=3D null ? =
IntPtr.Zero : parent.Handle, (int)action,=20
+=09=09=09=09=09Gtk.Stock.Cancel, (int)ResponseType.Cancel,
+=09=09=09=09=09acceptButtonText, (int)ResponseType.Accept,
+=09=09=09=09=09IntPtr.Zero);
+=09=09}
+=09=09
+=09=09
+
+=09=09[DllImport("libgtk-win32-2.0-0.dll")]
=09=09static extern IntPtr gtk_file_chooser_dialog_new(string title, IntPt=
r parent, int action, IntPtr nil);
=20
=09=09public FileChooserDialog (string title, Window parent, FileChooserAc=
tion action)
@@ -131,3 +154,5 @@
=09=09=09=09return result;
=09=09=09}
=09=09}
+
+=20
------=_Part_4940_5219300.1106602818956--