Use correct memory functions for GG oauth.
[pidgin-git.git] / libpurple / action.c
blob1beb94b52fea0550c0e6ffda3dbf1cc03bf38b46
1 /* Purple is the legal property of its developers, whose names are too numerous
2 * to list here. Please refer to the COPYRIGHT file distributed with this
3 * source distribution.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
20 #include "action.h"
22 struct _PurpleActionMenu {
23 gchar *label;
24 GCallback callback;
25 gpointer data;
26 GList *children;
29 /******************************************************************************
30 * ActionMenu API
31 *****************************************************************************/
32 PurpleActionMenu *
33 purple_action_menu_new(const gchar *label, GCallback callback, gpointer data,
34 GList *children)
36 PurpleActionMenu *act = g_new(PurpleActionMenu, 1);
38 act->label = g_strdup(label);
39 act->callback = callback;
40 act->data = data;
41 act->children = children;
43 return act;
46 void
47 purple_action_menu_free(PurpleActionMenu *act) {
48 g_return_if_fail(act != NULL);
50 purple_action_menu_set_children(act, NULL);
52 g_free(act->label);
53 g_free(act);
56 const gchar *
57 purple_action_menu_get_label(const PurpleActionMenu *act) {
58 g_return_val_if_fail(act != NULL, NULL);
60 return act->label;
63 GCallback
64 purple_action_menu_get_callback(const PurpleActionMenu *act) {
65 g_return_val_if_fail(act != NULL, NULL);
67 return act->callback;
70 gpointer
71 purple_action_menu_get_data(const PurpleActionMenu *act) {
72 g_return_val_if_fail(act != NULL, NULL);
74 return act->data;
77 GList *
78 purple_action_menu_get_children(const PurpleActionMenu *act) {
79 g_return_val_if_fail(act != NULL, NULL);
81 return act->children;
84 void
85 purple_action_menu_set_label(PurpleActionMenu *act, const gchar *label) {
86 g_return_if_fail(act != NULL);
88 g_free(act->label);
90 act->label = g_strdup(label);
93 void
94 purple_action_menu_set_callback(PurpleActionMenu *act, GCallback callback) {
95 g_return_if_fail(act != NULL);
97 act->callback = callback;
100 void
101 purple_action_menu_set_data(PurpleActionMenu *act, gpointer data) {
102 g_return_if_fail(act != NULL);
104 act->data = data;
107 void
108 purple_action_menu_set_children(PurpleActionMenu *act, GList *children) {
109 g_return_if_fail(act != NULL);
111 g_list_free_full(act->children, (GDestroyNotify)purple_action_menu_free);
113 act->children = children;
116 /******************************************************************************
117 * Protocol Action API
118 *****************************************************************************/
119 PurpleProtocolAction *
120 purple_protocol_action_new(const gchar* label, PurpleProtocolActionCallback callback) {
121 PurpleProtocolAction *action;
123 g_return_val_if_fail(label != NULL, NULL);
124 g_return_val_if_fail(callback != NULL, NULL);
126 action = g_new0(PurpleProtocolAction, 1);
128 action->label = g_strdup(label);
129 action->callback = callback;
131 return action;
134 void
135 purple_protocol_action_free(PurpleProtocolAction *action) {
136 g_return_if_fail(action != NULL);
138 g_free(action->label);
139 g_free(action);
142 PurpleProtocolAction *
143 purple_protocol_action_copy(PurpleProtocolAction *action) {
144 g_return_val_if_fail(action != NULL, NULL);
146 return purple_protocol_action_new(action->label, action->callback);
149 G_DEFINE_BOXED_TYPE(
150 PurpleProtocolAction,
151 purple_protocol_action,
152 purple_protocol_action_copy,
153 purple_protocol_action_free