* Copyright (C) 2007 Richard Nelson <wabz@whatsbeef.net> * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * 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 General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA #define PLUGIN_ID "gntclipboard" #define PLUGIN_DOMAIN (g_quark_from_static_string(PLUGIN_ID)) #define PLUGIN_STATIC_NAME GntClipboard static gulong sig_handle; XSelectionRequestEvent *req; Display *dpy = XOpenDisplay(NULL); ids = getenv("WINDOWID"); XSetSelectionOwner(dpy, XA_PRIMARY, w, CurrentTime); XSelectInput(dpy, w, StructureNotifyMask); XNextEvent(dpy, &e); /* this blocks. */ req = &e.xselectionrequest; if (e.type == SelectionRequest) { respond.xselection.property = req->property; respond.xselection.type = SelectionNotify; respond.xselection.display = req->display; respond.xselection.requestor = req->requestor; respond.xselection.selection = req->selection; respond.xselection.target= req->target; respond.xselection.time = req->time; XSendEvent(dpy, req->requestor, 0, 0, &respond); } else if (e.type == SelectionClear) { clipboard_changed(GntWM *wm, gchar *string) if ((child = fork()) == 0) { plugin_query(GError **error) const gchar * const authors[] = { "Richard Nelson <wabz@whatsbeef.net>", return finch_plugin_info_new( "name", N_("GntClipboard"), "version", DISPLAY_VERSION, "category", N_("Utility"), "summary", N_("Clipboard plugin"), "description", N_("When the gnt clipboard contents change, the " "contents are made available to X, if possible."), "website", PURPLE_WEBSITE, "abi-version", PURPLE_ABI_VERSION, plugin_load(PurplePlugin *plugin, GError **error) if (!XOpenDisplay(NULL)) { purple_debug_warning("gntclipboard", "Couldn't find X display\n"); purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), _("Couldn't find X display"), NULL); if (!getenv("WINDOWID")) { purple_debug_warning("gntclipboard", "Couldn't find window\n"); purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), _("Couldn't find window"), NULL); sig_handle = g_signal_connect(G_OBJECT(gnt_get_clipboard()), "clipboard_changed", G_CALLBACK(clipboard_changed), NULL); g_set_error(error, PLUGIN_DOMAIN, 0, _("This plugin cannot be loaded " "because it was not built with X11 support.")); plugin_unload(PurplePlugin *plugin, GError **error) g_signal_handler_disconnect(G_OBJECT(gnt_get_clipboard()), sig_handle); PURPLE_PLUGIN_INIT(PLUGIN_STATIC_NAME, plugin_query, plugin_load, plugin_unload);