Make return clearer
[pidgin-git.git] / libpurple / plugins / test-request-input.c
blobeee7682deb0f6974c2bc84ce70b87f686ccd6cdd
1 /* pidgin
3 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #include <glib.h>
24 #include "internal.h"
25 #include <purple.h>
27 #define PREF_ROOT "/plugins"
28 #define PREF_TEST "/plugins/tests"
29 #define PREF_PREFIX "/plugins/tests/request-input"
30 #define PREF_SINGLE PREF_PREFIX "/single"
31 #define PREF_MULTIPLE PREF_PREFIX "/multiple"
32 #define PREF_HTML PREF_PREFIX "/html"
34 static void
35 plugin_input_callback(const gchar *pref, const gchar *text) {
36 purple_prefs_set_string(pref, text);
39 static void
40 plugin_input_single(PurplePluginAction *action) {
41 purple_request_input(
42 NULL,
43 _("Test request input single"),
44 _("Test request input single"),
45 NULL,
46 purple_prefs_get_string(PREF_SINGLE),
47 FALSE,
48 FALSE,
49 NULL,
50 _("OK"),
51 PURPLE_CALLBACK(plugin_input_callback),
52 _("Cancel"),
53 NULL,
54 purple_request_cpar_new(),
55 PREF_SINGLE
59 static void
60 plugin_input_multiple(PurplePluginAction *action) {
61 purple_request_input(
62 NULL,
63 _("Test request input multiple"),
64 _("Test request input multiple"),
65 NULL,
66 purple_prefs_get_string(PREF_MULTIPLE),
67 TRUE,
68 FALSE,
69 NULL,
70 _("OK"),
71 PURPLE_CALLBACK(plugin_input_callback),
72 _("Cancel"),
73 NULL,
74 purple_request_cpar_new(),
75 PREF_MULTIPLE
79 static void
80 plugin_input_html(PurplePluginAction *action) {
81 purple_request_input(
82 NULL,
83 _("Test request input HTML"),
84 _("Test request input HTML"),
85 NULL,
86 purple_prefs_get_string(PREF_HTML),
87 FALSE,
88 FALSE,
89 "html",
90 _("OK"),
91 PURPLE_CALLBACK(plugin_input_callback),
92 _("Cancel"),
93 NULL,
94 purple_request_cpar_new(),
95 PREF_HTML
99 static GList *
100 plugin_actions(PurplePlugin *plugin) {
101 GList *l = NULL;
102 PurplePluginAction *action = NULL;
104 action = purple_plugin_action_new(_("Input single"), plugin_input_single);
105 l = g_list_append(l, action);
107 action = purple_plugin_action_new(_("Input multiple"), plugin_input_multiple);
108 l = g_list_append(l, action);
110 action = purple_plugin_action_new(_("Input html"), plugin_input_html);
111 l = g_list_append(l, action);
113 return l;
116 static PurplePluginInfo *
117 plugin_query(GError **error) {
118 const gchar * const authors[] = {
119 "Gary Kramlich <grim@reaperworld.com>",
120 NULL
123 return purple_plugin_info_new(
124 "id", "core-test_request_input",
125 "name", N_("Test: request input"),
126 "version", DISPLAY_VERSION,
127 "category", N_("Testing"),
128 "summary", N_("Test Request Input"),
129 "description", N_("This plugin adds actions to test purple_request_input"),
130 "authors", authors,
131 "website", "https://pidgin.im",
132 "abi-version", PURPLE_ABI_VERSION,
133 "actions-cb", plugin_actions,
134 NULL
138 static gboolean
139 plugin_load(PurplePlugin *plugin, GError **error) {
140 purple_prefs_add_none(PREF_ROOT);
141 purple_prefs_add_none(PREF_TEST);
142 purple_prefs_add_none(PREF_PREFIX);
143 purple_prefs_add_string(PREF_SINGLE, "");
144 purple_prefs_add_string(PREF_MULTIPLE, "");
145 purple_prefs_add_string(PREF_HTML, "");
147 return TRUE;
150 static gboolean
151 plugin_unload(PurplePlugin *plugin, GError **error) {
152 return TRUE;
155 PURPLE_PLUGIN_INIT(test_request_input, plugin_query, plugin_load, plugin_unload);