Mon, 16 Sep 2013 23:02:23 +0530
Use g_object_[sg]et_data in joinpart
| 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 | ||
|
36741
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
110 | static PurplePluginInfo * |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
111 | plugin_query(GError **error) |
| 8713 | 112 | { |
|
36741
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
113 | const gchar * const authors[] = { |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
114 | "Gary Kramlich <amc_grim@users.sf.net>", |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
115 | NULL |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
116 | }; |
| 8713 | 117 | |
|
36741
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
118 | return purple_plugin_info_new( |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
119 | "id", "core-pluginpref_example", |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
120 | "name", "Pluginpref Example", |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
121 | "version", DISPLAY_VERSION, |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
122 | "category", "Example", |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
123 | "summary", "An example of how to use pluginprefs", |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
124 | "description", "An example of how to use pluginprefs", |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
125 | "authors", authors, |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
126 | "website", PURPLE_WEBSITE, |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
127 | "abi-version", PURPLE_ABI_VERSION, |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
128 | "preferences-frame", get_plugin_pref_frame, |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
129 | NULL |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
130 | ); |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
131 | } |
| 8713 | 132 | |
|
36741
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
133 | static gboolean |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
134 | plugin_load(PurplePlugin *plugin, GError **error) |
| 8713 | 135 | { |
| 16481 | 136 | purple_prefs_add_none("/plugins/core/pluginpref_example"); |
| 137 | purple_prefs_add_bool("/plugins/core/pluginpref_example/bool", TRUE); | |
| 138 | purple_prefs_add_int("/plugins/core/pluginpref_example/int", 0); | |
| 139 | purple_prefs_add_int("/plugins/core/pluginpref_example/int_choice", 1); | |
| 140 | purple_prefs_add_string("/plugins/core/pluginpref_example/string", | |
| 8713 | 141 | "string"); |
| 16481 | 142 | purple_prefs_add_string("/plugins/core/pluginpref_example/max_string", |
| 8713 | 143 | "max length string"); |
| 16481 | 144 | purple_prefs_add_string("/plugins/core/pluginpref_example/masked_string", "masked"); |
| 145 | purple_prefs_add_string("/plugins/core/pluginpref_example/string_choice", "red"); | |
|
36741
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
146 | |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
147 | return TRUE; |
| 8713 | 148 | } |
| 149 | ||
|
36741
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
150 | static gboolean |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
151 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
152 | { |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
153 | return TRUE; |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
154 | } |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
155 | |
|
c96edeed7ea7
Refactored notify_example, one_time_password, pluginpref_example plugins to use the new API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
156 | PURPLE_PLUGIN_INIT(ppexample, plugin_query, plugin_load, plugin_unload); |