2005-04-01 16:46:43 +00:00
|
|
|
// Gtk.Clipboard.custom - Customizations for the Clipboard class
|
|
|
|
//
|
|
|
|
// Authors: Mike Kestner <mkestner@novell.com>
|
|
|
|
//
|
|
|
|
// Copyright (c) 2005 Novell, Inc.
|
2004-06-25 18:42:19 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2003-02-22 04:34:56 +00:00
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
2005-04-01 16:46:43 +00:00
|
|
|
static extern bool gtk_clipboard_set_with_data(IntPtr raw, TargetEntry[] targets, int n_targets, GtkSharp.ClipboardGetFuncNative get_func, GtkSharp.ClipboardClearFuncNative clear_func, IntPtr data);
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2005-04-01 16:46:43 +00:00
|
|
|
[DllImport("libgtk-win32-2.0-0.dll")]
|
|
|
|
static extern bool gtk_clipboard_set_with_owner(IntPtr raw, TargetEntry[] targets, int n_targets, GtkSharp.ClipboardGetFuncNative get_func, GtkSharp.ClipboardClearFuncNative clear_func, IntPtr owner);
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2005-04-01 16:46:43 +00:00
|
|
|
void ClearProxy (Clipboard clipboard)
|
2002-11-10 10:03:51 +00:00
|
|
|
{
|
2005-04-01 16:46:43 +00:00
|
|
|
if (PersistentData ["clear_func"] != null) {
|
|
|
|
ClipboardClearFunc clear = PersistentData ["clear_func"] as ClipboardClearFunc;
|
|
|
|
clear (clipboard);
|
2002-11-10 10:03:51 +00:00
|
|
|
}
|
2005-04-01 16:46:43 +00:00
|
|
|
SetPersistentData (null, null, null);
|
|
|
|
}
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2005-04-01 16:46:43 +00:00
|
|
|
void SetPersistentData (object get_func_wrapper, object clear_func, object clear_proxy_wrapper)
|
|
|
|
{
|
|
|
|
PersistentData ["get_func_wrapper"] = get_func_wrapper;
|
|
|
|
PersistentData ["clear_func"] = clear_func;
|
|
|
|
PersistentData ["clear_proxy_wrapper"] = clear_proxy_wrapper;
|
|
|
|
}
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2005-04-01 16:46:43 +00:00
|
|
|
public bool SetWithData (TargetEntry[] targets, ClipboardGetFunc get_func, ClipboardClearFunc clear_func)
|
|
|
|
{
|
|
|
|
ClipboardClearFunc clear_proxy = new ClipboardClearFunc (ClearProxy);
|
|
|
|
GtkSharp.ClipboardGetFuncWrapper get_func_wrapper = new GtkSharp.ClipboardGetFuncWrapper (get_func);
|
|
|
|
GtkSharp.ClipboardClearFuncWrapper clear_proxy_wrapper = new GtkSharp.ClipboardClearFuncWrapper (clear_proxy);
|
|
|
|
bool ret = gtk_clipboard_set_with_data (Handle, targets, targets.Length, get_func_wrapper.NativeDelegate, clear_proxy_wrapper.NativeDelegate, IntPtr.Zero);
|
|
|
|
SetPersistentData (get_func_wrapper, clear_func, clear_proxy_wrapper);
|
|
|
|
return ret;
|
|
|
|
}
|
2002-11-10 10:03:51 +00:00
|
|
|
|
2005-04-01 16:46:43 +00:00
|
|
|
public bool SetWithOwner (TargetEntry[] targets, ClipboardGetFunc get_func, ClipboardClearFunc clear_func, GLib.Object owner)
|
|
|
|
{
|
|
|
|
ClipboardClearFunc clear_proxy = new ClipboardClearFunc (ClearProxy);
|
|
|
|
GtkSharp.ClipboardGetFuncWrapper get_func_wrapper = new GtkSharp.ClipboardGetFuncWrapper (get_func);
|
|
|
|
GtkSharp.ClipboardClearFuncWrapper clear_proxy_wrapper = new GtkSharp.ClipboardClearFuncWrapper (clear_proxy);
|
|
|
|
bool ret = gtk_clipboard_set_with_owner (Handle, targets, targets.Length, get_func_wrapper.NativeDelegate, clear_proxy_wrapper.NativeDelegate, owner == null ? IntPtr.Zero : owner.Handle);
|
|
|
|
SetPersistentData (get_func_wrapper, clear_func, clear_proxy_wrapper);
|
2002-11-10 10:03:51 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|