From 7c0a6a4f9b051657d324f2f554b5cce45a4296f5 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Mon, 7 Aug 2006 20:45:47 +0000 Subject: [PATCH] 2006-08-07 Mike Kestner * gtk/Gtk.metadata : remainder of new API massaging for existing types. * gtk/Printer.custom : new static method. * gtk/TextBuffer.custom : serialization API implementations. svn path=/trunk/gtk-sharp/; revision=63448 --- ChangeLog | 7 +++++++ gtk/Gtk.metadata | 5 +++++ gtk/Makefile.am | 1 + gtk/Printer.custom | 40 +++++++++++++++++++++++++++++++++++ gtk/TextBuffer.custom | 49 ++++++++++++++++++++++++++++++++++++++++++- 5 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 gtk/Printer.custom diff --git a/ChangeLog b/ChangeLog index 730085f64..3a2fd751c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-07 Mike Kestner + + * gtk/Gtk.metadata : remainder of new API massaging for existing + types. + * gtk/Printer.custom : new static method. + * gtk/TextBuffer.custom : serialization API implementations. + 2006-08-07 Mike Kestner * gtk/Gtk.metadata : mark an out param in Style.LookupColor. diff --git a/gtk/Gtk.metadata b/gtk/Gtk.metadata index 7924b3088..899eafbd7 100644 --- a/gtk/Gtk.metadata +++ b/gtk/Gtk.metadata @@ -62,6 +62,7 @@ const-gchar* 1 1 + 1 1 1 n_points @@ -470,7 +471,9 @@ ref ApplyTag DeleteMark + 1 out + 1 out GetInsertMark out @@ -480,6 +483,7 @@ out out out + 1 out 1 1 @@ -489,6 +493,7 @@ 1 MoveMark RemoveTag + 1 1 TagApplied UserActionBegun diff --git a/gtk/Makefile.am b/gtk/Makefile.am index d7226977e..a23069bc2 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -80,6 +80,7 @@ customs = \ Notebook.custom \ Object.custom \ Plug.custom \ + Printer.custom \ RadioButton.custom \ RadioMenuItem.custom \ RadioToolButton.custom \ diff --git a/gtk/Printer.custom b/gtk/Printer.custom new file mode 100644 index 000000000..732c31342 --- /dev/null +++ b/gtk/Printer.custom @@ -0,0 +1,40 @@ +// Printer.custom - customizations to Gtk.Printer +// +// Authors: Mike Kestner +// +// Copyright (c) 2006 Novell, Inc. +// +// 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 void gtk_enumerate_printers (GtkSharp.PrinterFuncNative func, IntPtr func_data, GLib.DestroyNotify destroy, bool wait); + + public static void EnumeratePrinters (Gtk.PrinterFunc func, bool wait) + { + GtkSharp.PrinterFuncWrapper func_wrapper; + IntPtr func_data; + GLib.DestroyNotify destroy; + if (func == null) { + func_wrapper = null; + func_data = IntPtr.Zero; + destroy = null; + } else { + func_wrapper = new GtkSharp.PrinterFuncWrapper (func); + func_data = (IntPtr) GCHandle.Alloc (func_wrapper); + destroy = GLib.DestroyHelper.NotifyHandler; + } + gtk_enumerate_printers (func_wrapper.NativeDelegate, func_data, destroy, wait); + } + diff --git a/gtk/TextBuffer.custom b/gtk/TextBuffer.custom index 37ebfcadd..328b4fdb3 100644 --- a/gtk/TextBuffer.custom +++ b/gtk/TextBuffer.custom @@ -2,7 +2,7 @@ // // Authors: Mike Kestner // -// Copyright (c) 2004 Novell, Inc. +// Copyright (c) 2004-2006 Novell, Inc. // // This program is free software; you can redistribute it and/or // modify it under the terms of version 2 of the Lesser GNU General @@ -151,3 +151,50 @@ public void InsertAtCursor(string text) GLib.Marshaller.Free (native); } +[DllImport("libgtk-win32-2.0-0.dll")] +static extern IntPtr gtk_text_buffer_serialize (IntPtr raw, IntPtr content_buffer, IntPtr format, ref Gtk.TextIter start, ref Gtk.TextIter end, out UIntPtr length); + +public byte[] Serialize(Gtk.TextBuffer content_buffer, Gdk.Atom format, Gtk.TextIter start, Gtk.TextIter end) +{ + UIntPtr length; + IntPtr raw_ret = gtk_text_buffer_serialize (Handle, content_buffer == null ? IntPtr.Zero : content_buffer.Handle, format == null ? IntPtr.Zero : format.Handle, ref start, ref end, out length); + if (raw_ret == IntPtr.Zero) + return new byte [0]; + int sz = (int) (uint) length; + byte[] ret = new byte [sz]; + Marshal.Copy (ret, 0, raw_ret, sz); + return ret; +} + +[DllImport("libgtk-win32-2.0-0.dll")] +static extern IntPtr gtk_text_buffer_get_serialize_formats(IntPtr raw, out int n_formats); + +[DllImport("libgtk-win32-2.0-0.dll")] +static extern IntPtr gtk_text_buffer_get_deserialize_formats(IntPtr raw, out int n_formats); + +public Gdk.Atom[] DeserializeFormats { + get { + int n_formats; + IntPtr raw_ret = gtk_text_buffer_get_deserialize_formats(Handle, out n_formats); + Gdk.Atom[] result = new Gdk.Atom [n_formats]; + for (int i = 0; i < n_formats; i++) { + IntPtr format = Marshal.ReadIntPtr (raw_ret, i * IntPtr.Size); + result [i] = format == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format, typeof (Gdk.Atom), false); + } + return result; + } +} + +public Gdk.Atom[] SerializeFormats { + get { + int n_formats; + IntPtr raw_ret = gtk_text_buffer_get_serialize_formats(Handle, out n_formats); + Gdk.Atom[] result = new Gdk.Atom [n_formats]; + for (int i = 0; i < n_formats; i++) { + IntPtr format = Marshal.ReadIntPtr (raw_ret, i * IntPtr.Size); + result [i] = format == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format, typeof (Gdk.Atom), false); + } + return result; + } +} +