Sat, 03 Aug 2013 20:35:56 +0530
OCD
| 8713 | 1 | /* |
| 12362 | 2 | * PluginPref Example Plugin |
| 8713 | 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16786
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16786
diff
changeset
|
19 | * 02111-1301, USA. |
| 8713 | 20 | */ |
| 21 | ||
| 22 | #ifdef HAVE_CONFIG_H | |
| 23 | # include <config.h> | |
| 24 | #endif | |
| 25 | ||
| 15884 | 26 | #ifndef PURPLE_PLUGINS |
| 27 | # define PURPLE_PLUGINS | |
| 8713 | 28 | #endif |
| 29 | ||
| 30 | #include "internal.h" | |
| 31 | ||
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
20288
diff
changeset
|
32 | #include "plugins.h" |
| 8713 | 33 | #include "pluginpref.h" |
| 34 | #include "prefs.h" | |
| 9954 | 35 | #include "version.h" |
| 8713 | 36 | |
| 15884 | 37 | static PurplePluginPrefFrame * |
| 38 | get_plugin_pref_frame(PurplePlugin *plugin) { | |
| 39 | PurplePluginPrefFrame *frame; | |
| 40 | PurplePluginPref *ppref; | |
| 8713 | 41 | |
| 15884 | 42 | frame = purple_plugin_pref_frame_new(); |
| 8713 | 43 | |
| 15884 | 44 | ppref = purple_plugin_pref_new_with_label("boolean"); |
| 45 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 46 | |
| 15884 | 47 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 48 | "/plugins/core/pluginpref_example/bool", |
| 8713 | 49 | "boolean pref"); |
| 15884 | 50 | purple_plugin_pref_frame_add(frame, ppref); |
| 8713 | 51 | |
| 15884 | 52 | ppref = purple_plugin_pref_new_with_label("integer"); |
| 53 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 54 | |
| 15884 | 55 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 56 | "/plugins/core/pluginpref_example/int", |
| 8713 | 57 | "integer pref"); |
| 15884 | 58 | purple_plugin_pref_set_bounds(ppref, 0, 255); |
| 59 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 60 | |
| 15884 | 61 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 62 | "/plugins/core/pluginpref_example/int_choice", |
| 8713 | 63 | "integer choice"); |
| 15884 | 64 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
| 65 | purple_plugin_pref_add_choice(ppref, "One", GINT_TO_POINTER(1)); | |
| 66 | purple_plugin_pref_add_choice(ppref, "Two", GINT_TO_POINTER(2)); | |
| 67 | purple_plugin_pref_add_choice(ppref, "Four", GINT_TO_POINTER(4)); | |
| 68 | purple_plugin_pref_add_choice(ppref, "Eight", GINT_TO_POINTER(8)); | |
| 69 | purple_plugin_pref_add_choice(ppref, "Sixteen", GINT_TO_POINTER(16)); | |
| 70 | purple_plugin_pref_add_choice(ppref, "Thirty Two", GINT_TO_POINTER(32)); | |
| 71 | purple_plugin_pref_add_choice(ppref, "Sixty Four", GINT_TO_POINTER(64)); | |
| 72 | purple_plugin_pref_add_choice(ppref, "One Hundred Twenty Eight", GINT_TO_POINTER(128)); | |
| 73 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 74 | |
| 15884 | 75 | ppref = purple_plugin_pref_new_with_label("string"); |
| 76 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 77 | |
| 15884 | 78 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 79 | "/plugins/core/pluginpref_example/string", |
| 8713 | 80 | "string pref"); |
| 15884 | 81 | purple_plugin_pref_frame_add(frame, ppref); |
| 8713 | 82 | |
| 15884 | 83 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 84 | "/plugins/core/pluginpref_example/masked_string", |
| 9841 | 85 | "masked string"); |
| 15884 | 86 | purple_plugin_pref_set_masked(ppref, TRUE); |
| 87 | purple_plugin_pref_frame_add(frame, ppref); | |
| 9841 | 88 | |
| 15884 | 89 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 90 | "/plugins/core/pluginpref_example/max_string", |
| 8713 | 91 | "string pref\n(max length of 16)"); |
| 15884 | 92 | purple_plugin_pref_set_max_length(ppref, 16); |
| 93 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 94 | |
| 15884 | 95 | ppref = purple_plugin_pref_new_with_name_and_label( |
| 16481 | 96 | "/plugins/core/pluginpref_example/string_choice", |
| 8713 | 97 | "string choice"); |
| 15884 | 98 | purple_plugin_pref_set_type(ppref, PURPLE_PLUGIN_PREF_CHOICE); |
| 99 | purple_plugin_pref_add_choice(ppref, "red", "red"); | |
| 100 | purple_plugin_pref_add_choice(ppref, "orange", "orange"); | |
| 101 | purple_plugin_pref_add_choice(ppref, "yellow", "yellow"); | |
| 102 | purple_plugin_pref_add_choice(ppref, "green", "green"); | |
| 103 | purple_plugin_pref_add_choice(ppref, "blue", "blue"); | |
| 104 | purple_plugin_pref_add_choice(ppref, "purple", "purple"); | |
| 105 | purple_plugin_pref_frame_add(frame, ppref); | |
| 8713 | 106 | |
| 107 | return frame; | |
| 108 | } | |
| 109 | ||
| 15884 | 110 | static PurplePluginUiInfo prefs_info = { |
| 13212 | 111 | get_plugin_pref_frame, |
| 112 | 0, /* page_num (Reserved) */ | |
|
16786
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
113 | NULL, /* frame (Reserved) */ |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
114 | /* Padding */ |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
115 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
116 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
117 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
118 | NULL |
| 8713 | 119 | }; |
| 120 | ||
| 15884 | 121 | static PurplePluginInfo info = |
| 8713 | 122 | { |
| 15884 | 123 | PURPLE_PLUGIN_MAGIC, |
| 124 | PURPLE_MAJOR_VERSION, | |
| 125 | PURPLE_MINOR_VERSION, | |
| 126 | PURPLE_PLUGIN_STANDARD, /**< type */ | |
| 8713 | 127 | NULL, /**< ui_requirement */ |
| 128 | 0, /**< flags */ | |
| 129 | NULL, /**< dependencies */ | |
| 15884 | 130 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
| 8713 | 131 | |
| 132 | "core-pluginpref_example", /**< id */ | |
| 133 | "Pluginpref Example", /**< name */ | |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
134 | DISPLAY_VERSION, /**< version */ |
| 8713 | 135 | /** summary */ |
| 136 | "An example of how to use pluginprefs", | |
| 137 | /** description */ | |
| 138 | "An example of how to use pluginprefs", | |
| 139 | "Gary Kramlich <amc_grim@users.sf.net>", /**< author */ | |
| 15884 | 140 | PURPLE_WEBSITE, /**< homepage */ |
| 8713 | 141 | |
| 142 | NULL, /**< load */ | |
| 143 | NULL, /**< unload */ | |
| 144 | NULL, /**< destroy */ | |
| 145 | ||
| 146 | NULL, /**< ui_info */ | |
| 147 | NULL, /**< extra_info */ | |
| 8993 | 148 | &prefs_info, /**< prefs_info */ |
|
16786
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
149 | NULL, /**< actions */ |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
150 | /* padding */ |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
151 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
152 | NULL, |
|
65c04c7e5c8a
Add padding to structs as necessary to silence compiler warnings
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16481
diff
changeset
|
153 | NULL, |
| 8993 | 154 | NULL |
| 8713 | 155 | }; |
| 156 | ||
| 157 | static void | |
| 15884 | 158 | init_plugin(PurplePlugin *plugin) |
| 8713 | 159 | { |
| 16481 | 160 | purple_prefs_add_none("/plugins/core/pluginpref_example"); |
| 161 | purple_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE); | |
| 162 | purple_prefs_add_int("/plugins/core/pluginpref_example/int", 0); | |
| 163 | purple_prefs_add_int("/plugins/core/pluginpref_example/int_choice", 1); | |
| 164 | purple_prefs_add_string("/plugins/core/pluginpref_example/string", | |
| 8713 | 165 | "string"); |
| 16481 | 166 | purple_prefs_add_string("/plugins/core/pluginpref_example/max_string", |
| 8713 | 167 | "max length string"); |
| 16481 | 168 | purple_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked"); |
| 169 | purple_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red"); | |
| 8713 | 170 | } |
| 171 | ||
| 15884 | 172 | PURPLE_INIT_PLUGIN(ppexample, init_plugin, info) |