Replace functions which called once with their bodies
[pidgin-git.git] / pidgin / gtkutils.h
blobda2d43081b20d65467710e7dabddbd7542e6a9b0
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_protocol_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_setup_screenname_autocomplete:
288 * @entry: The GtkEntry on which to setup autocomplete.
289 * @chooser: A menu for accounts, returned by pidgin_account_chooser_new(). If
290 * @chooser is not %NULL, it'll be updated when a username is chosen
291 * from the autocomplete list.
292 * @filter_func: (scope call): A function for checking if an autocomplete entry
293 * should be shown. This can be %NULL.
294 * @user_data: The data to be passed to the filter_func function.
296 * Add autocompletion of screenames to an entry, supporting a filtering
297 * function.
299 void pidgin_setup_screenname_autocomplete(
300 GtkWidget *entry, GtkWidget *chooser,
301 PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data);
304 * pidgin_screenname_autocomplete_default_filter:
305 * @completion_entry: The completion entry to filter.
306 * @all_accounts: If this is %FALSE, only the autocompletion entries
307 * which belong to an online account will be filtered.
309 * The default filter function for username autocomplete.
311 * Returns: Returns %TRUE if the autocompletion entry is filtered.
313 gboolean pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts);
316 * pidgin_save_accels_cb:
318 * Save menu accelerators callback
320 void pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
321 GdkModifierType arg2, GClosure *arg3,
322 gpointer data);
325 * pidgin_save_accels:
327 * Save menu accelerators
329 gboolean pidgin_save_accels(gpointer data);
332 * pidgin_load_accels:
334 * Load menu accelerators
336 void pidgin_load_accels(void);
339 * pidgin_retrieve_user_info:
340 * @conn: The connection to get information from.
341 * @name: The user to get information about.
343 * Get information about a user. Show immediate feedback.
345 void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name);
348 * pidgin_retrieve_user_info_in_chat:
349 * @conn: The connection to get information from.
350 * @name: The user to get information about.
351 * @chatid: The chat id.
353 * Get information about a user in a chat. Show immediate feedback.
355 void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chatid);
358 * pidgin_parse_x_im_contact:
359 * @msg: The MIME message.
360 * @all_accounts: If TRUE, check all compatible accounts, online or
361 * offline. If FALSE, check only online accounts.
362 * @ret_account: The best guess at a compatible protocol,
363 * based on ret_protocol. If NULL, no account was found.
364 * @ret_protocol: The returned protocol type.
365 * @ret_username: The returned username.
366 * @ret_alias: The returned alias.
368 * Parses an application/x-im-contact MIME message and returns the
369 * data inside.
371 * Returns: TRUE if the message was parsed for the minimum necessary data.
372 * FALSE otherwise.
374 gboolean pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts,
375 PurpleAccount **ret_account,
376 char **ret_protocol, char **ret_username,
377 char **ret_alias);
380 * pidgin_set_accessible_label:
381 * @w: The widget that we want to name.
382 * @l: A GtkLabel that we want to use as the ATK name for the widget.
384 * Sets an ATK name for a given widget. Also sets the labelled-by
385 * and label-for ATK relationships.
387 void pidgin_set_accessible_label(GtkWidget *w, GtkLabel *l);
390 * pidgin_set_accessible_relations:
391 * @w: The widget that we want to label.
392 * @l: A GtkLabel that we want to use as the label for the widget.
394 * Sets the labelled-by and label-for ATK relationships.
396 void pidgin_set_accessible_relations(GtkWidget *w, GtkLabel *l);
399 * pidgin_menu_position_func_helper:
400 * @menu: The menu we are positioning.
401 * @x: Address of the gint representing the horizontal position
402 * where the menu shall be drawn. This is an output parameter.
403 * @y: Address of the gint representing the vertical position
404 * where the menu shall be drawn. This is an output parameter.
405 * @push_in: This is an output parameter?
406 * @data: Not used by this particular position function.
408 * A helper function for GtkMenuPositionFuncs. This ensures the menu will
409 * be kept on screen if possible.
411 void pidgin_menu_position_func_helper(GtkMenu *menu, gint *x, gint *y,
412 gboolean *push_in, gpointer data);
415 * pidgin_menu_popup_at_treeview_selection:
416 * @menu: The menu to show.
417 * @treeview: The treeview to use for positioning.
419 * Open a menu popup at the position determined by the selection of a given
420 * treeview. This function is similar to @gtk_menu_popup_at_pointer, but should
421 * be used when the menu is activated via a keyboard shortcut.
423 void pidgin_menu_popup_at_treeview_selection(GtkWidget *menu, GtkWidget *treeview);
426 * pidgin_dnd_file_manage:
427 * @sd: GtkSelectionData for managing drag'n'drop
428 * @account: Account to be used (may be NULL if conv is not NULL)
429 * @who: Buddy name (may be NULL if conv is not NULL)
431 * Manages drag'n'drop of files.
433 void pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who);
436 * pidgin_buddy_icon_get_scale_size:
438 * Convenience wrapper for purple_buddy_icon_spec_get_scaled_size
440 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleBuddyIconScaleFlags rules, int *width, int *height);
443 * pidgin_create_protocol_icon:
444 * @account: The account.
445 * @size: The size of the icon to return.
447 * Returns the base image to represent the account, based on
448 * the currently selected theme.
450 * Returns: (transfer full): A newly-created pixbuf with a reference count of 1,
451 * or NULL if any of several error conditions occurred:
452 * the file could not be opened, there was no loader
453 * for the file's format, there was not enough memory
454 * to allocate the image buffer, or the image file
455 * contained invalid data.
457 GdkPixbuf *pidgin_create_protocol_icon(PurpleAccount *account, PidginProtocolIconSize size);
460 * pidgin_create_status_icon:
461 * @primitive: The status primitive
462 * @w: The widget to render this
463 * @size: The icon size to render at
465 * Creates a status icon for a given primitve
467 * Returns: (transfer full): A GdkPixbuf, created from stock
469 GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size);
472 * pidgin_stock_id_from_status_primitive:
473 * @prim: The status primitive
475 * Returns an appropriate stock-id for a status primitive.
477 * Returns: The stock-id
479 const char *pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim);
482 * pidgin_stock_id_from_presence:
483 * @presence: The presence.
485 * Returns an appropriate stock-id for a PurplePresence.
487 * Returns: The stock-id
489 const char *pidgin_stock_id_from_presence(PurplePresence *presence);
492 * pidgin_append_menu_action:
493 * @menu: The menu to append to.
494 * @act: The PurpleActionMenu to append.
495 * @gobject: The object to be passed to the action callback.
497 * Append a PurpleActionMenu to a menu.
499 * Returns: (transfer full): The menuitem added.
501 GtkWidget *pidgin_append_menu_action(GtkWidget *menu, PurpleActionMenu *act,
502 gpointer gobject);
505 * pidgin_set_cursor:
506 * @widget: The widget for which to set the mouse pointer
507 * @cursor_type: The type of cursor to set
509 * Sets the mouse pointer for a GtkWidget.
511 * After setting the cursor, the display is flushed, so the change will
512 * take effect immediately.
514 * If the window for @widget is %NULL, this function simply returns.
516 void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type);
519 * pidgin_clear_cursor:
521 * Sets the mouse point for a GtkWidget back to that of its parent window.
523 * If @widget is %NULL, this function simply returns.
525 * If the window for @widget is %NULL, this function simply returns.
527 * Note: The display is not flushed from this function.
529 void pidgin_clear_cursor(GtkWidget *widget);
532 * pidgin_buddy_icon_chooser_new:
533 * @parent: The parent window
534 * @callback: The callback to call when the window is closed. If the user chose an icon, the char* argument will point to its path
535 * @data: Data to pass to @callback
537 * Creates a File Selection widget for choosing a buddy icon
539 * Returns: (transfer full): The file dialog
541 GtkFileChooserNative *pidgin_buddy_icon_chooser_new(
542 GtkWindow *parent, void (*callback)(const char *, gpointer),
543 gpointer data);
546 * pidgin_convert_buddy_icon:
547 * @protocol: The protocol to convert the icon
548 * @path: The path of a file to convert
549 * @len: If not %NULL, the length of the returned data will be set here.
551 * Converts a buddy icon to the required size and format
553 * Returns: The converted image data, or %NULL if an error occurred.
555 gpointer pidgin_convert_buddy_icon(PurpleProtocol *protocol, const char *path, size_t *len);
558 * PidginUtilMiniDialogCallback:
560 * The type of callbacks passed to pidgin_make_mini_dialog().
562 typedef void (*PidginUtilMiniDialogCallback)(gpointer user_data, GtkButton *button);
565 * pidgin_make_mini_dialog:
566 * @handle: The #PurpleConnection to which this mini-dialog
567 * refers, or %NULL if it does not refer to a
568 * connection. If @handle is supplied, the mini-dialog
569 * will be automatically removed and destroyed when the
570 * connection signs off.
571 * @stock_id: The ID of a stock image to use in the mini dialog.
572 * @primary: The primary text
573 * @secondary: The secondary text, or %NULL for no description.
574 * @user_data: Data to pass to the callbacks
575 * @...: a %NULL-terminated list of button labels
576 * (<type>char *</type>) and callbacks
577 * (#PidginUtilMiniDialogCallback). @user_data will be
578 * passed as the first argument. (Callbacks may lack a
579 * second argument, or be %NULL to take no action when
580 * the corresponding button is pressed.) When a button is
581 * pressed, the callback (if any) will be called; when
582 * the callback returns the dialog will be destroyed.
584 * Creates a #PidginMiniDialog, tied to a #PurpleConnection, suitable for
585 * embedding in the buddy list scrollbook with pidgin_blist_add_alert().
587 * See <link linkend="pidgin-pidginstock">Stock Resources</link>.
589 * Returns: (transfer full): A #PidginMiniDialog, suitable for passing to
590 * pidgin_blist_add_alert().
592 GtkWidget *pidgin_make_mini_dialog(PurpleConnection *handle,
593 const char* stock_id, const char *primary, const char *secondary,
594 void *user_data, ...) G_GNUC_NULL_TERMINATED;
597 * pidgin_make_mini_dialog_with_custom_icon:
598 * @custom_icon: A custom GdkPixbuf to use.
599 * @primary: The primary text
600 * @secondary: The secondary text, or %NULL for no description.
601 * @user_data: Data to pass to the callbacks
602 * @...: a %NULL-terminated list of button labels
603 * (<type>char *</type>) and callbacks
604 * (#PidginUtilMiniDialogCallback). @user_data will be
605 * passed as the first argument. (Callbacks may lack a
606 * second argument, or be %NULL to take no action when
607 * the corresponding button is pressed.) When a button is
608 * pressed, the callback (if any) will be called; when
609 * the callback returns the dialog will be destroyed.
611 * Does exactly what pidgin_make_mini_dialog() does, except you can specify
612 * a custom icon for the dialog.
614 * Returns: (transfer full): A #PidginMiniDialog, suitable for passing to
615 * pidgin_blist_add_alert().
617 GtkWidget *pidgin_make_mini_dialog_with_custom_icon(PurpleConnection *gc,
618 GdkPixbuf *custom_icon,
619 const char *primary,
620 const char *secondary,
621 void *user_data,
622 ...) G_GNUC_NULL_TERMINATED;
625 * pidgin_tree_view_search_equal_func:
627 * This is a callback function to be used for Ctrl+F searching in treeviews.
628 * Sample Use:
629 * gtk_tree_view_set_search_equal_func(treeview,
630 * pidgin_tree_view_search_equal_func,
631 * search_data, search_data_destroy_cb);
634 gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
635 const gchar *key, GtkTreeIter *iter, gpointer data);
638 * pidgin_set_urgent:
639 * @window: The window to draw attention to
640 * @urgent: Whether to set the urgent hint or not
642 * Sets or resets a window to 'urgent,' by setting the URGENT hint in X
643 * or blinking in the win32 taskbar
645 void pidgin_set_urgent(GtkWindow *window, gboolean urgent);
648 * pidgin_get_dim_grey_string:
649 * @widget: The widget to return dim grey for
651 * Returns an HTML-style color string for use as a dim grey
652 * string
654 * Returns: The dim grey string
656 const char *pidgin_get_dim_grey_string(GtkWidget *widget);
659 * pidgin_text_combo_box_entry_new:
660 * @default_item: Initial contents of GtkEntry
661 * @items: (element-type utf8): GList containing strings to add to GtkComboBox
663 * Create a simple text GtkComboBoxEntry equivalent
665 * Returns: (transfer full): A newly created text GtkComboBox containing a GtkEntry
666 * child.
668 GtkWidget *pidgin_text_combo_box_entry_new(const char *default_item, GList *items);
671 * pidgin_text_combo_box_entry_get_text:
672 * @widget: The simple text GtkComboBoxEntry equivalent widget
674 * Retrieve the text from the entry of the simple text GtkComboBoxEntry equivalent
676 * Returns: The text in the widget's entry. It must not be freed
678 const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget);
681 * pidgin_text_combo_box_entry_set_text:
682 * @widget: The simple text GtkComboBoxEntry equivalent widget
683 * @text: The text to set
685 * Set the text in the entry of the simple text GtkComboBoxEntry equivalent
687 void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text);
690 * pidgin_auto_parent_window:
691 * @window: The window to make transient.
693 * Automatically make a window transient to a suitable parent window.
695 * Returns: Whether the window was made transient or not.
697 gboolean pidgin_auto_parent_window(GtkWidget *window);
700 * pidgin_add_widget_to_vbox:
701 * @vbox: The vertically-oriented GtkBox to add the widget to.
702 * @widget_label: The label to give the widget, can be %NULL.
703 * @sg: The GtkSizeGroup to add the label to, can be %NULL.
704 * @widget: The GtkWidget to add.
705 * @expand: Whether to expand the widget horizontally.
706 * @p_label: Place to store a pointer to the GtkLabel, or %NULL if you don't care.
708 * Add a labelled widget to a GtkBox
710 * Returns: (transfer full): A GtkBox already added to the GtkBox containing the GtkLabel and the GtkWidget.
712 GtkWidget *pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label);
715 * pidgin_pixbuf_from_data:
716 * @buf: The raw binary image data.
717 * @count: The length of buf in bytes.
719 * Create a GdkPixbuf from a chunk of image data.
721 * Returns: (transfer full): A GdkPixbuf created from the image data, or NULL if
722 * there was an error parsing the data.
724 GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count);
727 * pidgin_pixbuf_anim_from_data:
728 * @buf: The raw binary image data.
729 * @count: The length of buf in bytes.
731 * Create a GdkPixbufAnimation from a chunk of image data.
733 * Returns: (transfer full): A GdkPixbufAnimation created from the image data, or NULL if
734 * there was an error parsing the data.
736 GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count);
739 * pidgin_pixbuf_from_image:
740 * @image: a PurpleImage.
742 * Create a GdkPixbuf from a PurpleImage.
744 * Returns: (transfer full): a GdkPixbuf created from the @image.
746 GdkPixbuf *
747 pidgin_pixbuf_from_image(PurpleImage *image);
750 * pidgin_pixbuf_new_from_file:
751 * @filename: Name of file to load, in the GLib file name encoding
753 * Helper function that calls gdk_pixbuf_new_from_file() and checks both
754 * the return code and the GError and returns NULL if either one failed.
756 * The gdk-pixbuf documentation implies that it is sufficient to check
757 * the return value of gdk_pixbuf_new_from_file() to determine
758 * whether the image was able to be loaded. However, this is not the case
759 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
760 * cases a GdkPixbuf object is returned that will cause some operations
761 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
762 * infinite loop.
764 * This function shouldn't be necessary once Pidgin requires a version of
765 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
766 * nice to keep this function around for the debug message that it logs.
768 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and
769 * a warning is logged.
771 GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename);
774 * pidgin_pixbuf_new_from_file_at_size:
775 * @filename: Name of file to load, in the GLib file name encoding
776 * @width: The width the image should have or -1 to not constrain the width
777 * @height: The height the image should have or -1 to not constrain the height
779 * Helper function that calls gdk_pixbuf_new_from_file_at_size() and checks
780 * both the return code and the GError and returns NULL if either one failed.
782 * The gdk-pixbuf documentation implies that it is sufficient to check
783 * the return value of gdk_pixbuf_new_from_file_at_size() to determine
784 * whether the image was able to be loaded. However, this is not the case
785 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
786 * cases a GdkPixbuf object is returned that will cause some operations
787 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
788 * infinite loop.
790 * This function shouldn't be necessary once Pidgin requires a version of
791 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
792 * nice to keep this function around for the debug message that it logs.
794 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and
795 * a warning is logged.
797 GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height);
800 * pidgin_pixbuf_new_from_file_at_scale:
801 * @filename: Name of file to load, in the GLib file name encoding
802 * @width: The width the image should have or -1 to not constrain the width
803 * @height: The height the image should have or -1 to not constrain the height
804 * @preserve_aspect_ratio: TRUE to preserve the image's aspect ratio
806 * Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks
807 * both the return code and the GError and returns NULL if either one failed.
809 * The gdk-pixbuf documentation implies that it is sufficient to check
810 * the return value of gdk_pixbuf_new_from_file_at_scale() to determine
811 * whether the image was able to be loaded. However, this is not the case
812 * with gdk-pixbuf 2.23.3 and probably many earlier versions. In some
813 * cases a GdkPixbuf object is returned that will cause some operations
814 * (like gdk_pixbuf_scale_simple()) to rapidly consume memory in an
815 * infinite loop.
817 * This function shouldn't be necessary once Pidgin requires a version of
818 * gdk-pixbuf where the aforementioned bug is fixed. However, it might be
819 * nice to keep this function around for the debug message that it logs.
821 * Returns: (transfer full): The GdkPixbuf if successful. Otherwise NULL is returned and
822 * a warning is logged.
824 GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio);
827 * pidgin_pixbuf_scale_down:
828 * @src: The source image.
829 * @max_width: Maximum width in px.
830 * @max_height: Maximum height in px.
831 * @interp_type: Interpolation method.
832 * @preserve_ratio: %TRUE to preserve image's aspect ratio.
834 * Scales the image to the desired dimensions. If image is smaller, it will be
835 * returned without modifications.
837 * If new image is created, @src reference cound will be decreased and new image
838 * with a ref count of 1 will be returned.
840 * Returns: (transfer full): The image with proper sizing. %NULL in case of error.
842 GdkPixbuf *
843 pidgin_pixbuf_scale_down(GdkPixbuf *src, guint max_width, guint max_height,
844 GdkInterpType interp_type, gboolean preserve_ratio);
847 * pidgin_make_scrollable:
848 * @child: The child widget
849 * @hscrollbar_policy: Horizontal scrolling policy
850 * @vscrollbar_policy: Vertical scrolling policy
851 * @shadow_type: Shadow type
852 * @width: Desired widget width, or -1 for default
853 * @height: Desired widget height, or -1 for default
855 * Add scrollbars to a widget
857 * Returns: (transfer full): A scrolled window with @child packed inside of it.
859 GtkWidget *pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int height);
861 G_END_DECLS
863 #endif /* _PIDGINUTILS_H_ */