[Gtk-sharp-list] [PATCH] Basic FileChooserButton Support
Eric Butler
eric@extremeboredom.net
Mon, 02 May 2005 21:08:06 -0700
--=-U0O4AuwQITRbB+AajEv4
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Hey,
This little patch adds just enough to FileChooserButton so that it is
usable if added in glade, since you wouldn't have any way to get a
reference to the associated GtkFileChooserDialog.
It was all basically yanked from the autogenerated FileChooserWidget
file. There are probably a few other basic things that should be added,
but I haven't had a need for anything else yet personally.
Regards,
Eric
(I hope this didn't send twice. I've about given up on Thunderbird now
with the amount of trouble it causes me... I can't even tell if my
messages send or not. Using evo now =)
--=-U0O4AuwQITRbB+AajEv4
Content-Disposition: attachment; filename=FileChooserButton.custom.patch
Content-Type: text/x-patch; name=FileChooserButton.custom.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit
Index: gtk/FileChooserButton.custom
===================================================================
--- gtk/FileChooserButton.custom (revision 0)
+++ gtk/FileChooserButton.custom (revision 0)
@@ -0,0 +1,68 @@
+// Gtk.FileChooserButton.custom - Gtk FileChooserButton customizations
+//
+// Authors: Eric Butler <eric@extremeboredom.net>
+//
+// Copyright (c) 2005 Eric Butler
+//
+// 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.
+
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_file_chooser_get_current_folder(IntPtr raw);
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern bool gtk_file_chooser_set_current_folder(IntPtr raw, IntPtr filename);
+
+ public string CurrentFolder {
+ get {
+ IntPtr raw_ret = gtk_file_chooser_get_current_folder(Handle);
+ string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
+ return ret;
+ }
+ set {
+ IntPtr filename_as_native = GLib.Marshaller.StringToPtrGStrdup (value);
+ bool raw_ret = gtk_file_chooser_set_current_folder(Handle, filename_as_native);
+ bool ret = raw_ret;
+ GLib.Marshaller.Free (filename_as_native);
+ if (ret == false) {
+ throw new Exception("Operation failed");
+ }
+ }
+ }
+
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern IntPtr gtk_file_chooser_get_current_folder_uri(IntPtr raw);
+
+ [DllImport("libgtk-win32-2.0-0.dll")]
+ static extern bool gtk_file_chooser_set_current_folder_uri(IntPtr raw, IntPtr uri);
+
+ public Uri CurrentFolderUri {
+ get {
+ IntPtr raw_ret = gtk_file_chooser_get_current_folder_uri(Handle);
+ string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
+ return new Uri(ret);
+ }
+ set {
+ IntPtr uri_as_native = GLib.Marshaller.StringToPtrGStrdup (value.ToString());
+ bool raw_ret = gtk_file_chooser_set_current_folder_uri(Handle, uri_as_native);
+ bool ret = raw_ret;
+ GLib.Marshaller.Free (uri_as_native);
+ if (ret == false) {
+ throw new Exception("Operation failed");
+ }
+ }
+ }
+
Index: gtk/Makefile.am
===================================================================
--- gtk/Makefile.am (revision 43910)
+++ gtk/Makefile.am (working copy)
@@ -53,6 +53,7 @@
EntryCompletion.custom \
FileChooserDialog.custom \
FileChooserWidget.custom \
+ FileChooserButton.custom \
FileFilter.custom \
FileSelection.custom \
FileSystemModel.custom \
--=-U0O4AuwQITRbB+AajEv4--