Mercurial > pidgin
comparison libpurple/plugins/pluginpref_example.c @ 15373:5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Sat, 20 Jan 2007 02:32:10 +0000 |
| parents | |
| children | 32c366eeeb99 |
comparison
equal
deleted
inserted
replaced
| 15372:f79e0f4df793 | 15373:5fe8042783c1 |
|---|---|
| 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 0, /* page_num (Reserved) */ | |
| 113 NULL /* frame (Reserved) */ | |
| 114 }; | |
| 115 | |
| 116 static GaimPluginInfo info = | |
| 117 { | |
| 118 GAIM_PLUGIN_MAGIC, | |
| 119 GAIM_MAJOR_VERSION, | |
| 120 GAIM_MINOR_VERSION, | |
| 121 GAIM_PLUGIN_STANDARD, /**< type */ | |
| 122 NULL, /**< ui_requirement */ | |
| 123 0, /**< flags */ | |
| 124 NULL, /**< dependencies */ | |
| 125 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
| 126 | |
| 127 "core-pluginpref_example", /**< id */ | |
| 128 "Pluginpref Example", /**< name */ | |
| 129 VERSION, /**< version */ | |
| 130 /** summary */ | |
| 131 "An example of how to use pluginprefs", | |
| 132 /** description */ | |
| 133 "An example of how to use pluginprefs", | |
| 134 "Gary Kramlich <amc_grim@users.sf.net>", /**< author */ | |
| 135 GAIM_WEBSITE, /**< homepage */ | |
| 136 | |
| 137 NULL, /**< load */ | |
| 138 NULL, /**< unload */ | |
| 139 NULL, /**< destroy */ | |
| 140 | |
| 141 NULL, /**< ui_info */ | |
| 142 NULL, /**< extra_info */ | |
| 143 &prefs_info, /**< prefs_info */ | |
| 144 NULL | |
| 145 }; | |
| 146 | |
| 147 static void | |
| 148 init_plugin(GaimPlugin *plugin) | |
| 149 { | |
| 150 gaim_prefs_add_none("/plugins/core/pluginpref_example"); | |
| 151 gaim_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE); | |
| 152 gaim_prefs_add_int("/plugins/core/pluginpref_example/int", 0); | |
| 153 gaim_prefs_add_int("/plugins/core/pluginpref_example/int_choice", 1); | |
| 154 gaim_prefs_add_string("/plugins/core/pluginpref_example/string", | |
| 155 "string"); | |
| 156 gaim_prefs_add_string("/plugins/core/pluginpref_example/max_string", | |
| 157 "max length string"); | |
| 158 gaim_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked"); | |
| 159 gaim_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red"); | |
| 160 } | |
| 161 | |
| 162 GAIM_INIT_PLUGIN(ppexample, init_plugin, info) |
