2 * PluginPref Example Plugin
4 * Copyright (C) 2004, Gary Kramlich <amc_grim@users.sf.net>
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
22 /* When writing a third-party plugin, do not include libpurple's internal.h
23 * included below. This file is for internal libpurple use only. We're including
24 * it here for our own convenience. */
27 /* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
30 static PurplePluginPrefFrame
*
31 get_plugin_pref_frame(PurplePlugin
*plugin
) {
32 PurplePluginPrefFrame
*frame
;
33 PurplePluginPref
*ppref
;
35 frame
= purple_plugin_pref_frame_new();
37 ppref
= purple_plugin_pref_new_with_label("boolean");
38 purple_plugin_pref_frame_add(frame
, ppref
);
40 ppref
= purple_plugin_pref_new_with_name_and_label(
41 "/plugins/core/pluginpref_example/bool",
43 purple_plugin_pref_frame_add(frame
, ppref
);
45 ppref
= purple_plugin_pref_new_with_label("integer");
46 purple_plugin_pref_frame_add(frame
, ppref
);
48 ppref
= purple_plugin_pref_new_with_name_and_label(
49 "/plugins/core/pluginpref_example/int",
51 purple_plugin_pref_set_bounds(ppref
, 0, 255);
52 purple_plugin_pref_frame_add(frame
, ppref
);
54 ppref
= purple_plugin_pref_new_with_name_and_label(
55 "/plugins/core/pluginpref_example/int_choice",
57 purple_plugin_pref_set_pref_type(ppref
, PURPLE_PLUGIN_PREF_CHOICE
);
58 purple_plugin_pref_add_choice(ppref
, "One", GINT_TO_POINTER(1));
59 purple_plugin_pref_add_choice(ppref
, "Two", GINT_TO_POINTER(2));
60 purple_plugin_pref_add_choice(ppref
, "Four", GINT_TO_POINTER(4));
61 purple_plugin_pref_add_choice(ppref
, "Eight", GINT_TO_POINTER(8));
62 purple_plugin_pref_add_choice(ppref
, "Sixteen", GINT_TO_POINTER(16));
63 purple_plugin_pref_add_choice(ppref
, "Thirty Two", GINT_TO_POINTER(32));
64 purple_plugin_pref_add_choice(ppref
, "Sixty Four", GINT_TO_POINTER(64));
65 purple_plugin_pref_add_choice(ppref
, "One Hundred Twenty Eight", GINT_TO_POINTER(128));
66 purple_plugin_pref_frame_add(frame
, ppref
);
68 ppref
= purple_plugin_pref_new_with_label("string");
69 purple_plugin_pref_frame_add(frame
, ppref
);
71 ppref
= purple_plugin_pref_new_with_name_and_label(
72 "/plugins/core/pluginpref_example/string",
74 purple_plugin_pref_frame_add(frame
, ppref
);
76 ppref
= purple_plugin_pref_new_with_name_and_label(
77 "/plugins/core/pluginpref_example/masked_string",
79 purple_plugin_pref_set_masked(ppref
, TRUE
);
80 purple_plugin_pref_frame_add(frame
, ppref
);
82 ppref
= purple_plugin_pref_new_with_name_and_label(
83 "/plugins/core/pluginpref_example/max_string",
84 "string pref\n(max length of 16)");
85 purple_plugin_pref_set_max_length(ppref
, 16);
86 purple_plugin_pref_frame_add(frame
, ppref
);
88 ppref
= purple_plugin_pref_new_with_name_and_label(
89 "/plugins/core/pluginpref_example/string_choice",
91 purple_plugin_pref_set_pref_type(ppref
, PURPLE_PLUGIN_PREF_CHOICE
);
92 purple_plugin_pref_add_choice(ppref
, "red", "red");
93 purple_plugin_pref_add_choice(ppref
, "orange", "orange");
94 purple_plugin_pref_add_choice(ppref
, "yellow", "yellow");
95 purple_plugin_pref_add_choice(ppref
, "green", "green");
96 purple_plugin_pref_add_choice(ppref
, "blue", "blue");
97 purple_plugin_pref_add_choice(ppref
, "purple", "purple");
98 purple_plugin_pref_frame_add(frame
, ppref
);
103 static PurplePluginInfo
*
104 plugin_query(GError
**error
)
106 const gchar
* const authors
[] = {
107 "Gary Kramlich <amc_grim@users.sf.net>",
111 return purple_plugin_info_new(
112 "id", "core-pluginpref_example",
113 "name", "Pluginpref Example",
114 "version", DISPLAY_VERSION
,
115 "category", "Example",
116 "summary", "An example of how to use pluginprefs",
117 "description", "An example of how to use pluginprefs",
119 "website", PURPLE_WEBSITE
,
120 "abi-version", PURPLE_ABI_VERSION
,
121 "pref-frame-cb", get_plugin_pref_frame
,
127 plugin_load(PurplePlugin
*plugin
, GError
**error
)
129 purple_prefs_add_none("/plugins/core/pluginpref_example");
130 purple_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE
);
131 purple_prefs_add_int("/plugins/core/pluginpref_example/int", 0);
132 purple_prefs_add_int("/plugins/core/pluginpref_example/int_choice", 1);
133 purple_prefs_add_string("/plugins/core/pluginpref_example/string",
135 purple_prefs_add_string("/plugins/core/pluginpref_example/max_string",
136 "max length string");
137 purple_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked");
138 purple_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red");
144 plugin_unload(PurplePlugin
*plugin
, GError
**error
)
149 PURPLE_PLUGIN_INIT(ppexample
, plugin_query
, plugin_load
, plugin_unload
);