pidgin 2.14.14dev
gtkutils.h
Go to the documentation of this file.
1
6/* pidgin
7 *
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.
11 *
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.
16 *
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.
21 *
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
25 */
26#ifndef _PIDGINUTILS_H_
27#define _PIDGINUTILS_H_
28
29#include "gtkconv.h"
30#include "pidgin.h"
31#include "prpl.h"
32#include "util.h"
33
34
35
36
37
38typedef enum
39{
40 PIDGIN_BUTTON_HORIZONTAL,
41 PIDGIN_BUTTON_VERTICAL
42
43} PidginButtonOrientation;
44
45typedef enum
46{
47 PIDGIN_BUTTON_NONE = 0,
48 PIDGIN_BUTTON_TEXT,
49 PIDGIN_BUTTON_IMAGE,
50 PIDGIN_BUTTON_TEXT_IMAGE
51
52} PidginButtonStyle;
53
54typedef enum
55{
56 PIDGIN_PRPL_ICON_SMALL,
57 PIDGIN_PRPL_ICON_MEDIUM,
58 PIDGIN_PRPL_ICON_LARGE
59} PidginPrplIconSize;
60
61#ifndef _WIN32
62typedef enum
63{
64 PIDGIN_BROWSER_DEFAULT = 0,
65 PIDGIN_BROWSER_CURRENT,
66 PIDGIN_BROWSER_NEW_WINDOW,
67 PIDGIN_BROWSER_NEW_TAB
68
69} PidginBrowserPlace;
70#endif /* _WIN32 */
71
72typedef struct {
73 gboolean is_buddy;
74 union {
75 PurpleBuddy *buddy;
76 PurpleLogSet *logged_buddy;
77 } entry;
79
80typedef gboolean (*PidginFilterBuddyCompletionEntryFunc) (const PidginBuddyCompletionEntry *completion_entry, gpointer user_data);
81
82
89void pidgin_setup_imhtml(GtkWidget *imhtml);
90
109GtkWidget *pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret);
110
119GtkWidget *pidgin_create_small_button(GtkWidget *image);
120
131GtkWidget *pidgin_create_window(const char *title, guint border_width, const char *role, gboolean resizable);
132
143GtkWidget *pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable);
144
154GtkWidget *pidgin_dialog_get_vbox_with_properties(GtkDialog *dialog, gboolean homogeneous, gint spacing);
155
163GtkWidget *pidgin_dialog_get_vbox(GtkDialog *dialog);
164
176GtkWidget *pidgin_dialog_add_button(GtkDialog *dialog, const char *label,
177 GCallback callback, gpointer callbackdata);
178
186GtkWidget *pidgin_dialog_get_action_area(GtkDialog *dialog);
187
194void pidgin_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle);
195
204void pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog);
205
212void pidgin_toggle_sensitive_array(GtkWidget *w, GPtrArray *data);
213
220void pidgin_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle);
221
229GtkWidget *pidgin_separator(GtkWidget *menu);
230
239GtkWidget *pidgin_new_item(GtkWidget *menu, const char *str);
240
252GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str,
253 GCallback cb, gpointer data, gboolean checked);
254
270GtkWidget *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);
274
284GtkWidget *pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
285 PidginButtonOrientation style);
286
294GtkWidget *pidgin_pixbuf_toolbar_button_from_stock(const char *stock);
295
304GtkWidget *pidgin_make_frame(GtkWidget *parent, const char *title);
305
315GtkWidget *pidgin_protocol_option_menu_new(const char *id,
316 GCallback cb,
317 gpointer user_data);
318
326const char *pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu);
327
342 gboolean show_all, GCallback cb,
343 PurpleFilterAccountFunc filter_func, gpointer user_data);
344
353
362
374void pidgin_setup_screenname_autocomplete_with_filter(GtkWidget *entry, GtkWidget *optmenu, PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data);
375
384gboolean pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts);
385
402void pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *optmenu, gboolean all);
403
417gboolean pidgin_check_if_dir(const char *path, GtkFileSelection *filesel);
418
427void pidgin_setup_gtkspell(GtkTextView *textview);
428
432void pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1,
433 GdkModifierType arg2, GClosure *arg3,
434 gpointer data);
435
439gboolean pidgin_save_accels(gpointer data);
440
445
454void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name);
455
465void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chatid);
466
483gboolean 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);
487
495void pidgin_set_accessible_label(GtkWidget *w, GtkWidget *l);
496
505void pidgin_set_accessible_relations(GtkWidget *w, GtkWidget *l);
506
521void pidgin_menu_position_func_helper(GtkMenu *menu, gint *x, gint *y,
522 gboolean *push_in, gpointer data);
523
540 gint *x,
541 gint *y,
542 gboolean *push_in,
543 gpointer user_data);
544
552void pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who);
553
557void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height);
558
573GdkPixbuf *pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size);
574
583GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size);
584
595
605const char *pidgin_stock_id_from_presence(PurplePresence *presence);
606
616GtkWidget *pidgin_append_menu_action(GtkWidget *menu, PurpleMenuAction *act,
617 gpointer gobject);
618
630void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type);
631
641void pidgin_clear_cursor(GtkWidget *widget);
642
651GtkWidget *pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char*,gpointer), gpointer data);
652
662gpointer pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len);
663
664#if !(defined PIDGIN_DISABLE_DEPRECATED) || (defined _PIDGIN_GTKUTILS_C_)
674void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename);
675#endif
676
684char *pidgin_make_pretty_arrows(const char *str);
685
689typedef void (*PidginUtilMiniDialogCallback)(gpointer user_data, GtkButton *);
690
717 const char* stock_id, const char *primary, const char *secondary,
718 void *user_data, ...) G_GNUC_NULL_TERMINATED;
719
725 GdkPixbuf *custom_icon,
726 const char *primary,
727 const char *secondary,
728 void *user_data,
729 ...) G_GNUC_NULL_TERMINATED;
730
739gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column,
740 const gchar *key, GtkTreeIter *iter, gpointer data);
741
749void pidgin_set_urgent(GtkWindow *window, gboolean urgent);
750
758gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf);
759
765void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf);
766
774const char *pidgin_get_dim_grey_string(GtkWidget *widget);
775
787GtkWidget *pidgin_text_combo_box_entry_new(const char *default_item, GList *items);
788
798const char *pidgin_text_combo_box_entry_get_text(GtkWidget *widget);
799
808void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text);
809
819gboolean pidgin_auto_parent_window(GtkWidget *window);
820
834GtkWidget *pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label);
835
847GdkPixbuf *pidgin_pixbuf_from_data(const guchar *buf, gsize count);
848
860GdkPixbufAnimation *pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count);
861
872
896GdkPixbuf *pidgin_pixbuf_new_from_file(const char *filename);
897
923GdkPixbuf *pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height);
924
951GdkPixbuf *pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio);
952
964GtkWidget *pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int height);
965
972
979
980#endif /* _PIDGINUTILS_H_ */
981
GTK+ Conversation API.
void pidgin_load_accels(void)
Load menu accelerators.
void pidgin_gdk_pixbuf_make_round(GdkPixbuf *pixbuf)
Rounds the corners of a 32x32 GdkPixbuf in place.
void pidgin_set_accessible_label(GtkWidget *w, GtkWidget *l)
Sets an ATK name for a given widget.
GtkWidget * pidgin_text_combo_box_entry_new(const char *default_item, GList *items)
Create a simple text GtkComboBoxEntry equivalent.
const char * pidgin_stock_id_from_presence(PurplePresence *presence)
Returns an appropriate stock-id for a PurplePresence.
void pidgin_toggle_showhide(GtkWidget *widget, GtkWidget *to_toggle)
Toggles the visibility of a widget.
void pidgin_set_cursor(GtkWidget *widget, GdkCursorType cursor_type)
Sets the mouse pointer for a GtkWidget.
GtkWidget * pidgin_dialog_get_vbox_with_properties(GtkDialog *dialog, gboolean homogeneous, gint spacing)
Retrieves the main content box (vbox) from a pidgin dialog window.
GdkPixbuf * pidgin_pixbuf_from_imgstore(PurpleStoredImage *image)
Create a GdkPixbuf from a PurpleStoredImage.
GtkWidget * pidgin_make_mini_dialog(PurpleConnection *handle, const char *stock_id, const char *primary, const char *secondary, void *user_data,...) G_GNUC_NULL_TERMINATED
Creates a PidginMiniDialog, tied to a PurpleConnection, suitable for embedding in the buddy list scro...
const char * pidgin_get_dim_grey_string(GtkWidget *widget)
Returns an HTML-style color string for use as a dim grey string.
void pidgin_toggle_sensitive(GtkWidget *widget, GtkWidget *to_toggle)
Toggles the sensitivity of a widget.
GtkWidget * pidgin_create_small_button(GtkWidget *image)
Creates a small button.
void pidgin_set_accessible_relations(GtkWidget *w, GtkWidget *l)
Sets the labelled-by and label-for ATK relationships.
GtkWidget * pidgin_protocol_option_menu_new(const char *id, GCallback cb, gpointer user_data)
Creates a drop-down option menu filled with protocols.
gboolean pidgin_gdk_pixbuf_is_opaque(GdkPixbuf *pixbuf)
Returns TRUE if the GdkPixbuf is opaque, as determined by no alpha at any of the edge pixels.
GtkWidget * pidgin_buddy_icon_chooser_new(GtkWindow *parent, void(*callback)(const char *, gpointer), gpointer data)
Creates a File Selection widget for choosing a buddy icon.
GtkWidget * pidgin_create_imhtml(gboolean editable, GtkWidget **imhtml_ret, GtkWidget **toolbar_ret, GtkWidget **sw_ret)
Create an GtkIMHtml widget and associated GtkIMHtmlToolbar widget.
gboolean pidgin_check_if_dir(const char *path, GtkFileSelection *filesel)
Check if the given path is a directory or not.
void pidgin_treeview_popup_menu_position_func(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
A valid GtkMenuPositionFunc.
void pidgin_clear_cursor(GtkWidget *widget)
Sets the mouse point for a GtkWidget back to that of its parent window.
void pidgin_account_option_menu_set_selected(GtkWidget *optmenu, PurpleAccount *account)
Sets the currently selected account for an account drop down box.
GtkWidget * pidgin_new_check_item(GtkWidget *menu, const char *str, GCallback cb, gpointer data, gboolean checked)
Creates a check menu item.
gboolean pidgin_parse_x_im_contact(const char *msg, gboolean all_accounts, PurpleAccount **ret_account, char **ret_protocol, char **ret_username, char **ret_alias)
Parses an application/x-im-contact MIME message and returns the data inside.
void pidgin_toggle_sensitive_array(GtkWidget *w, GPtrArray *data)
Toggles the sensitivity of all widgets in a pointer array.
GdkPixbuf * pidgin_pixbuf_new_from_file_at_scale(const char *filename, int width, int height, gboolean preserve_aspect_ratio)
Helper function that calls gdk_pixbuf_new_from_file_at_scale() and checks both the return code and th...
void pidgin_set_sensitive_if_input(GtkWidget *entry, GtkWidget *dialog)
Checks if text has been entered into a GtkTextEntry widget.
gboolean pidgin_save_accels(gpointer data)
Save menu accelerators.
void pidgin_utils_init(void)
Initialize some utility functions.
void pidgin_set_custom_buddy_icon(PurpleAccount *account, const char *who, const char *filename)
Set or unset a custom buddyicon for a user.
const char * pidgin_protocol_option_menu_get_selected(GtkWidget *optmenu)
Gets the currently selected protocol from a protocol drop down box.
GdkPixbuf * pidgin_pixbuf_new_from_file_at_size(const char *filename, int width, int height)
Helper function that calls gdk_pixbuf_new_from_file_at_size() and checks both the return code and the...
GtkWidget * pidgin_account_option_menu_new(PurpleAccount *default_account, gboolean show_all, GCallback cb, PurpleFilterAccountFunc filter_func, gpointer user_data)
Creates a drop-down option menu filled with accounts.
GtkWidget * pidgin_append_menu_action(GtkWidget *menu, PurpleMenuAction *act, gpointer gobject)
Append a PurpleMenuAction to a menu.
GtkWidget * pidgin_add_widget_to_vbox(GtkBox *vbox, const char *widget_label, GtkSizeGroup *sg, GtkWidget *widget, gboolean expand, GtkWidget **p_label)
Add a labelled widget to a GtkVBox.
GtkWidget * pidgin_dialog_get_action_area(GtkDialog *dialog)
Retrieves the action area (button box) from a pidgin dialog window.
void pidgin_set_urgent(GtkWindow *window, gboolean urgent)
Sets or resets a window to 'urgent,' by setting the URGENT hint in X or blinking in the win32 taskbar...
PurpleAccount * pidgin_account_option_menu_get_selected(GtkWidget *optmenu)
Gets the currently selected account from an account drop down box.
GtkWidget * pidgin_pixbuf_toolbar_button_from_stock(const char *stock)
Creates a toolbar button with the stock icon.
char * pidgin_make_pretty_arrows(const char *str)
Converts "->" and "<-" in strings to Unicode arrow characters, for use in referencing menu items.
GtkWidget * pidgin_create_dialog(const char *title, guint border_width, const char *role, gboolean resizable)
Creates a new dialog window.
void pidgin_retrieve_user_info(PurpleConnection *conn, const char *name)
Get information about a user.
gboolean pidgin_screenname_autocomplete_default_filter(const PidginBuddyCompletionEntry *completion_entry, gpointer all_accounts)
The default filter function for username autocomplete.
gboolean pidgin_tree_view_search_equal_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer data)
This is a callback function to be used for Ctrl+F searching in treeviews.
GtkWidget * pidgin_make_frame(GtkWidget *parent, const char *title)
Creates a HIG preferences frame.
void(* PidginUtilMiniDialogCallback)(gpointer user_data, GtkButton *)
The type of callbacks passed to pidgin_make_mini_dialog().
Definition: gtkutils.h:689
GtkWidget * pidgin_dialog_get_vbox(GtkDialog *dialog)
Retrieves the main content box (vbox) from a pidgin dialog window.
void pidgin_menu_position_func_helper(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer data)
A helper function for GtkMenuPositionFuncs.
void pidgin_setup_imhtml(GtkWidget *imhtml)
Sets up a gtkimhtml widget, loads it with smileys, and sets the default signal handlers.
GdkPixbuf * pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size)
Returns the base image to represent the account, based on the currently selected theme.
void pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who)
Manages drag'n'drop of files.
GtkWidget * pidgin_dialog_add_button(GtkDialog *dialog, const char *label, GCallback callback, gpointer callbackdata)
Add a button to a dialog created by pidgin_create_dialog.
GdkPixbuf * pidgin_pixbuf_new_from_file(const char *filename)
Helper function that calls gdk_pixbuf_new_from_file() and checks both the return code and the GError ...
gpointer pidgin_convert_buddy_icon(PurplePlugin *plugin, const char *path, size_t *len)
Converts a buddy icon to the required size and format.
GdkPixbufAnimation * pidgin_pixbuf_anim_from_data(const guchar *buf, gsize count)
Create a GdkPixbufAnimation from a chunk of image data.
void pidgin_text_combo_box_entry_set_text(GtkWidget *widget, const char *text)
Set the text in the entry of the simple text GtkComboBoxEntry equivalent.
void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height)
Convenience wrapper for purple_buddy_icon_get_scale_size.
void pidgin_utils_uninit(void)
Uninitialize some utility functions.
gboolean pidgin_auto_parent_window(GtkWidget *window)
Automatically make a window transient to a suitable parent window.
const char * pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim)
Returns an appropriate stock-id for a status primitive.
GtkWidget * pidgin_make_mini_dialog_with_custom_icon(PurpleConnection *gc, GdkPixbuf *custom_icon, const char *primary, const char *secondary, void *user_data,...) G_GNUC_NULL_TERMINATED
Does exactly what pidgin_make_mini_dialog() does, except you can specify a custom icon for the dialog...
GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size)
Creates a status icon for a given primitve.
void pidgin_setup_screenname_autocomplete_with_filter(GtkWidget *entry, GtkWidget *optmenu, PidginFilterBuddyCompletionEntryFunc filter_func, gpointer user_data)
Add autocompletion of screenames to an entry, supporting a filtering function.
void pidgin_setup_gtkspell(GtkTextView *textview)
Sets up GtkSpell for the given GtkTextView, reporting errors if encountered.
GtkWidget * pidgin_make_scrollable(GtkWidget *child, GtkPolicyType hscrollbar_policy, GtkPolicyType vscrollbar_policy, GtkShadowType shadow_type, int width, int height)
Add scrollbars to a widget.
void pidgin_retrieve_user_info_in_chat(PurpleConnection *conn, const char *name, int chatid)
Get information about a user in a chat.
const char * pidgin_text_combo_box_entry_get_text(GtkWidget *widget)
Retrieve the text from the entry of the simple text GtkComboBoxEntry equivalent.
GtkWidget * pidgin_pixbuf_button_from_stock(const char *text, const char *icon, PidginButtonOrientation style)
Creates a button with the specified text and stock icon.
GtkWidget * pidgin_separator(GtkWidget *menu)
Adds a separator to a menu.
GtkWidget * pidgin_create_window(const char *title, guint border_width, const char *role, gboolean resizable)
Creates a new window.
void pidgin_save_accels_cb(GtkAccelGroup *accel_group, guint arg1, GdkModifierType arg2, GClosure *arg3, gpointer data)
Save menu accelerators callback.
void pidgin_setup_screenname_autocomplete(GtkWidget *entry, GtkWidget *optmenu, gboolean all)
Add autocompletion of screenames to an entry.
GdkPixbuf * pidgin_pixbuf_from_data(const guchar *buf, gsize count)
Create a GdkPixbuf from a chunk of image data.
GtkWidget * pidgin_new_item(GtkWidget *menu, const char *str)
Creates a menu item.
GtkWidget * pidgin_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GCallback cb, gpointer data, guint accel_key, guint accel_mods, char *mod)
Creates a menu item.
struct _PurpleStoredImage PurpleStoredImage
A set of utility functions that provide a reference-counted immutable wrapper around an image's data ...
Definition: imgstore.h:37
UI definitions and includes.
Protocol Plugin functions.
PurpleIconScaleRules
Definition: prpl.h:41
PurpleStatusPrimitive
A primitive defining the basic structure of a status type.
Definition: status.h:118
Structure representing an account.
Definition: account.h:170
A description of a Buddy Icon specification.
Definition: prpl.h:85
A buddy.
Definition: blist.h:140
Describes available logs.
Definition: log.h:163
A plugin handle.
Definition: plugin.h:152
Utility Functions.