Migrate xmpp-caps.xml to XDG cache dir
[pidgin-git.git] / pidgin / gtkblist.h
blob0dba4ad25934a3f6db9544884e912479ba44d620
1 /* pidgin
3 * Pidgin 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 _PIDGINBLIST_H_
23 #define _PIDGINBLIST_H_
24 /**
25 * SECTION:gtkblist
26 * @section_id: pidgin-gtkblist
27 * @short_description: <filename>gtkblist.h</filename>
28 * @title: Buddy List API
29 * @see_also: <link linkend="chapter-signals-gtkblist">Buddy List signals</link>
32 #define PIDGIN_TYPE_BUDDY_LIST (pidgin_buddy_list_get_type())
34 typedef struct _PidginBuddyList PidginBuddyList;
36 enum {
37 STATUS_ICON_COLUMN,
38 STATUS_ICON_VISIBLE_COLUMN,
39 NAME_COLUMN,
40 IDLE_COLUMN,
41 IDLE_VISIBLE_COLUMN,
42 BUDDY_ICON_COLUMN,
43 BUDDY_ICON_VISIBLE_COLUMN,
44 NODE_COLUMN,
45 BGCOLOR_COLUMN,
46 GROUP_EXPANDER_COLUMN,
47 GROUP_EXPANDER_VISIBLE_COLUMN,
48 CONTACT_EXPANDER_COLUMN,
49 CONTACT_EXPANDER_VISIBLE_COLUMN,
50 EMBLEM_COLUMN,
51 EMBLEM_VISIBLE_COLUMN,
52 PROTOCOL_ICON_COLUMN,
53 PROTOCOL_ICON_VISIBLE_COLUMN,
54 BLIST_COLUMNS
58 typedef enum {
59 PIDGIN_STATUS_ICON_LARGE,
60 PIDGIN_STATUS_ICON_SMALL
62 } PidginStatusIconSize;
64 #include "pidgin.h"
65 #include "buddylist.h"
66 #include "gtkblist-theme.h"
68 /**************************************************************************
69 * Structures
70 **************************************************************************/
71 /**
72 * PidginBuddyList:
73 * @notebook: The notebook that switches between the real buddy list
74 * and the helpful instructions page
75 * @main_vbox: This vbox contains the menu and notebook
76 * @vbox: This is the vbox that everything important gets packed
77 * into. Your plugin might want to pack something in it
78 * itself. Go, plugins!
79 * @treeview: It's a treeview... d'uh.
80 * @treemodel: This is the treemodel.
81 * @text_column: Column
82 * @menutray: The menu tray widget.
83 * @menutrayicon: The menu tray icon.
84 * @refresh_timer: The timer for refreshing every 30 seconds
85 * @timeout: The timeout for the tooltip.
86 * @drag_timeout: The timeout for expanding contacts on drags
87 * @tip_rect: This is the bounding rectangle of the cell we're
88 * currently hovering over. This is used for tooltips.
89 * @contact_rect: This is the bounding rectangle of the contact node and
90 * its children. This is used for auto-expand on mouseover.
91 * @mouseover_contact: This is the contact currently mouse-over expanded
92 * @tipwindow: The window used by the tooltip
93 * @tooltipdata: The data for each "chunk" of the tooltip
94 * @selected_node: The currently selected node
95 * @scrollbook: Scrollbook for alerts
96 * @headline: Widget for headline notifications
97 * @headline_label: Label for headline notifications
98 * @headline_image: Image for headline notifications
99 * @headline_callback: Callback for headline notifications
100 * @headline_data: User data for headline notifications
101 * @headline_destroy: Callback to use for destroying the headline-data
102 * @statusbox: The status selector dropdown
103 * @empty_avatar: A 32x32 transparent pixbuf
104 * @priv: Pointer to opaque private data
106 * Like, everything you need to know about the gtk buddy list
108 struct _PidginBuddyList {
109 GtkWidget *window;
110 GtkWidget *notebook;
111 GtkWidget *main_vbox;
112 GtkWidget *vbox;
114 GtkWidget *treeview;
115 GtkTreeStore *treemodel;
116 GtkTreeViewColumn *text_column;
118 GtkCellRenderer *text_rend;
120 GtkUIManager *ui;
121 GtkWidget *menutray;
122 GtkWidget *menutrayicon;
124 guint refresh_timer;
126 guint timeout;
127 guint drag_timeout;
128 GdkRectangle tip_rect;
129 GdkRectangle contact_rect;
130 PurpleBlistNode *mouseover_contact;
132 GtkWidget *tipwindow;
133 GList *tooltipdata;
135 PurpleBlistNode *selected_node;
137 GtkWidget *scrollbook;
138 GtkWidget *headline;
139 GtkWidget *headline_label;
140 GtkWidget *headline_image;
141 GCallback headline_callback;
142 gpointer headline_data;
143 GDestroyNotify headline_destroy;
145 GtkWidget *statusbox;
146 GdkPixbuf *empty_avatar;
148 gpointer priv;
151 #define PIDGIN_BLIST(list) ((PidginBuddyList *)purple_blist_get_ui_data())
152 #define PIDGIN_IS_PIDGIN_BLIST(list) \
153 (purple_blist_get_ui_ops() == pidgin_blist_get_ui_ops())
155 G_BEGIN_DECLS
157 /**************************************************************************
158 * GTK+ Buddy List API
159 **************************************************************************/
162 * pidgin_buddy_list_get_type:
164 * Returns: The #GType for the #PidginBuddyList boxed structure.
166 GType pidgin_buddy_list_get_type(void);
169 * pidgin_blist_get_handle:
171 * Get the handle for the GTK+ blist system.
173 * Returns: the handle to the blist system
175 void *pidgin_blist_get_handle(void);
178 * pidgin_blist_init:
180 * Initializes the GTK+ blist system.
182 void pidgin_blist_init(void);
185 * pidgin_blist_uninit:
187 * Uninitializes the GTK+ blist system.
189 void pidgin_blist_uninit(void);
192 * pidgin_blist_get_ui_ops:
194 * Returns the UI operations structure for the buddy list.
196 * Returns: The GTK+ list operations structure.
198 PurpleBlistUiOps *pidgin_blist_get_ui_ops(void);
201 * pidgin_blist_get_default_gtk_blist:
203 * Returns the default gtk buddy list
205 * There's normally only one buddy list window, but that isn't a necessity. This function
206 * returns the PidginBuddyList we're most likely wanting to work with. This is slightly
207 * cleaner than an externed global.
209 * Returns: The default GTK+ buddy list
211 PidginBuddyList *pidgin_blist_get_default_gtk_blist(void);
214 * pidgin_blist_make_buddy_menu:
215 * @menu: The menu to populate
216 * @buddy: The buddy whose menu to get
217 * @sub: %TRUE if this is a sub-menu, %FALSE otherwise
219 * Populates a menu with the items shown on the buddy list for a buddy.
221 void pidgin_blist_make_buddy_menu(GtkWidget *menu, PurpleBuddy *buddy, gboolean sub);
224 * pidgin_blist_refresh:
225 * @list: This is the core list that gets updated from
227 * Refreshes all the nodes of the buddy list.
228 * This should only be called when something changes to affect most of the nodes (such as a ui preference changing)
230 void pidgin_blist_refresh(PurpleBuddyList *list);
232 void pidgin_blist_update_columns(void);
233 void pidgin_blist_update_refresh_timeout(void);
236 * pidgin_blist_get_emblem:
237 * @node: The node to return an emblem for
239 * Returns the blist emblem.
241 * This may be an existing pixbuf that has been given an additional ref,
242 * so it shouldn't be modified.
244 * Returns: A GdkPixbuf for the emblem to show, or NULL
246 GdkPixbuf *
247 pidgin_blist_get_emblem(PurpleBlistNode *node);
250 * pidgin_blist_get_status_icon:
252 * Useful for the buddy ticker
254 GdkPixbuf *pidgin_blist_get_status_icon(PurpleBlistNode *node,
255 PidginStatusIconSize size);
258 * pidgin_blist_node_is_contact_expanded:
259 * @node: The node in question.
261 * Returns a boolean indicating if @node is part of an expanded contact.
263 * This only makes sense for contact and buddy nodes. %FALSE is returned
264 * for other types of nodes.
266 * Returns: A boolean indicating if @node is part of an expanded contact.
268 gboolean pidgin_blist_node_is_contact_expanded(PurpleBlistNode *node);
271 * pidgin_blist_toggle_visibility:
273 * Intelligently toggles the visibility of the buddy list. If the buddy
274 * list is obscured, it is brought to the front. If it is not obscured,
275 * it is hidden. If it is hidden it is shown.
277 void pidgin_blist_toggle_visibility(void);
280 * pidgin_blist_visibility_manager_add:
282 * Increases the reference count of visibility managers. Callers should
283 * call the complementary remove function when no longer managing
284 * visibility.
286 * A visibility manager is something that provides some method for
287 * showing the buddy list after it is hidden (e.g. docklet plugin).
289 void pidgin_blist_visibility_manager_add(void);
292 * pidgin_blist_visibility_manager_remove:
294 * Decreases the reference count of visibility managers. If the count
295 * drops below zero, the buddy list is shown.
297 void pidgin_blist_visibility_manager_remove(void);
300 * pidgin_blist_add_alert:
301 * @widget: The widget to add
303 * Adds a mini-alert to the blist scrollbook
305 void pidgin_blist_add_alert(GtkWidget *widget);
308 * pidgin_blist_set_theme:
309 * @theme: the new theme to use
311 * Sets the current theme for Pidgin to use
313 void pidgin_blist_set_theme(PidginBlistTheme *theme);
316 * pidgin_blist_get_theme:
318 * Gets Pidgin's current buddy list theme
320 * Returns: the current theme
322 PidginBlistTheme *pidgin_blist_get_theme(void);
324 /**************************************************************************
325 * GTK+ Buddy List sorting functions
326 **************************************************************************/
328 typedef void (*pidgin_blist_sort_function)(PurpleBlistNode *new, PurpleBuddyList *blist, GtkTreeIter group, GtkTreeIter *cur, GtkTreeIter *iter);
331 * pidgin_blist_get_sort_methods:
333 * Gets the current list of sort methods.
335 * Returns: A GSlist of sort methods
337 GList *pidgin_blist_get_sort_methods(void);
339 struct _PidginBlistSortMethod {
340 char *id;
341 char *name;
342 pidgin_blist_sort_function func;
345 typedef struct _PidginBlistSortMethod PidginBlistSortMethod;
348 * pidgin_blist_sort_method_reg:
349 * @id: The unique ID of the sorting method
350 * @name: The method's name.
351 * @func: A pointer to the function.
353 * Registers a buddy list sorting method.
355 void pidgin_blist_sort_method_reg(const char *id, const char *name, pidgin_blist_sort_function func);
358 * pidgin_blist_sort_method_unreg:
359 * @id: The method's id
361 * Unregisters a buddy list sorting method.
363 void pidgin_blist_sort_method_unreg(const char *id);
366 * pidgin_blist_sort_method_set:
367 * @id: The method's id.
369 * Sets a buddy list sorting method.
371 void pidgin_blist_sort_method_set(const char *id);
374 * pidgin_blist_setup_sort_methods:
376 * Sets up the programs default sort methods
378 void pidgin_blist_setup_sort_methods(void);
381 * pidgin_blist_update_accounts_menu:
383 * Updates the accounts menu on the GTK+ buddy list window.
385 void pidgin_blist_update_accounts_menu(void);
388 * pidgin_blist_update_plugin_actions:
390 * Updates the plugin actions menu on the GTK+ buddy list window.
392 void pidgin_blist_update_plugin_actions(void);
395 * pidgin_blist_update_sort_methods:
397 * Updates the Sorting menu on the GTK+ buddy list window.
399 void pidgin_blist_update_sort_methods(void);
402 * pidgin_blist_joinchat_is_showable:
404 * Determines if showing the join chat dialog is a valid action.
406 * Returns: Returns TRUE if there are accounts online capable of
407 * joining chat rooms. Otherwise returns FALSE.
409 gboolean pidgin_blist_joinchat_is_showable(void);
412 * pidgin_blist_joinchat_show:
414 * Shows the join chat dialog.
416 void pidgin_blist_joinchat_show(void);
419 * pidgin_append_blist_node_privacy_menu:
421 * Appends the privacy menu items for a PurpleBlistNode
423 /* TODO Rename these. */
424 void pidgin_append_blist_node_privacy_menu(GtkWidget *menu, PurpleBlistNode *node);
427 * pidgin_append_blist_node_proto_menu:
429 * Appends the protocol specific menu items for a PurpleBlistNode
431 /* TODO Rename these. */
432 void pidgin_append_blist_node_proto_menu (GtkWidget *menu, PurpleConnection *gc, PurpleBlistNode *node);
435 * pidgin_append_blist_node_extended_menu:
437 * Appends the extended menu items for a PurpleBlistNode
439 /* TODO Rename these. */
440 void pidgin_append_blist_node_extended_menu(GtkWidget *menu, PurpleBlistNode *node);
443 * pidgin_blist_set_headline:
444 * @text: Pango Markup for the label text
445 * @pixbuf: The GdkPixbuf for the icon
446 * @callback: The callback to call when headline is clicked
447 * @user_data: The userdata to include in the callback
448 * @destroy: The callback to call when headline is closed or replaced by another headline.
450 * Sets a headline notification
452 * This is currently used for mail notification, but could theoretically be used for anything.
453 * Only the most recent headline will be shown.
455 void pidgin_blist_set_headline(const char *text, GdkPixbuf *pixbuf, GCallback callback, gpointer user_data,
456 GDestroyNotify destroy);
459 * pidgin_blist_get_name_markup:
460 * @buddy: The buddy to return markup from
461 * @selected: Whether this buddy is selected. If TRUE, the markup will not change the color.
462 * @aliased: TRUE to return the appropriate alias of this buddy, FALSE to return its username and status information
464 * Returns a buddy's Pango markup appropriate for setting in a GtkCellRenderer.
466 * Returns: The markup for this buddy
468 gchar *pidgin_blist_get_name_markup(PurpleBuddy *buddy, gboolean selected, gboolean aliased);
471 * pidgin_blist_draw_tooltip:
472 * @node: The buddy list node to show a tooltip for
473 * @widget: The widget to draw the tooltip on
475 * Creates the Buddy List tooltip at the current pointer location for the given buddy list node.
477 * This tooltip will be destroyed the next time this function is called, or when XXXX
478 * is called
480 void pidgin_blist_draw_tooltip(PurpleBlistNode *node, GtkWidget *widget);
483 * pidgin_blist_tooltip_destroy:
485 * Destroys the current (if any) Buddy List tooltip
487 void pidgin_blist_tooltip_destroy(void);
489 G_END_DECLS
491 #endif /* _PIDGINBLIST_H_ */