Replace strcmp() with purple_strequal()
[pidgin-git.git] / pidgin / gtkutils.h
blob716ec6de8168a3afd0eb46eb31f18888c459688b
1 /**
2 * @file gtkutils.h GTK+ utility functions
3 * @ingroup pidgin
4 */
6 /* pidgin
8 * Pidgin is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PIDGINUTILS_H_
27 #define _PIDGINUTILS_H_
29 #include "gtkconv.h"
30 #include "pidgin.h"
31 #include "prpl.h"
32 #include "util.h"
38 typedef enum
40 PIDGIN_BUTTON_HORIZONTAL,
41 PIDGIN_BUTTON_VERTICAL
43 } PidginButtonOrientation;
45 typedef enum
47 PIDGIN_BUTTON_NONE = 0,
48 PIDGIN_BUTTON_TEXT,
49 PIDGIN_BUTTON_IMAGE,
50 PIDGIN_BUTTON_TEXT_IMAGE
52 } PidginButtonStyle;
54 typedef enum
56 PIDGIN_PRPL_ICON_SMALL,
57 PIDGIN_PRPL_ICON_MEDIUM,
58 PIDGIN_PRPL_ICON_LARGE
59 } PidginPrplIconSize;
61 #ifndef _WIN32
62 typedef enum
64 PIDGIN_BROWSER_DEFAULT = 0,
65 PIDGIN_BROWSER_CURRENT,
66 PIDGIN_BROWSER_NEW_WINDOW,
67 PIDGIN_BROWSER_NEW_TAB
69 } PidginBrowserPlace;
70 #endif /* _WIN32 */
72 typedef struct {
73 gboolean is_buddy;
74 union {
75 PurpleBuddy *buddy;
76 PurpleLogSet *logged_buddy;
77 } entry;
78 } PidginBuddyCompletionEntry;
80 typedef gboolean (*PidginFilterBuddyCompletionEntryFunc) (const PidginBuddyCompletionEntry *completion_entry, gpointer user_data);
83 /**
84 * Sets up a gtkimhtml widget, loads it with smileys, and sets the
85 * default signal handlers.
87 * @param imhtml The gtkimhtml widget to setup.
89 void pidgin_setup_imhtml(GtkWidget *imhtml);
91 /**
92 * Create an GtkIMHtml widget and associated GtkIMHtmlToolbar widget. This
93 * functions puts both widgets in a nice GtkFrame. They're separate by an
94 * attractive GtkSeparator.
96 * @param editable @c TRUE if this imhtml should be editable. If this is @c FALSE,
97 * then the toolbar will NOT be created. If this imthml should be
98 * read-only at first, but may become editable later, then pass in
99 * @c TRUE here and then manually call gtk_imhtml_set_editable() later.
100 * @param imhtml_ret A pointer to a pointer to a GtkWidget. This pointer
101 * will be set to the imhtml when this function exits.
102 * @param toolbar_ret A pointer to a pointer to a GtkWidget. If editable is
103 * TRUE then this will be set to the toolbar when this function exits.
104 * Otherwise this will be set to @c NULL.
105 * @param sw_ret This will be filled with a pointer to the scrolled window
106 * widget which contains the imhtml.
107 * @return The GtkFrame containing the toolbar and imhtml.
109 GtkWidget *pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret);
112 * Creates a small button
114 * @param image A button image.
116 * @return A GtkButton created from the image.
117 * @since 2.7.0
119 GtkWidget *pidgin_create_small_button(GtkWidget *image);
122 * Creates a new window
124 * @param title The window title, or @c NULL
125 * @param border_width The window's desired border width
126 * @param role A string indicating what the window is responsible for doing, or @c NULL
127 * @param resizable Whether the window should be resizable (@c TRUE) or not (@c FALSE)
129 * @since 2.1.0
131 GtkWidget *pidgin_create_window(const char *title, guint border_width, const char *role, gboolean resizable);
134 * Creates a new dialog window
136 * @param title The window title, or @c NULL
137 * @param border_width The window's desired border width
138 * @param role A string indicating what the window is responsible for doing, or @c NULL
139 * @param resizable Whether the window should be resizable (@c TRUE) or not (@c FALSE)
141 * @since 2.4.0
143 GtkWidget *pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable);
146 * Retrieves the main content box (vbox) from a pidgin dialog window
148 * @param dialog The dialog window
149 * @param homogeneous TRUE if all children are to be given equal space allotments.
150 * @param spacing the number of pixels to place by default between children
152 * @since 2.4.0
154 GtkWidget *pidgin_dialog_get_vbox_with_properties(GtkDialog *dialog, gboolean homogeneous, gint spacing);
157 * Retrieves the main content box (vbox) from a pidgin dialog window
159 * @param dialog The dialog window
161 * @since 2.4.0
163 GtkWidget *pidgin_dialog_get_vbox(GtkDialog *dialog);
166 * Add a button to a dialog created by #pidgin_create_dialog.
168 * @param dialog The dialog window
169 * @param label The stock-id or the label for the button
170 * @param callback The callback function for the button
171 * @param callbackdata The user data for the callback function
173 * @return The created button.
174 * @since 2.4.0
176 GtkWidget *pidgin_dialog_add_button(GtkDialog *dialog, const char *label,
177 GCallback callback, gpointer callbackdata);
180 * Retrieves the action area (button box) from a pidgin dialog window
182 * @param dialog The dialog window
184 * @since 2.4.0
186 GtkWidget *pidgin_dialog_get_action_area(GtkDialog *dialog);
189 * Toggles the sensitivity of a widget.
191 * @param widget @c NULL. Used for signal handlers.
192 * @param to_toggle The widget to toggle.
194 void pidgin_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle);
197 * Checks if text has been entered into a GtkTextEntry widget. If
198 * so, the GTK_RESPONSE_OK on the given dialog is set to TRUE.
199 * Otherwise GTK_RESPONSE_OK is set to FALSE.
201 * @param entry The text entry widget.
202 * @param dialog The dialog containing the text entry widget.
204 void pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog);
207 * Toggles the sensitivity of all widgets in a pointer array.
209 * @param w @c NULL. Used for signal handlers.
210 * @param data The array containing the widgets to toggle.
212 void pidgin_toggle_sensitive_array(GtkWidget *w, GPtrArray *data);
215 * Toggles the visibility of a widget.
217 * @param widget @c NULL. Used for signal handlers.
218 * @param to_toggle The widget to toggle.
220 void pidgin_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle);
223 * Adds a separator to a menu.
225 * @param menu The menu to add a separator to.
227 * @return The separator.
229 GtkWidget *pidgin_separator(GtkWidget *menu);
232 * Creates a menu item.
234 * @param menu The menu to which to append the menu item.
235 * @param str The title to use for the newly created menu item.
237 * @return The newly created menu item.
239 GtkWidget *pidgin_new_item(GtkWidget *menu, const char *str);
242 * Creates a check menu item.
244 * @param menu The menu to which to append the check menu item.
245 * @param str The title to use for the newly created menu item.
246 * @param cb A function to call when the menu item is activated.
247 * @param data Data to pass to the signal function.
248 * @param checked The initial state of the check item
250 * @return The newly created menu item.
252 GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str,
253 GCallback cb, gpointer data, gboolean checked);
256 * Creates a menu item.
258 * @param menu The menu to which to append the menu item.
259 * @param str The title for the menu item.
260 * @param icon An icon to place to the left of the menu item,
261 * or @c NULL for no icon.
262 * @param cb A function to call when the menu item is activated.
263 * @param data Data to pass to the signal function.
264 * @param accel_key Something.
265 * @param accel_mods Something.
266 * @param mod Something.
268 * @return The newly created menu item.
270 GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str,
271 const char *icon, GCallback cb,
272 gpointer data, guint accel_key,
273 guint accel_mods, char *mod);
276 * Creates a button with the specified text and stock icon.
278 * @param text The text for the button.
279 * @param icon The stock icon name.
280 * @param style The orientation of the button.
282 * @return The button.
284 GtkWidget *pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
285 PidginButtonOrientation style);
288 * Creates a toolbar button with the stock icon.
290 * @param stock The stock icon name.
292 * @return The button.
294 GtkWidget *pidgin_pixbuf_toolbar_button_from_stock(const char *stock);
297 * Creates a HIG preferences frame.
299 * @param parent The widget to put the frame into.
300 * @param title The title for the frame.
302 * @return The vbox to put things into.
304 GtkWidget *pidgin_make_frame(GtkWidget *parent, const char *title);
307 * Creates a drop-down option menu filled with protocols.
309 * @param id The protocol to select by default.
310 * @param cb The callback to call when a protocol is selected.
311 * @param user_data Data to pass to the callback function.
313 * @return The drop-down option menu.
315 GtkWidget *pidgin_protocol_option_menu_new(const char *id,
316 GCallback cb,
317 gpointer user_data);
320 * Gets the currently selected protocol from a protocol drop down box.
322 * @param optmenu The drop-down option menu created by
323 * pidgin_account_option_menu_new.
324 * @return Returns the protocol ID that is currently selected.
326 const char *pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu);
329 * Creates a drop-down option menu filled with accounts.
331 * @param default_account The account to select by default.
332 * @param show_all Whether or not to show all accounts, or just
333 * active accounts.
334 * @param cb The callback to call when an account is selected.
335 * @param filter_func A function for checking if an account should
336 * be shown. This can be NULL.
337 * @param user_data Data to pass to the callback function.
339 * @return The drop-down option menu.
341 GtkWidget *pidgin_account_option_menu_new(PurpleAccount *default_account,
342 gboolean show_all, GCallback cb,
343 PurpleFilterAccountFunc filter_func, gpointer user_data);
346 * Gets the currently selected account from an account drop down box.
348 * @param optmenu The drop-down option menu created by
349 * pidgin_account_option_menu_new.
350 * @return Returns the PurpleAccount that is currently selected.
352 PurpleAccount *pidgin_account_option_menu_get_selected(GtkWidget *optmenu);
355 * Sets the currently selected account for an account drop down box.
357 * @param optmenu The GtkOptionMenu created by
358 * pidgin_account_option_menu_new.
359 * @param account The PurpleAccount to select.
361 void pidgin_account_option_menu_set_selected(GtkWidget *optmenu, PurpleAccount *account);
364 * Add autocompletion of screenames to an entry, supporting a filtering function.
366 * @param entry The GtkEntry on which to setup autocomplete.
367 * @param optmenu A menu for accounts, returned by pidgin_account_option_menu_new().
368 * If @a optmenu is not @c NULL, it'll be updated when a username is chosen
369 * from the autocomplete list.
370 * @param filter_func A function for checking if an autocomplete entry
371 * should be shown. This can be @c NULL.
372 * @param user_data The data to be passed to the filter_func function.
374 void pidgin_setup_screenname_autocomplete_with_filter(GtkWidget *entry, GtkWidget *optmenu, PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data);
377 * The default filter function for username autocomplete.
379 * @param completion_entry The completion entry to filter.
380 * @param all_accounts If this is @c FALSE, only the autocompletion entries
381 * which belong to an online account will be filtered.
382 * @return Returns @c TRUE if the autocompletion entry is filtered.
384 gboolean pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts);
387 * Add autocompletion of screenames to an entry.
389 * @deprecated
390 * For new code, use the equivalent:
391 * #pidgin_setup_screenname_autocomplete_with_filter(@a entry, @a optmenu,
392 * #pidgin_screenname_autocomplete_default_filter, <tt>GINT_TO_POINTER(@a
393 * all)</tt>)
395 * @param entry The GtkEntry on which to setup autocomplete.
396 * @param optmenu A menu for accounts, returned by
397 * pidgin_account_option_menu_new(). If @a optmenu is not @c
398 * NULL, it'll be updated when a username is chosen from the
399 * autocomplete list.
400 * @param all Whether to include usernames from disconnected accounts.
402 void pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *optmenu, gboolean all);
405 * Check if the given path is a directory or not. If it is, then modify
406 * the given GtkFileSelection dialog so that it displays the given path.
407 * If the given path is not a directory, then do nothing.
409 * @param path The path entered in the file selection window by the user.
410 * @param filesel The file selection window.
412 * @return TRUE if given path is a directory, FALSE otherwise.
413 * @deprecated Pidgin no longer uses GtkFileSelection internally. It has also
414 * been deprecated by GTK+. Use GtkFileChooser instead and ignore
415 * this function.
417 gboolean pidgin_check_if_dir(const char *path, GtkFileSelection *filesel);
420 * Sets up GtkSpell for the given GtkTextView, reporting errors
421 * if encountered.
423 * This does nothing if Pidgin is not compiled with GtkSpell support.
425 * @param textview The textview widget to setup spellchecking for.
427 void pidgin_setup_gtkspell(GtkTextView *textview);
430 * Save menu accelerators callback
432 void pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
433 GdkModifierType arg2, GClosure *arg3,
434 gpointer data);
437 * Save menu accelerators
439 gboolean pidgin_save_accels(gpointer data);
442 * Load menu accelerators
444 void pidgin_load_accels(void);
447 * Get information about a user. Show immediate feedback.
449 * @param conn The connection to get information from.
450 * @param name The user to get information about.
452 * @since 2.1.0
454 void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name);
457 * Get information about a user in a chat. Show immediate feedback.
459 * @param conn The connection to get information from.
460 * @param name The user to get information about.
461 * @param chatid The chat id.
463 * @since 2.1.0
465 void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chatid);
468 * Parses an application/x-im-contact MIME message and returns the
469 * data inside.
471 * @param msg The MIME message.
472 * @param all_accounts If TRUE, check all compatible accounts, online or
473 * offline. If FALSE, check only online accounts.
474 * @param ret_account The best guess at a compatible protocol,
475 * based on ret_protocol. If NULL, no account was found.
476 * @param ret_protocol The returned protocol type.
477 * @param ret_username The returned username.
478 * @param ret_alias The returned alias.
480 * @return TRUE if the message was parsed for the minimum necessary data.
481 * FALSE otherwise.
483 gboolean pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
484 PurpleAccount **ret_account,
485 char **ret_protocol, char **ret_username,
486 char **ret_alias);
489 * Sets an ATK name for a given widget. Also sets the labelled-by
490 * and label-for ATK relationships.
492 * @param w The widget that we want to name.
493 * @param l A GtkLabel that we want to use as the ATK name for the widget.
495 void pidgin_set_accessible_label(GtkWidget *w, GtkWidget *l);
498 * Sets the labelled-by and label-for ATK relationships.
500 * @param w The widget that we want to label.
501 * @param l A GtkLabel that we want to use as the label for the widget.
503 * @since 2.2.0
505 void pidgin_set_accessible_relations(GtkWidget *w, GtkWidget *l);
508 * A helper function for GtkMenuPositionFuncs. This ensures the menu will
509 * be kept on screen if possible.
511 * @param menu The menu we are positioning.
512 * @param x Address of the gint representing the horizontal position
513 * where the menu shall be drawn. This is an output parameter.
514 * @param y Address of the gint representing the vertical position
515 * where the menu shall be drawn. This is an output parameter.
516 * @param push_in This is an output parameter?
517 * @param data Not used by this particular position function.
519 * @since 2.1.0
521 void pidgin_menu_position_func_helper(GtkMenu *menu, gint *x, gint *y,
522 gboolean *push_in, gpointer data);
525 * A valid GtkMenuPositionFunc. This is used to determine where
526 * to draw context menus when the menu is activated with the
527 * keyboard (shift+F10). If the menu is activated with the mouse,
528 * then you should just use GTK's built-in position function,
529 * because it does a better job of positioning the menu.
531 * @param menu The menu we are positioning.
532 * @param x Address of the gint representing the horizontal position
533 * where the menu shall be drawn. This is an output parameter.
534 * @param y Address of the gint representing the vertical position
535 * where the menu shall be drawn. This is an output parameter.
536 * @param push_in This is an output parameter?
537 * @param user_data Not used by this particular position function.
539 void pidgin_treeview_popup_menu_position_func(GtkMenu *menu,
540 gint *x,
541 gint *y,
542 gboolean *push_in,
543 gpointer user_data);
546 * Manages drag'n'drop of files.
548 * @param sd GtkSelectionData for managing drag'n'drop
549 * @param account Account to be used (may be NULL if conv is not NULL)
550 * @param who Buddy name (may be NULL if conv is not NULL)
552 void pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who);
555 * Convenience wrapper for purple_buddy_icon_get_scale_size
557 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height);
560 * Returns the base image to represent the account, based on
561 * the currently selected theme.
563 * @param account The account.
564 * @param size The size of the icon to return.
566 * @return A newly-created pixbuf with a reference count of 1,
567 * or NULL if any of several error conditions occurred:
568 * the file could not be opened, there was no loader
569 * for the file's format, there was not enough memory
570 * to allocate the image buffer, or the image file
571 * contained invalid data.
573 GdkPixbuf *pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size);
576 * Creates a status icon for a given primitve
578 * @param primitive The status primitive
579 * @param w The widget to render this
580 * @param size The icon size to render at
581 * @return A GdkPixbuf, created from stock
583 GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size);
586 * Returns an appropriate stock-id for a status primitive.
588 * @param prim The status primitive
590 * @return The stock-id
592 * @since 2.6.0
594 const char *pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim);
597 * Returns an appropriate stock-id for a PurplePresence.
599 * @param presence The presence.
601 * @return The stock-id
603 * @since 2.6.0
605 const char *pidgin_stock_id_from_presence(PurplePresence *presence);
608 * Append a PurpleMenuAction to a menu.
610 * @param menu The menu to append to.
611 * @param act The PurpleMenuAction to append.
612 * @param gobject The object to be passed to the action callback.
614 * @return The menuitem added.
616 GtkWidget *pidgin_append_menu_action(GtkWidget *menu, PurpleMenuAction *act,
617 gpointer gobject);
620 * Sets the mouse pointer for a GtkWidget.
622 * After setting the cursor, the display is flushed, so the change will
623 * take effect immediately.
625 * If the window for @a widget is @c NULL, this function simply returns.
627 * @param widget The widget for which to set the mouse pointer
628 * @param cursor_type The type of cursor to set
630 void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type);
633 * Sets the mouse point for a GtkWidget back to that of its parent window.
635 * If @a widget is @c NULL, this function simply returns.
637 * If the window for @a widget is @c NULL, this function simply returns.
639 * @note The display is not flushed from this function.
641 void pidgin_clear_cursor(GtkWidget *widget);
644 * Creates a File Selection widget for choosing a buddy icon
646 * @param parent The parent window
647 * @param callback The callback to call when the window is closed. If the user chose an icon, the char* argument will point to its path
648 * @param data Data to pass to @a callback
649 * @return The file dialog
651 GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data);
654 * Converts a buddy icon to the required size and format
656 * @param plugin The prpl to convert the icon
657 * @param path The path of a file to convert
658 * @param len If not @c NULL, the length of the returned data will be set here.
660 * @return The converted image data, or @c NULL if an error occurred.
662 gpointer pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len);
664 #if !(defined PIDGIN_DISABLE_DEPRECATED) || (defined _PIDGIN_GTKUTILS_C_)
666 * Set or unset a custom buddyicon for a user.
668 * @param account The account the user belongs to.
669 * @param who The name of the user.
670 * @param filename The path of the custom icon. If this is @c NULL, then any
671 * previously set custom buddy icon for the user is removed.
672 * @deprecated See purple_buddy_icons_node_set_custom_icon_from_file()
674 void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename);
675 #endif
678 * Converts "->" and "<-" in strings to Unicode arrow characters, for use in referencing
679 * menu items.
681 * @param str The text to convert
682 * @return A newly allocated string with unicode arrow characters
684 char *pidgin_make_pretty_arrows(const char *str);
687 * The type of callbacks passed to pidgin_make_mini_dialog().
689 typedef void (*PidginUtilMiniDialogCallback)(gpointer user_data, GtkButton *);
692 * Creates a #PidginMiniDialog, tied to a #PurpleConnection, suitable for
693 * embedding in the buddy list scrollbook with pidgin_blist_add_alert().
695 * @param handle The #PurpleConnection to which this mini-dialog
696 * refers, or @c NULL if it does not refer to a
697 * connection. If @a handle is supplied, the mini-dialog
698 * will be automatically removed and destroyed when the
699 * connection signs off.
700 * @param stock_id The ID of a stock image to use in the mini dialog.
701 * @param primary The primary text
702 * @param secondary The secondary text, or @c NULL for no description.
703 * @param user_data Data to pass to the callbacks
704 * @param ... a <tt>NULL</tt>-terminated list of button labels
705 * (<tt>char *</tt>) and callbacks
706 * (#PidginUtilMiniDialogCallback). @a user_data will be
707 * passed as the first argument. (Callbacks may lack a
708 * second argument, or be @c NULL to take no action when
709 * the corresponding button is pressed.) When a button is
710 * pressed, the callback (if any) will be called; when
711 * the callback returns the dialog will be destroyed.
712 * @return A #PidginMiniDialog, suitable for passing to
713 * pidgin_blist_add_alert().
714 * @see pidginstock.h
716 GtkWidget *pidgin_make_mini_dialog(PurpleConnection *handle,
717 const char* stock_id, const char *primary, const char *secondary,
718 void *user_data, ...) G_GNUC_NULL_TERMINATED;
721 * Does exactly what pidgin_make_mini_dialog() does, except you can specify
722 * a custom icon for the dialog.
724 GtkWidget *pidgin_make_mini_dialog_with_custom_icon(PurpleConnection *gc,
725 GdkPixbuf *custom_icon,
726 const char *primary,
727 const char *secondary,
728 void *user_data,
729 ...) G_GNUC_NULL_TERMINATED;
732 * This is a callback function to be used for Ctrl+F searching in treeviews.
733 * Sample Use:
734 * gtk_tree_view_set_search_equal_func(treeview,
735 * pidgin_tree_view_search_equal_func,
736 * search_data, search_data_destroy_cb);
739 gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
740 const gchar *key, GtkTreeIter *iter, gpointer data);
743 * Sets or resets a window to 'urgent,' by setting the URGENT hint in X
744 * or blinking in the win32 taskbar
746 * @param window The window to draw attention to
747 * @param urgent Whether to set the urgent hint or not
749 void pidgin_set_urgent(GtkWindow *window, gboolean urgent);
752 * Returns TRUE if the GdkPixbuf is opaque, as determined by no
753 * alpha at any of the edge pixels.
755 * @param pixbuf The pixbug
756 * @return TRUE if the pixbuf is opaque around the edges, FALSE otherwise
758 gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf);
761 * Rounds the corners of a 32x32 GdkPixbuf in place
763 * @param pixbuf The buddy icon to transform
765 void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf);
768 * Returns an HTML-style color string for use as a dim grey
769 * string
771 * @param widget The widget to return dim grey for
772 * @return The dim grey string
774 const char *pidgin_get_dim_grey_string(GtkWidget *widget);
777 * Create a simple text GtkComboBoxEntry equivalent
779 * @param default_item Initial contents of GtkEntry
780 * @param items GList containing strings to add to GtkComboBox
782 * @return A newly created text GtkComboBox containing a GtkEntry
783 * child.
785 * @since 2.2.0
787 GtkWidget *pidgin_text_combo_box_entry_new(const char *default_item, GList *items);
790 * Retrieve the text from the entry of the simple text GtkComboBoxEntry equivalent
792 * @param widget The simple text GtkComboBoxEntry equivalent widget
794 * @return The text in the widget's entry. It must not be freed
796 * @since 2.2.0
798 const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget);
801 * Set the text in the entry of the simple text GtkComboBoxEntry equivalent
803 * @param widget The simple text GtkComboBoxEntry equivalent widget
804 * @param text The text to set
806 * @since 2.2.0
808 void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text);
811 * Automatically make a window transient to a suitable parent window.
813 * @param window The window to make transient.
815 * @return Whether the window was made transient or not.
817 * @since 2.4.0
819 gboolean pidgin_auto_parent_window(GtkWidget *window);
822 * Add a labelled widget to a GtkVBox
824 * @param vbox The GtkVBox to add the widget to.
825 * @param widget_label The label to give the widget, can be @c NULL.
826 * @param sg The GtkSizeGroup to add the label to, can be @c NULL.
827 * @param widget The GtkWidget to add.
828 * @param expand Whether to expand the widget horizontally.
829 * @param p_label Place to store a pointer to the GtkLabel, or @c NULL if you don't care.
831 * @return A GtkHBox already added to the GtkVBox containing the GtkLabel and the GtkWidget.
832 * @since 2.4.0
834 GtkWidget *pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label);
837 * Create a GdkPixbuf from a chunk of image data.
839 * @param buf The raw binary image data.
840 * @param count The length of buf in bytes.
842 * @return A GdkPixbuf created from the image data, or NULL if
843 * there was an error parsing the data.
845 * @since 2.9.0
847 GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count);
850 * Create a GdkPixbufAnimation from a chunk of image data.
852 * @param buf The raw binary image data.
853 * @param count The length of buf in bytes.
855 * @return A GdkPixbufAnimation created from the image data, or NULL if
856 * there was an error parsing the data.
858 * @since 2.9.0
860 GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count);
863 * Create a GdkPixbuf from a PurpleStoredImage.
865 * @param image A PurpleStoredImage.
867 * @return A GdkPixbuf created from the stored image.
869 * @since 2.5.0
871 GdkPixbuf *pidgin_pixbuf_from_imgstore(PurpleStoredImage *image);
874 * Helper function that calls gdk_pixbuf_new_from_file() and checks both
875 * the return code and the GError and returns NULL if either one failed.
877 * The gdk-pixbuf documentation implies that it is sufficient to check
878 * the return value of gdk_pixbuf_new_from_file() to determine
879 * whether the image was able to be loaded. However, this is not the case
880 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
881 * cases a GdkPixbuf object is returned that will cause some operations
882 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
883 * infinite loop.
885 * This function shouldn't be necessary once Pidgin requires a version of
886 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
887 * nice to keep this function around for the debug message that it logs.
889 * @param filename Name of file to load, in the GLib file name encoding
891 * @return The GdkPixbuf if successful. Otherwise NULL is returned and
892 * a warning is logged.
894 * @since 2.9.0
896 GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename);
899 * Helper function that calls gdk_pixbuf_new_from_file_at_size() and checks
900 * both the return code and the GError and returns NULL if either one failed.
902 * The gdk-pixbuf documentation implies that it is sufficient to check
903 * the return value of gdk_pixbuf_new_from_file_at_size() to determine
904 * whether the image was able to be loaded. However, this is not the case
905 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
906 * cases a GdkPixbuf object is returned that will cause some operations
907 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
908 * infinite loop.
910 * This function shouldn't be necessary once Pidgin requires a version of
911 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
912 * nice to keep this function around for the debug message that it logs.
914 * @param filename Name of file to load, in the GLib file name encoding
915 * @param width The width the image should have or -1 to not constrain the width
916 * @param height The height the image should have or -1 to not constrain the height
918 * @return The GdkPixbuf if successful. Otherwise NULL is returned and
919 * a warning is logged.
921 * @since 2.9.0
923 GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height);
926 * Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks
927 * both the return code and the GError and returns NULL if either one failed.
929 * The gdk-pixbuf documentation implies that it is sufficient to check
930 * the return value of gdk_pixbuf_new_from_file_at_scale() to determine
931 * whether the image was able to be loaded. However, this is not the case
932 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
933 * cases a GdkPixbuf object is returned that will cause some operations
934 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
935 * infinite loop.
937 * This function shouldn't be necessary once Pidgin requires a version of
938 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
939 * nice to keep this function around for the debug message that it logs.
941 * @param filename Name of file to load, in the GLib file name encoding
942 * @param width The width the image should have or -1 to not constrain the width
943 * @param height The height the image should have or -1 to not constrain the height
944 * @param preserve_aspect_ratio TRUE to preserve the image's aspect ratio
946 * @return The GdkPixbuf if successful. Otherwise NULL is returned and
947 * a warning is logged.
949 * @since 2.9.0
951 GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio);
954 * Add scrollbars to a widget
955 * @param widget The child widget
956 * @hscrollbar_policy Horizontal scrolling policy
957 * @vscrollbar_policy Vertical scrolling policy
958 * @shadow Shadow type
959 * @width Desired widget width, or -1 for default
960 * @height Desired widget height, or -1 for default
962 * @since 2.8.0
964 GtkWidget *pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int height);
967 * Initialize some utility functions.
969 * @since 2.6.0
971 void pidgin_utils_init(void);
974 * Uninitialize some utility functions.
976 * @since 2.6.0
978 void pidgin_utils_uninit(void);
980 #endif /* _PIDGINUTILS_H_ */