# HG changeset patch # User Sadrul Habib Chowdhury <imadil@gmail.com> # Date 1188768032 0 # Node ID 87e9d418cbf6e8cc77b56f4bf25f691654f719eb # Parent cfc4e56a6a1ec3f50d1b37e05cd579d7203bce80 Show a helpful error message when the plugin fails to load. diff -r cfc4e56a6a1e -r 87e9d418cbf6 finch/plugins/gntclipboard.c --- a/finch/plugins/gntclipboard.c Sun Sep 02 14:40:04 2007 +0000 +++ b/finch/plugins/gntclipboard.c Sun Sep 02 21:20:32 2007 +0000 @@ -38,10 +38,12 @@ #include <plugin.h> #include <version.h> #include <debug.h> +#include <notify.h> #include <gntwm.h> #include <gntplugin.h> +#ifdef HAVE_X11 static pid_t child = 0; static gulong sig_handle; @@ -49,7 +51,6 @@ static void set_clip(gchar *string) { -#ifdef HAVE_X11 Window w; XEvent e, respond; XSelectionRequestEvent *req; @@ -89,14 +90,12 @@ return; } } -#endif return; } static void clipboard_changed(GntWM *wm, gchar *string) { -#ifdef HAVE_X11 if (child) { kill(child, SIGTERM); } @@ -104,8 +103,8 @@ set_clip(string); _exit(0); } +} #endif -} static gboolean plugin_load(PurplePlugin *plugin) @@ -113,25 +112,35 @@ #ifdef HAVE_X11 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")); return FALSE; } -#endif 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")); return FALSE; } sig_handle = g_signal_connect(G_OBJECT(gnt_get_clipboard()), "clipboard_changed", G_CALLBACK(clipboard_changed), NULL); return TRUE; +#else + purple_notify_error(NULL, _("Error"), _("Error loading the plugin."), + _("This plugin cannot be loaded because it was not built with X11 support.")); + return FALSE; +#endif } static gboolean plugin_unload(PurplePlugin *plugin) { +#ifdef HAVE_X11 if (child) { kill(child, SIGTERM); child = 0; } g_signal_handler_disconnect(G_OBJECT(gnt_get_clipboard()), sig_handle); +#endif return TRUE; }