Merge heads.
[pidgin-git.git] / libpurple / action.h
blobb6b887ea8edd3a34d9d3c83e2aa3cd4a0e5a4e59
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_ACTION
23 #define PURPLE_ACTION
25 #include <glib.h>
26 #include <glib-object.h>
28 #define PURPLE_TYPE_PROTOCOL_ACTION (purple_protocol_action_get_type())
29 typedef struct _PurpleProtocolAction PurpleProtocolAction;
31 typedef void (*PurpleProtocolActionCallback)(PurpleProtocolAction *action);
33 /**
34 * PurpleActionMenu:
36 * A generic structure that contains information about an "action". One
37 * place this is used is by protocols to tell the core the list of available
38 * right-click actions for a buddy list row.
40 typedef struct _PurpleActionMenu PurpleActionMenu;
42 #include "connection.h"
44 /**
45 * PurpleProtocolAction:
46 * @label: A translated string to be shown in a user interface.
47 * @callback: The function to call when the user wants to perform this action.
48 * @connection: The connection that this action should be performed against.
49 * @user_data: User data to pass to @callback.
51 * Represents an action that the protocol can perform. This shows up in the
52 * Accounts menu, under a submenu with the name of the account.
54 struct _PurpleProtocolAction {
55 gchar *label;
56 PurpleProtocolActionCallback callback;
57 PurpleConnection *connection;
58 gpointer user_data;
61 G_BEGIN_DECLS
63 /******************************************************************************
64 * Menu Action API
65 *****************************************************************************/
67 /**
68 * purple_action_menu_new:
69 * @label: The text label to display for this action.
70 * @callback: The function to be called when the action is used on
71 * the selected item.
72 * @data: Additional data to be passed to the callback.
73 * @children: (element-type PurpleActionMenu) (transfer full): Menu actions to
74 * be added as a submenu of this action.
76 * Creates a new PurpleActionMenu.
78 * Returns: The PurpleActionMenu.
80 PurpleActionMenu *purple_action_menu_new(const gchar *label, GCallback callback, gpointer data, GList *children);
82 /**
83 * purple_action_menu_free:
84 * @act: The PurpleActionMenu to free.
86 * Frees a PurpleActionMenu
88 void purple_action_menu_free(PurpleActionMenu *act);
90 /**
91 * purple_action_menu_get_label:
92 * @act: The PurpleActionMenu.
94 * Returns the label of the PurpleActionMenu.
96 * Returns: The label string.
98 const gchar *purple_action_menu_get_label(const PurpleActionMenu *act);
101 * purple_action_menu_get_callback:
102 * @act: The PurpleActionMenu.
104 * Returns the callback of the PurpleActionMenu.
106 * Returns: The callback function.
108 GCallback purple_action_menu_get_callback(const PurpleActionMenu *act);
111 * purple_action_menu_get_data:
112 * @act: The PurpleActionMenu.
114 * Returns the data stored in the PurpleActionMenu.
116 * Returns: The data.
118 gpointer purple_action_menu_get_data(const PurpleActionMenu *act);
121 * purple_action_menu_get_children:
122 * @act: The PurpleActionMenu.
124 * Returns the children of the PurpleActionMenu.
126 * Returns: (element-type PurpleActionMenu) (transfer none): The menu children.
128 GList* purple_action_menu_get_children(const PurpleActionMenu *act);
131 * purple_action_menu_set_label:
132 * @act: The menu action.
133 * @label: The label for the menu action.
135 * Set the label to the PurpleActionMenu.
137 void purple_action_menu_set_label(PurpleActionMenu *act, const gchar *label);
140 * purple_action_menu_set_callback:
141 * @act: The menu action.
142 * @callback: The callback.
144 * Set the callback that will be used by the PurpleActionMenu.
146 void purple_action_menu_set_callback(PurpleActionMenu *act, GCallback callback);
149 * purple_action_menu_set_data:
150 * @act: The menu action.
151 * @data: The data used by this PurpleActionMenu
153 * Set the label to the PurpleActionMenu.
155 void purple_action_menu_set_data(PurpleActionMenu *act, gpointer data);
158 * purple_action_menu_set_children:
159 * @act: The menu action.
160 * @children: (element-type PurpleActionMenu) (transfer full): The menu children
162 * Set the children of the PurpleActionMenu.
164 void purple_action_menu_set_children(PurpleActionMenu *act, GList *children);
166 /******************************************************************************
167 * Protocol Action API
168 *****************************************************************************/
171 * purple_protocol_action_get_type:
173 * Returns: The #GType for the #PurpleProtocolAction boxed structure.
175 GType purple_protocol_action_get_type(void);
178 * purple_protocol_action_new:
179 * @label: The description of the action to show to the user.
180 * @callback: (scope call): The callback to call when the user selects this
181 * action.
183 * Allocates and returns a new PurpleProtocolAction. Use this to add actions in
184 * a list in the get_actions function of the protocol.
186 * Returns: (transfer full): The new #PurpleProtocolAction.
188 PurpleProtocolAction *purple_protocol_action_new(const gchar *label, PurpleProtocolActionCallback callback);
191 * purple_protocol_action_copy:
192 * @action: The #PurpleProtocolAction to copy.
194 * Creates a newly allocated copy of @action.
196 * Returns: (transfer full): A copy of @action.
198 PurpleProtocolAction *purple_protocol_action_copy(PurpleProtocolAction *action);
201 * purple_protocol_action_free:
202 * @action: The PurpleProtocolAction to free.
204 * Frees a PurpleProtocolAction
206 void purple_protocol_action_free(PurpleProtocolAction *action);
209 G_END_DECLS
211 #endif /* PURPLE_ACTION */