| 1 /* |
|
| 2 * PluginPref Example Plugin |
|
| 3 * |
|
| 4 * Copyright (C) 2004, Gary Kramlich <amc_grim@users.sf.net> |
|
| 5 * |
|
| 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. |
|
| 10 * |
|
| 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. |
|
| 15 * |
|
| 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., 59 Temple Place - Suite 330, Boston, MA |
|
| 19 * 02111-1307, USA. |
|
| 20 */ |
|
| 21 |
|
| 22 #ifdef HAVE_CONFIG_H |
|
| 23 # include <config.h> |
|
| 24 #endif |
|
| 25 |
|
| 26 #ifndef GAIM_PLUGINS |
|
| 27 # define GAIM_PLUGINS |
|
| 28 #endif |
|
| 29 |
|
| 30 #include "internal.h" |
|
| 31 |
|
| 32 #include "plugin.h" |
|
| 33 #include "pluginpref.h" |
|
| 34 #include "prefs.h" |
|
| 35 #include "version.h" |
|
| 36 |
|
| 37 static GaimPluginPrefFrame * |
|
| 38 get_plugin_pref_frame(GaimPlugin *plugin) { |
|
| 39 GaimPluginPrefFrame *frame; |
|
| 40 GaimPluginPref *ppref; |
|
| 41 |
|
| 42 frame = gaim_plugin_pref_frame_new(); |
|
| 43 |
|
| 44 ppref = gaim_plugin_pref_new_with_label("boolean"); |
|
| 45 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 46 |
|
| 47 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 48 "/plugins/core/pluginpref_example/bool", |
|
| 49 "boolean pref"); |
|
| 50 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 51 |
|
| 52 ppref = gaim_plugin_pref_new_with_label("integer"); |
|
| 53 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 54 |
|
| 55 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 56 "/plugins/core/pluginpref_example/int", |
|
| 57 "integer pref"); |
|
| 58 gaim_plugin_pref_set_bounds(ppref, 0, 255); |
|
| 59 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 60 |
|
| 61 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 62 "/plugins/core/pluginpref_example/int_choice", |
|
| 63 "integer choice"); |
|
| 64 gaim_plugin_pref_set_type(ppref, GAIM_PLUGIN_PREF_CHOICE); |
|
| 65 gaim_plugin_pref_add_choice(ppref, "One", GINT_TO_POINTER(1)); |
|
| 66 gaim_plugin_pref_add_choice(ppref, "Two", GINT_TO_POINTER(2)); |
|
| 67 gaim_plugin_pref_add_choice(ppref, "Four", GINT_TO_POINTER(4)); |
|
| 68 gaim_plugin_pref_add_choice(ppref, "Eight", GINT_TO_POINTER(8)); |
|
| 69 gaim_plugin_pref_add_choice(ppref, "Sixteen", GINT_TO_POINTER(16)); |
|
| 70 gaim_plugin_pref_add_choice(ppref, "Thirty Two", GINT_TO_POINTER(32)); |
|
| 71 gaim_plugin_pref_add_choice(ppref, "Sixty Four", GINT_TO_POINTER(64)); |
|
| 72 gaim_plugin_pref_add_choice(ppref, "One Hundred Twenty Eight", GINT_TO_POINTER(128)); |
|
| 73 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 74 |
|
| 75 ppref = gaim_plugin_pref_new_with_label("string"); |
|
| 76 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 77 |
|
| 78 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 79 "/plugins/core/pluginpref_example/string", |
|
| 80 "string pref"); |
|
| 81 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 82 |
|
| 83 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 84 "/plugins/core/pluginpref_example/masked_string", |
|
| 85 "masked string"); |
|
| 86 gaim_plugin_pref_set_masked(ppref, TRUE); |
|
| 87 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 88 |
|
| 89 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 90 "/plugins/core/pluginpref_example/max_string", |
|
| 91 "string pref\n(max length of 16)"); |
|
| 92 gaim_plugin_pref_set_max_length(ppref, 16); |
|
| 93 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 94 |
|
| 95 ppref = gaim_plugin_pref_new_with_name_and_label( |
|
| 96 "/plugins/core/pluginpref_example/string_choice", |
|
| 97 "string choice"); |
|
| 98 gaim_plugin_pref_set_type(ppref, GAIM_PLUGIN_PREF_CHOICE); |
|
| 99 gaim_plugin_pref_add_choice(ppref, "red", "red"); |
|
| 100 gaim_plugin_pref_add_choice(ppref, "orange", "orange"); |
|
| 101 gaim_plugin_pref_add_choice(ppref, "yellow", "yellow"); |
|
| 102 gaim_plugin_pref_add_choice(ppref, "green", "green"); |
|
| 103 gaim_plugin_pref_add_choice(ppref, "blue", "blue"); |
|
| 104 gaim_plugin_pref_add_choice(ppref, "purple", "purple"); |
|
| 105 gaim_plugin_pref_frame_add(frame, ppref); |
|
| 106 |
|
| 107 return frame; |
|
| 108 } |
|
| 109 |
|
| 110 static GaimPluginUiInfo prefs_info = { |
|
| 111 get_plugin_pref_frame |
|
| 112 }; |
|
| 113 |
|
| 114 static GaimPluginInfo info = |
|
| 115 { |
|
| 116 GAIM_PLUGIN_MAGIC, |
|
| 117 GAIM_MAJOR_VERSION, |
|
| 118 GAIM_MINOR_VERSION, |
|
| 119 GAIM_PLUGIN_STANDARD, /**< type */ |
|
| 120 NULL, /**< ui_requirement */ |
|
| 121 0, /**< flags */ |
|
| 122 NULL, /**< dependencies */ |
|
| 123 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
| 124 |
|
| 125 "core-pluginpref_example", /**< id */ |
|
| 126 "Pluginpref Example", /**< name */ |
|
| 127 VERSION, /**< version */ |
|
| 128 /** summary */ |
|
| 129 "An example of how to use pluginprefs", |
|
| 130 /** description */ |
|
| 131 "An example of how to use pluginprefs", |
|
| 132 "Gary Kramlich <amc_grim@users.sf.net>", /**< author */ |
|
| 133 GAIM_WEBSITE, /**< homepage */ |
|
| 134 |
|
| 135 NULL, /**< load */ |
|
| 136 NULL, /**< unload */ |
|
| 137 NULL, /**< destroy */ |
|
| 138 |
|
| 139 NULL, /**< ui_info */ |
|
| 140 NULL, /**< extra_info */ |
|
| 141 &prefs_info, /**< prefs_info */ |
|
| 142 NULL |
|
| 143 }; |
|
| 144 |
|
| 145 static void |
|
| 146 init_plugin(GaimPlugin *plugin) |
|
| 147 { |
|
| 148 gaim_prefs_add_none("/plugins/core/pluginpref_example"); |
|
| 149 gaim_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE); |
|
| 150 gaim_prefs_add_int("/plugins/core/pluginpref_example/int", 0); |
|
| 151 gaim_prefs_add_int("/plugins/core/pluginpref_example/int_choice", 1); |
|
| 152 gaim_prefs_add_string("/plugins/core/pluginpref_example/string", |
|
| 153 "string"); |
|
| 154 gaim_prefs_add_string("/plugins/core/pluginpref_example/max_string", |
|
| 155 "max length string"); |
|
| 156 gaim_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked"); |
|
| 157 gaim_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red"); |
|
| 158 } |
|
| 159 |
|
| 160 GAIM_INIT_PLUGIN(ppexample, init_plugin, info) |
|