Fix broken `priv != NULL` checks in Pidgin.
[pidgin-git.git] / pidgin / gtkutils.h
blob7819084825f4ce69a9fadcc7b564b890b8e58875
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 _PIDGINUTILS_H_
23 #define _PIDGINUTILS_H_
24 /**
25 * SECTION:gtkutils
26 * @section_id: pidgin-gtkutils
27 * @short_description: <filename>gtkutils.h</filename>
28 * @title: Utility functions
31 #include "gtkconv.h"
32 #include "pidgin.h"
33 #include "action.h"
34 #include "protocol.h"
35 #include "util.h"
37 typedef enum
39 PIDGIN_BUTTON_HORIZONTAL,
40 PIDGIN_BUTTON_VERTICAL
42 } PidginButtonOrientation;
44 typedef enum
46 PIDGIN_BUTTON_NONE = 0,
47 PIDGIN_BUTTON_TEXT,
48 PIDGIN_BUTTON_IMAGE,
49 PIDGIN_BUTTON_TEXT_IMAGE
51 } PidginButtonStyle;
53 typedef enum
55 PIDGIN_PROTOCOL_ICON_SMALL,
56 PIDGIN_PROTOCOL_ICON_MEDIUM,
57 PIDGIN_PROTOCOL_ICON_LARGE
58 } PidginProtocolIconSize;
60 #ifndef _WIN32
61 typedef enum
63 PIDGIN_BROWSER_DEFAULT = 0,
64 /* value '1' was used by PIDGIN_BROWSER_CURRENT, which no longer exists */
65 PIDGIN_BROWSER_NEW_WINDOW = 2,
66 PIDGIN_BROWSER_NEW_TAB
68 } PidginBrowserPlace;
69 #endif /* _WIN32 */
71 typedef struct {
72 gboolean is_buddy;
73 union {
74 PurpleBuddy *buddy;
75 PurpleLogSet *logged_buddy;
76 } entry;
77 } PidginBuddyCompletionEntry;
79 typedef gboolean (*PidginFilterBuddyCompletionEntryFunc) (const PidginBuddyCompletionEntry *completion_entry, gpointer user_data);
82 G_BEGIN_DECLS
84 /**
85 * pidgin_create_small_button:
86 * @image: A button image.
88 * Creates a small button
90 * Returns: (transfer full): A GtkButton created from the image.
92 GtkWidget *pidgin_create_small_button(GtkWidget *image);
94 /**
95 * pidgin_create_window:
96 * @title: The window title, or %NULL
97 * @border_width: The window's desired border width
98 * @role: A string indicating what the window is responsible for doing, or %NULL
99 * @resizable: Whether the window should be resizable (%TRUE) or not (%FALSE)
101 * Creates a new window
103 * Returns: (transfer full): A new window.
105 GtkWidget *pidgin_create_window(const char *title, guint border_width, const char *role, gboolean resizable);
108 * pidgin_create_dialog:
109 * @title: The window title, or %NULL
110 * @border_width: The window's desired border width
111 * @role: A string indicating what the window is responsible for doing, or %NULL
112 * @resizable: Whether the window should be resizable (%TRUE) or not (%FALSE)
114 * Creates a new dialog window
116 * Returns: (transfer full): A new dialog window.
118 GtkWidget *pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable);
121 * pidgin_create_video_widget:
123 * Creates a new drawing area suitable for displaying a video
125 * Returns: (transfer full): A new drawing area for displaying video.
127 GtkWidget *pidgin_create_video_widget(void);
130 * pidgin_dialog_get_vbox_with_properties:
131 * @dialog: The dialog window
132 * @homogeneous: TRUE if all children are to be given equal space allotments.
133 * @spacing: the number of pixels to place by default between children
135 * Retrieves the main content box (vbox) from a pidgin dialog window
137 * Returns: (transfer none): The main vbox from @dialog.
139 GtkWidget *pidgin_dialog_get_vbox_with_properties(GtkDialog *dialog, gboolean homogeneous, gint spacing);
142 * pidgin_dialog_get_vbox:
143 * @dialog: The dialog window
145 * Retrieves the main content box (vbox) from a pidgin dialog window
147 * Returns: (transfer none): the main vbox from @dialog.
149 GtkWidget *pidgin_dialog_get_vbox(GtkDialog *dialog);
152 * pidgin_dialog_add_button:
153 * @dialog: The dialog window
154 * @label: The stock-id or the label for the button
155 * @callback: (scope call): The callback function for the button
156 * @callbackdata: The user data for the callback function
158 * Add a button to a dialog created by #pidgin_create_dialog.
160 * Returns: (transfer full): The created button.
162 GtkWidget *pidgin_dialog_add_button(GtkDialog *dialog, const char *label,
163 GCallback callback, gpointer callbackdata);
166 * pidgin_dialog_get_action_area:
167 * @dialog: The dialog window
169 * Retrieves the action area (button box) from a pidgin dialog window
171 * Returns: (transfer none): The action area (button box) from @dialog.
173 GtkWidget *pidgin_dialog_get_action_area(GtkDialog *dialog);
176 * pidgin_set_sensitive_if_input:
177 * @entry: The text entry widget.
178 * @dialog: The dialog containing the text entry widget.
180 * Checks if text has been entered into a GtkTextEntry widget. If
181 * so, the GTK_RESPONSE_OK on the given dialog is set to TRUE.
182 * Otherwise GTK_RESPONSE_OK is set to FALSE.
184 void pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog);
187 * pidgin_separator:
188 * @menu: The menu to add a separator to.
190 * Adds a separator to a menu.
192 * Returns: (transfer full): The separator.
194 GtkWidget *pidgin_separator(GtkWidget *menu);
197 * pidgin_new_check_item:
198 * @menu: The menu to which to append the check menu item.
199 * @str: The title to use for the newly created menu item.
200 * @cb: (scope call): A function to call when the menu item is activated.
201 * @data: Data to pass to the signal function.
202 * @checked: The initial state of the check item
204 * Creates a check menu item.
206 * Returns: (transfer full): The newly created menu item.
208 GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str,
209 GCallback cb, gpointer data, gboolean checked);
212 * pidgin_new_menu_item:
213 * @menu: The menu to which to append the menu item.
214 * @mnemonic: The title for the menu item.
215 * @icon: An icon to place to the left of the menu item,
216 * or %NULL for no icon.
217 * @cb: (scope call): A function to call when the menu item is activated.
218 * @data: Data to pass to the signal function.
220 * Creates a menu item.
222 * Returns: (transfer full): The newly created menu item.
224 GtkWidget *pidgin_new_menu_item(GtkWidget *menu, const char *mnemonic,
225 const char *icon, GCallback cb, gpointer data);
228 * pidgin_pixbuf_button_from_stock:
229 * @text: The text for the button.
230 * @icon: The stock icon name.
231 * @style: The orientation of the button.
233 * Creates a button with the specified text and stock icon.
235 * Returns: (transfer full): The button.
237 GtkWidget *pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
238 PidginButtonOrientation style);
241 * pidgin_pixbuf_toolbar_button_from_stock:
242 * @stock: The stock icon name.
244 * Creates a toolbar button with the stock icon.
246 * Returns: (transfer full): The button.
248 GtkWidget *pidgin_pixbuf_toolbar_button_from_stock(const char *stock);
251 * pidgin_make_frame:
252 * @parent: The widget to put the frame into.
253 * @title: The title for the frame.
255 * Creates a HIG preferences frame.
257 * Returns: (transfer full): The vbox to put things into.
259 GtkWidget *pidgin_make_frame(GtkWidget *parent, const char *title);
262 * pidgin_protocol_option_menu_new:
263 * @id: The protocol to select by default.
264 * @cb: (scope call): The callback to call when a protocol is selected.
265 * @user_data: Data to pass to the callback function.
267 * Creates a drop-down option menu filled with protocols.
269 * Returns: (transfer full): The drop-down option menu.
271 GtkWidget *pidgin_protocol_option_menu_new(const char *id,
272 GCallback cb,
273 gpointer user_data);
276 * pidgin_protocol_option_menu_get_selected:
277 * @optmenu: The drop-down option menu created by
278 * pidgin_account_option_menu_new.
280 * Gets the currently selected protocol from a protocol drop down box.
282 * Returns: Returns the protocol ID that is currently selected.
284 const char *pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu);
287 * pidgin_account_option_menu_new:
288 * @default_account: The account to select by default.
289 * @show_all: Whether or not to show all accounts, or just
290 * active accounts.
291 * @cb: (scope call): The callback to call when an account is selected.
292 * @filter_func: (scope call): A function for checking if an account should
293 * be shown. This can be NULL.
294 * @user_data: Data to pass to the callback function.
296 * Creates a drop-down option menu filled with accounts.
298 * Returns: (transfer full): The drop-down option menu.
300 GtkWidget *pidgin_account_option_menu_new(PurpleAccount *default_account,
301 gboolean show_all, GCallback cb,
302 PurpleFilterAccountFunc filter_func, gpointer user_data);
305 * pidgin_account_option_menu_get_selected:
306 * @optmenu: The drop-down option menu created by
307 * pidgin_account_option_menu_new.
309 * Gets the currently selected account from an account drop down box.
311 * Returns: (transfer none): Returns the PurpleAccount that is currently selected.
313 PurpleAccount *pidgin_account_option_menu_get_selected(GtkWidget *optmenu);
316 * pidgin_account_option_menu_set_selected:
317 * @optmenu: The GtkOptionMenu created by
318 * pidgin_account_option_menu_new.
319 * @account: The PurpleAccount to select.
321 * Sets the currently selected account for an account drop down box.
323 void pidgin_account_option_menu_set_selected(GtkWidget *optmenu, PurpleAccount *account);
326 * pidgin_setup_screenname_autocomplete:
327 * @entry: The GtkEntry on which to setup autocomplete.
328 * @optmenu: A menu for accounts, returned by pidgin_account_option_menu_new().
329 * If @optmenu is not %NULL, it'll be updated when a username is chosen
330 * from the autocomplete list.
331 * @filter_func: (scope call): A function for checking if an autocomplete entry
332 * should be shown. This can be %NULL.
333 * @user_data: The data to be passed to the filter_func function.
335 * Add autocompletion of screenames to an entry, supporting a filtering function.
337 void pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *optmenu, PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data);
340 * pidgin_screenname_autocomplete_default_filter:
341 * @completion_entry: The completion entry to filter.
342 * @all_accounts: If this is %FALSE, only the autocompletion entries
343 * which belong to an online account will be filtered.
345 * The default filter function for username autocomplete.
347 * Returns: Returns %TRUE if the autocompletion entry is filtered.
349 gboolean pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts);
352 * pidgin_save_accels_cb:
354 * Save menu accelerators callback
356 void pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
357 GdkModifierType arg2, GClosure *arg3,
358 gpointer data);
361 * pidgin_save_accels:
363 * Save menu accelerators
365 gboolean pidgin_save_accels(gpointer data);
368 * pidgin_load_accels:
370 * Load menu accelerators
372 void pidgin_load_accels(void);
375 * pidgin_retrieve_user_info:
376 * @conn: The connection to get information from.
377 * @name: The user to get information about.
379 * Get information about a user. Show immediate feedback.
381 void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name);
384 * pidgin_retrieve_user_info_in_chat:
385 * @conn: The connection to get information from.
386 * @name: The user to get information about.
387 * @chatid: The chat id.
389 * Get information about a user in a chat. Show immediate feedback.
391 void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chatid);
394 * pidgin_parse_x_im_contact:
395 * @msg: The MIME message.
396 * @all_accounts: If TRUE, check all compatible accounts, online or
397 * offline. If FALSE, check only online accounts.
398 * @ret_account: The best guess at a compatible protocol,
399 * based on ret_protocol. If NULL, no account was found.
400 * @ret_protocol: The returned protocol type.
401 * @ret_username: The returned username.
402 * @ret_alias: The returned alias.
404 * Parses an application/x-im-contact MIME message and returns the
405 * data inside.
407 * Returns: TRUE if the message was parsed for the minimum necessary data.
408 * FALSE otherwise.
410 gboolean pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
411 PurpleAccount **ret_account,
412 char **ret_protocol, char **ret_username,
413 char **ret_alias);
416 * pidgin_set_accessible_label:
417 * @w: The widget that we want to name.
418 * @l: A GtkLabel that we want to use as the ATK name for the widget.
420 * Sets an ATK name for a given widget. Also sets the labelled-by
421 * and label-for ATK relationships.
423 void pidgin_set_accessible_label(GtkWidget *w, GtkLabel *l);
426 * pidgin_set_accessible_relations:
427 * @w: The widget that we want to label.
428 * @l: A GtkLabel that we want to use as the label for the widget.
430 * Sets the labelled-by and label-for ATK relationships.
432 void pidgin_set_accessible_relations(GtkWidget *w, GtkLabel *l);
435 * pidgin_menu_position_func_helper:
436 * @menu: The menu we are positioning.
437 * @x: Address of the gint representing the horizontal position
438 * where the menu shall be drawn. This is an output parameter.
439 * @y: Address of the gint representing the vertical position
440 * where the menu shall be drawn. This is an output parameter.
441 * @push_in: This is an output parameter?
442 * @data: Not used by this particular position function.
444 * A helper function for GtkMenuPositionFuncs. This ensures the menu will
445 * be kept on screen if possible.
447 void pidgin_menu_position_func_helper(GtkMenu *menu, gint *x, gint *y,
448 gboolean *push_in, gpointer data);
451 * pidgin_menu_popup_at_treeview_selection:
452 * @menu: The menu to show.
453 * @treeview: The treeview to use for positioning.
455 * Open a menu popup at the position determined by the selection of a given
456 * treeview. This function is similar to @gtk_menu_popup_at_pointer, but should
457 * be used when the menu is activated via a keyboard shortcut.
459 void pidgin_menu_popup_at_treeview_selection(GtkWidget *menu, GtkWidget *treeview);
462 * pidgin_dnd_file_manage:
463 * @sd: GtkSelectionData for managing drag'n'drop
464 * @account: Account to be used (may be NULL if conv is not NULL)
465 * @who: Buddy name (may be NULL if conv is not NULL)
467 * Manages drag'n'drop of files.
469 void pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who);
472 * pidgin_buddy_icon_get_scale_size:
474 * Convenience wrapper for purple_buddy_icon_spec_get_scaled_size
476 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleBuddyIconScaleFlags rules, int *width, int *height);
479 * pidgin_create_protocol_icon:
480 * @account: The account.
481 * @size: The size of the icon to return.
483 * Returns the base image to represent the account, based on
484 * the currently selected theme.
486 * Returns: (transfer full): A newly-created pixbuf with a reference count of 1,
487 * or NULL if any of several error conditions occurred:
488 * the file could not be opened, there was no loader
489 * for the file's format, there was not enough memory
490 * to allocate the image buffer, or the image file
491 * contained invalid data.
493 GdkPixbuf *pidgin_create_protocol_icon(PurpleAccount *account, PidginProtocolIconSize size);
496 * pidgin_create_status_icon:
497 * @primitive: The status primitive
498 * @w: The widget to render this
499 * @size: The icon size to render at
501 * Creates a status icon for a given primitve
503 * Returns: (transfer full): A GdkPixbuf, created from stock
505 GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size);
508 * pidgin_stock_id_from_status_primitive:
509 * @prim: The status primitive
511 * Returns an appropriate stock-id for a status primitive.
513 * Returns: The stock-id
515 const char *pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim);
518 * pidgin_stock_id_from_presence:
519 * @presence: The presence.
521 * Returns an appropriate stock-id for a PurplePresence.
523 * Returns: The stock-id
525 const char *pidgin_stock_id_from_presence(PurplePresence *presence);
528 * pidgin_append_menu_action:
529 * @menu: The menu to append to.
530 * @act: The PurpleActionMenu to append.
531 * @gobject: The object to be passed to the action callback.
533 * Append a PurpleActionMenu to a menu.
535 * Returns: (transfer full): The menuitem added.
537 GtkWidget *pidgin_append_menu_action(GtkWidget *menu, PurpleActionMenu *act,
538 gpointer gobject);
541 * pidgin_set_cursor:
542 * @widget: The widget for which to set the mouse pointer
543 * @cursor_type: The type of cursor to set
545 * Sets the mouse pointer for a GtkWidget.
547 * After setting the cursor, the display is flushed, so the change will
548 * take effect immediately.
550 * If the window for @widget is %NULL, this function simply returns.
552 void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type);
555 * pidgin_clear_cursor:
557 * Sets the mouse point for a GtkWidget back to that of its parent window.
559 * If @widget is %NULL, this function simply returns.
561 * If the window for @widget is %NULL, this function simply returns.
563 * Note: The display is not flushed from this function.
565 void pidgin_clear_cursor(GtkWidget *widget);
568 * pidgin_buddy_icon_chooser_new:
569 * @parent: The parent window
570 * @callback: The callback to call when the window is closed. If the user chose an icon, the char* argument will point to its path
571 * @data: Data to pass to @callback
573 * Creates a File Selection widget for choosing a buddy icon
575 * Returns: (transfer full): The file dialog
577 GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data);
580 * pidgin_convert_buddy_icon:
581 * @protocol: The protocol to convert the icon
582 * @path: The path of a file to convert
583 * @len: If not %NULL, the length of the returned data will be set here.
585 * Converts a buddy icon to the required size and format
587 * Returns: The converted image data, or %NULL if an error occurred.
589 gpointer pidgin_convert_buddy_icon(PurpleProtocol *protocol, const char *path, size_t *len);
592 * PidginUtilMiniDialogCallback:
594 * The type of callbacks passed to pidgin_make_mini_dialog().
596 typedef void (*PidginUtilMiniDialogCallback)(gpointer user_data, GtkButton *button);
599 * pidgin_make_mini_dialog:
600 * @handle: The #PurpleConnection to which this mini-dialog
601 * refers, or %NULL if it does not refer to a
602 * connection. If @handle is supplied, the mini-dialog
603 * will be automatically removed and destroyed when the
604 * connection signs off.
605 * @stock_id: The ID of a stock image to use in the mini dialog.
606 * @primary: The primary text
607 * @secondary: The secondary text, or %NULL for no description.
608 * @user_data: Data to pass to the callbacks
609 * @...: a %NULL-terminated list of button labels
610 * (<type>char *</type>) and callbacks
611 * (#PidginUtilMiniDialogCallback). @user_data will be
612 * passed as the first argument. (Callbacks may lack a
613 * second argument, or be %NULL to take no action when
614 * the corresponding button is pressed.) When a button is
615 * pressed, the callback (if any) will be called; when
616 * the callback returns the dialog will be destroyed.
618 * Creates a #PidginMiniDialog, tied to a #PurpleConnection, suitable for
619 * embedding in the buddy list scrollbook with pidgin_blist_add_alert().
621 * See <link linkend="pidgin-pidginstock">Stock Resources</link>.
623 * Returns: (transfer full): A #PidginMiniDialog, suitable for passing to
624 * pidgin_blist_add_alert().
626 GtkWidget *pidgin_make_mini_dialog(PurpleConnection *handle,
627 const char* stock_id, const char *primary, const char *secondary,
628 void *user_data, ...) G_GNUC_NULL_TERMINATED;
631 * pidgin_make_mini_dialog_with_custom_icon:
632 * @custom_icon: A custom GdkPixbuf to use.
633 * @primary: The primary text
634 * @secondary: The secondary text, or %NULL for no description.
635 * @user_data: Data to pass to the callbacks
636 * @...: a %NULL-terminated list of button labels
637 * (<type>char *</type>) and callbacks
638 * (#PidginUtilMiniDialogCallback). @user_data will be
639 * passed as the first argument. (Callbacks may lack a
640 * second argument, or be %NULL to take no action when
641 * the corresponding button is pressed.) When a button is
642 * pressed, the callback (if any) will be called; when
643 * the callback returns the dialog will be destroyed.
645 * Does exactly what pidgin_make_mini_dialog() does, except you can specify
646 * a custom icon for the dialog.
648 * Returns: (transfer full): A #PidginMiniDialog, suitable for passing to
649 * pidgin_blist_add_alert().
651 GtkWidget *pidgin_make_mini_dialog_with_custom_icon(PurpleConnection *gc,
652 GdkPixbuf *custom_icon,
653 const char *primary,
654 const char *secondary,
655 void *user_data,
656 ...) G_GNUC_NULL_TERMINATED;
659 * pidgin_tree_view_search_equal_func:
661 * This is a callback function to be used for Ctrl+F searching in treeviews.
662 * Sample Use:
663 * gtk_tree_view_set_search_equal_func(treeview,
664 * pidgin_tree_view_search_equal_func,
665 * search_data, search_data_destroy_cb);
668 gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
669 const gchar *key, GtkTreeIter *iter, gpointer data);
672 * pidgin_set_urgent:
673 * @window: The window to draw attention to
674 * @urgent: Whether to set the urgent hint or not
676 * Sets or resets a window to 'urgent,' by setting the URGENT hint in X
677 * or blinking in the win32 taskbar
679 void pidgin_set_urgent(GtkWindow *window, gboolean urgent);
682 * pidgin_get_dim_grey_string:
683 * @widget: The widget to return dim grey for
685 * Returns an HTML-style color string for use as a dim grey
686 * string
688 * Returns: The dim grey string
690 const char *pidgin_get_dim_grey_string(GtkWidget *widget);
693 * pidgin_text_combo_box_entry_new:
694 * @default_item: Initial contents of GtkEntry
695 * @items: (element-type utf8): GList containing strings to add to GtkComboBox
697 * Create a simple text GtkComboBoxEntry equivalent
699 * Returns: (transfer full): A newly created text GtkComboBox containing a GtkEntry
700 * child.
702 GtkWidget *pidgin_text_combo_box_entry_new(const char *default_item, GList *items);
705 * pidgin_text_combo_box_entry_get_text:
706 * @widget: The simple text GtkComboBoxEntry equivalent widget
708 * Retrieve the text from the entry of the simple text GtkComboBoxEntry equivalent
710 * Returns: The text in the widget's entry. It must not be freed
712 const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget);
715 * pidgin_text_combo_box_entry_set_text:
716 * @widget: The simple text GtkComboBoxEntry equivalent widget
717 * @text: The text to set
719 * Set the text in the entry of the simple text GtkComboBoxEntry equivalent
721 void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text);
724 * pidgin_auto_parent_window:
725 * @window: The window to make transient.
727 * Automatically make a window transient to a suitable parent window.
729 * Returns: Whether the window was made transient or not.
731 gboolean pidgin_auto_parent_window(GtkWidget *window);
734 * pidgin_add_widget_to_vbox:
735 * @vbox: The vertically-oriented GtkBox to add the widget to.
736 * @widget_label: The label to give the widget, can be %NULL.
737 * @sg: The GtkSizeGroup to add the label to, can be %NULL.
738 * @widget: The GtkWidget to add.
739 * @expand: Whether to expand the widget horizontally.
740 * @p_label: Place to store a pointer to the GtkLabel, or %NULL if you don't care.
742 * Add a labelled widget to a GtkBox
744 * Returns: (transfer full): A GtkBox already added to the GtkBox containing the GtkLabel and the GtkWidget.
746 GtkWidget *pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label);
749 * pidgin_pixbuf_from_data:
750 * @buf: The raw binary image data.
751 * @count: The length of buf in bytes.
753 * Create a GdkPixbuf from a chunk of image data.
755 * Returns: (transfer full): A GdkPixbuf created from the image data, or NULL if
756 * there was an error parsing the data.
758 GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count);
761 * pidgin_pixbuf_anim_from_data:
762 * @buf: The raw binary image data.
763 * @count: The length of buf in bytes.
765 * Create a GdkPixbufAnimation from a chunk of image data.
767 * Returns: (transfer full): A GdkPixbufAnimation created from the image data, or NULL if
768 * there was an error parsing the data.
770 GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count);
773 * pidgin_pixbuf_from_image:
774 * @image: a PurpleImage.
776 * Create a GdkPixbuf from a PurpleImage.
778 * Returns: (transfer full): a GdkPixbuf created from the @image.
780 GdkPixbuf *
781 pidgin_pixbuf_from_image(PurpleImage *image);
784 * pidgin_pixbuf_new_from_file:
785 * @filename: Name of file to load, in the GLib file name encoding
787 * Helper function that calls gdk_pixbuf_new_from_file() and checks both
788 * the return code and the GError and returns NULL if either one failed.
790 * The gdk-pixbuf documentation implies that it is sufficient to check
791 * the return value of gdk_pixbuf_new_from_file() to determine
792 * whether the image was able to be loaded. However, this is not the case
793 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
794 * cases a GdkPixbuf object is returned that will cause some operations
795 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
796 * infinite loop.
798 * This function shouldn't be necessary once Pidgin requires a version of
799 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
800 * nice to keep this function around for the debug message that it logs.
802 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and
803 * a warning is logged.
805 GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename);
808 * pidgin_pixbuf_new_from_file_at_size:
809 * @filename: Name of file to load, in the GLib file name encoding
810 * @width: The width the image should have or -1 to not constrain the width
811 * @height: The height the image should have or -1 to not constrain the height
813 * Helper function that calls gdk_pixbuf_new_from_file_at_size() and checks
814 * both the return code and the GError and returns NULL if either one failed.
816 * The gdk-pixbuf documentation implies that it is sufficient to check
817 * the return value of gdk_pixbuf_new_from_file_at_size() to determine
818 * whether the image was able to be loaded. However, this is not the case
819 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
820 * cases a GdkPixbuf object is returned that will cause some operations
821 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
822 * infinite loop.
824 * This function shouldn't be necessary once Pidgin requires a version of
825 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
826 * nice to keep this function around for the debug message that it logs.
828 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and
829 * a warning is logged.
831 GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height);
834 * pidgin_pixbuf_new_from_file_at_scale:
835 * @filename: Name of file to load, in the GLib file name encoding
836 * @width: The width the image should have or -1 to not constrain the width
837 * @height: The height the image should have or -1 to not constrain the height
838 * @preserve_aspect_ratio: TRUE to preserve the image's aspect ratio
840 * Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks
841 * both the return code and the GError and returns NULL if either one failed.
843 * The gdk-pixbuf documentation implies that it is sufficient to check
844 * the return value of gdk_pixbuf_new_from_file_at_scale() to determine
845 * whether the image was able to be loaded. However, this is not the case
846 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
847 * cases a GdkPixbuf object is returned that will cause some operations
848 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
849 * infinite loop.
851 * This function shouldn't be necessary once Pidgin requires a version of
852 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
853 * nice to keep this function around for the debug message that it logs.
855 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and
856 * a warning is logged.
858 GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio);
861 * pidgin_pixbuf_scale_down:
862 * @src: The source image.
863 * @max_width: Maximum width in px.
864 * @max_height: Maximum height in px.
865 * @interp_type: Interpolation method.
866 * @preserve_ratio: %TRUE to preserve image's aspect ratio.
868 * Scales the image to the desired dimensions. If image is smaller, it will be
869 * returned without modifications.
871 * If new image is created, @src reference cound will be decreased and new image
872 * with a ref count of 1 will be returned.
874 * Returns: (transfer full): The image with proper sizing. %NULL in case of error.
876 GdkPixbuf *
877 pidgin_pixbuf_scale_down(GdkPixbuf *src, guint max_width, guint max_height,
878 GdkInterpType interp_type, gboolean preserve_ratio);
881 * pidgin_make_scrollable:
882 * @child: The child widget
883 * @hscrollbar_policy: Horizontal scrolling policy
884 * @vscrollbar_policy: Vertical scrolling policy
885 * @shadow_type: Shadow type
886 * @width: Desired widget width, or -1 for default
887 * @height: Desired widget height, or -1 for default
889 * Add scrollbars to a widget
891 * Returns: (transfer full): A scrolled window with @child packed inside of it.
893 GtkWidget *pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int height);
895 G_END_DECLS
897 #endif /* _PIDGINUTILS_H_ */