1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
/*
* PluginPref Example Plugin
*
* Copyright (C) 2004, Gary Kramlich <amc_grim@users.sf.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.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifndef PURPLE_PLUGINS
# define PURPLE_PLUGINS
#endif
#include "internal.h"
#include "plugin.h"
#include "pluginpref.h"
#include "prefs.h"
#include "version.h"
static PurplePluginPrefFrame *
get_plugin_pref_frame(PurplePlugin *plugin) {
PurplePluginPrefFrame *frame;
PurplePluginPref *ppref;
frame = purple_plugin_pref_frame_new();
ppref = purple_plugin_pref_new_with_label("boolean");
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/bool",
"boolean pref");
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_label("integer");
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/int",
"integer pref");
purple_plugin_pref_set_bounds(ppref, 0, 255);
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/int_choice",
"integer choice");
purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);
purple_plugin_pref_add_choice(ppref, "One", GINT_TO_POINTER(1));
purple_plugin_pref_add_choice(ppref, "Two", GINT_TO_POINTER(2));
purple_plugin_pref_add_choice(ppref, "Four", GINT_TO_POINTER(4));
purple_plugin_pref_add_choice(ppref, "Eight", GINT_TO_POINTER(8));
purple_plugin_pref_add_choice(ppref, "Sixteen", GINT_TO_POINTER(16));
purple_plugin_pref_add_choice(ppref, "Thirty Two", GINT_TO_POINTER(32));
purple_plugin_pref_add_choice(ppref, "Sixty Four", GINT_TO_POINTER(64));
purple_plugin_pref_add_choice(ppref, "One Hundred Twenty Eight", GINT_TO_POINTER(128));
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_label("string");
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/string",
"string pref");
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/masked_string",
"masked string");
purple_plugin_pref_set_masked(ppref, TRUE);
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/max_string",
"string pref\n(max length of 16)");
purple_plugin_pref_set_max_length(ppref, 16);
purple_plugin_pref_frame_add(frame, ppref);
ppref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/pluginpref_example/string_choice",
"string choice");
purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE);
purple_plugin_pref_add_choice(ppref, "red", "red");
purple_plugin_pref_add_choice(ppref, "orange", "orange");
purple_plugin_pref_add_choice(ppref, "yellow", "yellow");
purple_plugin_pref_add_choice(ppref, "green", "green");
purple_plugin_pref_add_choice(ppref, "blue", "blue");
purple_plugin_pref_add_choice(ppref, "purple", "purple");
purple_plugin_pref_frame_add(frame, ppref);
return frame;
}
static PurplePluginUiInfo prefs_info = {
get_plugin_pref_frame,
0, /* page_num (Reserved) */
NULL, /* frame (Reserved) */
/* Padding */
NULL,
NULL,
NULL,
NULL
};
static PurplePluginInfo info =
{
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
PURPLE_MINOR_VERSION,
PURPLE_PLUGIN_STANDARD, /**< type */
NULL, /**< ui_requirement */
0, /**< flags */
NULL, /**< dependencies */
PURPLE_PRIORITY_DEFAULT, /**< priority */
"core-pluginpref_example", /**< id */
"Pluginpref Example", /**< name */
DISPLAY_VERSION, /**< version */
/** summary */
"An example of how to use pluginprefs",
/** description */
"An example of how to use pluginprefs",
"Gary Kramlich <amc_grim@users.sf.net>", /**< author */
PURPLE_WEBSITE, /**< homepage */
NULL, /**< load */
NULL, /**< unload */
NULL, /**< destroy */
NULL, /**< ui_info */
NULL, /**< extra_info */
&prefs_info, /**< prefs_info */
NULL, /**< actions */
/* padding */
NULL,
NULL,
NULL,
NULL
};
static void
init_plugin(PurplePlugin *plugin)
{
purple_prefs_add_none("/plugins/core/pluginpref_example");
purple_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE);
purple_prefs_add_int("/plugins/core/pluginpref_example/int", 0);
purple_prefs_add_int("/plugins/core/pluginpref_example/int_choice", 1);
purple_prefs_add_string("/plugins/core/pluginpref_example/string",
"string");
purple_prefs_add_string("/plugins/core/pluginpref_example/max_string",
"max length string");
purple_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked");
purple_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red");
}
PURPLE_INIT_PLUGIN(ppexample, init_plugin, info)
|