2 * Notify API Example Plugin
4 * Copyright (C) 2007, John Bailey <rekkanoryo@cpw.pidgin.im>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 /* When writing a third-party plugin, do not include libpurple's internal.h
24 * included below. This file is for internal libpurple use only. We're including
25 * it here for our own convenience. */
28 /* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
31 #define PLUGIN_ID "core-notifyexample"
32 #define PLUGIN_AUTHORS { "John Bailey <rekkanoryo@cpw.pidgin.im>", NULL }
34 /* The next four functions and the calls within them should cause dialog boxes to appear
35 * when you select the plugin action from the Tools->Notify Example menu */
37 notify_error_cb(PurplePluginAction
*action
)
39 purple_notify_error(action
->plugin
, "Test Notification", "Test Notification",
40 "This is a test error notification", NULL
);
44 notify_info_cb(PurplePluginAction
*action
)
46 purple_notify_info(action
->plugin
, "Test Notification", "Test Notification",
47 "This is a test informative notification", NULL
);
51 notify_warn_cb(PurplePluginAction
*action
)
53 purple_notify_warning(action
->plugin
, "Test Notification", "Test Notification",
54 "This is a test warning notification", NULL
);
58 notify_format_cb(PurplePluginAction
*action
)
60 purple_notify_formatted(action
->plugin
, "Test Notification", "Test Notification",
62 "<I>This is a test notification with formatted text.</I>", NULL
, NULL
);
66 notify_uri_cb(PurplePluginAction
*action
)
68 /* This one should open your web browser of choice. */
69 purple_notify_uri(action
->plugin
, "https://pidgin.im/");
73 plugin_actions(PurplePlugin
*plugin
)
75 GList
*actions
= NULL
;
77 /* Here we take advantage of return values to avoid the need for a temp variable */
78 actions
= g_list_prepend(actions
,
79 purple_plugin_action_new("Show Error Notification", notify_error_cb
));
81 actions
= g_list_prepend(actions
,
82 purple_plugin_action_new("Show Info Notification", notify_info_cb
));
84 actions
= g_list_prepend(actions
,
85 purple_plugin_action_new("Show Warning Notification", notify_warn_cb
));
87 actions
= g_list_prepend(actions
,
88 purple_plugin_action_new("Show Formatted Notification", notify_format_cb
));
90 actions
= g_list_prepend(actions
,
91 purple_plugin_action_new("Show URI Notification", notify_uri_cb
));
93 return g_list_reverse(actions
);
96 static PurplePluginInfo
*
97 plugin_query(GError
**error
)
99 const gchar
* const authors
[] = PLUGIN_AUTHORS
;
101 return purple_plugin_info_new(
103 "name", "Notify API Example",
104 "version", DISPLAY_VERSION
,
105 "category", "Example",
106 "summary", "Notify API Example",
107 "description", "Notify API Example",
109 "website", "https://pidgin.im",
110 "abi-version", PURPLE_ABI_VERSION
,
111 "actions-cb", plugin_actions
,
117 plugin_load(PurplePlugin
*plugin
, GError
**error
)
123 plugin_unload(PurplePlugin
*plugin
, GError
**error
)
128 PURPLE_PLUGIN_INIT(notifyexample
, plugin_query
, plugin_load
, plugin_unload
);