2004-10-30 20:32:54 +00:00
|
|
|
// Gtk.FileChooserDialog.custom - Gtk FileChooserDialog customizations
|
2004-10-30 03:31:43 +00:00
|
|
|
//
|
|
|
|
// Authors: Todd Berman <tberman@off.net>
|
|
|
|
// Jeroen Zwartepoorte <jeroen@xs4all.nl>
|
|
|
|
//
|
|
|
|
// Copyright (c) 2004 Todd Berman, Jeroen Zwartepoorte
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the Lesser GNU General
|
|
|
|
// Public License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
|
2004-10-29 20:33:07 +00:00
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
2005-03-09 20:32:24 +00:00
|
|
|
static extern IntPtr gtk_file_chooser_dialog_new(IntPtr title, IntPtr parent, int action, IntPtr nil);
|
2004-10-29 20:33:07 +00:00
|
|
|
|
2005-01-28 16:03:27 +00:00
|
|
|
public FileChooserDialog (string title, Window parent, FileChooserAction action, params object[] button_data) : base (IntPtr.Zero)
|
2004-10-29 20:33:07 +00:00
|
|
|
{
|
2004-10-30 03:31:43 +00:00
|
|
|
if (GetType () != typeof (FileChooserDialog)) {
|
|
|
|
CreateNativeObject (new string[0], new GLib.Value[0]);
|
|
|
|
Title = title;
|
|
|
|
if (parent != null)
|
2004-11-17 19:38:32 +00:00
|
|
|
TransientFor = parent;
|
2004-10-30 03:31:43 +00:00
|
|
|
Action = action;
|
2005-03-09 20:32:24 +00:00
|
|
|
} else {
|
|
|
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (title);
|
|
|
|
Raw = gtk_file_chooser_dialog_new (native, parent == null ? IntPtr.Zero : parent.Handle, (int)action, IntPtr.Zero);
|
|
|
|
GLib.Marshaller.Free (native);
|
|
|
|
}
|
2005-01-28 16:03:27 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < button_data.Length - 1; i += 2)
|
|
|
|
AddButton ((string) button_data [i], (int) button_data [i + 1]);
|
2004-10-29 20:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
2005-03-09 20:32:24 +00:00
|
|
|
static extern IntPtr gtk_file_chooser_dialog_new_with_backend(IntPtr title, IntPtr parent, int action, IntPtr backend, IntPtr nil);
|
2004-10-29 20:33:07 +00:00
|
|
|
|
2005-01-31 15:49:56 +00:00
|
|
|
public FileChooserDialog (string backend, string title, Window parent, FileChooserAction action, params object[] button_data) : base (IntPtr.Zero)
|
2004-10-29 20:33:07 +00:00
|
|
|
{
|
2004-10-30 03:31:43 +00:00
|
|
|
if (GetType () != typeof (FileChooserDialog)) {
|
|
|
|
CreateNativeObject (new string[] { "file-system-backend" }, new GLib.Value[] { new GLib.Value (backend) } );
|
|
|
|
Title = title;
|
|
|
|
if (parent != null)
|
2004-11-17 19:38:32 +00:00
|
|
|
TransientFor = parent;
|
2004-10-30 03:31:43 +00:00
|
|
|
Action = action;
|
2005-03-09 20:32:24 +00:00
|
|
|
} else {
|
|
|
|
IntPtr ntitle = GLib.Marshaller.StringToPtrGStrdup (title);
|
|
|
|
IntPtr nbackend = GLib.Marshaller.StringToPtrGStrdup (backend);
|
|
|
|
Raw = gtk_file_chooser_dialog_new_with_backend (ntitle, parent == null ? IntPtr.Zero : parent.Handle, (int)action, nbackend, IntPtr.Zero);
|
|
|
|
GLib.Marshaller.Free (ntitle);
|
|
|
|
GLib.Marshaller.Free (nbackend);
|
|
|
|
}
|
2005-01-28 16:03:27 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < button_data.Length - 1; i += 2)
|
|
|
|
AddButton ((string) button_data [i], (int) button_data [i + 1]);
|
2004-10-29 20:33:07 +00:00
|
|
|
}
|
2004-10-30 02:40:00 +00:00
|
|
|
|
|
|
|
[DllImport ("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern IntPtr gtk_file_chooser_get_filenames (IntPtr raw);
|
|
|
|
public string[] Filenames {
|
|
|
|
get {
|
2004-11-04 04:06:07 +00:00
|
|
|
IntPtr raw_ret = gtk_file_chooser_get_filenames (Handle);
|
|
|
|
if (raw_ret == IntPtr.Zero)
|
|
|
|
return new string[0];
|
2005-06-02 16:16:28 +00:00
|
|
|
GLib.SList list = new GLib.SList (raw_ret, typeof (GLib.ListBase.FilenameString));
|
2004-11-04 04:06:07 +00:00
|
|
|
string[] result = new string [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = (string) list [i];
|
2004-11-04 19:29:01 +00:00
|
|
|
list.Empty ();
|
2004-11-04 04:06:07 +00:00
|
|
|
return result;
|
2004-10-30 02:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-04 20:33:35 +00:00
|
|
|
|
|
|
|
[DllImport ("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern IntPtr gtk_file_chooser_get_uris (IntPtr raw);
|
|
|
|
public string[] Uris {
|
|
|
|
get {
|
|
|
|
IntPtr raw_ret = gtk_file_chooser_get_uris (Handle);
|
|
|
|
if (raw_ret == IntPtr.Zero)
|
|
|
|
return new string[0];
|
|
|
|
GLib.SList list = new GLib.SList (raw_ret, typeof (string));
|
|
|
|
string[] result = new string [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = (string) list [i];
|
|
|
|
list.Empty ();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport ("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern IntPtr gtk_file_chooser_list_filters (IntPtr raw);
|
|
|
|
public FileFilter[] Filters {
|
|
|
|
get {
|
|
|
|
IntPtr raw_ret = gtk_file_chooser_list_filters (Handle);
|
|
|
|
if (raw_ret == IntPtr.Zero)
|
|
|
|
return new FileFilter[0];
|
|
|
|
GLib.SList list = new GLib.SList (raw_ret, typeof (FileFilter));
|
|
|
|
FileFilter[] result = new FileFilter [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = (FileFilter) list [i];
|
|
|
|
list.Dispose ();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport ("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern IntPtr gtk_file_chooser_list_shortcut_folders (IntPtr raw);
|
|
|
|
public string[] ShortcutFolders {
|
|
|
|
get {
|
|
|
|
IntPtr raw_ret = gtk_file_chooser_list_shortcut_folders (Handle);
|
|
|
|
if (raw_ret == IntPtr.Zero)
|
|
|
|
return new string[0];
|
2005-06-02 16:16:28 +00:00
|
|
|
GLib.SList list = new GLib.SList (raw_ret, typeof (GLib.ListBase.FilenameString));
|
2004-11-04 20:33:35 +00:00
|
|
|
string[] result = new string [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = (string) list [i];
|
|
|
|
list.Empty ();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[DllImport ("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern IntPtr gtk_file_chooser_list_shortcut_folder_uris (IntPtr raw);
|
|
|
|
public string[] ShortcutFolderUris {
|
|
|
|
get {
|
|
|
|
IntPtr raw_ret = gtk_file_chooser_list_shortcut_folder_uris (Handle);
|
|
|
|
if (raw_ret == IntPtr.Zero)
|
|
|
|
return new string[0];
|
|
|
|
GLib.SList list = new GLib.SList (raw_ret, typeof (string));
|
|
|
|
string[] result = new string [list.Count];
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
result [i] = (string) list [i];
|
|
|
|
list.Empty ();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|