Cast back and forth between int and pointer instead of putting pointers
[pidgin-git.git] / pidgin / gtkblist.h
blob9a5a56d18de9c95d60e577757544e77529c6db15
1 /**
2 * @file gtkblist.h GTK+ Buddy List API
3 * @ingroup pidgin
4 * @see @ref gtkblist-signals
5 */
7 /* pidgin
9 * Pidgin is the legal property of its developers, whose names are too numerous
10 * to list here. Please refer to the COPYRIGHT file distributed with this
11 * source distribution.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef _PIDGINBLIST_H_
28 #define _PIDGINBLIST_H_
30 /** @copydoc _PidginBuddyList */
31 typedef struct _PidginBuddyList PidginBuddyList;
33 enum {
34 STATUS_ICON_COLUMN,
35 STATUS_ICON_VISIBLE_COLUMN,
36 NAME_COLUMN,
37 IDLE_COLUMN,
38 IDLE_VISIBLE_COLUMN,
39 BUDDY_ICON_COLUMN,
40 BUDDY_ICON_VISIBLE_COLUMN,
41 NODE_COLUMN,
42 BGCOLOR_COLUMN,
43 GROUP_EXPANDER_COLUMN,
44 GROUP_EXPANDER_VISIBLE_COLUMN,
45 CONTACT_EXPANDER_COLUMN,
46 CONTACT_EXPANDER_VISIBLE_COLUMN,
47 EMBLEM_COLUMN,
48 EMBLEM_VISIBLE_COLUMN,
49 PROTOCOL_ICON_COLUMN,
50 PROTOCOL_ICON_VISIBLE_COLUMN,
51 BLIST_COLUMNS
55 typedef enum {
56 PIDGIN_STATUS_ICON_LARGE,
57 PIDGIN_STATUS_ICON_SMALL
59 } PidginStatusIconSize;
61 #include "pidgin.h"
62 #include "blist.h"
63 #include "gtkblist-theme.h"
65 /**************************************************************************
66 * @name Structures
67 **************************************************************************/
68 /**
69 * Like, everything you need to know about the gtk buddy list
71 struct _PidginBuddyList {
72 GtkWidget *window;
73 GtkWidget *notebook; /**< The notebook that switches between the real buddy list and the helpful
74 instructions page */
75 GtkWidget *main_vbox; /**< This vbox contains the menu and notebook */
76 GtkWidget *vbox; /**< This is the vbox that everything important gets packed into.
77 Your plugin might want to pack something in it itself. Go, plugins! */
79 GtkWidget *treeview; /**< It's a treeview... d'uh. */
80 GtkTreeStore *treemodel; /**< This is the treemodel. */
81 GtkTreeViewColumn *text_column; /**< Column */
83 GtkCellRenderer *text_rend;
85 GtkItemFactory *ift;
86 GtkWidget *menutray; /**< The menu tray widget. */
87 GtkWidget *menutrayicon; /**< The menu tray icon. */
89 /** Caches connection error messages; keys are #PurpleAccount and
90 * values are non-@c NULL <tt>const char *</tt>s containing localised
91 * error messages. (If an account does not have an error, it will not
92 * appear in the table.)
93 * @deprecated in favour of purple_account_get_current_error(), which also
94 * gives you the #PurpleConnectionError value.
96 GHashTable *connection_errors;
98 guint refresh_timer; /**< The timer for refreshing every 30 seconds */
100 guint timeout; /**< The timeout for the tooltip. */
101 guint drag_timeout; /**< The timeout for expanding contacts on drags */
102 GdkRectangle tip_rect; /**< This is the bounding rectangle of the
103 cell we're currently hovering over. This is
104 used for tooltips. */
105 GdkRectangle contact_rect; /**< This is the bounding rectangle of the contact node
106 and its children. This is used for auto-expand on
107 mouseover. */
108 PurpleBlistNode *mouseover_contact; /**< This is the contact currently mouse-over expanded */
110 GtkWidget *tipwindow; /**< The window used by the tooltip */
111 GList *tooltipdata; /**< The data for each "chunk" of the tooltip */
113 PurpleBlistNode *selected_node; /**< The currently selected node */
115 GdkCursor *hand_cursor; /**< Hand cursor */
116 GdkCursor *arrow_cursor; /**< Arrow cursor */
118 GtkWidget *scrollbook; /**< Scrollbook for alerts */
119 GtkWidget *headline_hbox; /**< Hbox for headline notification */
120 GtkWidget *headline_label; /**< Label for headline notifications */
121 GtkWidget *headline_image; /**< Image for headline notifications */
122 GdkPixbuf *headline_close; /**< @deprecated: Close image for closing the headline without triggering the callback */
123 GCallback headline_callback; /**< Callback for headline notifications */
124 gpointer headline_data; /**< User data for headline notifications */
125 GDestroyNotify headline_destroy; /**< Callback to use for destroying the headline-data */
126 gboolean changing_style; /**< True when changing GTK+ theme style */
128 GtkWidget *error_buttons; /**< Box containing the connection error buttons */
129 GtkWidget *statusbox; /**< The status selector dropdown */
130 GdkPixbuf *empty_avatar; /**< A 32x32 transparent pixbuf */
132 gpointer priv; /**< Pointer to opaque private data */
135 #define PIDGIN_BLIST(list) ((PidginBuddyList *)purple_blist_get_ui_data())
136 #define PIDGIN_IS_PIDGIN_BLIST(list) \
137 (purple_blist_get_ui_ops() == pidgin_blist_get_ui_ops())
139 /**************************************************************************
140 * @name GTK+ Buddy List API
141 **************************************************************************/
144 * Get the handle for the GTK+ blist system.
146 * @return the handle to the blist system
148 void *pidgin_blist_get_handle(void);
151 * Initializes the GTK+ blist system.
153 void pidgin_blist_init(void);
156 * Uninitializes the GTK+ blist system.
158 void pidgin_blist_uninit(void);
161 * Returns the UI operations structure for the buddy list.
163 * @return The GTK+ list operations structure.
165 PurpleBlistUiOps *pidgin_blist_get_ui_ops(void);
168 * Returns the default gtk buddy list
170 * There's normally only one buddy list window, but that isn't a necessity. This function
171 * returns the PidginBuddyList we're most likely wanting to work with. This is slightly
172 * cleaner than an externed global.
174 * @return The default GTK+ buddy list
176 PidginBuddyList *pidgin_blist_get_default_gtk_blist(void);
179 * Populates a menu with the items shown on the buddy list for a buddy.
181 * @param menu The menu to populate
182 * @param buddy The buddy whose menu to get
183 * @param sub TRUE if this is a sub-menu, FALSE otherwise
185 void pidgin_blist_make_buddy_menu(GtkWidget *menu, PurpleBuddy *buddy, gboolean sub);
188 * Refreshes all the nodes of the buddy list.
189 * This should only be called when something changes to affect most of the nodes (such as a ui preference changing)
191 * @param list This is the core list that gets updated from
193 void pidgin_blist_refresh(PurpleBuddyList *list);
195 void pidgin_blist_update_columns(void);
196 void pidgin_blist_update_refresh_timeout(void);
199 * Returns the blist emblem.
201 * This may be an existing pixbuf that has been given an additional ref,
202 * so it shouldn't be modified.
204 * @param node The node to return an emblem for
206 * @return A GdkPixbuf for the emblem to show, or NULL
208 GdkPixbuf *
209 pidgin_blist_get_emblem(PurpleBlistNode *node);
212 * Useful for the buddy ticker
214 GdkPixbuf *pidgin_blist_get_status_icon(PurpleBlistNode *node,
215 PidginStatusIconSize size);
218 * Returns a boolean indicating if @a node is part of an expanded contact.
220 * This only makes sense for contact and buddy nodes. @c FALSE is returned
221 * for other types of nodes.
223 * @param node The node in question.
224 * @return A boolean indicating if @a node is part of an expanded contact.
226 gboolean pidgin_blist_node_is_contact_expanded(PurpleBlistNode *node);
229 * Intelligently toggles the visibility of the buddy list. If the buddy
230 * list is obscured, it is brought to the front. If it is not obscured,
231 * it is hidden. If it is hidden it is shown.
233 void pidgin_blist_toggle_visibility(void);
236 * Increases the reference count of visibility managers. Callers should
237 * call the complementary remove function when no longer managing
238 * visibility.
240 * A visibility manager is something that provides some method for
241 * showing the buddy list after it is hidden (e.g. docklet plugin).
243 void pidgin_blist_visibility_manager_add(void);
246 * Decreases the reference count of visibility managers. If the count
247 * drops below zero, the buddy list is shown.
249 void pidgin_blist_visibility_manager_remove(void);
252 * Adds a mini-alert to the blist scrollbook
254 * @param widget The widget to add
256 void pidgin_blist_add_alert(GtkWidget *widget);
259 * Sets the current theme for Pidgin to use
261 * @param theme the new theme to use
263 * @since 2.6.0
265 void pidgin_blist_set_theme(PidginBlistTheme *theme);
268 * Gets Pidgin's current buddy list theme
270 * @returns the current theme
272 * @since 2.6.0
274 PidginBlistTheme *pidgin_blist_get_theme(void);
276 /**************************************************************************
277 * @name GTK+ Buddy List sorting functions
278 **************************************************************************/
280 typedef void (*pidgin_blist_sort_function)(PurpleBlistNode *new, PurpleBuddyList *blist, GtkTreeIter group, GtkTreeIter *cur, GtkTreeIter *iter);
283 * Gets the current list of sort methods.
285 * @return A GSlist of sort methods
287 GList *pidgin_blist_get_sort_methods(void);
289 struct pidgin_blist_sort_method {
290 char *id;
291 char *name;
292 pidgin_blist_sort_function func;
295 typedef struct pidgin_blist_sort_method PidginBlistSortMethod;
298 * Registers a buddy list sorting method.
300 * @param id The unique ID of the sorting method
301 * @param name The method's name.
302 * @param func A pointer to the function.
305 void pidgin_blist_sort_method_reg(const char *id, const char *name, pidgin_blist_sort_function func);
308 * Unregisters a buddy list sorting method.
310 * @param id The method's id
312 void pidgin_blist_sort_method_unreg(const char *id);
315 * Sets a buddy list sorting method.
317 * @param id The method's id.
319 void pidgin_blist_sort_method_set(const char *id);
322 * Sets up the programs default sort methods
324 void pidgin_blist_setup_sort_methods(void);
327 * Updates the accounts menu on the GTK+ buddy list window.
329 void pidgin_blist_update_accounts_menu(void);
332 * Updates the plugin actions menu on the GTK+ buddy list window.
334 void pidgin_blist_update_plugin_actions(void);
337 * Updates the Sorting menu on the GTK+ buddy list window.
339 void pidgin_blist_update_sort_methods(void);
342 * Determines if showing the join chat dialog is a valid action.
344 * @return Returns TRUE if there are accounts online capable of
345 * joining chat rooms. Otherwise returns FALSE.
347 gboolean pidgin_blist_joinchat_is_showable(void);
350 * Shows the join chat dialog.
352 void pidgin_blist_joinchat_show(void);
355 * Appends the privacy menu items for a PurpleBlistNode
356 * TODO: Rename these.
358 void pidgin_append_blist_node_privacy_menu(GtkWidget *menu, PurpleBlistNode *node);
361 * Appends the protocol specific menu items for a PurpleBlistNode
362 * TODO: Rename these.
364 void pidgin_append_blist_node_proto_menu (GtkWidget *menu, PurpleConnection *gc, PurpleBlistNode *node);
367 * Appends the extended menu items for a PurpleBlistNode
368 * TODO: Rename these.
370 void pidgin_append_blist_node_extended_menu(GtkWidget *menu, PurpleBlistNode *node);
373 * Was used by the connection API to tell the blist if an account has a
374 * connection error or no longer has a connection error, but the blist now does
375 * this itself with the @ref account-error-changed signal.
377 * @param account The account that either has a connection error
378 * or no longer has a connection error.
379 * @param message The connection error message, or NULL if this
380 * account is no longer in an error state.
381 * @deprecated There was no good reason for code other than gtkconn to call
382 * this.
384 void pidgin_blist_update_account_error_state(PurpleAccount *account, const char *message);
387 * Sets a headline notification
389 * This is currently used for mail notification, but could theoretically be used for anything.
390 * Only the most recent headline will be shown.
392 * @param text Pango Markup for the label text
393 * @param pixbuf The GdkPixbuf for the icon
394 * @param callback The callback to call when headline is clicked
395 * @param user_data The userdata to include in the callback
396 * @param destroy The callback to call when headline is closed or replaced by another headline.
398 void pidgin_blist_set_headline(const char *text, GdkPixbuf *pixbuf, GCallback callback, gpointer user_data,
399 GDestroyNotify destroy);
402 * Returns a buddy's Pango markup appropriate for setting in a GtkCellRenderer.
404 * @param buddy The buddy to return markup from
405 * @param selected Whether this buddy is selected. If TRUE, the markup will not change the color.
406 * @param aliased TRUE to return the appropriate alias of this buddy, FALSE to return its username and status information
407 * @return The markup for this buddy
409 * @since 2.1.0
411 gchar *pidgin_blist_get_name_markup(PurpleBuddy *buddy, gboolean selected, gboolean aliased);
414 * Creates the Buddy List tooltip at the current pointer location for the given buddy list node.
416 * This tooltip will be destroyed the next time this function is called, or when XXXX
417 * is called
419 * @param node The buddy list node to show a tooltip for
420 * @param widget The widget to draw the tooltip on
422 * @since 2.1.0
424 void pidgin_blist_draw_tooltip(PurpleBlistNode *node, GtkWidget *widget);
427 * Destroys the current (if any) Buddy List tooltip
429 * @since 2.1.0
431 void pidgin_blist_tooltip_destroy(void);
434 #endif /* _PIDGINBLIST_H_ */