# HG changeset patch # User Paul Aurich # Date 1240944237 0 # Node ID 3912f55a1633f8c70e5a394bd521277a8b94a589 # Parent de9816c970fe1dd0334c111939bf5000d8a1c8d8# Parent c26c6d25142db2a3eac1c7392ae9f365f0d64acb propagate from branch 'im.pidgin.pidgin' (head fbb4fe5da444943eecc76bdcd6c8ba967790b6c8) to branch 'im.pidgin.cpw.darkrain42.xmpp.bosh' (head 601bc627c9430320848361f0ed81c6c4c6ee53e0) diff -r de9816c970fe -r 3912f55a1633 AUTHORS --- a/AUTHORS Sat Apr 18 18:17:16 2009 +0000 +++ b/AUTHORS Tue Apr 28 18:43:57 2009 +0000 @@ -9,6 +9,7 @@ ------------------ Daniel 'datallah' Atallah - Developer +Paul 'darkrain42' Aurich - Developer John 'rekkanoryo' Bailey - Developer Ethan 'Paco-Paco' Blanton - Developer Thomas Butter - Developer @@ -24,6 +25,7 @@ Bartosz Oler - Developer Etan 'deryni' Reisner - Developer Tim 'marv' Ringenbach - Developer +Michael 'Maiku' Ruprecht - Developer, voice and video Elliott 'QuLogic' Sales de Andrade - Developer Luke 'LSchiere' Schierer - Support Megan 'Cae' Schneider - support/QA @@ -35,7 +37,6 @@ Crazy Patch Writers: ------------------- -Paul 'darkrain42' Aurich Marcus 'malu' Lundblad Dennis 'EvilDennisR' Ristuccia Peter 'Fmoo' Ruibal diff -r de9816c970fe -r 3912f55a1633 ChangeLog --- a/ChangeLog Sat Apr 18 18:17:16 2009 +0000 +++ b/ChangeLog Tue Apr 28 18:43:57 2009 +0000 @@ -18,17 +18,24 @@ * Add voice & video support with Jingle (XEP-0166, 0167, 0176, & 0177), and voice support with GTalk and GMail. (Mike "Maiku" Ruprecht) * Add support for in-band bytestreams for file transfers (XEP-0047). - * Add support for sending and receiving attentions (equivalent to "buzz" - and "nudge") using the command /buzz (XEP-0224). + * Add support for sending and receiving attentions (equivalent to "buzz" + and "nudge") using the command /buzz. (XEP-0224) * A buddy's local time is displayed in the Get Info dialog if the remote client supports it. + * The set_chat_topic function can unset the chat topic. + * Fix crash on connection with recent gstreamer0.10-plugins-bad. + * Don't create a new conversation window for incoming messages of + type 'headline'. + * The Ad-Hoc commands associated with our server are now always shown at + login. + * Support showing and reporting idle times in the buddy list. (XEP-0256) + * Support most recent version of User Avatar. (XEP-0084 v1.1) IRC: * Correctly handle WHOIS for users who are joined to a large number of channels. * Notify the user if a /nick command fails, rather than trying fallback nicks. - Pidgin: * Added -f command line option to tell Pidgin to ignore NetworkManager @@ -41,9 +48,12 @@ the next line. * Created a unified Buddy Pounce notification window for all pounces where "Pop up a notification" is selected, which avoids having a - new dialog box every time a pounce is triggered. (Jorge Villaseñor) + new dialog box every time a pounce is triggered. (Jorge Villaseñor) * The New Account dialog is now broken into three tabs. Proxy configuration has been moved from the Advanced tab to the new tab. + * The nicks of the persons who leave the chatroom are italicized in the + chat's conversation history. The nicks are un-italicized when they + rejoin. Finch: * The hardware cursor is updated correctly. This will be useful diff -r de9816c970fe -r 3912f55a1633 ChangeLog.API --- a/ChangeLog.API Sat Apr 18 18:17:16 2009 +0000 +++ b/ChangeLog.API Tue Apr 28 18:43:57 2009 +0000 @@ -9,6 +9,7 @@ * PURPLE_CONTACT * PURPLE_BUDDY * PURPLE_CHAT + * account-actions-changed (see account-signals.dox) * purple_buddy_destroy * purple_buddy_get_protocol_data * purple_buddy_set_protocol_data @@ -32,6 +33,7 @@ * purple_network_get_stun_ip * purple_network_get_turn_ip * purple_prpl_get_media_caps + * purple_prpl_got_account_actions * purple_prpl_initiate_media * purple_request_field_get_group * purple_request_field_get_ui_data @@ -77,6 +79,10 @@ * pidgin_sound_is_customized * pidgin_utils_init, pidgin_utils_uninit * pidgin_notify_pounce_add + * PidginBlistTheme, PidginBlistThemeLoader API + * PidginIconTheme, PidginStatusIconTheme, PidginIconThemeLoader + API + * pidgin_stock_id_from_status_primitive libgnt: Added: diff -r de9816c970fe -r 3912f55a1633 doc/account-signals.dox --- a/doc/account-signals.dox Sat Apr 18 18:17:16 2009 +0000 +++ b/doc/account-signals.dox Tue Apr 28 18:43:57 2009 +0000 @@ -9,6 +9,7 @@ @signal account-setting-info @signal account-set-info @signal account-status-changed + @signal account-actions-changed @signal account-alias-changed @signal account-authorization-requested @signal account-authorization-denied @@ -97,6 +98,15 @@ @param new The status after change. @endsignaldef + @signaldef account-actions-changed + @signalproto +void (*account_actions_changed)(PurpleAccount *account); + @endsignalproto + @signaldesc + Emitted when the account actions are changed after initial connection. + @param account The account whose actions changed. + @endsignaldef + @signaldef account-alias-changed @signalproto void (*account_alias_changed)(PurpleAccount *account, const char *old); diff -r de9816c970fe -r 3912f55a1633 doc/pidgin.1.in --- a/doc/pidgin.1.in Sat Apr 18 18:17:16 2009 +0000 +++ b/doc/pidgin.1.in Tue Apr 28 18:43:57 2009 +0000 @@ -602,7 +602,9 @@ .br Daniel 'datallah' Atallah (developer) .br - John 'rekkanoryo' Bailey (developer) + Paul 'darkrain42' Aurich (developer) +.br + John 'rekkanoryo' Bailey (developer and bugmaster) .br Ethan 'Paco-Paco' Blanton (developer) .br @@ -632,6 +634,8 @@ .br Tim 'marv' Ringenbach (developer) <\fImarv_sf@users.sf.net\fR> .br + Michael 'Maiku' Ruprecht (developer, voice and video) +.br Elliott 'QuLogic' Sales de Andrade (developer) .br Luke 'LSchiere' Schierer (support) diff -r de9816c970fe -r 3912f55a1633 finch/gntblist.c --- a/finch/gntblist.c Sat Apr 18 18:17:16 2009 +0000 +++ b/finch/gntblist.c Tue Apr 28 18:43:57 2009 +0000 @@ -935,7 +935,7 @@ else if (PURPLE_BLIST_NODE_IS_GROUP(node)) return purple_group_get_name((PurpleGroup*)node); - snprintf(text, sizeof(text) - 1, "%s %s", status, name); + g_snprintf(text, sizeof(text) - 1, "%s %s", status, name); return text; } @@ -2642,7 +2642,7 @@ char menuid[128]; FinchBlistManager *manager = iter->data; GntMenuItem *item = gnt_menuitem_new(_(manager->name)); - snprintf(menuid, sizeof(menuid), "grouping-%s", manager->id); + g_snprintf(menuid, sizeof(menuid), "grouping-%s", manager->id); gnt_menuitem_set_id(GNT_MENU_ITEM(item), menuid); gnt_menu_add_item(GNT_MENU(subsub), item); g_object_set_data_full(G_OBJECT(item), "grouping-id", g_strdup(manager->id), g_free); @@ -3123,6 +3123,8 @@ PURPLE_CALLBACK(reconstruct_accounts_menu), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-off", finch_blist_get_handle(), PURPLE_CALLBACK(reconstruct_accounts_menu), NULL); + purple_signal_connect(purple_accounts_get_handle(), "account-actions-changed", finch_blist_get_handle(), + PURPLE_CALLBACK(reconstruct_accounts_menu), NULL); purple_signal_connect(purple_blist_get_handle(), "buddy-status-changed", finch_blist_get_handle(), PURPLE_CALLBACK(buddy_status_changed), ggblist); purple_signal_connect(purple_blist_get_handle(), "buddy-idle-changed", finch_blist_get_handle(), diff -r de9816c970fe -r 3912f55a1633 finch/gntnotify.c --- a/finch/gntnotify.c Sat Apr 18 18:17:16 2009 +0000 +++ b/finch/gntnotify.c Tue Apr 28 18:43:57 2009 +0000 @@ -263,7 +263,7 @@ userinfo_hash(PurpleAccount *account, const char *who) { char key[256]; - snprintf(key, sizeof(key), "%s - %s", purple_account_get_username(account), purple_normalize(account, who)); + g_snprintf(key, sizeof(key), "%s - %s", purple_account_get_username(account), purple_normalize(account, who)); return g_utf8_strup(key, -1); } diff -r de9816c970fe -r 3912f55a1633 libpurple/account.c --- a/libpurple/account.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/account.c Tue Apr 28 18:43:57 2009 +0000 @@ -2742,6 +2742,10 @@ purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_STATUS)); + purple_signal_register(handle, "account-actions-changed", + purple_marshal_VOID__POINTER, NULL, 1, + purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_ACCOUNT)); + purple_signal_register(handle, "account-alias-changed", purple_marshal_VOID__POINTER_POINTER, NULL, 2, purple_value_new(PURPLE_TYPE_SUBTYPE, diff -r de9816c970fe -r 3912f55a1633 libpurple/blist.h --- a/libpurple/blist.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/blist.h Tue Apr 28 18:43:57 2009 +0000 @@ -118,8 +118,8 @@ /** * A Buddy list node. This can represent a group, a buddy, or anything else. - * This is a base class for struct buddy and struct group and for anything - * else that wants to put itself in the buddy list. */ + * This is a base class for PurpleBuddy, PurpleContact, PurpleGroup, and for + * anything else that wants to put itself in the buddy list. */ struct _PurpleBlistNode { PurpleBlistNodeType type; /**< The type of node this is */ PurpleBlistNode *prev; /**< The sibling before this buddy. */ @@ -207,7 +207,7 @@ PurpleBlistNode *node); /**< This will update a node in the buddy list. */ void (*remove)(PurpleBuddyList *list, PurpleBlistNode *node); /**< This removes a node from the list */ - void (*destroy)(PurpleBuddyList *list); /**< When the list gets destroyed, this gets called to destroy the UI. */ + void (*destroy)(PurpleBuddyList *list); /**< When the list is destroyed, this is called to destroy the UI. */ void (*set_visible)(PurpleBuddyList *list, gboolean show); /**< Hides or unhides the buddy list */ void (*request_add_buddy)(PurpleAccount *account, const char *username, @@ -276,7 +276,7 @@ * * @since 2.6.0 */ -void *purple_blist_get_ui_data(void); +gpointer purple_blist_get_ui_data(void); /** * Sets the UI data for the list. @@ -285,7 +285,7 @@ * * @since 2.6.0 */ -void purple_blist_set_ui_data(void *ui_data); +void purple_blist_set_ui_data(gpointer ui_data); /** * Returns the next node of a given node. This function is to be used to iterate @@ -360,7 +360,7 @@ * @return The UI data. * @since 2.6.0 */ -void *purple_blist_node_get_ui_data(const PurpleBlistNode *node); +gpointer purple_blist_node_get_ui_data(const PurpleBlistNode *node); /** * Sets the UI data of a given node. @@ -370,7 +370,7 @@ * * @since 2.6.0 */ -void purple_blist_node_set_ui_data(PurpleBlistNode *node, void *ui_data); +void purple_blist_node_set_ui_data(PurpleBlistNode *node, gpointer ui_data); /** * Shows the buddy list, creating a new one if necessary. @@ -393,6 +393,8 @@ /** * Updates a buddy's status. * + * This should only be called from within Purple. + * * @param buddy The buddy whose status has changed. * @param old_status The status from which we are changing. */ @@ -499,12 +501,19 @@ void purple_blist_add_chat(PurpleChat *chat, PurpleGroup *group, PurpleBlistNode *node); /** - * Creates a new buddy + * Creates a new buddy. + * + * This function only creates the PurpleBuddy. Use purple_blist_add_buddy + * to add the buddy to the list and purple_account_add_buddy to sync up + * with the server. * * @param account The account this buddy will get added to * @param name The name of the new buddy * @param alias The alias of the new buddy (or NULL if unaliased) * @return A newly allocated buddy + * + * @see purple_account_add_buddy + * @see purple_blist_add_buddy */ PurpleBuddy *purple_buddy_new(PurpleAccount *account, const char *name, const char *alias); @@ -618,7 +627,7 @@ * Creates a new group * * You can't have more than one group with the same name. Sorry. If you pass - * this the * name of a group that already exists, it will return that group. + * this the name of a group that already exists, it will return that group. * * @param name The name of the new group * @return A new group struct @@ -727,18 +736,22 @@ /** * Removes a buddy from the buddy list and frees the memory allocated to it. - * This doesn't actually try to remove the buddy from the server list, nor does - * it clean up the prpl_data. + * This doesn't actually try to remove the buddy from the server list. * * @param buddy The buddy to be removed + * + * @see purple_account_remove_buddy */ void purple_blist_remove_buddy(PurpleBuddy *buddy); /** * Removes a contact, and any buddies it contains, and frees the memory - * allocated to it. + * allocated to it. This calls purple_blist_remove_buddy and therefore + * doesn't remove the buddies from the server list. * * @param contact The contact to be removed + * + * @see purple_blist_remove_buddy */ void purple_blist_remove_contact(PurpleContact *contact); @@ -850,7 +863,7 @@ * Finds all PurpleBuddy structs given a name and an account * * @param account The account this buddy belongs to - * @param name The buddy's name (or NULL to return all buddies in the account) + * @param name The buddy's name (or NULL to return all buddies for the account) * * @return A GSList of buddies (which must be freed), or NULL if the buddy doesn't exist */ @@ -945,7 +958,7 @@ const char *purple_group_get_name(PurpleGroup *group); /** - * Called when an account gets signed on. Tells the UI to update all the + * Called when an account connects. Tells the UI to update all the * buddies. * * @param account The account @@ -954,7 +967,7 @@ /** - * Called when an account gets signed off. Sets the presence of all the buddies to 0 + * Called when an account disconnects. Sets the presence of all the buddies to 0 * and tells the UI to update them. * * @param account The account diff -r de9816c970fe -r 3912f55a1633 libpurple/media.c --- a/libpurple/media.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/media.c Tue Apr 28 18:43:57 2009 +0000 @@ -1851,7 +1851,7 @@ #endif GList * -purple_media_get_session_names(PurpleMedia *media) +purple_media_get_session_ids(PurpleMedia *media) { #ifdef USE_VV g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); @@ -2664,12 +2664,13 @@ } GList * -purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, const gchar *name) +purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, + const gchar *participant) { #ifdef USE_VV PurpleMediaStream *stream; g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); - stream = purple_media_get_stream(media, sess_id, name); + stream = purple_media_get_stream(media, sess_id, participant); return purple_media_candidate_list_from_fs(stream->local_candidates); #else return NULL; @@ -2678,20 +2679,21 @@ void purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id, - const gchar *name, GList *remote_candidates) + const gchar *participant, + GList *remote_candidates) { #ifdef USE_VV PurpleMediaStream *stream; GError *err = NULL; g_return_if_fail(PURPLE_IS_MEDIA(media)); - stream = purple_media_get_stream(media, sess_id, name); + stream = purple_media_get_stream(media, sess_id, participant); if (stream == NULL) { purple_debug_error("media", "purple_media_add_remote_candidates: " "couldn't find stream %s %s.\n", - sess_id, name); + sess_id, participant); return; } @@ -2717,12 +2719,12 @@ GList * purple_media_get_active_local_candidates(PurpleMedia *media, - const gchar *sess_id, const gchar *name) + const gchar *sess_id, const gchar *participant) { #ifdef USE_VV PurpleMediaStream *stream; g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); - stream = purple_media_get_stream(media, sess_id, name); + stream = purple_media_get_stream(media, sess_id, participant); return purple_media_candidate_list_from_fs( stream->active_local_candidates); #else @@ -2732,12 +2734,12 @@ GList * purple_media_get_active_remote_candidates(PurpleMedia *media, - const gchar *sess_id, const gchar *name) + const gchar *sess_id, const gchar *participant) { #ifdef USE_VV PurpleMediaStream *stream; g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL); - stream = purple_media_get_stream(media, sess_id, name); + stream = purple_media_get_stream(media, sess_id, participant); return purple_media_candidate_list_from_fs( stream->active_remote_candidates); #else @@ -2747,7 +2749,8 @@ #endif gboolean -purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, const gchar *name, GList *codecs) +purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, + const gchar *participant, GList *codecs) { #ifdef USE_VV PurpleMediaStream *stream; @@ -2756,7 +2759,7 @@ GError *err = NULL; g_return_val_if_fail(PURPLE_IS_MEDIA(media), FALSE); - stream = purple_media_get_stream(media, sess_id, name); + stream = purple_media_get_stream(media, sess_id, participant); if (stream == NULL) return FALSE; @@ -3030,7 +3033,7 @@ stream->session->id, stream->participant); } - iter = purple_media_get_session_names(media); + iter = purple_media_get_session_ids(media); for (; iter; iter = g_list_delete_link(iter, iter)) { gchar *session_name = iter->data; purple_media_manager_remove_output_windows( diff -r de9816c970fe -r 3912f55a1633 libpurple/media.h --- a/libpurple/media.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/media.h Tue Apr 28 18:43:57 2009 +0000 @@ -351,15 +351,15 @@ void purple_media_codec_list_free(GList *codecs); /** - * Gets a list of session names. + * Gets a list of session IDs. * - * @param media The media session to retrieve session names from. + * @param media The media session from which to retrieve session IDs. * - * @return GList of session names. + * @return GList of session IDs. The caller must free the list. * * @since 2.6.0 */ -GList *purple_media_get_session_names(PurpleMedia *media); +GList *purple_media_get_session_ids(PurpleMedia *media); /** * Gets the PurpleAccount this media session is on. @@ -495,14 +495,14 @@ * * @param media The media object to find the session in. * @param sess_id The session id of the session find the stream in. - * @param name The name of the remote user to add the candidates for. + * @param participant The name of the remote user to add the candidates for. * @param remote_candidates The remote candidates to add. * * @since 2.6.0 */ void purple_media_add_remote_candidates(PurpleMedia *media, const gchar *sess_id, - const gchar *name, + const gchar *participant, GList *remote_candidates); /** @@ -510,13 +510,13 @@ * * @param media The media object to find the session in. * @param sess_id The session id of the session to find the stream in. - * @param name The name of the remote user to get the candidates from. + * @param participant The name of the remote user to get the candidates from. * * @since 2.6.0 */ GList *purple_media_get_local_candidates(PurpleMedia *media, const gchar *sess_id, - const gchar *name); + const gchar *participant); #if 0 /* @@ -529,24 +529,26 @@ * * @param media The media object to find the session in. * @param sess_id The session id of the session to find the stream in. - * @param name The name of the remote user to get the active candidate from. + * @param participant The name of the remote user to get the active candidate + * from. * * @return The active candidates retrieved. */ GList *purple_media_get_active_local_candidates(PurpleMedia *media, - const gchar *sess_id, const gchar *name); + const gchar *sess_id, const gchar *participant); /** * Gets the active remote candidates for the stream. * * @param media The media object to find the session in. * @param sess_id The session id of the session to find the stream in. - * @param name The name of the remote user to get the remote candidate from. + * @param participant The name of the remote user to get the remote candidate + * from. * * @return The remote candidates retrieved. */ GList *purple_media_get_active_remote_candidates(PurpleMedia *media, - const gchar *sess_id, const gchar *name); + const gchar *sess_id, const gchar *participant); #endif /** @@ -554,14 +556,14 @@ * * @param media The media object to find the session in. * @param sess_id The session id of the session find the stream in. - * @param name The name of the remote user to get the candidates from. + * @param participant The name of the remote user to set the candidates from. * * @return @c TRUE The codecs were set successfully, or @c FALSE otherwise. * * @since 2.6.0 */ gboolean purple_media_set_remote_codecs(PurpleMedia *media, const gchar *sess_id, - const gchar *name, GList *codecs); + const gchar *participant, GList *codecs); /** * Returns whether or not the candidates for set of streams are prepared diff -r de9816c970fe -r 3912f55a1633 libpurple/mediamanager.h --- a/libpurple/mediamanager.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/mediamanager.h Tue Apr 28 18:43:57 2009 +0000 @@ -52,7 +52,7 @@ #endif /**************************************************************************/ -/** @cname Media Manager API */ +/** @name Media Manager API */ /**************************************************************************/ /*@{*/ diff -r de9816c970fe -r 3912f55a1633 libpurple/plugin.h --- a/libpurple/plugin.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/plugin.h Tue Apr 28 18:43:57 2009 +0000 @@ -105,6 +105,20 @@ void *ui_info; /**< Used only by UI-specific plugins to build a preference screen with a custom UI */ void *extra_info; PurplePluginUiInfo *prefs_info; /**< Used by any plugin to display preferences. If #ui_info has been specified, this will be ignored. */ + + /** + * This callback has a different use depending on whether this + * plugin type is PURPLE_PLUGIN_STANDARD or PURPLE_PLUGIN_PROTOCOL. + * + * If PURPLE_PLUGIN_STANDARD then the list of actions will show up + * in the Tools menu, under a submenu with the name of the plugin. + * context will be NULL. + * + * If PURPLE_PLUGIN_PROTOCOL then the list of actions will show up + * in the Accounts menu, under a submenu with the name of the + * account. context will be set to the PurpleConnection for that + * account. This callback will only be called for online accounts. + */ GList *(*actions)(PurplePlugin *plugin, gpointer context); void (*_purple_reserved1)(void); diff -r de9816c970fe -r 3912f55a1633 libpurple/plugins/statenotify.c --- a/libpurple/plugins/statenotify.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/plugins/statenotify.c Tue Apr 28 18:43:57 2009 +0000 @@ -71,9 +71,9 @@ void *data) { if (purple_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { - if (idle) { + if (idle && !old_idle) { write_status(buddy, _("%s has become idle.")); - } else { + } else if (!idle && old_idle) { write_status(buddy, _("%s is no longer idle.")); } } diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/bonjour/parser.c --- a/libpurple/protocols/bonjour/parser.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/bonjour/parser.c Tue Apr 28 18:43:57 2009 +0000 @@ -153,6 +153,18 @@ xmlnode_insert_data(bconv->current, (const char*) text, text_len); } +static void +bonjour_parser_structured_error_handler(void *user_data, xmlErrorPtr error) +{ + BonjourJabberConversation *bconv = user_data; + + purple_debug_error("jabber", "XML parser error for BonjourJabberConversation %p: " + "Domain %i, code %i, level %i: %s", + bconv, + error->domain, error->code, error->level, + (error->message ? error->message : "(null)\n")); +} + static xmlSAXHandler bonjour_parser_libxml = { NULL, /*internalSubset*/ NULL, /*isStandalone*/ @@ -185,7 +197,7 @@ NULL, /*_private*/ bonjour_parser_element_start_libxml, /*startElementNs*/ bonjour_parser_element_end_libxml, /*endElementNs*/ - NULL /*serror*/ + bonjour_parser_structured_error_handler /*serror*/ }; void diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/irc/msgs.c --- a/libpurple/protocols/irc/msgs.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/irc/msgs.c Tue Apr 28 18:43:57 2009 +0000 @@ -1019,6 +1019,8 @@ _("Nickname in use"), buf); g_free(buf); g_free(irc->reqnick); + irc->reqnick = NULL; + return; } if (strlen(args[1]) < strlen(irc->reqnick) || irc->nickused) diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/Makefile.am --- a/libpurple/protocols/jabber/Makefile.am Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/Makefile.am Tue Apr 28 18:43:57 2009 +0000 @@ -63,6 +63,8 @@ adhoccommands.h \ pep.c \ pep.h \ + useravatar.c \ + useravatar.h \ usermood.c \ usermood.h \ usernick.c \ diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/adhoccommands.c --- a/libpurple/protocols/jabber/adhoccommands.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/adhoccommands.c Tue Apr 28 18:43:57 2009 +0000 @@ -39,30 +39,18 @@ GList *actionslist; } JabberAdHocActionInfo; -void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from, - JabberIqType type, const char *id, - xmlnode *packet, gpointer data) +static void +jabber_adhoc_got_buddy_list(JabberStream *js, const char *from, xmlnode *query) { - const char *node; - xmlnode *query, *item; - JabberID *jabberid; + JabberID *jid; JabberBuddy *jb; JabberBuddyResource *jbr = NULL; - - if (type == JABBER_IQ_ERROR) - return; + xmlnode *item; - query = xmlnode_get_child_with_namespace(packet,"query","http://jabber.org/protocol/disco#items"); - if(!query) - return; - node = xmlnode_get_attrib(query,"node"); - if(!node || strcmp(node, "http://jabber.org/protocol/commands")) - return; - - if((jabberid = jabber_id_new(from))) { - if(jabberid->resource && (jb = jabber_buddy_find(js, from, TRUE))) - jbr = jabber_buddy_find_resource(jb, jabberid->resource); - jabber_id_free(jabberid); + if ((jid = jabber_id_new(from))) { + if (jid->resource && (jb = jabber_buddy_find(js, from, TRUE))) + jbr = jabber_buddy_find_resource(jb, jid->resource); + jabber_id_free(jid); } if(!jbr) @@ -96,11 +84,31 @@ } } +void +jabber_adhoc_disco_result_cb(JabberStream *js, const char *from, + JabberIqType type, const char *id, + xmlnode *packet, gpointer data) +{ + xmlnode *query; + const char *node; + + if (type == JABBER_IQ_ERROR) + return; + + query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); + if (!query) + return; + node = xmlnode_get_attrib(query, "node"); + if (!purple_strequal(node, "http://jabber.org/protocol/commands")) + return; + + jabber_adhoc_got_buddy_list(js, from, query); +} + static void jabber_adhoc_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *packet, gpointer data); - static void do_adhoc_action_cb(JabberStream *js, xmlnode *result, const char *actionhandle, gpointer user_data) { xmlnode *command; GList *action; @@ -224,11 +232,8 @@ } static void -jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from, - JabberIqType type, const char *id, - xmlnode *packet, gpointer data) +jabber_adhoc_got_server_list(JabberStream *js, const char *from, xmlnode *query) { - xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); xmlnode *item; if(!query) @@ -258,6 +263,29 @@ js->commands = g_list_append(js->commands,cmd); } + + if (js->state == JABBER_STREAM_CONNECTED) + purple_prpl_got_account_actions(purple_connection_get_account(js->gc)); +} + +static void +jabber_adhoc_server_got_list_cb(JabberStream *js, const char *from, + JabberIqType type, const char *id, + xmlnode *packet, gpointer data) +{ + xmlnode *query = xmlnode_get_child_with_namespace(packet, "query", "http://jabber.org/protocol/disco#items"); + + jabber_adhoc_got_server_list(js, from, query); + +} + +void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query) +{ + if (purple_strequal(from, js->user->domain)) { + jabber_adhoc_got_server_list(js, from, query); + } else { + jabber_adhoc_got_buddy_list(js, from, query); + } } void jabber_adhoc_server_get_list(JabberStream *js) { diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/adhoccommands.h --- a/libpurple/protocols/jabber/adhoccommands.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/adhoccommands.h Tue Apr 28 18:43:57 2009 +0000 @@ -34,6 +34,8 @@ void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data); +void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query); + void jabber_adhoc_server_get_list(JabberStream *js); void jabber_adhoc_init_server_commands(JabberStream *js, GList **m); diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Tue Apr 28 18:43:57 2009 +0000 @@ -32,12 +32,11 @@ #include "jabber.h" #include "iq.h" #include "presence.h" +#include "useravatar.h" #include "xdata.h" #include "pep.h" #include "adhoccommands.h" -#define MAX_HTTP_BUDDYICON_BYTES (200 * 1024) - typedef struct { long idle_seconds; } JabberBuddyInfoResource; @@ -98,36 +97,41 @@ for(l = jb->resources; l; l = l->next) { - if(!jbr && !resource) { - jbr = l->data; - } else if(!resource) { - if(((JabberBuddyResource *)l->data)->priority > jbr->priority) - jbr = l->data; - else if(((JabberBuddyResource *)l->data)->priority == jbr->priority) { + JabberBuddyResource *tmp = (JabberBuddyResource *) l->data; + if (!jbr && !resource) { + jbr = tmp; + } else if (!resource) { + if (tmp->priority > jbr->priority) + jbr = tmp; + else if (tmp->priority == jbr->priority) { /* Determine if this resource is more available than the one we've currently chosen */ - switch(((JabberBuddyResource *)l->data)->state) { + switch(tmp->state) { case JABBER_BUDDY_STATE_ONLINE: case JABBER_BUDDY_STATE_CHAT: /* This resource is online/chatty. Prefer to one which isn't either. */ - if ((jbr->state != JABBER_BUDDY_STATE_ONLINE) && (jbr->state != JABBER_BUDDY_STATE_CHAT)) - jbr = l->data; + if (((jbr->state != JABBER_BUDDY_STATE_ONLINE) && (jbr->state != JABBER_BUDDY_STATE_CHAT)) + || (jbr->idle && !tmp->idle) + || (jbr->idle && tmp->idle && tmp->idle > jbr->idle)) + jbr = tmp; break; case JABBER_BUDDY_STATE_AWAY: case JABBER_BUDDY_STATE_DND: /* This resource is away/dnd. Prefer to one which is extended away, unavailable, or unknown. */ - if ((jbr->state == JABBER_BUDDY_STATE_XA) || (jbr->state == JABBER_BUDDY_STATE_UNAVAILABLE) || + if (((jbr->state == JABBER_BUDDY_STATE_XA) || (jbr->state == JABBER_BUDDY_STATE_UNAVAILABLE) || (jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR)) - jbr = l->data; + || (jbr->idle && !tmp->idle) + || (jbr->idle && tmp->idle && tmp->idle > jbr->idle)) + jbr = tmp; break; case JABBER_BUDDY_STATE_XA: /* This resource is extended away. That's better than unavailable or unknown. */ if ((jbr->state == JABBER_BUDDY_STATE_UNAVAILABLE) || (jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR)) - jbr = l->data; + jbr = tmp; break; case JABBER_BUDDY_STATE_UNAVAILABLE: /* This resource is unavailable. That's better than unknown. */ if ((jbr->state == JABBER_BUDDY_STATE_UNKNOWN) || (jbr->state == JABBER_BUDDY_STATE_ERROR)) - jbr = l->data; + jbr = tmp; break; case JABBER_BUDDY_STATE_UNKNOWN: case JABBER_BUDDY_STATE_ERROR: @@ -135,9 +139,9 @@ break; } } - } else if(((JabberBuddyResource *)l->data)->name) { - if(!strcmp(((JabberBuddyResource *)l->data)->name, resource)) { - jbr = l->data; + } else if(tmp->name) { + if(!strcmp(tmp->name, resource)) { + jbr = tmp; break; } } @@ -204,21 +208,6 @@ jabber_buddy_resource_free(jbr); } -const char *jabber_buddy_get_status_msg(JabberBuddy *jb) -{ - JabberBuddyResource *jbr; - - if(!jb) - return NULL; - - jbr = jabber_buddy_find_resource(jb, NULL); - - if(!jbr) - return NULL; - - return jbr->status; -} - /******* * This is the old vCard stuff taken from the old prpl. vCards, by definition * are a temporary thing until jabber can get its act together and come up @@ -487,129 +476,25 @@ iq = jabber_iq_new(js, JABBER_IQ_SET); xmlnode_insert_child(iq->node, vc_node); jabber_iq_send(iq); + + /* Send presence to update vcard-temp:x:update */ + jabber_presence_send(js, FALSE); } } void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img) { - if(((JabberStream*)purple_connection_get_protocol_data(gc))->pep) { - /* XEP-0084: User Avatars */ - if(img) { - /* - * TODO: This is pretty gross. The Jabber PRPL really shouldn't - * do voodoo to try to determine the image type, height - * and width. - */ - /* A PNG header, including the IHDR, but nothing else */ - const struct { - guchar signature[8]; /* must be hex 89 50 4E 47 0D 0A 1A 0A */ - struct { - guint32 length; /* must be 0x0d */ - guchar type[4]; /* must be 'I' 'H' 'D' 'R' */ - guint32 width; - guint32 height; - guchar bitdepth; - guchar colortype; - guchar compression; - guchar filter; - guchar interlace; - } ihdr; - } *png = purple_imgstore_get_data(img); /* ATTN: this is in network byte order! */ - - /* check if the data is a valid png file (well, at least to some extend) */ - if(png->signature[0] == 0x89 && - png->signature[1] == 0x50 && - png->signature[2] == 0x4e && - png->signature[3] == 0x47 && - png->signature[4] == 0x0d && - png->signature[5] == 0x0a && - png->signature[6] == 0x1a && - png->signature[7] == 0x0a && - ntohl(png->ihdr.length) == 0x0d && - png->ihdr.type[0] == 'I' && - png->ihdr.type[1] == 'H' && - png->ihdr.type[2] == 'D' && - png->ihdr.type[3] == 'R') { - /* parse PNG header to get the size of the image (yes, this is required) */ - guint32 width = ntohl(png->ihdr.width); - guint32 height = ntohl(png->ihdr.height); - xmlnode *publish, *item, *data, *metadata, *info; - char *lengthstring, *widthstring, *heightstring; - - /* compute the sha1 hash */ - char *hash = jabber_calculate_data_sha1sum(purple_imgstore_get_data(img), purple_imgstore_get_size(img)); - char *base64avatar; - - publish = xmlnode_new("publish"); - xmlnode_set_attrib(publish,"node",AVATARNAMESPACEDATA); - - item = xmlnode_new_child(publish, "item"); - xmlnode_set_attrib(item, "id", hash); - - data = xmlnode_new_child(item, "data"); - xmlnode_set_namespace(data,AVATARNAMESPACEDATA); + PurpleAccount *account = purple_connection_get_account(gc); - base64avatar = purple_base64_encode(purple_imgstore_get_data(img), purple_imgstore_get_size(img)); - xmlnode_insert_data(data,base64avatar,-1); - g_free(base64avatar); - - /* publish the avatar itself */ - jabber_pep_publish((JabberStream*)purple_connection_get_protocol_data(gc), publish); - - /* next step: publish the metadata */ - publish = xmlnode_new("publish"); - xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA); - - item = xmlnode_new_child(publish, "item"); - xmlnode_set_attrib(item, "id", hash); - - metadata = xmlnode_new_child(item, "metadata"); - xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA); - - info = xmlnode_new_child(metadata, "info"); - xmlnode_set_attrib(info, "id", hash); - xmlnode_set_attrib(info, "type", "image/png"); - lengthstring = g_strdup_printf("%u", (unsigned)purple_imgstore_get_size(img)); - xmlnode_set_attrib(info, "bytes", lengthstring); - g_free(lengthstring); - widthstring = g_strdup_printf("%u", width); - xmlnode_set_attrib(info, "width", widthstring); - g_free(widthstring); - heightstring = g_strdup_printf("%u", height); - xmlnode_set_attrib(info, "height", heightstring); - g_free(heightstring); + /* Publish the avatar as specified in XEP-0084 */ + jabber_avatar_set(gc->proto_data, img); + /* Set the image in our vCard */ + jabber_set_info(gc, purple_account_get_user_info(account)); - /* publish the metadata */ - jabber_pep_publish((JabberStream*)purple_connection_get_protocol_data(gc), publish); - - g_free(hash); - } else { - purple_debug_error("jabber", "jabber_set_buddy_icon received non-png data"); - } - } else { - /* remove the metadata */ - xmlnode *metadata, *item; - xmlnode *publish = xmlnode_new("publish"); - xmlnode_set_attrib(publish,"node",AVATARNAMESPACEMETA); - - item = xmlnode_new_child(publish, "item"); - - metadata = xmlnode_new_child(item, "metadata"); - xmlnode_set_namespace(metadata,AVATARNAMESPACEMETA); - - xmlnode_new_child(metadata, "stop"); - - /* publish the metadata */ - jabber_pep_publish((JabberStream*)gc->proto_data, publish); - } - } - - /* vCard avatars do not have an image type requirement so update our - * vCard avatar regardless of image type for those poor older clients - */ - jabber_set_info(gc, purple_account_get_user_info(gc->account)); - - jabber_presence_send(gc->proto_data, FALSE); + /* TODO: Fake image to ourselves, since a number of servers do not echo + * back our presence to us. To do this without uselessly copying the data + * of the image, we need purple_buddy_icons_set_for_user_image (i.e. takes + * an existing icon/stored image). */ } /* @@ -1184,9 +1069,8 @@ JabberIqType type, const char *id, xmlnode *packet, gpointer data) { - xmlnode *vcard; - char *txt; - PurpleStoredImage *img; + xmlnode *vcard, *photo, *binval; + char *txt, *vcard_hash = NULL; if (type == JABBER_IQ_ERROR) { purple_debug_warning("jabber", "Server returned error while retrieving vCard"); @@ -1206,10 +1090,29 @@ js->vcard_fetched = TRUE; - if(NULL != (img = purple_buddy_icons_find_account_icon(js->gc->account))) { - jabber_set_buddy_icon(js->gc, img); - purple_imgstore_unref(img); + if (vcard && (photo = xmlnode_get_child(vcard, "PHOTO")) && + (binval = xmlnode_get_child(photo, "BINVAL"))) { + gsize size; + char *bintext = xmlnode_get_data(binval); + guchar *data = purple_base64_decode(bintext, &size); + g_free(bintext); + + if (data) { + vcard_hash = jabber_calculate_data_sha1sum(data, size); + g_free(data); + } } + + /* Republish our vcard if the photo is different than the server's */ + if (!purple_strequal(vcard_hash, js->initial_avatar_hash)) { + PurpleAccount *account = purple_connection_get_account(js->gc); + jabber_set_info(js->gc, purple_account_get_user_info(account)); + } else if (js->initial_avatar_hash) { + /* Our photo is in the vcard, so advertise vcard-temp updates */ + js->avatar_hash = g_strdup(js->initial_avatar_hash); + } + + g_free(vcard_hash); } void jabber_vcard_fetch_mine(JabberStream *js) @@ -1457,127 +1360,6 @@ jabber_buddy_info_show_if_ready(jbi); } -typedef struct _JabberBuddyAvatarUpdateURLInfo { - JabberStream *js; - char *from; - char *id; -} JabberBuddyAvatarUpdateURLInfo; - -static void do_buddy_avatar_update_fromurl(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message) { - JabberBuddyAvatarUpdateURLInfo *info = user_data; - if(!url_text) { - purple_debug(PURPLE_DEBUG_ERROR, "jabber", - "do_buddy_avatar_update_fromurl got error \"%s\"", error_message); - return; - } - - purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, (void*)url_text, len, info->id); - g_free(info->from); - g_free(info->id); - g_free(info); -} - -static void do_buddy_avatar_update_data(JabberStream *js, const char *from, xmlnode *items) { - xmlnode *item, *data; - const char *checksum; - char *b64data; - void *img; - size_t size; - if(!items) - return; - - item = xmlnode_get_child(items, "item"); - if(!item) - return; - - data = xmlnode_get_child_with_namespace(item,"data",AVATARNAMESPACEDATA); - if(!data) - return; - - checksum = xmlnode_get_attrib(item,"id"); - if(!checksum) - return; - - b64data = xmlnode_get_data(data); - if(!b64data) - return; - - img = purple_base64_decode(b64data, &size); - if(!img) { - g_free(b64data); - return; - } - - purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, img, size, checksum); - g_free(b64data); -} - -void jabber_buddy_avatar_update_metadata(JabberStream *js, const char *from, xmlnode *items) { - PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); - const char *checksum; - xmlnode *item, *metadata; - if(!buddy) - return; - - checksum = purple_buddy_icons_get_checksum_for_user(buddy); - item = xmlnode_get_child(items,"item"); - metadata = xmlnode_get_child_with_namespace(item, "metadata", AVATARNAMESPACEMETA); - if(!metadata) - return; - /* check if we have received a stop */ - if(xmlnode_get_child(metadata, "stop")) { - purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); - } else { - xmlnode *info, *goodinfo = NULL; - gboolean has_children = FALSE; - - /* iterate over all info nodes to get one we can use */ - for(info = metadata->child; info; info = info->next) { - if(info->type == XMLNODE_TYPE_TAG) - has_children = TRUE; - if(info->type == XMLNODE_TYPE_TAG && !strcmp(info->name,"info")) { - const char *type = xmlnode_get_attrib(info,"type"); - const char *id = xmlnode_get_attrib(info,"id"); - - if(checksum && id && !strcmp(id, checksum)) { - /* we already have that avatar, so we don't have to do anything */ - goodinfo = NULL; - break; - } - /* We'll only pick the png one for now. It's a very nice image format anyways. */ - if(type && id && !goodinfo && !strcmp(type, "image/png")) - goodinfo = info; - } - } - if(has_children == FALSE) { - purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); - } else if(goodinfo) { - const char *url = xmlnode_get_attrib(goodinfo, "url"); - const char *id = xmlnode_get_attrib(goodinfo,"id"); - - /* the avatar might either be stored in a pep node, or on a HTTP/HTTPS URL */ - if(!url) - jabber_pep_request_item(js, from, AVATARNAMESPACEDATA, id, do_buddy_avatar_update_data); - else { - PurpleUtilFetchUrlData *url_data; - JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1); - info->js = js; - - url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE, - MAX_HTTP_BUDDYICON_BYTES, - do_buddy_avatar_update_fromurl, info); - if (url_data) { - info->from = g_strdup(from); - info->id = g_strdup(id); - js->url_datas = g_slist_prepend(js->url_datas, url_data); - } else - g_free(info); - - } - } - } -} - static void jabber_buddy_info_resource_free(gpointer data) { JabberBuddyInfoResource *jbri = data; @@ -1650,12 +1432,49 @@ if(seconds) { char *end = NULL; long sec = strtol(seconds, &end, 10); - if(end != seconds) { + JabberBuddy *jb = NULL; + char *resource = NULL; + char *buddy_name = NULL; + JabberBuddyResource *jbr = NULL; + + if(end != seconds) { JabberBuddyInfoResource *jbir = g_hash_table_lookup(jbi->resources, resource_name); if(jbir) { jbir->idle_seconds = sec; } } + /* Update the idle time of the buddy resource, if we got it. + This will correct the value when a server doesn't mark + delayed presence and we got the presence when signing on */ + jb = jabber_buddy_find(js, from, FALSE); + if (jb) { + resource = jabber_get_resource(from); + buddy_name = jabber_get_bare_jid(from); + /* if the resource already has an idle time set, we + must have gotten it originally from a presence. In + this case we update it. Otherwise don't update it, to + avoid setting an idle and not getting informed about + the resource getting unidle */ + if (resource && buddy_name) { + jbr = jabber_buddy_find_resource(jb, resource); + + if (jbr->idle) { + if (sec) { + jbr->idle = time(NULL) - sec; + } else { + jbr->idle = 0; + } + + if (jbr == + jabber_buddy_find_resource(jb, NULL)) { + purple_prpl_got_user_idle(js->gc->account, + buddy_name, jbr->idle, jbr->idle); + } + } + } + g_free(resource); + g_free(buddy_name); + } } } } diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/buddy.h --- a/libpurple/protocols/jabber/buddy.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.h Tue Apr 28 18:43:57 2009 +0000 @@ -36,9 +36,6 @@ #include "jabber.h" #include "caps.h" -#define AVATARNAMESPACEDATA "http://www.xmpp.org/extensions/xep-0084.html#ns-data" -#define AVATARNAMESPACEMETA "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata" - typedef struct _JabberBuddy { GList *resources; char *error_msg; @@ -69,6 +66,7 @@ int priority; JabberBuddyState state; char *status; + time_t idle; JabberCapabilities capabilities; char *thread_id; enum { @@ -99,7 +97,6 @@ int priority, JabberBuddyState state, const char *status); void jabber_buddy_resource_free(JabberBuddyResource *jbr); void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource); -const char *jabber_buddy_get_status_msg(JabberBuddy *jb); void jabber_buddy_get_info(PurpleConnection *gc, const char *who); GList *jabber_blist_node_menu(PurpleBlistNode *node); @@ -107,7 +104,6 @@ void jabber_set_info(PurpleConnection *gc, const char *info); void jabber_setup_set_info(PurplePluginAction *action); void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img); -void jabber_buddy_avatar_update_metadata(JabberStream *js, const char *from, xmlnode *items); const char *jabber_buddy_state_get_name(JabberBuddyState state); const char *jabber_buddy_state_get_status_id(JabberBuddyState state); diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/chat.c --- a/libpurple/protocols/jabber/chat.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/chat.c Tue Apr 28 18:43:57 2009 +0000 @@ -597,37 +597,25 @@ /* merge this with the function below when we get everyone on the same page wrt /commands */ void jabber_chat_change_topic(JabberChat *chat, const char *topic) { - if(topic && *topic) { - JabberMessage *jm; - jm = g_new0(JabberMessage, 1); - jm->js = chat->js; - jm->type = JABBER_MESSAGE_GROUPCHAT; - jm->subject = purple_markup_strip_html(topic); - jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); - jabber_message_send(jm); - jabber_message_free(jm); - } else { - const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(chat->conv)); - char *buf, *tmp, *tmp2; + JabberMessage *jm; + + jm = g_new0(JabberMessage, 1); + jm->js = chat->js; + jm->type = JABBER_MESSAGE_GROUPCHAT; + jm->to = g_strdup_printf("%s@%s", chat->room, chat->server); - if(cur) { - tmp = g_markup_escape_text(cur, -1); - tmp2 = purple_markup_linkify(tmp); - buf = g_strdup_printf(_("current topic is: %s"), tmp2); - g_free(tmp); - g_free(tmp2); - } else - buf = g_strdup(_("No topic is set")); - purple_conv_chat_write(PURPLE_CONV_CHAT(chat->conv), "", buf, - PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); - g_free(buf); - } + if (topic && *topic) + jm->subject = purple_markup_strip_html(topic); + else + jm->subject = g_strdup(""); + jabber_message_send(jm); + jabber_message_free(jm); } void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic) { - JabberStream *js = gc->proto_data; + JabberStream *js = purple_connection_get_protocol_data(gc); JabberChat *chat = jabber_chat_find_by_id(js, id); if(!chat) diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/disco.c --- a/libpurple/protocols/jabber/disco.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/disco.c Tue Apr 28 18:43:57 2009 +0000 @@ -23,17 +23,17 @@ #include "prefs.h" #include "debug.h" +#include "adhoccommands.h" #include "buddy.h" +#include "disco.h" #include "google.h" #include "iq.h" -#include "disco.h" #include "jabber.h" #include "jingle/jingle.h" +#include "pep.h" #include "presence.h" #include "roster.h" -#include "pep.h" -#include "adhoccommands.h" - +#include "useravatar.h" struct _jabber_disco_info_cb_data { gpointer data; @@ -312,8 +312,16 @@ { const char *ft_proxies; + /* + * This *should* happen only if the server supports vcard-temp, but there + * are apparently some servers that don't advertise it even though they + * support it. + */ jabber_vcard_fetch_mine(js); + if (js->pep) + jabber_avatar_fetch_mine(js); + if (!(js->server_caps & JABBER_CAP_GOOGLE_ROSTER)) { /* If the server supports JABBER_CAP_GOOGLE_ROSTER; we will have already requested it */ jabber_roster_request(js); diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/jabber.c --- a/libpurple/protocols/jabber/jabber.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.c Tue Apr 28 18:43:57 2009 +0000 @@ -28,6 +28,7 @@ #include "conversation.h" #include "debug.h" #include "dnssrv.h" +#include "imgstore.h" #include "message.h" #include "notify.h" #include "pluginpref.h" @@ -36,6 +37,7 @@ #include "prpl.h" #include "request.h" #include "server.h" +#include "status.h" #include "util.h" #include "version.h" #include "xmlnode.h" @@ -81,6 +83,10 @@ "xmlns:stream='http://etherx.jabber.org/streams' " "version='1.0'>", js->user->domain); + if (js->reinit) + /* Close down the current stream to keep the XML parser happy */ + jabber_parser_close_stream(js); + /* setup the parser fresh for each stream */ jabber_parser_setup(js); jabber_send_raw(js, open_stream, -1); @@ -675,6 +681,9 @@ static void tls_init(JabberStream *js) { + /* Close down the current stream to keep the XML parser happy */ + jabber_parser_close_stream(js); + purple_input_remove(js->gc->inpa); js->gc->inpa = 0; js->gsc = purple_ssl_connect_with_host_fd(js->gc->account, js->fd, @@ -747,6 +756,8 @@ const char *connect_server = purple_account_get_string(account, "connect_server", ""); JabberStream *js; + PurplePresence *presence; + PurpleStoredImage *image; JabberBuddy *my_jb = NULL; gc->flags |= PURPLE_CONNECTION_HTML | @@ -765,7 +776,7 @@ js->user = jabber_id_new(purple_account_get_username(account)); js->next_id = g_random_int(); js->write_buffer = purple_circ_buffer_new(512); - js->old_length = 0; + js->old_length = -1; js->keepalive_timeout = -1; /* Set the default protocol version to 1.0. Overridden in parser.c. */ js->protocol_version = JABBER_PROTO_1_0; @@ -774,6 +785,13 @@ js->stun_port = 0; js->stun_query = NULL; + /* if we are idle, set idle-ness on the stream (this could happen if we get + disconnected and the reconnects while being idle. I don't think it makes + sense to do this when registering a new account... */ + presence = purple_account_get_presence(account); + if (purple_presence_is_idle(presence)) + js->idle = purple_presence_get_idle_time(presence); + if(!js->user) { purple_connection_error_reason (gc, PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, @@ -788,6 +806,17 @@ return; } + /* + * Calculate the avatar hash for our current image so we know (when we + * fetch our vCard and PEP avatar) if we should send our avatar to the + * server. + */ + if ((image = purple_buddy_icons_find_account_icon(account))) { + js->initial_avatar_hash = jabber_calculate_data_sha1sum(purple_imgstore_get_data(image), + purple_imgstore_get_size(image)); + purple_imgstore_unref(image); + } + if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE))) my_jb->subscription |= JABBER_SUB_BOTH; @@ -1411,6 +1440,11 @@ jabber_unregister_account_cb(js); } +/* TODO: As Will pointed out in IRC, after being notified by the core to + * shutdown, we should async. wait for the server to send us the stream + * termination before destorying everything. That seems like it would require + * changing the semantics of prpl->close(), so it's a good idea for 3.0.0. + */ void jabber_close(PurpleConnection *gc) { JabberStream *js = gc->proto_data; @@ -1486,6 +1520,7 @@ g_free(js->stream_id); if(js->user) jabber_id_free(js->user); + g_free(js->initial_avatar_hash); g_free(js->avatar_hash); g_free(js->caps_hash); @@ -1602,8 +1637,14 @@ void jabber_idle_set(PurpleConnection *gc, int idle) { JabberStream *js = gc->proto_data; + PurpleAccount *account = purple_connection_get_account(gc); + PurpleStatus *status = purple_account_get_active_status(account); js->idle = idle ? time(NULL) - idle : idle; + + /* send out an updated prescence */ + purple_debug_info("jabber", "sending updated presence for idle\n"); + jabber_presence_send(account, status); } static void jabber_blocklist_parse(JabberStream *js, const char *from, @@ -1830,10 +1871,11 @@ } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { ret = g_strdup(jb->error_msg); } else { + PurplePresence *presence = purple_buddy_get_presence(b); + PurpleStatus *status =purple_presence_get_active_status(presence); char *stripped; - if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { - PurplePresence *presence = purple_buddy_get_presence(b); + if(!(stripped = purple_markup_strip_html(purple_status_get_attr_string(status, "message")))) { if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) { PurpleStatus *status = purple_presence_get_status(presence, "tune"); stripped = g_strdup(purple_status_get_attr_string(status, PURPLE_TUNE_TITLE)); @@ -1849,6 +1891,56 @@ return ret; } +static void +jabber_tooltip_add_resource_text(JabberBuddyResource *jbr, + PurpleNotifyUserInfo *user_info, gboolean multiple_resources) +{ + char *text = NULL; + char *res = NULL; + char *label, *value; + const char *state; + + if(jbr->status) { + char *tmp; + text = purple_strreplace(jbr->status, "\n", "
\n"); + tmp = purple_markup_strip_html(text); + g_free(text); + text = g_markup_escape_text(tmp, -1); + g_free(tmp); + } + + if(jbr->name) + res = g_strdup_printf(" (%s)", jbr->name); + + state = jabber_buddy_state_get_name(jbr->state); + if (text != NULL && !purple_utf8_strcasecmp(state, text)) { + g_free(text); + text = NULL; + } + + label = g_strdup_printf("%s%s", _("Status"), (res ? res : "")); + value = g_strdup_printf("%s%s%s", state, (text ? ": " : ""), (text ? text : "")); + + purple_notify_user_info_add_pair(user_info, label, value); + g_free(label); + g_free(value); + g_free(text); + + /* if the resource is idle, show that */ + /* only show it if there is more than one resource available for + the buddy, since the "general" idleness will be shown anyway, + this way we can see see the idleness of lower-priority resources */ + if (jbr->idle && multiple_resources) { + gchar *idle_str = + purple_str_seconds_to_string(time(NULL) - jbr->idle); + label = g_strdup_printf("%s%s", _("Idle"), (res ? res : "")); + purple_notify_user_info_add_pair(user_info, label, idle_str); + g_free(idle_str); + g_free(label); + } + g_free(res); +} + void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { JabberBuddy *jb; @@ -1872,28 +1964,28 @@ const char *sub; GList *l; const char *mood; - + gboolean multiple_resources = + jb->resources && g_list_next(jb->resources); + JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL); + + /* resource-specific info for the top resource */ + if (top_jbr) { + jabber_tooltip_add_resource_text(top_jbr, user_info, + multiple_resources); + } + + for(l=jb->resources; l; l = l->next) { + jbr = l->data; + /* the remaining resources */ + if (jbr != top_jbr) { + jabber_tooltip_add_resource_text(jbr, user_info, + multiple_resources); + } + } + if (full) { PurpleStatus *status; - if(jb->subscription & JABBER_SUB_FROM) { - if(jb->subscription & JABBER_SUB_TO) - sub = _("Both"); - else if(jb->subscription & JABBER_SUB_PENDING) - sub = _("From (To pending)"); - else - sub = _("From"); - } else { - if(jb->subscription & JABBER_SUB_TO) - sub = _("To"); - else if(jb->subscription & JABBER_SUB_PENDING) - sub = _("None (To pending)"); - else - sub = _("None"); - } - - purple_notify_user_info_add_pair(user_info, _("Subscription"), sub); - status = purple_presence_get_active_status(presence); mood = purple_status_get_attr_string(status, "mood"); if(mood != NULL) { @@ -1918,47 +2010,25 @@ g_free(playing); } } - } - - for(l=jb->resources; l; l = l->next) { - char *text = NULL; - char *res = NULL; - char *label, *value; - const char *state; - - jbr = l->data; - - if(jbr->status) { - char *tmp; - text = purple_strreplace(jbr->status, "\n", "
\n"); - tmp = purple_markup_strip_html(text); - g_free(text); - text = g_markup_escape_text(tmp, -1); - g_free(tmp); + + if(jb->subscription & JABBER_SUB_FROM) { + if(jb->subscription & JABBER_SUB_TO) + sub = _("Both"); + else if(jb->subscription & JABBER_SUB_PENDING) + sub = _("From (To pending)"); + else + sub = _("From"); + } else { + if(jb->subscription & JABBER_SUB_TO) + sub = _("To"); + else if(jb->subscription & JABBER_SUB_PENDING) + sub = _("None (To pending)"); + else + sub = _("None"); } - if(jbr->name) - res = g_strdup_printf(" (%s)", jbr->name); - - state = jabber_buddy_state_get_name(jbr->state); - if (text != NULL && !purple_utf8_strcasecmp(state, text)) { - g_free(text); - text = NULL; - } - - label = g_strdup_printf("%s%s", - _("Status"), (res ? res : "")); - value = g_strdup_printf("%s%s%s", - state, - (text ? ": " : ""), - (text ? text : "")); - - purple_notify_user_info_add_pair(user_info, label, value); - - g_free(label); - g_free(value); - g_free(text); - g_free(res); + purple_notify_user_info_add_pair(user_info, _("Subscription"), sub); + } if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { @@ -2451,7 +2521,25 @@ if (!chat) return PURPLE_CMD_RET_FAILED; - jabber_chat_change_topic(chat, args ? args[0] : NULL); + if (args && args[0] && *args[0]) + jabber_chat_change_topic(chat, args[0]); + else { + const char *cur = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); + char *buf, *tmp, *tmp2; + + if (cur) { + tmp = g_markup_escape_text(cur, -1); + tmp2 = purple_markup_linkify(tmp); + buf = g_strdup_printf(_("current topic is: %s"), tmp2); + g_free(tmp); + g_free(tmp2); + } else + buf = g_strdup(_("No topic is set")); + purple_conv_chat_write(PURPLE_CONV_CHAT(conv), "", buf, + PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG, time(NULL)); + g_free(buf); + } + return PURPLE_CMD_RET_OK; } diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/jabber.h --- a/libpurple/protocols/jabber/jabber.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/jabber.h Tue Apr 28 18:43:57 2009 +0000 @@ -159,6 +159,7 @@ GList *file_transfers; time_t idle; + time_t old_idle; JabberID *user; PurpleConnection *gc; @@ -166,6 +167,7 @@ gboolean registration; + char *initial_avatar_hash; char *avatar_hash; GSList *pending_avatar_requests; diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/jingle/content.c --- a/libpurple/protocols/jabber/jingle/content.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/content.c Tue Apr 28 18:43:57 2009 +0000 @@ -391,7 +391,13 @@ jingle_content_parse(xmlnode *content) { const gchar *type = xmlnode_get_namespace(xmlnode_get_child(content, "description")); - return JINGLE_CONTENT_CLASS(g_type_class_ref(jingle_get_type(type)))->parse(content); + GType jingle_type = jingle_get_type(type); + + if (jingle_type != G_TYPE_NONE) { + return JINGLE_CONTENT_CLASS(g_type_class_ref(jingle_type))->parse(content); + } else { + return NULL; + } } static xmlnode * diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/jingle/session.c --- a/libpurple/protocols/jabber/jingle/session.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/jingle/session.c Tue Apr 28 18:43:57 2009 +0000 @@ -363,17 +363,18 @@ g_hash_table_lookup(js->sessions, sid) : NULL; } +#if GLIB_CHECK_VERSION(2,4,0) static gboolean find_by_jid_ghr(gpointer key, gpointer value, gpointer user_data) { JingleSession *session = (JingleSession *)value; const gchar *jid = user_data; - gboolean use_bare = strchr(jid, '/') == NULL; + gboolean use_bare = g_utf8_strchr(jid, -1, '/') == NULL; gchar *remote_jid = jingle_session_get_remote_jid(session); gchar *cmp_jid = use_bare ? jabber_get_bare_jid(remote_jid) : g_strdup(remote_jid); g_free(remote_jid); - if (!strcmp(jid, cmp_jid)) { + if (g_str_equal(jid, cmp_jid)) { g_free(cmp_jid); return TRUE; } @@ -382,12 +383,58 @@ return FALSE; } +#else /* GLIB_CHECK_VERSION 2.4.0 */ + +/* Ugly code; g_hash_table_find version above is much nicer */ +struct session_find_jid +{ + const gchar *jid; + JingleSession *ret; + gboolean use_bare; +}; + +static void find_by_jid_ghr(gpointer key, gpointer value, gpointer user_data) +{ + JingleSession *session = (JingleSession *)value; + struct session_find_jid *data = user_data; + gchar *remote_jid; + gchar *cmp_jid; + + if (data->ret != NULL) + return; + + remote_jid = jingle_session_get_remote_jid(session); + cmp_jid = data->use_bare ? jabber_get_bare_jid(remote_jid) + : g_strdup(remote_jid); + g_free(remote_jid); + + if (g_str_equal(data->jid, cmp_jid)) + data->ret = session; + + g_free(cmp_jid); +} +#endif /* GLIB_CHECK_VERSION 2.4.0 */ + JingleSession * jingle_session_find_by_jid(JabberStream *js, const gchar *jid) { +#if GLIB_CHECK_VERSION(2,4,0) return js->sessions != NULL ? g_hash_table_find(js->sessions, find_by_jid_ghr, (gpointer)jid) : NULL; +#else + struct session_find_jid data; + + if (js->sessions == NULL) + return NULL; + + data.jid = jid; + data.ret = NULL; + data.use_bare = g_utf8_strchr(jid, -1, '/') == NULL; + + g_hash_table_foreach(js->sessions, find_by_jid_ghr, &data); + return data.ret; +#endif } static xmlnode * diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/libxmpp.c --- a/libpurple/protocols/jabber/libxmpp.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/libxmpp.c Tue Apr 28 18:43:57 2009 +0000 @@ -216,19 +216,24 @@ #endif PurpleAccountUserSplit *split; PurpleAccountOption *option; + /* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */ split = purple_account_user_split_new(_("Domain"), NULL, '@'); purple_account_user_split_set_reverse(split, FALSE); prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); + split = purple_account_user_split_new(_("Resource"), NULL, '/'); purple_account_user_split_set_reverse(split, FALSE); prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); + option = purple_account_option_bool_new(_("Require SSL/TLS"), "require_tls", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + option = purple_account_option_bool_new( _("Allow plaintext auth over unencrypted streams"), "auth_plain_in_clear", FALSE); @@ -294,14 +299,10 @@ jabber_ibb_init(); jabber_si_init(); - jabber_add_feature(AVATARNAMESPACEMETA, jabber_pep_namespace_only_when_pep_enabled_cb); - jabber_add_feature(AVATARNAMESPACEDATA, jabber_pep_namespace_only_when_pep_enabled_cb); jabber_add_feature("http://www.xmpp.org/extensions/xep-0224.html#ns", jabber_buzz_isenabled); jabber_add_feature(XEP_0231_NAMESPACE, jabber_custom_smileys_isenabled); jabber_add_feature(XEP_0047_NAMESPACE, NULL); - - jabber_pep_register_handler(AVATARNAMESPACEMETA, jabber_buddy_avatar_update_metadata); } diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/message.c --- a/libpurple/protocols/jabber/message.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/message.c Tue Apr 28 18:43:57 2009 +0000 @@ -24,6 +24,7 @@ #include "notify.h" #include "server.h" #include "util.h" +#include "adhoccommands.h" #include "buddy.h" #include "chat.h" #include "data.h" @@ -597,8 +598,11 @@ /* The following tests expect xmlns != NULL */ continue; } else if(!strcmp(child->name, "subject") && !strcmp(xmlns,"jabber:client")) { - if(!jm->subject) + if(!jm->subject) { jm->subject = xmlnode_get_data(child); + if(!jm->subject) + jm->subject = g_strdup(""); + } } else if(!strcmp(child->name, "thread") && !strcmp(xmlns,"jabber:client")) { if(!jm->thread_id) jm->thread_id = xmlnode_get_data(child); @@ -637,7 +641,8 @@ } jabber_id_free(jid); - } else { + } else if (jm->type == JABBER_MESSAGE_NORMAL || + jm->type == JABBER_MESSAGE_CHAT) { conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, who, account); @@ -776,6 +781,12 @@ } else { jm->etc = g_list_append(jm->etc, child); } + } else if (g_str_equal(child->name, "query")) { + const char *node = xmlnode_get_attrib(child, "node"); + if (purple_strequal(xmlns, "http://jabber.org/protocol/disco#items") + && purple_strequal(node, "http://jabber.org/protocol/commands")) { + jabber_adhoc_got_list(js, jm->from, child); + } } } diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/parser.c --- a/libpurple/protocols/jabber/parser.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/parser.c Tue Apr 28 18:43:57 2009 +0000 @@ -207,6 +207,12 @@ jabber_parser_free(js); } +void +jabber_parser_close_stream(JabberStream *js) +{ + xmlParseChunk(js->context, "", 16 /* length */, 0); +} + void jabber_parser_free(JabberStream *js) { if (js->context) { xmlParseChunk(js->context, NULL,0,1); @@ -226,8 +232,17 @@ xmlParseChunk(js->context, "", 0, 0); } else if ((ret = xmlParseChunk(js->context, buf, len, 0)) != XML_ERR_OK) { xmlError *err = xmlCtxtGetLastError(js->context); + /* + * libxml2 uses a global setting to determine whether or not to store + * warnings. Other libraries may set this, which causes err to be + * NULL. See #8136 for details. + */ + xmlErrorLevel level = XML_ERR_WARNING; - switch (err->level) { + if (err) + level = err->level; + + switch (level) { case XML_ERR_NONE: purple_debug_info("jabber", "xmlParseChunk returned info %i\n", ret); break; diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/parser.h --- a/libpurple/protocols/jabber/parser.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/parser.h Tue Apr 28 18:43:57 2009 +0000 @@ -25,6 +25,7 @@ #include "jabber.h" void jabber_parser_setup(JabberStream *js); +void jabber_parser_close_stream(JabberStream *js); void jabber_parser_free(JabberStream *js); void jabber_parser_process(JabberStream *js, const char *buf, int len); diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/pep.c --- a/libpurple/protocols/jabber/pep.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/pep.c Tue Apr 28 18:43:57 2009 +0000 @@ -24,6 +24,7 @@ #include "pep.h" #include "iq.h" #include +#include "useravatar.h" #include "usermood.h" #include "usernick.h" #include "usertune.h" @@ -35,6 +36,7 @@ pep_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); /* register PEP handlers */ + jabber_avatar_init(); jabber_mood_init(); jabber_tune_init(); jabber_nick_init(); @@ -104,7 +106,12 @@ /* this may be called even when the own server doesn't support pep! */ JabberPEPHandler *jph; GList *itemslist; - char *jid = jabber_get_bare_jid(jm->from); + char *jid; + + if (jm->type != JABBER_MESSAGE_EVENT) + return; + + jid = jabber_get_bare_jid(jm->from); for(itemslist = jm->eventitems; itemslist; itemslist = itemslist->next) { xmlnode *items = (xmlnode*)itemslist->data; @@ -118,6 +125,25 @@ g_free(jid); } +void jabber_pep_delete_node(JabberStream *js, const gchar *node) +{ + JabberIq *iq; + xmlnode *pubsub, *del; + + g_return_if_fail(node != NULL); + g_return_if_fail(js->pep); + + iq = jabber_iq_new(js, JABBER_IQ_SET); + + pubsub = xmlnode_new_child(iq->node, "pubsub"); + xmlnode_set_namespace(pubsub, "http://jabber.org/protocol/pubsub#owner"); + + del = xmlnode_new_child(pubsub, "delete"); + xmlnode_set_attrib(del, "node", node); + + jabber_iq_send(iq); +} + void jabber_pep_publish(JabberStream *js, xmlnode *publish) { JabberIq *iq; xmlnode *pubsub; diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/pep.h --- a/libpurple/protocols/jabber/pep.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/pep.h Tue Apr 28 18:43:57 2009 +0000 @@ -73,6 +73,11 @@ void jabber_handle_event(JabberMessage *jm); +/** + * Delete the specified PEP node. + */ +void jabber_pep_delete_node(JabberStream *js, const gchar *node); + /* * Publishes PEP item(s) * diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/presence.c --- a/libpurple/protocols/jabber/presence.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/jabber/presence.c Tue Apr 28 18:43:57 2009 +0000 @@ -154,17 +154,25 @@ /* check if there are any differences to the and send them in that case */ if (force || allowBuzz != js->allowBuzz || js->old_state != state || CHANGED(js->old_msg, stripped) || js->old_priority != priority || - CHANGED(js->old_avatarhash, js->avatar_hash)) { + CHANGED(js->old_avatarhash, js->avatar_hash) || js->old_idle != js->idle) { /* Need to update allowBuzz before creating the presence (with caps) */ js->allowBuzz = allowBuzz; presence = jabber_presence_create_js(js, state, stripped, priority); - if(js->avatar_hash) { - x = xmlnode_new_child(presence, "x"); - xmlnode_set_namespace(x, "vcard-temp:x:update"); + /* Per XEP-0153 4.1, we must always send the */ + x = xmlnode_new_child(presence, "x"); + xmlnode_set_namespace(x, "vcard-temp:x:update"); + /* + * FIXME: Per XEP-0153 4.3.2 bullet 2, we must not publish our + * image hash if another resource has logged in and updated the + * vcard avatar. Requires changes in jabber_presence_parse. + */ + if (js->vcard_fetched) { + /* Always publish a ; it's empty if we have no image. */ photo = xmlnode_new_child(x, "photo"); - xmlnode_insert_data(photo, js->avatar_hash, -1); + if (js->avatar_hash) + xmlnode_insert_data(photo, js->avatar_hash, -1); } jabber_send(js, presence); @@ -182,6 +190,7 @@ js->old_avatarhash = g_strdup(js->avatar_hash); js->old_state = state; js->old_priority = priority; + js->old_idle = js->idle; } g_free(stripped); @@ -263,6 +272,16 @@ g_free(pstr); } + /* if we are idle and not offline, include idle */ + if (js->idle && state != JABBER_BUDDY_STATE_UNAVAILABLE) { + xmlnode *query = xmlnode_new_child(presence, "query"); + gchar seconds[10]; + g_snprintf(seconds, 10, "%d", (int) (time(NULL) - js->idle)); + + xmlnode_set_namespace(query, "jabber:iq:last"); + xmlnode_set_attrib(query, "seconds", seconds); + } + /* JEP-0115 */ /* calculate hash */ jabber_caps_calculate_own_hash(js); @@ -323,8 +342,6 @@ JabberBuddy *jb = NULL; xmlnode *vcard, *photo, *binval; char *text; - guchar *data; - gsize size; if(!from) return; @@ -339,10 +356,13 @@ (( (binval = xmlnode_get_child(photo, "BINVAL")) && (text = xmlnode_get_data(binval))) || (text = xmlnode_get_data(photo)))) { - char *hash; + guchar *data; + gchar *hash; + gsize size; data = purple_base64_decode(text, &size); hash = jabber_calculate_data_sha1sum(data, size); + purple_buddy_icons_set_for_user(js->gc->account, from, data, size, hash); g_free(hash); g_free(text); @@ -412,6 +432,7 @@ JabberBuddyResource *jbr = NULL, *found_jbr = NULL; PurpleConvChatBuddyFlags flags = PURPLE_CBFLAGS_NONE; gboolean delayed = FALSE; + const gchar *stamp = NULL; /* from element */ PurpleBuddy *b = NULL; char *buddy_name; JabberBuddyState state = JABBER_BUDDY_STATE_UNKNOWN; @@ -419,6 +440,7 @@ gboolean muc = FALSE; char *avatar_hash = NULL; xmlnode *caps = NULL; + int idle = 0; if(!(jb = jabber_buddy_find(js, from, TRUE))) return; @@ -501,12 +523,14 @@ } else if(!strcmp(y->name, "delay") && !strcmp(xmlns, "urn:xmpp:delay")) { /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ delayed = TRUE; + stamp = xmlnode_get_attrib(y, "stamp"); } else if(!strcmp(y->name, "c") && !strcmp(xmlns, "http://jabber.org/protocol/caps")) { caps = y; /* store for later, when creating buddy resource */ } else if(!strcmp(y->name, "x")) { if(!strcmp(xmlns, "jabber:x:delay")) { /* XXX: compare the time. jabber:x:delay can happen on presence packets that aren't really and truly delayed */ delayed = TRUE; + stamp = xmlnode_get_attrib(y, "stamp"); } else if(!strcmp(xmlns, "http://jabber.org/protocol/muc#user")) { xmlnode *z; @@ -557,9 +581,26 @@ avatar_hash = xmlnode_get_data(photo); } } + } else if (!strcmp(y->name, "query") && + !strcmp(xmlnode_get_namespace(y), "jabber:iq:last")) { + /* resource has specified idle */ + const gchar *seconds = xmlnode_get_attrib(y, "seconds"); + if (seconds) { + /* we may need to take "delayed" into account here */ + idle = atoi(seconds); + } } } + if (idle && delayed && stamp) { + /* if we have a delayed presence, we need to add the delay to the idle + value */ + time_t offset = time(NULL) - purple_str_to_time(stamp, TRUE, NULL, NULL, + NULL); + purple_debug_info("jabber", "got delay %s yielding %ld s offset\n", + stamp, offset); + idle += offset; + } if(jid->node && (chat = jabber_chat_find(js, jid->node, jid->domain))) { static int i = 1; @@ -734,6 +775,12 @@ } else { jbr = jabber_buddy_track_resource(jb, jid->resource, priority, state, status); + if (idle) { + jbr->idle = time(NULL) - idle; + } else { + jbr->idle = 0; + } + if(caps) { /* handle XEP-0115 */ const char *node = xmlnode_get_attrib(caps,"node"); @@ -758,6 +805,7 @@ if((found_jbr = jabber_buddy_find_resource(jb, NULL))) { jabber_google_presence_incoming(js, buddy_name, found_jbr); purple_prpl_got_user_status(js->gc->account, buddy_name, jabber_buddy_state_get_status_id(found_jbr->state), "priority", found_jbr->priority, "message", found_jbr->status, NULL); + purple_prpl_got_user_idle(js->gc->account, buddy_name, found_jbr->idle, found_jbr->idle); } else { purple_prpl_got_user_status(js->gc->account, buddy_name, "offline", status ? "message" : NULL, status, NULL); } diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/useravatar.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/jabber/useravatar.c Tue Apr 28 18:43:57 2009 +0000 @@ -0,0 +1,373 @@ +/* + * purple - Jabber Protocol Plugin + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "internal.h" + +#include "useravatar.h" +#include "pep.h" +#include "debug.h" + +#define MAX_HTTP_BUDDYICON_BYTES (200 * 1024) + +static void update_buddy_metadata(JabberStream *js, const char *from, xmlnode *items); + +void jabber_avatar_init(void) +{ + jabber_pep_register_handler("avatar", NS_AVATAR_0_12_METADATA, + update_buddy_metadata); + + jabber_add_feature("urn_avatarmeta", NS_AVATAR_1_1_METADATA, + jabber_pep_namespace_only_when_pep_enabled_cb); + jabber_add_feature("urn_avatardata", NS_AVATAR_1_1_DATA, + jabber_pep_namespace_only_when_pep_enabled_cb); + + jabber_pep_register_handler("urn_avatar", NS_AVATAR_1_1_METADATA, + update_buddy_metadata); +} + +static void +remove_avatar_0_12_nodes(JabberStream *js) +{ + jabber_pep_delete_node(js, NS_AVATAR_0_12_METADATA); + jabber_pep_delete_node(js, NS_AVATAR_0_12_DATA); +} + +void jabber_avatar_set(JabberStream *js, PurpleStoredImage *img) +{ + xmlnode *publish, *metadata, *item; + + if (!js->pep) + return; + + remove_avatar_0_12_nodes(js); + + if (!img) { + publish = xmlnode_new("publish"); + xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA); + + item = xmlnode_new_child(publish, "item"); + metadata = xmlnode_new_child(item, "metadata"); + xmlnode_set_namespace(metadata, NS_AVATAR_1_1_METADATA); + + /* publish */ + jabber_pep_publish(js, publish); + } else { + /* + * TODO: This is pretty gross. The Jabber PRPL really shouldn't + * do voodoo to try to determine the image type, height + * and width. + */ + /* A PNG header, including the IHDR, but nothing else */ + const struct { + guchar signature[8]; /* must be hex 89 50 4E 47 0D 0A 1A 0A */ + struct { + guint32 length; /* must be 0x0d */ + guchar type[4]; /* must be 'I' 'H' 'D' 'R' */ + guint32 width; + guint32 height; + guchar bitdepth; + guchar colortype; + guchar compression; + guchar filter; + guchar interlace; + } ihdr; + } *png = purple_imgstore_get_data(img); /* ATTN: this is in network byte order! */ + + /* check if the data is a valid png file (well, at least to some extent) */ + if(png->signature[0] == 0x89 && + png->signature[1] == 0x50 && + png->signature[2] == 0x4e && + png->signature[3] == 0x47 && + png->signature[4] == 0x0d && + png->signature[5] == 0x0a && + png->signature[6] == 0x1a && + png->signature[7] == 0x0a && + ntohl(png->ihdr.length) == 0x0d && + png->ihdr.type[0] == 'I' && + png->ihdr.type[1] == 'H' && + png->ihdr.type[2] == 'D' && + png->ihdr.type[3] == 'R') { + /* parse PNG header to get the size of the image (yes, this is required) */ + guint32 width = ntohl(png->ihdr.width); + guint32 height = ntohl(png->ihdr.height); + xmlnode *data, *info; + char *lengthstring, *widthstring, *heightstring; + + /* compute the sha1 hash */ + char *hash = jabber_calculate_data_sha1sum(purple_imgstore_get_data(img), + purple_imgstore_get_size(img)); + char *base64avatar = purple_base64_encode(purple_imgstore_get_data(img), + purple_imgstore_get_size(img)); + + publish = xmlnode_new("publish"); + xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_DATA); + + item = xmlnode_new_child(publish, "item"); + xmlnode_set_attrib(item, "id", hash); + + data = xmlnode_new_child(item, "data"); + xmlnode_set_namespace(data, NS_AVATAR_1_1_DATA); + + xmlnode_insert_data(data, base64avatar, -1); + /* publish the avatar itself */ + jabber_pep_publish(js, publish); + + g_free(base64avatar); + + lengthstring = g_strdup_printf("%" G_GSIZE_FORMAT, + purple_imgstore_get_size(img)); + widthstring = g_strdup_printf("%u", width); + heightstring = g_strdup_printf("%u", height); + + /* publish the metadata */ + publish = xmlnode_new("publish"); + xmlnode_set_attrib(publish, "node", NS_AVATAR_1_1_METADATA); + + item = xmlnode_new_child(publish, "item"); + xmlnode_set_attrib(item, "id", hash); + + metadata = xmlnode_new_child(item, "metadata"); + xmlnode_set_namespace(metadata, NS_AVATAR_1_1_METADATA); + + info = xmlnode_new_child(metadata, "info"); + xmlnode_set_attrib(info, "id", hash); + xmlnode_set_attrib(info, "type", "image/png"); + xmlnode_set_attrib(info, "bytes", lengthstring); + xmlnode_set_attrib(info, "width", widthstring); + xmlnode_set_attrib(info, "height", heightstring); + + jabber_pep_publish(js, publish); + + g_free(lengthstring); + g_free(widthstring); + g_free(heightstring); + g_free(hash); + } else { + purple_debug_error("jabber", "Cannot set PEP avatar to non-PNG data\n"); + } + } +} + +static void +do_got_own_avatar_cb(JabberStream *js, const char *from, xmlnode *items) +{ + xmlnode *item = NULL, *metadata = NULL, *info = NULL; + PurpleAccount *account = purple_connection_get_account(js->gc); + const char *server_hash = NULL; + const char *ns; + + if ((item = xmlnode_get_child(items, "item")) && + (metadata = xmlnode_get_child(item, "metadata")) && + (info = xmlnode_get_child(metadata, "info"))) { + server_hash = xmlnode_get_attrib(info, "id"); + } + + if (!metadata) + return; + + ns = xmlnode_get_namespace(metadata); + if (!ns) + return; + + /* + * We no longer publish avatars to the older namespace. If there is one + * there, delete it. + */ + if (g_str_equal(ns, NS_AVATAR_0_12_METADATA) && server_hash) { + remove_avatar_0_12_nodes(js); + return; + } + + /* Publish ours if it's different than the server's */ + if (!purple_strequal(server_hash, js->initial_avatar_hash)) { + PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account); + jabber_avatar_set(js, img); + purple_imgstore_unref(img); + } +} + +void jabber_avatar_fetch_mine(JabberStream *js) +{ + char *jid = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + jabber_pep_request_item(js, jid, NS_AVATAR_0_12_METADATA, NULL, + do_got_own_avatar_cb); + jabber_pep_request_item(js, jid, NS_AVATAR_1_1_METADATA, NULL, + do_got_own_avatar_cb); + g_free(jid); +} + +typedef struct _JabberBuddyAvatarUpdateURLInfo { + JabberStream *js; + char *from; + char *id; +} JabberBuddyAvatarUpdateURLInfo; + +static void +do_buddy_avatar_update_fromurl(PurpleUtilFetchUrlData *url_data, + gpointer user_data, const gchar *url_text, + gsize len, const gchar *error_message) +{ + JabberBuddyAvatarUpdateURLInfo *info = user_data; + if(!url_text) { + purple_debug(PURPLE_DEBUG_ERROR, "jabber", + "do_buddy_avatar_update_fromurl got error \"%s\"", + error_message); + goto out; + } + + purple_buddy_icons_set_for_user(purple_connection_get_account(info->js->gc), info->from, (void*)url_text, len, info->id); + +out: + g_free(info->from); + g_free(info->id); + g_free(info); +} + +static void +do_buddy_avatar_update_data(JabberStream *js, const char *from, xmlnode *items) +{ + xmlnode *item, *data; + const char *checksum, *ns; + char *b64data; + void *img; + size_t size; + if(!items) + return; + + item = xmlnode_get_child(items, "item"); + if(!item) + return; + + data = xmlnode_get_child(item, "data"); + if(!data) + return; + + ns = xmlnode_get_namespace(data); + /* Make sure the namespace is one of the two valid possibilities */ + if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_DATA) && + !g_str_equal(ns, NS_AVATAR_1_1_DATA))) + return; + + checksum = xmlnode_get_attrib(item,"id"); + if(!checksum) + return; + + b64data = xmlnode_get_data(data); + if(!b64data) + return; + + img = purple_base64_decode(b64data, &size); + if(!img) { + g_free(b64data); + return; + } + + purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, img, size, checksum); + g_free(b64data); +} + +static void +update_buddy_metadata(JabberStream *js, const char *from, xmlnode *items) +{ + PurpleBuddy *buddy = purple_find_buddy(purple_connection_get_account(js->gc), from); + const char *checksum, *ns; + xmlnode *item, *metadata; + if(!buddy) + return; + + if (!items) + return; + + item = xmlnode_get_child(items,"item"); + if (!item) + return; + + metadata = xmlnode_get_child(item, "metadata"); + if(!metadata) + return; + + ns = xmlnode_get_namespace(metadata); + /* Make sure the namespace is one of the two valid possibilities */ + if (!ns || (!g_str_equal(ns, NS_AVATAR_0_12_METADATA) && + !g_str_equal(ns, NS_AVATAR_1_1_METADATA))) + return; + + checksum = purple_buddy_icons_get_checksum_for_user(buddy); + + /* check if we have received a stop */ + if(xmlnode_get_child(metadata, "stop")) { + purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); + } else { + xmlnode *info, *goodinfo = NULL; + gboolean has_children = FALSE; + + /* iterate over all info nodes to get one we can use */ + for(info = metadata->child; info; info = info->next) { + if(info->type == XMLNODE_TYPE_TAG) + has_children = TRUE; + if(info->type == XMLNODE_TYPE_TAG && !strcmp(info->name,"info")) { + const char *type = xmlnode_get_attrib(info,"type"); + const char *id = xmlnode_get_attrib(info,"id"); + + if(checksum && id && !strcmp(id, checksum)) { + /* we already have that avatar, so we don't have to do anything */ + goodinfo = NULL; + break; + } + /* We'll only pick the png one for now. It's a very nice image format anyways. */ + if(type && id && !goodinfo && !strcmp(type, "image/png")) + goodinfo = info; + } + } + if(has_children == FALSE) { + purple_buddy_icons_set_for_user(purple_connection_get_account(js->gc), from, NULL, 0, NULL); + } else if(goodinfo) { + const char *url = xmlnode_get_attrib(goodinfo, "url"); + const char *id = xmlnode_get_attrib(goodinfo,"id"); + + /* the avatar might either be stored in a pep node, or on a HTTP(S) URL */ + if(!url) { + const char *data_ns; + data_ns = (g_str_equal(ns, NS_AVATAR_0_12_METADATA) ? + NS_AVATAR_0_12_DATA : NS_AVATAR_1_1_DATA); + jabber_pep_request_item(js, from, data_ns, id, + do_buddy_avatar_update_data); + } else { + PurpleUtilFetchUrlData *url_data; + JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1); + info->js = js; + + url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE, + MAX_HTTP_BUDDYICON_BYTES, + do_buddy_avatar_update_fromurl, info); + if (url_data) { + info->from = g_strdup(from); + info->id = g_strdup(id); + js->url_datas = g_slist_prepend(js->url_datas, url_data); + } else + g_free(info); + + } + } + } +} diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/jabber/useravatar.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/jabber/useravatar.h Tue Apr 28 18:43:57 2009 +0000 @@ -0,0 +1,43 @@ +/* + * purple - Jabber Protocol Plugin + * + * Purple is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef _PURPLE_JABBER_USERAVATAR_H_ +#define _PURPLE_JABBER_USERAVATAR_H_ + +#include "jabber.h" +#include "imgstore.h" + +/* Implementation of XEP-0084 */ + +#define NS_AVATAR_0_12_DATA "http://www.xmpp.org/extensions/xep-0084.html#ns-data" +#define NS_AVATAR_0_12_METADATA "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata" + +#define NS_AVATAR_1_1_DATA "urn:xmpp:avatar:data" +#define NS_AVATAR_1_1_METADATA "urn:xmpp:avatar:metadata" + +void jabber_avatar_init(void); +void jabber_avatar_set(JabberStream *js, PurpleStoredImage *img); + +void jabber_avatar_fetch_mine(JabberStream *js); + +#endif /* _PURPLE_JABBER_USERAVATAR_H_ */ diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/qq/ChangeLog --- a/libpurple/protocols/qq/ChangeLog Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/qq/ChangeLog Tue Apr 28 18:43:57 2009 +0000 @@ -1,3 +1,6 @@ +2009.04.23 - flos + * Fixed a bug of updating buddy who is not in user's buddy list + 2009.02.25 - flos * Changed text 'ZipCode' to 'Postal Code' diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/qq/buddy_info.c --- a/libpurple/protocols/qq/buddy_info.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/qq/buddy_info.c Tue Apr 28 18:43:57 2009 +0000 @@ -191,7 +191,7 @@ } switch (field_infos[index].type) { case QQ_FIELD_BOOL: - purple_notify_user_info_add_pair(user_info, field_infos[index].text, + purple_notify_user_info_add_pair(user_info, _(field_infos[index].text), strtol(segments[index], NULL, 10) ? _("True") : _("False")); break; case QQ_FIELD_CHOICE: @@ -200,7 +200,7 @@ choice_num = 0; } - purple_notify_user_info_add_pair(user_info, field_infos[index].text, field_infos[index].choice[choice_num]); + purple_notify_user_info_add_pair(user_info, _(field_infos[index].text), field_infos[index].choice[choice_num]); break; case QQ_FIELD_LABEL: case QQ_FIELD_STRING: @@ -208,7 +208,7 @@ default: if (strlen(segments[index]) != 0) { utf8_value = qq_to_utf8(segments[index], QQ_CHARSET_DEFAULT); - purple_notify_user_info_add_pair(user_info, field_infos[index].text, utf8_value); + purple_notify_user_info_add_pair(user_info, _(field_infos[index].text), utf8_value); g_free(utf8_value); } break; @@ -348,18 +348,18 @@ utf8_value = qq_to_utf8(segments[index], QQ_CHARSET_DEFAULT); if (field_infos[index].type == QQ_FIELD_STRING) { field = purple_request_field_string_new( - field_infos[index].id, field_infos[index].text, utf8_value, FALSE); + field_infos[index].id, _(field_infos[index].text), utf8_value, FALSE); } else { field = purple_request_field_string_new( - field_infos[index].id, field_infos[index].text, utf8_value, TRUE); + field_infos[index].id, _(field_infos[index].text), utf8_value, TRUE); } purple_request_field_group_add_field(group, field); g_free(utf8_value); break; case QQ_FIELD_BOOL: field = purple_request_field_bool_new( - field_infos[index].id, field_infos[index].text, - strtol(segments[index], NULL, 10) ? TRUE : FALSE); + field_infos[index].id, _(field_infos[index].text), + strtol(segments[index], NULL, 10) ? TRUE : FALSE); purple_request_field_group_add_field(group, field); break; case QQ_FIELD_CHOICE: @@ -374,7 +374,7 @@ } } field = purple_request_field_choice_new( - field_infos[index].id, field_infos[index].text, choice_num); + field_infos[index].id, _(field_infos[index].text), choice_num); for (i = 0; i < field_infos[index].choice_size; i++) { purple_request_field_choice_add(field, field_infos[index].choice[i]); } @@ -606,21 +606,21 @@ /* after getting info or modify myself, refresh the buddy list accordingly */ static void update_buddy_info(PurpleConnection *gc, gchar **segments) { - PurpleBuddy *buddy; - qq_data *qd; - qq_buddy_data *bd; + PurpleBuddy *buddy = NULL; + qq_data *qd = NULL; + qq_buddy_data *bd = NULL; guint32 uid; gchar *who; gchar *alias_utf8; + PurpleAccount *account = purple_connection_get_account(gc); - qd = (qq_data *)purple_connection_get_protocol_data(gc); uid = strtoul(segments[QQ_INFO_UID], NULL, 10); who = uid_to_purple_name(uid); - qq_filter_str(segments[QQ_INFO_NICK]); alias_utf8 = qq_to_utf8(segments[QQ_INFO_NICK], QQ_CHARSET_DEFAULT); + if (uid == qd->uid) { /* it is me */ purple_debug_info("QQ", "Got my info\n"); qd->my_icon = strtol(segments[QQ_INFO_FACE], NULL, 10); @@ -631,12 +631,14 @@ buddy = qq_buddy_find_or_new(gc, uid); } else { buddy = purple_find_buddy(gc->account, who); + /* purple_debug_info("QQ", "buddy=%p\n", (void*)buddy); */ } /* if the buddy is null, the api will catch it and return null here */ bd = purple_buddy_get_protocol_data(buddy); + /* purple_debug_info("QQ", "bd=%p\n", (void*)bd); */ - if (buddy == NULL || bd) { + if (bd == NULL || buddy == NULL) { g_free(who); g_free(alias_utf8); return; @@ -646,6 +648,7 @@ bd->age = strtol(segments[QQ_INFO_AGE], NULL, 10); bd->gender = strtol(segments[QQ_INFO_GENDER], NULL, 10); bd->face = strtol(segments[QQ_INFO_FACE], NULL, 10); + if (alias_utf8 != NULL) { if (bd->nickname) g_free(bd->nickname); bd->nickname = g_strdup(alias_utf8); diff -r de9816c970fe -r 3912f55a1633 libpurple/protocols/qq/qq.c --- a/libpurple/protocols/qq/qq.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/protocols/qq/qq.c Tue Apr 28 18:43:57 2009 +0000 @@ -674,8 +674,8 @@ g_string_append(info, "wd
\n"); g_string_append(info, "x6719620
\n"); g_string_append(info, "netelk
\n"); - g_string_append(info, "and more, please let me know... thank you!
\n"); - g_string_append(info, "
\n"); + g_string_append(info, _("and more, please let me know... thank you!))")); + g_string_append(info, "
\n
\n"); g_string_append(info, _("

And, all the boys in the backroom...
\n")); g_string_append(info, _("Feel free to join us! :)")); g_string_append(info, ""); diff -r de9816c970fe -r 3912f55a1633 libpurple/prpl.c --- a/libpurple/prpl.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/prpl.c Tue Apr 28 18:43:57 2009 +0000 @@ -182,6 +182,17 @@ } void +purple_prpl_got_account_actions(PurpleAccount *account) +{ + + g_return_if_fail(account != NULL); + g_return_if_fail(purple_account_is_connected(account)); + + purple_signal_emit(purple_accounts_get_handle(), "account-actions-changed", + account); +} + +void purple_prpl_got_user_idle(PurpleAccount *account, const char *name, gboolean idle, time_t idle_time) { diff -r de9816c970fe -r 3912f55a1633 libpurple/prpl.h --- a/libpurple/prpl.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/prpl.h Tue Apr 28 18:43:57 2009 +0000 @@ -661,6 +661,20 @@ const char *status_id, ...) G_GNUC_NULL_TERMINATED; /** + * Notifies Purple that our account's actions have changed. This is only + * called after the initial connection. Emits the account-actions-changed + * signal. + * + * This is meant to be called from protocol plugins. + * + * @param account The account. + * + * @see account-actions-changed + * @since 2.6.0 + */ +void purple_prpl_got_account_actions(PurpleAccount *account); + +/** * Notifies Purple that a buddy's idle state and time have changed. * * This is meant to be called from protocol plugins. diff -r de9816c970fe -r 3912f55a1633 libpurple/smiley.h --- a/libpurple/smiley.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/smiley.h Tue Apr 28 18:43:57 2009 +0000 @@ -61,44 +61,41 @@ /*@{*/ /** - * GObject foo. + * GObject-fu. * @internal. */ GType purple_smiley_get_type(void); /** - * Creates a new custom smiley structure and populates it. + * Creates a new custom smiley from a PurpleStoredImage. * - * If a custom smiley with the informed shortcut already exist, it + * If a custom smiley with the given shortcut already exists, it * will be automaticaly returned. * * @param img The image associated with the smiley. - * @param shortcut The custom smiley associated shortcut. + * @param shortcut The associated shortcut (e.g. "(homer)"). * - * @return The custom smiley structure filled up. + * @return The custom smiley. */ PurpleSmiley * purple_smiley_new(PurpleStoredImage *img, const char *shortcut); /** - * Creates a new custom smiley structure and populates it. + * Creates a new custom smiley, reading the image data from a file. * - * The data is retrieved from an already existent file. - * - * If a custom smiley with the informed shortcut already exist, it + * If a custom smiley with the given shortcut already exists, it * will be automaticaly returned. * - * @param shortcut The custom smiley associated shortcut. - * @param filepath The image file to be imported to a - * new custom smiley. + * @param shortcut The associated shortcut (e.g. "(homer)"). + * @param filepath The image file. * - * @return The custom smiley structure filled up. + * @return The custom smiley. */ PurpleSmiley * purple_smiley_new_from_file(const char *shortcut, const char *filepath); /** - * Destroy the custom smiley and release the associated resources. + * Destroys the custom smiley and release the associated resources. * * @param smiley The custom smiley. */ @@ -109,32 +106,28 @@ * Changes the custom smiley's shortcut. * * @param smiley The custom smiley. - * @param shortcut The custom smiley associated shortcut. + * @param shortcut The new shortcut. A custom smiley with this shortcut + * cannot already be in use. * - * @return TRUE whether the shortcut is not associated with another - * custom smiley and the parameters are valid. FALSE otherwise. + * @return TRUE if the shortcut was changed. FALSE otherwise. */ gboolean purple_smiley_set_shortcut(PurpleSmiley *smiley, const char *shortcut); /** - * Changes the custom smiley's data. - * - * When the filename controling is made outside this API, the param - * #keepfilename must be TRUE. - * Otherwise, the file and filename will be regenerated, and the - * old one will be removed. + * Changes the custom smiley's image data. * * @param smiley The custom smiley. - * @param smiley_data The custom smiley data. - * @param smiley_data_len The custom smiley data length. + * @param smiley_data The custom smiley data, which the smiley code + * takes ownership of and will free. + * @param smiley_data_len The length of the data in @a smiley_data. */ void purple_smiley_set_data(PurpleSmiley *smiley, guchar *smiley_data, size_t smiley_data_len); /** - * Returns the custom smiley's associated shortcut. + * Returns the custom smiley's associated shortcut (e.g. "(homer)"). * * @param smiley The custom smiley. * @@ -155,11 +148,11 @@ * Returns the PurpleStoredImage with the reference counter incremented. * * The returned PurpleStoredImage reference counter must be decremented - * after use. + * when the caller is done using it. * * @param smiley The custom smiley. * - * @return A PurpleStoredImage reference. + * @return A PurpleStoredImage. */ PurpleStoredImage *purple_smiley_get_stored_image(const PurpleSmiley *smiley); @@ -167,7 +160,7 @@ * Returns the custom smiley's data. * * @param smiley The custom smiley. - * @param len If not @c NULL, the length of the icon data returned + * @param len If not @c NULL, the length of the image data returned * will be set in the location pointed to by this. * * @return A pointer to the custom smiley data. @@ -194,6 +187,8 @@ * directly. If you find yourself wanting to use this function, think * very long and hard about it, and then don't. * + * Think some more. + * * @param smiley The custom smiley. * * @return A full path to the file, or @c NULL under various conditions. @@ -210,7 +205,8 @@ /*@{*/ /** - * Returns a list of all custom smileys. The caller should free the list. + * Returns a list of all custom smileys. The caller is responsible for freeing + * the list. * * @return A list of all custom smileys. */ @@ -218,23 +214,21 @@ purple_smileys_get_all(void); /** - * Returns the custom smiley given it's shortcut. + * Returns a custom smiley given its shortcut. * * @param shortcut The custom smiley's shortcut. * - * @return The custom smiley (with a reference for the caller) if found, - * or @c NULL if not found. + * @return The custom smiley if found, or @c NULL if not found. */ PurpleSmiley * purple_smileys_find_by_shortcut(const char *shortcut); /** - * Returns the custom smiley given it's checksum. + * Returns a custom smiley given its checksum. * * @param checksum The custom smiley's checksum. * - * @return The custom smiley (with a reference for the caller) if found, - * or @c NULL if not found. + * @return The custom smiley if found, or @c NULL if not found. */ PurpleSmiley * purple_smileys_find_by_checksum(const char *checksum); @@ -242,10 +236,9 @@ /** * Returns the directory used to store custom smiley cached files. * - * The default directory is PURPLEDIR/smileys, unless otherwise specified - * by purple_buddy_icons_set_cache_dir(). + * The default directory is PURPLEDIR/custom_smiley. * - * @return The directory to store custom smyles cached files to. + * @return The directory in which to store custom smileys cached files. */ const char *purple_smileys_get_storing_dir(void); diff -r de9816c970fe -r 3912f55a1633 libpurple/sound-theme.h --- a/libpurple/sound-theme.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/sound-theme.h Tue Apr 28 18:43:57 2009 +0000 @@ -73,6 +73,7 @@ /** * Returns a copy of the filename for the sound event. * + * @param theme The theme. * @param event The purple sound event to look up. * * @returns The filename of the sound event. @@ -83,6 +84,7 @@ /** * Returns a copy of the directory and filename for the sound event * + * @param theme The theme. * @param event The purple sound event to look up * * @returns The directory + '/' + filename of the sound event. This is @@ -94,8 +96,9 @@ /** * Sets the filename for a given sound event * - * @param event the purple sound event to look up - * @param filename the name of the file to be used for the event + * @param theme The theme. + * @param event the purple sound event to look up + * @param filename the name of the file to be used for the event */ void purple_sound_theme_set_file(PurpleSoundTheme *theme, const gchar *event, diff -r de9816c970fe -r 3912f55a1633 libpurple/theme-loader.h --- a/libpurple/theme-loader.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/theme-loader.h Tue Apr 28 18:43:57 2009 +0000 @@ -82,7 +82,8 @@ /** * Creates a new PurpleTheme * - * @param dir The directory containing the theme + * @param loader The theme loader + * @param dir The directory containing the theme * * @returns A PurpleTheme containing the information from the directory */ diff -r de9816c970fe -r 3912f55a1633 libpurple/theme-manager.h --- a/libpurple/theme-manager.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/theme-manager.h Tue Apr 28 18:43:57 2009 +0000 @@ -1,5 +1,5 @@ /** - * @file thememanager.h Theme Manager API + * @file theme-manager.h Theme Manager API */ /* diff -r de9816c970fe -r 3912f55a1633 libpurple/xmlnode.c --- a/libpurple/xmlnode.c Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/xmlnode.c Tue Apr 28 18:43:57 2009 +0000 @@ -647,6 +647,28 @@ purple_debug_error("xmlnode", "Error parsing xml file: %s", errmsg); } +static void +xmlnode_parser_structural_error_libxml(void *user_data, xmlErrorPtr error) +{ + struct _xmlnode_parser_data *xpd = user_data; + + if (error && (error->level == XML_ERR_ERROR || + error->level == XML_ERR_FATAL)) { + xpd->error = TRUE; + purple_debug_error("xmlnode", "XML parser error for xmlnode %p: " + "Domain %i, code %i, level %i: %s", + user_data, error->domain, error->code, error->level, + error->message ? error->message : "(null)\n"); + } else if (error) + purple_debug_warning("xmlnode", "XML parser error for xmlnode %p: " + "Domain %i, code %i, level %i: %s", + user_data, error->domain, error->code, error->level, + error->message ? error->message : "(null)\n"); + else + purple_debug_warning("xmlnode", "XML parser error for xmlnode %p\n", + user_data); +} + static xmlSAXHandler xmlnode_parser_libxml = { NULL, /* internalSubset */ NULL, /* isStandalone */ @@ -679,7 +701,7 @@ NULL, /* _private */ xmlnode_parser_element_start_libxml, /* startElementNs */ xmlnode_parser_element_end_libxml, /* endElementNs */ - NULL, /* serror */ + xmlnode_parser_structural_error_libxml, /* serror */ }; xmlnode * diff -r de9816c970fe -r 3912f55a1633 libpurple/xmlnode.h --- a/libpurple/xmlnode.h Sat Apr 18 18:17:16 2009 +0000 +++ b/libpurple/xmlnode.h Tue Apr 28 18:43:57 2009 +0000 @@ -335,11 +335,14 @@ * root node of an XML document will parse the entire document * into a tree of nodes, and return the xmlnode of the root. * - * @param str The string of xml. - * @param description The description of the file being parsed - * @process The utility that is calling xmlnode_from_file + * @param dir The directory where the file is located + * @param filename The filename + * @param description A description of the file being parsed. Displayed to + * the user if the file cannot be read. + * @param process The subsystem that is calling xmlnode_from_file. Used as + * the category for debugging. * - * @return The new node. + * @return The new node or NULL if an error occurred. * * @since 2.6.0 */ diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkaccount.c --- a/pidgin/gtkaccount.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkaccount.c Tue Apr 28 18:43:57 2009 +0000 @@ -413,7 +413,11 @@ if (dialog->protocol_menu != NULL) { +#if GTK_CHECK_VERSION(2,12,0) + g_object_ref(G_OBJECT(dialog->protocol_menu)); +#else gtk_widget_ref(dialog->protocol_menu); +#endif hbox = g_object_get_data(G_OBJECT(dialog->protocol_menu), "container"); gtk_container_remove(GTK_CONTAINER(hbox), dialog->protocol_menu); } @@ -440,13 +444,21 @@ { dialog->protocol_menu = pidgin_protocol_option_menu_new( dialog->protocol_id, G_CALLBACK(set_account_protocol_cb), dialog); +#if GTK_CHECK_VERSION(2,12,0) + g_object_ref(G_OBJECT(dialog->protocol_menu)); +#else gtk_widget_ref(dialog->protocol_menu); +#endif } hbox = add_pref_box(dialog, vbox, _("Pro_tocol:"), dialog->protocol_menu); g_object_set_data(G_OBJECT(dialog->protocol_menu), "container", hbox); +#if GTK_CHECK_VERSION(2,12,0) + g_object_unref(G_OBJECT(dialog->protocol_menu)); +#else gtk_widget_unref(dialog->protocol_menu); +#endif /* Username */ dialog->username_entry = gtk_entry_new(); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkblist-theme-loader.c --- a/pidgin/gtkblist-theme-loader.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkblist-theme-loader.c Tue Apr 28 18:43:57 2009 +0000 @@ -38,6 +38,22 @@ * Buddy List Theme Builder *****************************************************************************/ +static PidginThemeFont * +pidgin_theme_font_parse(xmlnode *node) +{ + const char *font; + const char *colordesc; + GdkColor color; + + font = xmlnode_get_attrib(node, "font"); + + if ((colordesc = xmlnode_get_attrib(node, "color")) == NULL || + !gdk_color_parse(colordesc, &color)) + gdk_color_parse(DEFAULT_TEXT_COLOR, &color); + + return pidgin_theme_font_new(font, &color); +} + static PurpleTheme * pidgin_blist_loader_build(const gchar *dir) { @@ -46,10 +62,35 @@ const gchar *temp; gboolean success = TRUE; GdkColor bgcolor, expanded_bgcolor, collapsed_bgcolor, contact_color; - GdkColor color; - FontColorPair expanded, collapsed, contact, online, away, offline, idle, message, message_nick_said, status; + PidginThemeFont *expanded, *collapsed, *contact, *online, *away, *offline, *idle, *message, *message_nick_said, *status; PidginBlistLayout layout; PidginBlistTheme *theme; + int i; + struct { + const char *tag; + PidginThemeFont **font; + } lookups[] = { + {"contact_text", &contact}, + {"online_text", &online}, + {"away_text", &away}, + {"offline_text", &offline}, + {"idle_text", &idle}, + {"message_text", &message}, + {"message_nick_said_text", &message_nick_said}, + {"status_text", &status}, + {NULL, NULL} + }; + + expanded = NULL; + collapsed = NULL; + contact = NULL; + online = NULL; + away = NULL; + offline = NULL; + idle = NULL; + message = NULL; + message_nick_said = NULL; + status = NULL; /* Find the theme file */ g_return_val_if_fail(dir != NULL, NULL); @@ -76,11 +117,7 @@ if ((success = (success && (sub_node = xmlnode_get_child(root_node, "groups")) != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "expanded")) != NULL))) { - expanded.font = xmlnode_get_attrib(sub_sub_node, "font"); - - if ((temp = xmlnode_get_attrib(sub_sub_node, "text_color")) != NULL && gdk_color_parse(temp, &color)) - expanded.color = temp; - else expanded.color = DEFAULT_TEXT_COLOR; + expanded = pidgin_theme_font_parse(sub_sub_node); if ((temp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(temp, &expanded_bgcolor)) gdk_colormap_alloc_color(gdk_colormap_get_system(), &expanded_bgcolor, FALSE, TRUE); @@ -90,11 +127,7 @@ if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "collapsed")) != NULL))) { - collapsed.font = xmlnode_get_attrib(sub_sub_node, "font"); - - if((temp = xmlnode_get_attrib(sub_sub_node, "text_color")) != NULL && gdk_color_parse(temp, &color)) - collapsed.color = temp; - else collapsed.color = DEFAULT_TEXT_COLOR; + collapsed = pidgin_theme_font_parse(sub_sub_node); if ((temp = xmlnode_get_attrib(sub_sub_node, "background")) != NULL && gdk_color_parse(temp, &collapsed_bgcolor)) gdk_colormap_alloc_color(gdk_colormap_get_system(), &collapsed_bgcolor, FALSE, TRUE); @@ -121,60 +154,13 @@ memset(&contact_color, 0, sizeof(GdkColor)); } - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "contact_text")) != NULL))) { - contact.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - contact.color = temp; - else contact.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "online_text")) != NULL))) { - online.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - online.color = temp; - else online.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "away_text")) != NULL))) { - away.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - away.color = temp; - else away.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "offline_text")) != NULL))) { - offline.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - offline.color = temp; - else offline.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "idle_text")) != NULL))) { - idle.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - idle.color = temp; - else idle.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_text")) != NULL))) { - message.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - message.color = temp; - else message.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "message_nick_said_text")) != NULL))) { - message_nick_said.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - message_nick_said.color = temp; - else message_nick_said.color = DEFAULT_TEXT_COLOR; - } - - if ((success = (success && sub_node != NULL && (sub_sub_node = xmlnode_get_child(sub_node, "status_text")) != NULL))) { - status.font = xmlnode_get_attrib(sub_sub_node, "font"); - if(gdk_color_parse(temp = xmlnode_get_attrib(sub_sub_node, "color"), &color)) - status.color = temp; - else status.color = DEFAULT_TEXT_COLOR; + for (i = 0; success && lookups[i].tag; i++) { + if ((success = (sub_node != NULL && + (sub_sub_node = xmlnode_get_child(sub_node, lookups[i].tag)) != NULL))) { + *(lookups[i].font) = pidgin_theme_font_parse(sub_sub_node); + } else { + *(lookups[i].font) = NULL; + } } /* name is required for theme manager */ @@ -191,18 +177,27 @@ "background-color", &bgcolor, "layout", &layout, "expanded-color", &expanded_bgcolor, - "expanded-text", &expanded, + "expanded-text", expanded, "collapsed-color", &collapsed_bgcolor, - "collapsed-text", &collapsed, + "collapsed-text", collapsed, "contact-color", &contact_color, - "contact", &contact, - "online", &online, - "away", &away, - "offline", &offline, - "idle", &idle, - "message", &message, - "message_nick_said", &message_nick_said, - "status", &status, NULL); + "contact", contact, + "online", online, + "away", away, + "offline", offline, + "idle", idle, + "message", message, + "message_nick_said", message_nick_said, + "status", status, NULL); + + for (i = 0; lookups[i].tag; i++) { + if (*lookups[i].font) { + pidgin_theme_font_free(*lookups[i].font); + } + } + + pidgin_theme_font_free(expanded); + pidgin_theme_font_free(collapsed); xmlnode_free(root_node); g_free(data); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkblist-theme-loader.h --- a/pidgin/gtkblist-theme-loader.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkblist-theme-loader.h Tue Apr 28 18:43:57 2009 +0000 @@ -1,5 +1,5 @@ /** - * @file gtkblist-loader.h Pidgin Buddy List Theme Loader Class API + * @file gtkblist-theme-loader.h Pidgin Buddy List Theme Loader Class API */ /* pidgin diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkblist-theme.c --- a/pidgin/gtkblist-theme.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkblist-theme.c Tue Apr 28 18:43:57 2009 +0000 @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ +#include "internal.h" #include "gtkblist-theme.h" #define PIDGIN_BLIST_THEME_GET_PRIVATE(Gobject) \ @@ -37,27 +38,34 @@ /* groups */ GdkColor *expanded_color; - FontColorPair *expanded; + PidginThemeFont *expanded; GdkColor *collapsed_color; - FontColorPair *collapsed; + PidginThemeFont *collapsed; /* buddy */ GdkColor *contact_color; - FontColorPair *contact; + PidginThemeFont *contact; - FontColorPair *online; - FontColorPair *away; - FontColorPair *offline; - FontColorPair *idle; - FontColorPair *message; - FontColorPair *message_nick_said; + PidginThemeFont *online; + PidginThemeFont *away; + PidginThemeFont *offline; + PidginThemeFont *idle; + PidginThemeFont *message; + PidginThemeFont *message_nick_said; - FontColorPair *status; + PidginThemeFont *status; } PidginBlistThemePrivate; +struct _PidginThemeFont +{ + gchar *font; + gchar color[10]; + GdkColor *gdkcolor; +}; + /****************************************************************************** * Globals *****************************************************************************/ @@ -92,23 +100,83 @@ * Helpers *****************************************************************************/ +PidginThemeFont * +pidgin_theme_font_new(const gchar *face, GdkColor *color) +{ + PidginThemeFont *font = g_new0(PidginThemeFont, 1); + font->font = g_strdup(face); + if (color) + pidgin_theme_font_set_color(font, color); + return font; +} + void -free_font_and_color(FontColorPair *pair) +pidgin_theme_font_free(PidginThemeFont *pair) { if (pair != NULL) { - g_free((gchar *)pair->font); - g_free((gchar *)pair->color); + g_free(pair->font); + if (pair->gdkcolor) + gdk_color_free(pair->gdkcolor); g_free(pair); } } -static FontColorPair * -copy_font_and_color(const FontColorPair *pair) +static PidginThemeFont * +copy_font_and_color(const PidginThemeFont *pair) +{ + PidginThemeFont *copy = g_new0(PidginThemeFont, 1); + copy->font = g_strdup(pair->font); + strncpy(copy->color, pair->color, sizeof(copy->color) - 1); + if (pair->gdkcolor) + copy->gdkcolor = gdk_color_copy(pair->gdkcolor); + return copy; +} + +void +pidgin_theme_font_set_font_face(PidginThemeFont *font, const gchar *face) +{ + g_return_if_fail(font); + g_return_if_fail(face); + + g_free(font->font); + font->font = g_strdup(face); +} + +void +pidgin_theme_font_set_color(PidginThemeFont *font, const GdkColor *color) { - FontColorPair *copy = g_new0(FontColorPair, 1); - copy->font = g_strdup(pair->font); - copy->color = g_strdup(pair->color); - return copy; + g_return_if_fail(font); + + if (font->gdkcolor) + gdk_color_free(font->gdkcolor); + + font->gdkcolor = color ? gdk_color_copy(color) : NULL; + if (color) + g_snprintf(font->color, sizeof(font->color), + "#%02x%02x%02x", color->red >> 8, color->green >> 8, color->blue >> 8); + else + font->color[0] = '\0'; +} + +const gchar * +pidgin_theme_font_get_font_face(PidginThemeFont *font) +{ + g_return_val_if_fail(font, NULL); + return font->font; +} + +const GdkColor * +pidgin_theme_font_get_color(PidginThemeFont *font) +{ + g_return_val_if_fail(font, NULL); + return font->gdkcolor; +} + +const gchar * +pidgin_theme_font_get_color_describe(PidginThemeFont *font) +{ + g_return_val_if_fail(font, NULL); + return font->color[0] ? font->color : NULL; } /****************************************************************************** @@ -130,7 +198,7 @@ switch (param_id) { case PROP_BACKGROUND_COLOR: - g_value_set_pointer(value, pidgin_blist_theme_get_background_color(theme)); + g_value_set_boxed(value, pidgin_blist_theme_get_background_color(theme)); break; case PROP_OPACITY: g_value_set_double(value, pidgin_blist_theme_get_opacity(theme)); @@ -139,19 +207,19 @@ g_value_set_pointer(value, pidgin_blist_theme_get_layout(theme)); break; case PROP_EXPANDED_COLOR: - g_value_set_pointer(value, pidgin_blist_theme_get_expanded_background_color(theme)); + g_value_set_boxed(value, pidgin_blist_theme_get_expanded_background_color(theme)); break; case PROP_EXPANDED_TEXT: g_value_set_pointer(value, pidgin_blist_theme_get_expanded_text_info(theme)); break; case PROP_COLLAPSED_COLOR: - g_value_set_pointer(value, pidgin_blist_theme_get_collapsed_background_color(theme)); + g_value_set_boxed(value, pidgin_blist_theme_get_collapsed_background_color(theme)); break; case PROP_COLLAPSED_TEXT: g_value_set_pointer(value, pidgin_blist_theme_get_collapsed_text_info(theme)); break; case PROP_CONTACT_COLOR: - g_value_set_pointer(value, pidgin_blist_theme_get_contact_color(theme)); + g_value_set_boxed(value, pidgin_blist_theme_get_contact_color(theme)); break; case PROP_CONTACT: g_value_set_pointer(value, pidgin_blist_theme_get_contact_text_info(theme)); @@ -191,7 +259,7 @@ switch (param_id) { case PROP_BACKGROUND_COLOR: - pidgin_blist_theme_set_background_color(theme, g_value_get_pointer(value)); + pidgin_blist_theme_set_background_color(theme, g_value_get_boxed(value)); break; case PROP_OPACITY: pidgin_blist_theme_set_opacity(theme, g_value_get_double(value)); @@ -200,19 +268,19 @@ pidgin_blist_theme_set_layout(theme, g_value_get_pointer(value)); break; case PROP_EXPANDED_COLOR: - pidgin_blist_theme_set_expanded_background_color(theme, g_value_get_pointer(value)); + pidgin_blist_theme_set_expanded_background_color(theme, g_value_get_boxed(value)); break; case PROP_EXPANDED_TEXT: pidgin_blist_theme_set_expanded_text_info(theme, g_value_get_pointer(value)); break; case PROP_COLLAPSED_COLOR: - pidgin_blist_theme_set_collapsed_background_color(theme, g_value_get_pointer(value)); + pidgin_blist_theme_set_collapsed_background_color(theme, g_value_get_boxed(value)); break; case PROP_COLLAPSED_TEXT: pidgin_blist_theme_set_collapsed_text_info(theme, g_value_get_pointer(value)); break; case PROP_CONTACT_COLOR: - pidgin_blist_theme_set_contact_color(theme, g_value_get_pointer(value)); + pidgin_blist_theme_set_contact_color(theme, g_value_get_boxed(value)); break; case PROP_CONTACT: pidgin_blist_theme_set_contact_text_info(theme, g_value_get_pointer(value)); @@ -252,25 +320,29 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(obj); /* Buddy List */ - gdk_color_free(priv->bgcolor); + if (priv->bgcolor) + gdk_color_free(priv->bgcolor); g_free(priv->layout); /* Group */ - gdk_color_free(priv->expanded_color); - free_font_and_color(priv->expanded); - gdk_color_free(priv->collapsed_color); - free_font_and_color(priv->collapsed); + if (priv->expanded_color) + gdk_color_free(priv->expanded_color); + pidgin_theme_font_free(priv->expanded); + if (priv->collapsed_color) + gdk_color_free(priv->collapsed_color); + pidgin_theme_font_free(priv->collapsed); /* Buddy */ - gdk_color_free(priv->contact_color); - free_font_and_color(priv->contact); - free_font_and_color(priv->online); - free_font_and_color(priv->away); - free_font_and_color(priv->offline); - free_font_and_color(priv->idle); - free_font_and_color(priv->message); - free_font_and_color(priv->message_nick_said); - free_font_and_color(priv->status); + if (priv->contact_color) + gdk_color_free(priv->contact_color); + pidgin_theme_font_free(priv->contact); + pidgin_theme_font_free(priv->online); + pidgin_theme_font_free(priv->away); + pidgin_theme_font_free(priv->offline); + pidgin_theme_font_free(priv->idle); + pidgin_theme_font_free(priv->message); + pidgin_theme_font_free(priv->message_nick_said); + pidgin_theme_font_free(priv->status); g_free(priv); @@ -290,81 +362,81 @@ obj_class->finalize = pidgin_blist_theme_finalize; /* Buddy List */ - pspec = g_param_spec_pointer("background-color", "Background Color", - "The background color for the buddy list", - G_PARAM_READWRITE); + pspec = g_param_spec_boxed("background-color", _("Background Color"), + _("The background color for the buddy list"), + GDK_TYPE_COLOR, G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_BACKGROUND_COLOR, pspec); - pspec = g_param_spec_pointer("layout", "Layout", - "The layout of icons, name, and status of the blist", + pspec = g_param_spec_pointer("layout", _("Layout"), + _("The layout of icons, name, and status of the blist"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_LAYOUT, pspec); /* Group */ - pspec = g_param_spec_pointer("expanded-color", "Expanded Background Color", - "The background color of an expanded group", - G_PARAM_READWRITE); + pspec = g_param_spec_boxed("expanded-color", _("Expanded Background Color"), + _("The background color of an expanded group"), + GDK_TYPE_COLOR, G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_EXPANDED_COLOR, pspec); - pspec = g_param_spec_pointer("expanded-text", "Expanded Text", - "The text information for when a group is expanded", + pspec = g_param_spec_pointer("expanded-text", _("Expanded Text"), + _("The text information for when a group is expanded"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_EXPANDED_TEXT, pspec); - pspec = g_param_spec_pointer("collapsed-color", "Collapsed Background Color", - "The background color of a collapsed group", - G_PARAM_READWRITE); + pspec = g_param_spec_boxed("collapsed-color", _("Collapsed Background Color"), + _("The background color of a collapsed group"), + GDK_TYPE_COLOR, G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_COLLAPSED_COLOR, pspec); - pspec = g_param_spec_pointer("collapsed-text", "Collapsed Text", - "The text information for when a group is collapsed", + pspec = g_param_spec_pointer("collapsed-text", _("Collapsed Text"), + _("The text information for when a group is collapsed"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_COLLAPSED_TEXT, pspec); /* Buddy */ - pspec = g_param_spec_pointer("contact-color", "Contact/Chat Background Color", - "The background color of a contact or chat", - G_PARAM_READWRITE); + pspec = g_param_spec_boxed("contact-color", _("Contact/Chat Background Color"), + _("The background color of a contact or chat"), + GDK_TYPE_COLOR, G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_CONTACT_COLOR, pspec); - pspec = g_param_spec_pointer("contact", "Contact Text", - "The text information for when a contact is expanded", + pspec = g_param_spec_pointer("contact", _("Contact Text"), + _("The text information for when a contact is expanded"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_CONTACT, pspec); - pspec = g_param_spec_pointer("online", "On-line Text", - "The text information for when a buddy is online", + pspec = g_param_spec_pointer("online", _("On-line Text"), + _("The text information for when a buddy is online"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_ONLINE, pspec); - pspec = g_param_spec_pointer("away", "Away Text", - "The text information for when a buddy is away", + pspec = g_param_spec_pointer("away", _("Away Text"), + _("The text information for when a buddy is away"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_AWAY, pspec); - pspec = g_param_spec_pointer("offline", "Off-line Text", - "The text information for when a buddy is off-line", + pspec = g_param_spec_pointer("offline", _("Off-line Text"), + _("The text information for when a buddy is off-line"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_OFFLINE, pspec); - pspec = g_param_spec_pointer("idle", "Idle Text", - "The text information for when a buddy is idle", + pspec = g_param_spec_pointer("idle", _("Idle Text"), + _("The text information for when a buddy is idle"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_IDLE, pspec); - pspec = g_param_spec_pointer("message", "Message Text", - "The text information for when a buddy has an unread message", + pspec = g_param_spec_pointer("message", _("Message Text"), + _("The text information for when a buddy has an unread message"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_MESSAGE, pspec); - pspec = g_param_spec_pointer("message_nick_said", "Message (Nick Said) Text", - "The text information for when a chat has an unread message that mentions your nick", + pspec = g_param_spec_pointer("message_nick_said", _("Message (Nick Said) Text"), + _("The text information for when a chat has an unread message that mentions your nick"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_MESSAGE_NICK_SAID, pspec); - pspec = g_param_spec_pointer("status", "Status Text", - "The text information for a buddy's status", + pspec = g_param_spec_pointer("status", _("Status Text"), + _("The text information for a buddy's status"), G_PARAM_READWRITE); g_object_class_install_property(obj_class, PROP_STATUS, pspec); } @@ -447,7 +519,7 @@ return priv->expanded_color; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_expanded_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -471,7 +543,7 @@ return priv->collapsed_color; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_collapsed_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -495,7 +567,7 @@ return priv->contact_color; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_contact_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -507,7 +579,7 @@ return priv->contact; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_online_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -519,7 +591,7 @@ return priv->online; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_away_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -531,7 +603,7 @@ return priv->away; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_offline_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -543,7 +615,7 @@ return priv->offline; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_idle_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -555,7 +627,7 @@ return priv->idle; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -567,7 +639,7 @@ return priv->message; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -579,7 +651,7 @@ return priv->message_nick_said; } -FontColorPair * +PidginThemeFont * pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme) { PidginBlistThemePrivate *priv; @@ -601,7 +673,8 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - gdk_color_free(priv->bgcolor); + if (priv->bgcolor) + gdk_color_free(priv->bgcolor); priv->bgcolor = gdk_color_copy(color); } @@ -639,12 +712,13 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - gdk_color_free(priv->expanded_color); + if (priv->expanded_color) + gdk_color_free(priv->expanded_color); priv->expanded_color = gdk_color_copy(color); } void -pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -652,7 +726,7 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->expanded); + pidgin_theme_font_free(priv->expanded); priv->expanded = copy_font_and_color(pair); } @@ -665,12 +739,13 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - gdk_color_free(priv->collapsed_color); + if (priv->collapsed_color) + gdk_color_free(priv->collapsed_color); priv->collapsed_color = gdk_color_copy(color); } void -pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -678,7 +753,7 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->collapsed); + pidgin_theme_font_free(priv->collapsed); priv->collapsed = copy_font_and_color(pair); } @@ -691,12 +766,13 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - gdk_color_free(priv->contact_color); + if (priv->contact_color) + gdk_color_free(priv->contact_color); priv->contact_color = gdk_color_copy(color); } void -pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -704,12 +780,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->contact); + pidgin_theme_font_free(priv->contact); priv->contact = copy_font_and_color(pair); } void -pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -717,12 +793,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->online); + pidgin_theme_font_free(priv->online); priv->online = copy_font_and_color(pair); } void -pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -730,12 +806,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->away); + pidgin_theme_font_free(priv->away); priv->away = copy_font_and_color(pair); } void -pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -743,12 +819,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->offline); + pidgin_theme_font_free(priv->offline); priv->offline = copy_font_and_color(pair); } void -pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -756,12 +832,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->idle); + pidgin_theme_font_free(priv->idle); priv->idle = copy_font_and_color(pair); } void -pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -769,12 +845,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->message); + pidgin_theme_font_free(priv->message); priv->message = copy_font_and_color(pair); } void -pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -782,12 +858,12 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->message_nick_said); + pidgin_theme_font_free(priv->message_nick_said); priv->message_nick_said = copy_font_and_color(pair); } void -pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const FontColorPair *pair) +pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair) { PidginBlistThemePrivate *priv; @@ -795,6 +871,6 @@ priv = PIDGIN_BLIST_THEME_GET_PRIVATE(G_OBJECT(theme)); - free_font_and_color(priv->status); + pidgin_theme_font_free(priv->status); priv->status = copy_font_and_color(pair); } diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkblist-theme.h --- a/pidgin/gtkblist-theme.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkblist-theme.h Tue Apr 28 18:43:57 2009 +0000 @@ -59,12 +59,15 @@ PurpleThemeClass parent_class; }; +#if 0 typedef struct { const gchar *font; const gchar *color; -} FontColorPair; +} PidginThemeFont; +#endif +typedef struct _PidginThemeFont PidginThemeFont; typedef struct { @@ -78,13 +81,68 @@ } PidginBlistLayout; /**************************************************************************/ -/** @name FontColorPair API */ +/** @name PidginThemeFont API */ /**************************************************************************/ /** + * Create a new PidginThemeFont. + * + * @param face The font face + * @param color The color of the font + * + * @return A newly created PidginThemeFont + */ +PidginThemeFont * pidgin_theme_font_new(const gchar *face, GdkColor *color); + +/** * Frees a font and color pair + * + * @param font The theme font + */ +void pidgin_theme_font_free(PidginThemeFont *font); + +/** + * Set the font-face of a PidginThemeFont. + * + * @param font The PidginThemeFont + * @param face The font-face */ -void free_font_and_color(FontColorPair *pair); +void pidgin_theme_font_set_font_face(PidginThemeFont *font, const gchar *face); + +/** + * Set the color of a PidginThemeFont. + * + * @param font The PidginThemeFont + * @param color The color + */ +void pidgin_theme_font_set_color(PidginThemeFont *font, const GdkColor *color); + +/** + * Get the font-face of a PidginThemeFont. + * + * @param font The PidginThemeFont + * + * @return The font-face, or NULL if none is set. + */ +const gchar * pidgin_theme_font_get_font_face(PidginThemeFont *font); + +/** + * Get the color of a PidginThemeFont as a GdkColor object. + * + * @param font The PidginThemeFont + * + * @return The color, or NULL if none is set. + */ +const GdkColor * pidgin_theme_font_get_color(PidginThemeFont *font); + +/** + * Get the color of a PidginThemeFont. + * + * @param font The PidginThemeFont + * + * @return The color, or NULL if none is set. + */ +const gchar * pidgin_theme_font_get_color_describe(PidginThemeFont *font); /**************************************************************************/ /** @name Purple Buddy List Theme API */ @@ -102,6 +160,8 @@ /** * Returns the background color of the buddy list. * + * @param theme The PidginBlist theme. + * * @returns A gdk color. */ GdkColor *pidgin_blist_theme_get_background_color(PidginBlistTheme *theme); @@ -110,6 +170,8 @@ * Returns the opacity of the buddy list window * (0.0 or clear to 1.0 fully opaque). * + * @param theme The PidginBlist theme. + * * @returns The opacity */ gdouble pidgin_blist_theme_get_opacity(PidginBlistTheme *theme); @@ -117,6 +179,8 @@ /** * Returns the layout to be used with the buddy list. * + * @param theme The PidginBlist theme. + * * @returns The buddy list layout. */ PidginBlistLayout *pidgin_blist_theme_get_layout(PidginBlistTheme *theme); @@ -124,6 +188,8 @@ /** * Returns the background color to be used with expanded groups. * + * @param theme The PidginBlist theme. + * * @returns A gdk color. */ GdkColor *pidgin_blist_theme_get_expanded_background_color(PidginBlistTheme *theme); @@ -131,13 +197,17 @@ /** * Returns the text font and color to be used with expanded groups. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_expanded_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_expanded_text_info(PidginBlistTheme *theme); /** * Returns the background color to be used with collapsed groups. * + * @param theme The PidginBlist theme. + * * @returns A gdk color. */ GdkColor *pidgin_blist_theme_get_collapsed_background_color(PidginBlistTheme *theme); @@ -145,13 +215,17 @@ /** * Returns the text font and color to be used with collapsed groups. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_collapsed_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_collapsed_text_info(PidginBlistTheme *theme); /** * Returns the colors to be used for contacts and chats. * + * @param theme The PidginBlist theme. + * * @returns A gdkcolor for contacts and chats. */ GdkColor *pidgin_blist_theme_get_contact_color(PidginBlistTheme *theme); @@ -159,65 +233,82 @@ /** * Returns the text font and color to be used for expanded contacts. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_contact_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_contact_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for online buddies. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_online_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_online_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for away and idle buddies. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_away_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_away_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for offline buddies. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_offline_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_offline_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for idle buddies. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_idle_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_idle_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for buddies with unread messages. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_unread_message_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for chats with unread messages * that mention your nick. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_unread_message_nick_said_text_info(PidginBlistTheme *theme); /** * Returns the text font and color to be used for a buddy's status message. * + * @param theme The PidginBlist theme. + * * @returns A font and color pair. */ - FontColorPair *pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme); + PidginThemeFont *pidgin_blist_theme_get_status_text_info(PidginBlistTheme *theme); /* Set Methods */ /** * Sets the background color to be used for this buddy list theme. * + * @param theme The PidginBlist theme. * @param color The new background color. */ void pidgin_blist_theme_set_background_color(PidginBlistTheme *theme, const GdkColor *color); @@ -225,6 +316,7 @@ /** * Sets the opacity to be used for this buddy list theme. * + * @param theme The PidginBlist theme. * @param opacity The new opacity setting. */ void pidgin_blist_theme_set_opacity(PidginBlistTheme *theme, gdouble opacity); @@ -232,6 +324,7 @@ /** * Sets the buddy list layout to be used for this buddy list theme. * + * @param theme The PidginBlist theme. * @param layout The new layout. */ void pidgin_blist_theme_set_layout(PidginBlistTheme *theme, const PidginBlistLayout *layout); @@ -239,6 +332,7 @@ /** * Sets the background color to be used for expanded groups. * + * @param theme The PidginBlist theme. * @param color The new background color. */ void pidgin_blist_theme_set_expanded_background_color(PidginBlistTheme *theme, const GdkColor *color); @@ -246,13 +340,15 @@ /** * Sets the text color and font to be used for expanded groups. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_expanded_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the background color to be used for collapsed groups. * + * @param theme The PidginBlist theme. * @param color The new background color. */ void pidgin_blist_theme_set_collapsed_background_color(PidginBlistTheme *theme, const GdkColor *color); @@ -260,13 +356,15 @@ /** * Sets the text color and font to be used for expanded groups. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_collapsed_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the background color to be used for contacts and chats. * + * @param theme The PidginBlist theme. * @param color The color to use for contacts and chats. */ void pidgin_blist_theme_set_contact_color(PidginBlistTheme *theme, const GdkColor *color); @@ -274,59 +372,67 @@ /** * Sets the text color and font to be used for expanded contacts. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_contact_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for online buddies. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_online_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for away and idle buddies. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_away_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for offline buddies. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_offline_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for idle buddies. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_idle_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for buddies with unread messages. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_unread_message_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for a chat with unread messages * that mention your nick. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_unread_message_nick_said_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); /** * Sets the text color and font to be used for buddy status messages. * - * @param pair The new text font at color pair. + * @param theme The PidginBlist theme. + * @param pair The new text font and color pair. */ -void pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const FontColorPair *pair); +void pidgin_blist_theme_set_status_text_info(PidginBlistTheme *theme, const PidginThemeFont *pair); G_END_DECLS #endif /* PIDGIN_BLIST_THEME_H */ diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkblist.c --- a/pidgin/gtkblist.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkblist.c Tue Apr 28 18:43:57 2009 +0000 @@ -3902,6 +3902,24 @@ return ret; } +static const char * +theme_font_get_color_default(PidginThemeFont *font, const char *def) +{ + const char *ret; + if (!font || !(ret = pidgin_theme_font_get_color_describe(font))) + ret = def; + return ret; +} + +static const char * +theme_font_get_face_default(PidginThemeFont *font, const char *def) +{ + const char *ret; + if (!font || !(ret = pidgin_theme_font_get_font_face(font))) + ret = def; + return ret; +} + gchar * pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected, gboolean aliased) { @@ -3916,7 +3934,7 @@ PurpleConversation *conv = find_conversation_with_buddy(b); gboolean hidden_conv = FALSE; gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); - FontColorPair *pair = NULL; + PidginThemeFont *statusfont = NULL, *namefont = NULL; PidginBlistTheme *theme; if (conv != NULL) { @@ -4034,46 +4052,29 @@ /* choose the colors of the text */ theme = pidgin_blist_get_theme(); - - if (purple_presence_is_idle(presence)) { - if (theme) - pair = pidgin_blist_theme_get_idle_text_info(theme); - status_color = name_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey"; - status_font = name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - - } else if (!purple_presence_is_online(presence)) { - if (theme) - pair = pidgin_blist_theme_get_offline_text_info(theme); - name_color = (pair != NULL && pair->color != NULL) ? pair->color : NULL; - name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - - if (theme) - pair = pidgin_blist_theme_get_status_text_info(theme); - status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey"; - status_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - - } else if (purple_presence_is_available(presence)) { - if (theme) - pair = pidgin_blist_theme_get_online_text_info(theme); - name_color = (pair != NULL && pair->color != NULL) ? pair->color : NULL; - name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - - if (theme) - pair = pidgin_blist_theme_get_status_text_info(theme); - status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey"; - status_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - - } else { - if (theme) - pair = pidgin_blist_theme_get_away_text_info(theme); - name_color = (pair != NULL && pair->color != NULL) ? pair->color : NULL; - name_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - - if (theme) - pair = pidgin_blist_theme_get_status_text_info(theme); - status_color = (pair != NULL && pair->color != NULL) ? pair->color : "dim grey"; - status_font = (pair != NULL && pair->font != NULL) ? pair->font : ""; - } + name_color = NULL; + + if (theme) { + if (purple_presence_is_idle(presence)) { + namefont = statusfont = pidgin_blist_theme_get_idle_text_info(theme); + name_color = "dim grey"; + } else if (!purple_presence_is_online(presence)) { + namefont = pidgin_blist_theme_get_offline_text_info(theme); + statusfont = pidgin_blist_theme_get_status_text_info(theme); + } else if (purple_presence_is_available(presence)) { + namefont = pidgin_blist_theme_get_online_text_info(theme); + statusfont = pidgin_blist_theme_get_status_text_info(theme); + } else { + namefont = pidgin_blist_theme_get_away_text_info(theme); + statusfont = pidgin_blist_theme_get_status_text_info(theme); + } + } + + name_color = theme_font_get_color_default(namefont, name_color); + name_font = theme_font_get_face_default(namefont, ""); + + status_color = theme_font_get_color_default(statusfont, "dim grey"); + status_font = theme_font_get_face_default(statusfont, ""); if (aliased && selected) { if (theme) { @@ -4651,6 +4652,12 @@ } static void +account_actions_changed(PurpleAccount *account, gpointer data) +{ + pidgin_blist_update_accounts_menu(); +} + +static void account_status_changed(PurpleAccount *account, PurpleStatus *old, PurpleStatus *new, PidginBuddyList *gtkblist) { @@ -5836,6 +5843,8 @@ purple_signal_connect(handle, "account-error-changed", gtkblist, PURPLE_CALLBACK(update_account_error_state), gtkblist); + purple_signal_connect(handle, "account-actions-changed", gtkblist, + PURPLE_CALLBACK(account_actions_changed), NULL); handle = pidgin_account_get_handle(); purple_signal_connect(handle, "account-modified", gtkblist, @@ -6196,7 +6205,7 @@ char *mark, *esc; PurpleBlistNode *selected_node = NULL; GtkTreeIter iter; - FontColorPair *pair; + PidginThemeFont *pair; gchar const *text_color, *text_font; PidginBlistTheme *theme; @@ -6223,8 +6232,8 @@ pair = pidgin_blist_theme_get_collapsed_text_info(theme); - text_color = (selected || pair == NULL || pair->color == NULL) ? NULL : pair->color; - text_font = (pair == NULL || pair->font == NULL) ? "" : pair->font; + text_color = selected ? NULL : theme_font_get_color_default(pair, NULL); + text_font = theme_font_get_face_default(pair, ""); esc = g_markup_escape_text(group->name, -1); if (text_color) { @@ -6282,7 +6291,7 @@ if (idle_secs > 0) { - FontColorPair *pair = NULL; + PidginThemeFont *pair = NULL; const gchar *textcolor; time_t t; int ihrs, imin; @@ -6291,18 +6300,18 @@ ihrs = (t - idle_secs) / 3600; imin = ((t - idle_secs) / 60) % 60; - if (!selected && theme != NULL && (pair = pidgin_blist_theme_get_idle_text_info(theme)) != NULL && pair->color != NULL) - textcolor = pair->color; + if (!selected && theme != NULL && (pair = pidgin_blist_theme_get_idle_text_info(theme)) != NULL) + textcolor = pidgin_theme_font_get_color_describe(pair); else textcolor = NULL; if (textcolor) { idle = g_strdup_printf("%d:%02d", - textcolor, (pair == NULL || pair->font == NULL) ? "" : pair->font, + textcolor, theme_font_get_face_default(pair, ""), ihrs, imin); } else { idle = g_strdup_printf("%d:%02d", - (pair == NULL || pair->font == NULL) ? "" : pair->font, + theme_font_get_face_default(pair, ""), ihrs, imin); } } @@ -6387,7 +6396,7 @@ const gchar *fg_color, *font; GdkColor *color = NULL; PidginBlistTheme *theme = pidgin_blist_get_theme(); - FontColorPair *pair; + PidginThemeFont *pair; gboolean selected = (gtkblist->selected_node == cnode); mark = g_markup_escape_text(purple_contact_get_alias(contact), -1); @@ -6400,8 +6409,8 @@ color = pidgin_blist_theme_get_contact_color(theme); } - font = (pair == NULL || pair->font == NULL) ? "" : pair->font; - fg_color = (selected || pair == NULL || pair->color == NULL) ? NULL : pair->color; + font = theme_font_get_face_default(pair, ""); + fg_color = selected ? NULL : theme_font_get_color_default(pair, NULL); if (fg_color) { tmp = g_strdup_printf("%s", @@ -6498,7 +6507,7 @@ PurpleConversation *conv; gboolean hidden = FALSE; GdkColor *bgcolor = NULL; - FontColorPair *pair; + PidginThemeFont *pair; PidginBlistTheme *theme; gboolean selected = (gtkblist->selected_node == node); gboolean nick_said = FALSE; @@ -6536,12 +6545,10 @@ else pair = pidgin_blist_theme_get_online_text_info(theme); - font = (pair == NULL || pair->font == NULL) ? "" : pair->font; - if (selected || pair == NULL || pair->color == NULL) + font = theme_font_get_face_default(pair, ""); + if (selected || !(color = theme_font_get_color_default(pair, NULL))) /* nick_said color is the same as gtkconv:tab-label-attention */ color = (nick_said ? "#006aff" : NULL); - else - color = pair->color; if (color) { tmp = g_strdup_printf("%s", @@ -6630,7 +6637,7 @@ purple_signals_disconnect_by_handle(gtkblist); if (gtkblist->headline_close) - gdk_pixbuf_unref(gtkblist->headline_close); + g_object_unref(G_OBJECT(gtkblist->headline_close)); gtk_widget_destroy(gtkblist->window); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkconv.c --- a/pidgin/gtkconv.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkconv.c Tue Apr 28 18:43:57 2009 +0000 @@ -2512,13 +2512,49 @@ return get_prpl_icon_list(account); } +static const char * +pidgin_conv_get_icon_stock(PurpleConversation *conv) +{ + PurpleAccount *account = NULL; + const char *stock = NULL; + + g_return_val_if_fail(conv != NULL, NULL); + + account = purple_conversation_get_account(conv); + g_return_val_if_fail(account != NULL, NULL); + + /* Use the buddy icon, if possible */ + if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { + const char *name = NULL; + PurpleBuddy *b; + name = purple_conversation_get_name(conv); + b = purple_find_buddy(account, name); + if (b != NULL) { + PurplePresence *p = purple_buddy_get_presence(b); + PurpleStatus *active = purple_presence_get_active_status(p); + PurpleStatusType *type = purple_status_get_type(active); + PurpleStatusPrimitive prim = purple_status_type_get_primitive(type); + stock = pidgin_stock_id_from_status_primitive(prim); + } else { + stock = PIDGIN_STOCK_STATUS_PERSON; + } + } else { + stock = PIDGIN_STOCK_STATUS_CHAT; + } + + return stock; +} + static GdkPixbuf * pidgin_conv_get_icon(PurpleConversation *conv, GtkWidget *parent, const char *icon_size) { PurpleAccount *account = NULL; const char *name = NULL; + const char *stock = NULL; GdkPixbuf *status = NULL; PurpleBlistUiOps *ops = purple_blist_get_ui_ops(); + GtkIconSize size; + g_return_val_if_fail(conv != NULL, NULL); account = purple_conversation_get_account(conv); @@ -2531,40 +2567,17 @@ if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { PurpleBuddy *b = purple_find_buddy(account, name); if (b != NULL) { - PurplePresence *p = purple_buddy_get_presence(b); /* I hate this hack. It fixes a bug where the pending message icon * displays in the conv tab even though it shouldn't. * A better solution would be great. */ if (ops && ops->update) ops->update(NULL, (PurpleBlistNode*)b); - - /* XXX Seanegan: We really need a util function to return a pixbuf for a Presence to avoid all this switching */ - if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) - status = pidgin_create_status_icon(PURPLE_STATUS_AWAY, parent, icon_size); - else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_EXTENDED_AWAY)) - status = pidgin_create_status_icon(PURPLE_STATUS_EXTENDED_AWAY, parent, icon_size); - else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_OFFLINE)) - status = pidgin_create_status_icon(PURPLE_STATUS_OFFLINE, parent, icon_size); - else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AVAILABLE)) - status = pidgin_create_status_icon(PURPLE_STATUS_AVAILABLE, parent, icon_size); - else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_INVISIBLE)) - status = pidgin_create_status_icon(PURPLE_STATUS_INVISIBLE, parent, icon_size); - else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) - status = pidgin_create_status_icon(PURPLE_STATUS_UNAVAILABLE, parent, icon_size); - } - } - - /* If they don't have a buddy icon, then use the PRPL icon */ - if (status == NULL) { - GtkIconSize size = gtk_icon_size_from_name(icon_size); - if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { - status = gtk_widget_render_icon (parent, PIDGIN_STOCK_STATUS_PERSON, - size, "GtkWidget"); - } else { - status = gtk_widget_render_icon (parent, PIDGIN_STOCK_STATUS_CHAT, - size, "GtkWidget"); - } - } + } + } + + stock = pidgin_conv_get_icon_stock(conv); + size = gtk_icon_size_from_name(icon_size); + status = gtk_widget_render_icon (parent, stock, size, "GtkWidget"); return status; } @@ -2582,9 +2595,9 @@ PidginConversation *gtkconv; PidginWindow *win; GList *l; - GdkPixbuf *status = NULL; - GdkPixbuf *infopane_status = NULL; GdkPixbuf *emblem = NULL; + const char *status = NULL; + const char *infopane_status = NULL; g_return_if_fail(conv != NULL); @@ -2593,8 +2606,7 @@ if (conv != gtkconv->active_conv) return; - status = pidgin_conv_get_tab_icon(conv, TRUE); - infopane_status = pidgin_conv_get_tab_icon(conv, FALSE); + status = infopane_status = pidgin_conv_get_icon_stock(conv); if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { PurpleBuddy *b = purple_find_buddy(conv->account, conv->name); @@ -2604,8 +2616,8 @@ g_return_if_fail(status != NULL); - gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); - gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); + g_object_set(G_OBJECT(gtkconv->icon), "stock", status, NULL); + g_object_set(G_OBJECT(gtkconv->menu_icon), "stock", status, NULL); gtk_list_store_set(GTK_LIST_STORE(gtkconv->infopane_model), &(gtkconv->infopane_iter), @@ -2633,9 +2645,6 @@ gtk_widget_queue_resize(gtkconv->infopane); gtk_widget_queue_draw(gtkconv->infopane); - if (status != NULL) - g_object_unref(status); - if (pidgin_conv_window_is_active_conversation(conv) && (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM || gtkconv->u.im->anim == NULL)) @@ -3071,16 +3080,13 @@ PurpleConversation *conv = (PurpleConversation*)l->data; PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); - GtkWidget *icon = gtk_image_new(); - GdkPixbuf *pbuf = pidgin_conv_get_icon(conv, icon, PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC); + GtkWidget *icon = gtk_image_new_from_stock(pidgin_conv_get_icon_stock(conv), + gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC)); GtkWidget *item; gchar *text = g_strdup_printf("%s (%d)", gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), gtkconv->unseen_count); - gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); - g_object_unref(pbuf); - item = gtk_image_menu_item_new_with_label(text); gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), icon); g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(unseen_conv_menu_cb), conv); @@ -3941,12 +3947,9 @@ update_send_to_selection(win); } -static GdkPixbuf * +static const char * get_chat_buddy_status_icon(PurpleConvChat *chat, const char *name, PurpleConvChatBuddyFlags flags) { - PidginConversation *gtkconv = PIDGIN_CONVERSATION(chat->conv); - GdkPixbuf *pixbuf, *scale, *scale2; - char *filename; const char *image = NULL; if (flags & PURPLE_CBFLAGS_FOUNDER) { @@ -3962,28 +3965,7 @@ } else { return NULL; } - - pixbuf = gtk_widget_render_icon (gtkconv->tab_cont, image, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), - "GtkTreeView"); - - if (!pixbuf) - return NULL; - - scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); - - if (flags && purple_conv_chat_is_user_ignored(chat, name)) { -/* TODO: the .../status/default directory isn't installed, should it be? */ - filename = g_build_filename(DATADIR, "pixmaps", "pidgin", "status", "default", "ignored.png", NULL); - pixbuf = gdk_pixbuf_new_from_file(filename, NULL); - g_free(filename); - scale2 = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); - g_object_unref(pixbuf); - gdk_pixbuf_composite(scale2, scale, 0, 0, 16, 16, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); - g_object_unref(scale2); - } - - return scale; + return image; } static void @@ -3995,7 +3977,7 @@ PurpleConnection *gc; PurplePluginProtocolInfo *prpl_info; GtkListStore *ls; - GdkPixbuf *pixbuf; + const char *stock; GtkTreeIter iter; gboolean is_me = FALSE; gboolean is_buddy; @@ -4017,7 +3999,7 @@ ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); - pixbuf = get_chat_buddy_status_icon(chat, name, flags); + stock = get_chat_buddy_status_icon(chat, name, flags); if (!strcmp(chat->nick, purple_normalize(conv->account, old_name != NULL ? old_name : name))) is_me = TRUE; @@ -4034,6 +4016,11 @@ "send-name"); g_object_get(tag, "foreground-gdk", &color, NULL); } else { + GtkTextTag *tag; + if ((tag = get_buddy_tag(conv, name, 0, FALSE))) + g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL); + if ((tag = get_buddy_tag(conv, name, PURPLE_MESSAGE_NICK, FALSE))) + g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL); color = (GdkColor*)get_nick_color(gtkconv, name); } @@ -4047,7 +4034,7 @@ * Inserting in the "wrong" location has no visible ill effects. - F.P. */ -1, /* "row" */ - CHAT_USERS_ICON_COLUMN, pixbuf, + CHAT_USERS_ICON_STOCK_COLUMN, stock, CHAT_USERS_ALIAS_COLUMN, alias, CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, CHAT_USERS_NAME_COLUMN, name, @@ -4058,7 +4045,7 @@ #else gtk_list_store_append(ls, &iter); gtk_list_store_set(ls, &iter, - CHAT_USERS_ICON_COLUMN, pixbuf, + CHAT_USERS_ICON_STOCK_COLUMN, stock, CHAT_USERS_ALIAS_COLUMN, alias, CHAT_USERS_ALIAS_KEY_COLUMN, alias_key, CHAT_USERS_NAME_COLUMN, name, @@ -4068,8 +4055,6 @@ -1); #endif - if (pixbuf) - g_object_unref(pixbuf); if (is_me && color) gdk_color_free(color); g_free(alias_key); @@ -4716,16 +4701,18 @@ ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, - GDK_TYPE_COLOR, G_TYPE_INT); + GDK_TYPE_COLOR, G_TYPE_INT, G_TYPE_STRING); gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, sort_chat_users, NULL, NULL); list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); rend = gtk_cell_renderer_pixbuf_new(); - + g_object_set(G_OBJECT(rend), + "stock-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), + NULL); col = gtk_tree_view_column_new_with_attributes(NULL, rend, - "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); + "stock-id", CHAT_USERS_ICON_STOCK_COLUMN, NULL); gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); ul_width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/userlist_width"); @@ -4752,7 +4739,7 @@ "foreground-set", TRUE, "weight-set", TRUE, NULL); - g_object_set(G_OBJECT(rend), "editable", TRUE, NULL); + g_object_set(G_OBJECT(rend), "editable", TRUE, NULL); col = gtk_tree_view_column_new_with_attributes(NULL, rend, "text", CHAT_USERS_ALIAS_COLUMN, @@ -4843,7 +4830,7 @@ pidgin_conv_create_tooltip, NULL); gtkconv->infopane = gtk_cell_view_new(); - gtkconv->infopane_model = gtk_list_store_new(CONV_NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF); + gtkconv->infopane_model = gtk_list_store_new(CONV_NUM_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF); gtk_cell_view_set_model(GTK_CELL_VIEW(gtkconv->infopane), GTK_TREE_MODEL(gtkconv->infopane_model)); g_object_unref(gtkconv->infopane_model); @@ -4866,8 +4853,10 @@ rend = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "pixbuf", CONV_ICON_COLUMN, NULL); - g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "stock-id", CONV_ICON_COLUMN, NULL); + g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, + "stock-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), + NULL); rend = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, TRUE); @@ -6063,6 +6052,7 @@ PurpleConvChatBuddy *cbuddy; GtkTreeIter iter; GtkTreeModel *model; + GtkTextTag *tag; int f = 1; chat = PURPLE_CONV_CHAT(conv); @@ -6090,6 +6080,11 @@ g_free(val); } + if ((tag = get_buddy_tag(conv, old_name, 0, FALSE))) + g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); + if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE))) + g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); + if (!purple_conv_chat_find_user(chat, old_name)) return; @@ -6112,6 +6107,7 @@ char tmp[BUF_LONG]; int num_users; gboolean f; + GtkTextTag *tag; chat = PURPLE_CONV_CHAT(conv); gtkconv = PIDGIN_CONVERSATION(conv); @@ -6144,6 +6140,11 @@ g_free(val); } while (f); + + if ((tag = get_buddy_tag(conv, l->data, 0, FALSE))) + g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); + if ((tag = get_buddy_tag(conv, l->data, PURPLE_MESSAGE_NICK, FALSE))) + g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); } g_snprintf(tmp, sizeof(tmp), @@ -9417,6 +9418,12 @@ /* Status icon. */ gtkconv->icon = gtk_image_new(); gtkconv->menu_icon = gtk_image_new(); + g_object_set(G_OBJECT(gtkconv->icon), + "icon-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC), + NULL); + g_object_set(G_OBJECT(gtkconv->menu_icon), + "icon-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC), + NULL); gtk_widget_show(gtkconv->icon); update_tab_icon(conv); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkconv.h --- a/pidgin/gtkconv.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkconv.h Tue Apr 28 18:43:57 2009 +0000 @@ -51,6 +51,7 @@ CHAT_USERS_FLAGS_COLUMN, CHAT_USERS_COLOR_COLUMN, CHAT_USERS_WEIGHT_COLUMN, + CHAT_USERS_ICON_STOCK_COLUMN, /** @since 2.6.0 */ CHAT_USERS_COLUMNS }; diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkdialogs.c --- a/pidgin/gtkdialogs.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkdialogs.c Tue Apr 28 18:43:57 2009 +0000 @@ -73,6 +73,7 @@ /* Order: Alphabetical by Last Name */ static const struct developer developers[] = { {"Daniel 'datallah' Atallah", NULL, NULL}, + {"Paul 'darkrain42' Aurich", NULL, NULL }, {"John 'rekkanoryo' Bailey", N_("bug master"), "rekkanoryo@pidgin.im"}, {"Ethan 'Paco-Paco' Blanton", NULL, NULL}, {"Hylke Bons", N_("artist"), "h.bons@student.rug.nl"}, @@ -90,6 +91,7 @@ {"Bartosz Oler", NULL, NULL}, {"Etan 'deryni' Reisner", NULL, NULL}, {"Tim 'marv' Ringenbach", NULL, NULL}, + {"Michael 'Maiku' Ruprecht", N_("voice and video"), NULL}, {"Elliott 'QuLogic' Sales de Andrade", NULL, NULL}, {"Luke 'LSchiere' Schierer", N_("support"), "lschiere@users.sf.net"}, {"Evan Schoenberg", NULL, NULL}, @@ -101,7 +103,6 @@ /* Order: Alphabetical by Last Name */ static const struct developer patch_writers[] = { - {"Paul 'darkrain42' Aurich", NULL, NULL }, {"Marcus 'malu' Lundblad", NULL, NULL}, {"Dennis 'EvilDennisR' Ristuccia", N_("Senior Contributor/QA"), NULL}, {"Peter 'Fmoo' Ruibal", NULL, NULL}, @@ -427,7 +428,7 @@ #endif gtk_widget_destroy(logo); logo = gtk_image_new_from_pixbuf(pixbuf); - gdk_pixbuf_unref(pixbuf); + g_object_unref(G_OBJECT(pixbuf)); /* Insert the logo */ obj = gtk_widget_get_accessible(logo); tmp = g_strconcat(PIDGIN_NAME, " " DISPLAY_VERSION, NULL); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkdocklet.c --- a/pidgin/gtkdocklet.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkdocklet.c Tue Apr 28 18:43:57 2009 +0000 @@ -482,7 +482,7 @@ } static GtkWidget * -new_menu_item_with_status_icon(GtkWidget *menu, const char *str, PurpleStatusPrimitive primitive, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) +new_menu_item_with_status_icon(GtkWidget *menu, const char *str, PurpleStatusPrimitive primitive, GCallback cb, gpointer data, guint accel_key, guint accel_mods, char *mod) { GtkWidget *menuitem; GdkPixbuf *pixbuf; @@ -493,8 +493,8 @@ if (menu) gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - if (sf) - g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); + if (cb) + g_signal_connect(G_OBJECT(menuitem), "activate", cb, data); pixbuf = pidgin_create_status_icon(primitive, menu, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); image = gtk_image_new_from_pixbuf(pixbuf); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkicon-theme-loader.h --- a/pidgin/gtkicon-theme-loader.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkicon-theme-loader.h Tue Apr 28 18:43:57 2009 +0000 @@ -1,5 +1,5 @@ /** - * @file gtkicon-loader.h Pidgin Icon Theme Loader Class API + * @file gtkicon-theme-loader.h Pidgin Icon Theme Loader Class API */ /* purple diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkicon-theme.h --- a/pidgin/gtkicon-theme.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkicon-theme.h Tue Apr 28 18:43:57 2009 +0000 @@ -1,5 +1,5 @@ /** - * @file icon-theme.h Pidgin Icon Theme Class API + * @file gtkicon-theme.h Pidgin Icon Theme Class API */ /* pidgin @@ -72,6 +72,7 @@ /** * Returns a copy of the filename for the icon event or NULL if it is not set * + * @param theme the theme * @param event the pidgin icon event to look up * * @returns the filename of the icon event @@ -82,6 +83,7 @@ /** * Sets the filename for a given icon id, setting the icon to NULL will remove the icon from the theme * + * @param theme the theme * @param icon_id a string representing what the icon is to be used for * @param filename the name of the file to be used for the given id */ diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkimhtml.c Tue Apr 28 18:43:57 2009 +0000 @@ -782,7 +782,7 @@ gc, TRUE, visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height); - gdk_gc_unref(gc); + g_object_unref(G_OBJECT(gc)); if (GTK_WIDGET_CLASS (parent_class)->expose_event) return (* GTK_WIDGET_CLASS (parent_class)->expose_event) @@ -873,7 +873,7 @@ !gtk_text_iter_begins_tag(&cur, NULL)); } - gdk_gc_unref(gc); + g_object_unref(G_OBJECT(gc)); if (GTK_WIDGET_CLASS (parent_class)->expose_event) return (* GTK_WIDGET_CLASS (parent_class)->expose_event) @@ -1384,7 +1384,7 @@ gtk_widget_destroy(imhtml->tip_window); } if(imhtml->tip_timer) - gtk_timeout_remove(imhtml->tip_timer); + g_source_remove(imhtml->tip_timer); for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { struct scalable_data *sd = scalables->data; @@ -1451,7 +1451,7 @@ GObjectClass *gobject_class; object_class = (GtkObjectClass*) klass; gobject_class = (GObjectClass*) klass; - parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW); + parent_class = g_type_class_ref(GTK_TYPE_TEXT_VIEW); signals[URL_CLICKED] = g_signal_new("url_clicked", G_TYPE_FROM_CLASS(gobject_class), G_SIGNAL_RUN_FIRST, diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkimhtml.h --- a/pidgin/gtkimhtml.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkimhtml.h Tue Apr 28 18:43:57 2009 +0000 @@ -40,13 +40,13 @@ **************************************************************************/ /*@{*/ -#define GTK_TYPE_IMHTML (gtk_imhtml_get_type ()) -#define GTK_IMHTML(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_IMHTML, GtkIMHtml)) -#define GTK_IMHTML_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMHTML, GtkIMHtmlClass)) -#define GTK_IS_IMHTML(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_IMHTML)) -#define GTK_IS_IMHTML_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMHTML)) +#define GTK_TYPE_IMHTML (gtk_imhtml_get_type()) +#define GTK_IMHTML(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_IMHTML, GtkIMHtml)) +#define GTK_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_IMHTML, GtkIMHtmlClass)) +#define GTK_IS_IMHTML(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_IMHTML)) +#define GTK_IS_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_IMHTML)) #define GTK_IMHTML_SCALABLE(obj) ((GtkIMHtmlScalable *)obj) -#define GTK_IMHTML_ANIMATION(obj) ((GtkIMHtmlAnimation *)obj) +#define GTK_IMHTML_ANIMATION(obj) ((GtkIMHtmlAnimation *)obj) typedef struct _GtkIMHtml GtkIMHtml; typedef struct _GtkIMHtmlClass GtkIMHtmlClass; diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkimhtmltoolbar.c --- a/pidgin/gtkimhtmltoolbar.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkimhtmltoolbar.c Tue Apr 28 18:43:57 2009 +0000 @@ -1198,7 +1198,7 @@ GObjectClass *gobject_class; object_class = (GtkObjectClass*) class; gobject_class = (GObjectClass*) class; - parent_class = gtk_type_class(GTK_TYPE_HBOX); + parent_class = g_type_class_ref(GTK_TYPE_HBOX); gobject_class->finalize = gtk_imhtmltoolbar_finalize; purple_prefs_add_none(PIDGIN_PREFS_ROOT "/conversations/toolbar"); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkimhtmltoolbar.h --- a/pidgin/gtkimhtmltoolbar.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkimhtmltoolbar.h Tue Apr 28 18:43:57 2009 +0000 @@ -32,11 +32,11 @@ #define DEFAULT_FONT_FACE "Helvetica 12" -#define GTK_TYPE_IMHTMLTOOLBAR (gtk_imhtmltoolbar_get_type ()) -#define GTK_IMHTMLTOOLBAR(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_IMHTMLTOOLBAR, GtkIMHtmlToolbar)) -#define GTK_IMHTMLTOOLBAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMHTMLTOOLBAR, GtkIMHtmlToolbarClass)) -#define GTK_IS_IMHTMLTOOLBAR(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_IMHTMLTOOLBAR)) -#define GTK_IS_IMHTMLTOOLBAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMHTMLTOOLBAR)) +#define GTK_TYPE_IMHTMLTOOLBAR (gtk_imhtmltoolbar_get_type()) +#define GTK_IMHTMLTOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_IMHTMLTOOLBAR, GtkIMHtmlToolbar)) +#define GTK_IMHTMLTOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_IMHTMLTOOLBAR, GtkIMHtmlToolbarClass)) +#define GTK_IS_IMHTMLTOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_IMHTMLTOOLBAR)) +#define GTK_IS_IMHTMLTOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_IMHTMLTOOLBAR)) typedef struct _GtkIMHtmlToolbar GtkIMHtmlToolbar; typedef struct _GtkIMHtmlToolbarClass GtkIMHtmlToolbarClass; diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkmenutray.h --- a/pidgin/gtkmenutray.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkmenutray.h Tue Apr 28 18:43:57 2009 +0000 @@ -26,12 +26,12 @@ #include -#define PIDGIN_TYPE_MENU_TRAY (pidgin_menu_tray_get_gtype()) -#define PIDGIN_MENU_TRAY(obj) (GTK_CHECK_CAST((obj), PIDGIN_TYPE_MENU_TRAY, PidginMenuTray)) -#define PIDGIN_MENU_TRAY_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_MENU_TRAY, PidginMenuTrayClass)) -#define PIDGIN_IS_MENU_TRAY(obj) (GTK_CHECK_TYPE((obj), PIDGIN_TYPE_MENU_TRAY)) -#define PIDGIN_IS_MENU_TRAY_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), PIDGIN_TYPE_MENU_TRAY)) -#define PIDGIN_MENU_TRAY_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), PIDGIN_TYPE_MENU_TRAY, PidginMenuTrayClass)) +#define PIDGIN_TYPE_MENU_TRAY (pidgin_menu_tray_get_gtype()) +#define PIDGIN_MENU_TRAY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PIDGIN_TYPE_MENU_TRAY, PidginMenuTray)) +#define PIDGIN_MENU_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PIDGIN_TYPE_MENU_TRAY, PidginMenuTrayClass)) +#define PIDGIN_IS_MENU_TRAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PIDGIN_TYPE_MENU_TRAY)) +#define PIDGIN_IS_MENU_TRAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PIDGIN_TYPE_MENU_TRAY)) +#define PIDGIN_MENU_TRAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PIDGIN_TYPE_MENU_TRAY, PidginMenuTrayClass)) typedef struct _PidginMenuTray PidginMenuTray; typedef struct _PidginMenuTrayClass PidginMenuTrayClass; diff -r de9816c970fe -r 3912f55a1633 pidgin/gtknotify.h --- a/pidgin/gtknotify.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtknotify.h Tue Apr 28 18:43:57 2009 +0000 @@ -32,8 +32,10 @@ /** * Adds a buddy pounce to the buddy pounce dialog * + * @param account The account + * @param pounce The pounce * @param alias The buddy alias - * @param event Event description + * @param event Event description * @param message Pounce message * @param date Pounce date */ diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkprefs.c --- a/pidgin/gtkprefs.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkprefs.c Tue Apr 28 18:43:57 2009 +0000 @@ -638,7 +638,7 @@ gtk_list_store_set(prefs_sound_themes, &iter, 0, pixbuf, 2, purple_theme_get_name(theme), -1); if (pixbuf != NULL) - gdk_pixbuf_unref(pixbuf); + g_object_unref(G_OBJECT(pixbuf)); } else if (PIDGIN_IS_BLIST_THEME(theme) || PIDGIN_IS_STATUS_ICON_THEME(theme)){ GtkListStore *store; @@ -665,7 +665,7 @@ g_free(markup); if (pixbuf != NULL) - gdk_pixbuf_unref(pixbuf); + g_object_unref(G_OBJECT(pixbuf)); } } @@ -702,7 +702,7 @@ gtk_list_store_set(prefs_status_icon_themes, &iter, 0, pixbuf, 1, "(Default) - None\n" "The default Pidgin status icon theme", 2, "", -1); - gdk_pixbuf_unref(pixbuf); + g_object_unref(G_OBJECT(pixbuf)); } /* builds a theme combo box from a list store with colums: icon preview, markup, theme name */ diff -r de9816c970fe -r 3912f55a1633 pidgin/gtksavedstatuses.c --- a/pidgin/gtksavedstatuses.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtksavedstatuses.c Tue Apr 28 18:43:57 2009 +0000 @@ -398,23 +398,7 @@ static const gchar * get_stock_icon_from_primitive(PurpleStatusPrimitive type) { - switch (type) { - case PURPLE_STATUS_AVAILABLE: - return PIDGIN_STOCK_STATUS_AVAILABLE; - case PURPLE_STATUS_AWAY: - return PIDGIN_STOCK_STATUS_AWAY; - case PURPLE_STATUS_EXTENDED_AWAY: - return PIDGIN_STOCK_STATUS_XA; - case PURPLE_STATUS_INVISIBLE: - return PIDGIN_STOCK_STATUS_INVISIBLE; - case PURPLE_STATUS_OFFLINE: - return PIDGIN_STOCK_STATUS_OFFLINE; - case PURPLE_STATUS_UNAVAILABLE: - return PIDGIN_STOCK_STATUS_BUSY; - default: - /* this shouldn't happen */ - return NULL; - } + return pidgin_stock_id_from_status_primitive(type); } static void @@ -1503,16 +1487,19 @@ gtk_size_group_add_widget(sg, label); dialog->model = gtk_list_store_new(SUBSTATUS_NUM_COLUMNS, - GDK_TYPE_PIXBUF, + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(dialog->model)); dialog->box = GTK_COMBO_BOX(combo); rend = GTK_CELL_RENDERER(gtk_cell_renderer_pixbuf_new()); + g_object_set(G_OBJECT(rend), + "stock-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), + NULL); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), rend, - "pixbuf", SUBSTATUS_COLUMN_ICON, NULL); + "stock-id", SUBSTATUS_COLUMN_ICON, NULL); rend = GTK_CELL_RENDERER(gtk_cell_renderer_text_new()); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, TRUE); @@ -1574,8 +1561,8 @@ for (list = purple_account_get_status_types(account); list; list = list->next) { PurpleStatusType *status_type; - GdkPixbuf *pixbuf; const char *id, *name; + PurpleStatusPrimitive prim; status_type = list->data; @@ -1588,17 +1575,15 @@ continue; id = purple_status_type_get_id(status_type); - pixbuf = pidgin_create_status_icon(purple_status_type_get_primitive(status_type), combo, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); + prim = purple_status_type_get_primitive(status_type); name = purple_status_type_get_name(status_type); gtk_list_store_append(dialog->model, &iter); gtk_list_store_set(dialog->model, &iter, - SUBSTATUS_COLUMN_ICON, pixbuf, + SUBSTATUS_COLUMN_ICON, pidgin_stock_id_from_status_primitive(prim), SUBSTATUS_COLUMN_STATUS_ID, id, SUBSTATUS_COLUMN_STATUS_NAME, name, -1); - if (pixbuf != NULL) - g_object_unref(pixbuf); if ((status_id != NULL) && !strcmp(status_id, id)) { gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter); @@ -1705,18 +1690,15 @@ { GtkTreeIter iter; gboolean currently_selected = FALSE; - GdkPixbuf *pixbuf = pidgin_create_status_icon(primitive, w, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); gtk_list_store_append(model, &iter); gtk_list_store_set(model, &iter, SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_PRIMITIVE, - SS_MENU_ICON_COLUMN, pixbuf, + SS_MENU_ICON_COLUMN, pidgin_stock_id_from_status_primitive(primitive), SS_MENU_TEXT_COLUMN, purple_primitive_get_name_from_type(primitive), SS_MENU_DATA_COLUMN, GINT_TO_POINTER(primitive), SS_MENU_EMBLEM_VISIBLE_COLUMN, FALSE, -1); - if (pixbuf != NULL) - g_object_unref(pixbuf); if (purple_savedstatus_is_transient(current_status) && !purple_savedstatus_has_substatuses(current_status) @@ -1730,23 +1712,20 @@ pidgin_status_menu_update_iter(GtkWidget *combobox, GtkListStore *store, GtkTreeIter *iter, PurpleSavedStatus *status) { - GdkPixbuf *pixbuf; + PurpleStatusPrimitive primitive; if (store == NULL) store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combobox))); - pixbuf = pidgin_create_status_icon(purple_savedstatus_get_type(status), - combobox, PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); + primitive = purple_savedstatus_get_type(status); gtk_list_store_set(store, iter, SS_MENU_TYPE_COLUMN, SS_MENU_ENTRY_TYPE_SAVEDSTATUS, - SS_MENU_ICON_COLUMN, pixbuf, + SS_MENU_ICON_COLUMN, pidgin_stock_id_from_status_primitive(primitive), SS_MENU_TEXT_COLUMN, purple_savedstatus_get_title(status), SS_MENU_DATA_COLUMN, GINT_TO_POINTER(purple_savedstatus_get_creation_time(status)), SS_MENU_EMBLEM_COLUMN, GTK_STOCK_SAVE, SS_MENU_EMBLEM_VISIBLE_COLUMN, TRUE, -1); - if (pixbuf) - g_object_unref(G_OBJECT(pixbuf)); } static gboolean @@ -1828,7 +1807,7 @@ GtkCellRenderer *icon_rend; GtkCellRenderer *emblem_rend; - model = gtk_list_store_new(SS_MENU_NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, + model = gtk_list_store_new(SS_MENU_NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN); combobox = gtk_combo_box_new(); @@ -1875,10 +1854,13 @@ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), icon_rend, FALSE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), text_rend, TRUE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combobox), emblem_rend, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), icon_rend, "pixbuf", SS_MENU_ICON_COLUMN, NULL); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), icon_rend, "stock-id", SS_MENU_ICON_COLUMN, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), text_rend, "markup", SS_MENU_TEXT_COLUMN, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combobox), emblem_rend, "stock-id", SS_MENU_EMBLEM_COLUMN, "visible", SS_MENU_EMBLEM_VISIBLE_COLUMN, NULL); + g_object_set(G_OBJECT(icon_rend), + "stock-size", gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), + NULL); gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index); g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback); diff -r de9816c970fe -r 3912f55a1633 pidgin/gtksmiley.c --- a/pidgin/gtksmiley.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtksmiley.c Tue Apr 28 18:43:57 2009 +0000 @@ -74,7 +74,7 @@ gtk_widget_destroy(smiley->parent); g_free(smiley->filename); if (smiley->custom_pixbuf) - gdk_pixbuf_unref(smiley->custom_pixbuf); + g_object_unref(G_OBJECT(smiley->custom_pixbuf)); g_free(smiley); } @@ -344,7 +344,7 @@ pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, 64, 64, FALSE, NULL); gtk_image_set_from_pixbuf(GTK_IMAGE(s->smiley_image), pixbuf); if (pixbuf) - gdk_pixbuf_unref(pixbuf); + g_object_unref(G_OBJECT(pixbuf)); gtk_widget_grab_focus(s->smile); } @@ -459,8 +459,8 @@ pidgin_smiley_editor_set_image(PidginSmiley *editor, GdkPixbuf *image) { if (editor->custom_pixbuf) - gdk_pixbuf_unref(editor->custom_pixbuf); - editor->custom_pixbuf = image ? gdk_pixbuf_ref(image) : NULL; + g_object_unref(G_OBJECT(editor->custom_pixbuf)); + editor->custom_pixbuf = image ? g_object_ref(G_OBJECT(image)) : NULL; if (image) gtk_image_set_from_pixbuf(GTK_IMAGE(editor->smiley_image), image); } diff -r de9816c970fe -r 3912f55a1633 pidgin/gtksourceundomanager.h --- a/pidgin/gtksourceundomanager.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtksourceundomanager.h Tue Apr 28 18:43:57 2009 +0000 @@ -28,12 +28,12 @@ #include -#define GTK_SOURCE_TYPE_UNDO_MANAGER (gtk_source_undo_manager_get_type ()) -#define GTK_SOURCE_UNDO_MANAGER(obj) (GTK_CHECK_CAST ((obj), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManager)) -#define GTK_SOURCE_UNDO_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManagerClass)) -#define GTK_SOURCE_IS_UNDO_MANAGER(obj) (GTK_CHECK_TYPE ((obj), GTK_SOURCE_TYPE_UNDO_MANAGER)) -#define GTK_SOURCE_IS_UNDO_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_SOURCE_TYPE_UNDO_MANAGER)) -#define GTK_SOURCE_UNDO_MANAGER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManagerClass)) +#define GTK_SOURCE_TYPE_UNDO_MANAGER (gtk_source_undo_manager_get_type()) +#define GTK_SOURCE_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManager)) +#define GTK_SOURCE_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManagerClass)) +#define GTK_SOURCE_IS_UNDO_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_SOURCE_TYPE_UNDO_MANAGER)) +#define GTK_SOURCE_IS_UNDO_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_SOURCE_TYPE_UNDO_MANAGER)) +#define GTK_SOURCE_UNDO_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_SOURCE_TYPE_UNDO_MANAGER, GtkSourceUndoManagerClass)) typedef struct _GtkSourceUndoManager GtkSourceUndoManager; diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkstatus-icon-theme.h --- a/pidgin/gtkstatus-icon-theme.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkstatus-icon-theme.h Tue Apr 28 18:43:57 2009 +0000 @@ -1,5 +1,5 @@ /** - * @file status_icon-theme.h Pidgin Icon Theme Class API + * @file gtkstatus-icon-theme.h Pidgin Icon Theme Class API */ /* pidgin diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkstatusbox.c --- a/pidgin/gtkstatusbox.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkstatusbox.c Tue Apr 28 18:43:57 2009 +0000 @@ -98,6 +98,9 @@ /** A PidginStatusBoxItemType */ TYPE_COLUMN, + /** This is the stock-id for the icon. */ + ICON_STOCK_COLUMN, + /** * This is a GdkPixbuf (the other columns are strings). * This column is visible. @@ -536,12 +539,12 @@ for (i = 0; i < G_N_ELEMENTS(statusbox->connecting_pixbufs); i++) { if (statusbox->connecting_pixbufs[i] != NULL) - gdk_pixbuf_unref(statusbox->connecting_pixbufs[i]); + g_object_unref(G_OBJECT(statusbox->connecting_pixbufs[i])); } for (i = 0; i < G_N_ELEMENTS(statusbox->typing_pixbufs); i++) { if (statusbox->typing_pixbufs[i] != NULL) - gdk_pixbuf_unref(statusbox->typing_pixbufs[i]); + g_object_unref(G_OBJECT(statusbox->typing_pixbufs[i])); } g_object_unref(G_OBJECT(statusbox->store)); @@ -600,28 +603,14 @@ } static GdkPixbuf * -pidgin_status_box_get_pixbuf(PidginStatusBox *status_box, PurpleStatusPrimitive prim) +pidgin_status_box_get_pixbuf(PidginStatusBox *status_box, const char *stock) { GdkPixbuf *pixbuf; GtkIconSize icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); - if (prim == PURPLE_STATUS_UNAVAILABLE) - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_BUSY, - icon_size, "PidginStatusBox"); - else if (prim == PURPLE_STATUS_AWAY) - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_AWAY, - icon_size, "PidginStatusBox"); - else if (prim == PURPLE_STATUS_EXTENDED_AWAY) - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_XA, - icon_size, "PidginStatusBox"); - else if (prim == PURPLE_STATUS_INVISIBLE) - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_INVISIBLE, - icon_size, "PidginStatusBox"); - else if (prim == PURPLE_STATUS_OFFLINE) - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_OFFLINE, - icon_size, "PidginStatusBox"); - else - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), PIDGIN_STOCK_STATUS_AVAILABLE, - icon_size, "PidginStatusBox"); + + pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box), stock, + icon_size, "PidginStatusBox"); + return pixbuf; } @@ -638,7 +627,8 @@ char aa_color[8]; PurpleSavedStatus *saved_status; char *primary, *secondary, *text; - GdkPixbuf *pixbuf, *emblem = NULL; + const char *stock = NULL; + GdkPixbuf *pixbuf = NULL, *emblem = NULL; GtkTreePath *path; gboolean account_status = FALSE; PurpleAccount *acct = (status_box->account) ? status_box->account : status_box->token_status_account; @@ -722,13 +712,15 @@ PurpleStatusType *status_type; PurpleStatusPrimitive prim; if (account_status) { - status_type = purple_status_get_type(purple_account_get_active_status(acct)); + status_type = purple_status_get_type(purple_account_get_active_status(acct)); prim = purple_status_type_get_primitive(status_type); } else { - prim = purple_savedstatus_get_type(saved_status); + prim = purple_savedstatus_get_type(saved_status); } - pixbuf = pidgin_status_box_get_pixbuf(status_box, prim); + stock = pidgin_stock_id_from_status_primitive(prim); + if (stock) + pixbuf = pidgin_status_box_get_pixbuf(status_box, stock); } if (status_box->account != NULL) { @@ -750,12 +742,13 @@ * really need to be a list store?) */ gtk_list_store_set(status_box->store, &(status_box->iter), + ICON_STOCK_COLUMN, (gpointer)stock, ICON_COLUMN, pixbuf, TEXT_COLUMN, text, EMBLEM_COLUMN, emblem, EMBLEM_VISIBLE_COLUMN, (emblem != NULL), -1); - if ((status_box->typing == 0) && (!status_box->connecting)) + if (pixbuf && (status_box->typing == 0) && (!status_box->connecting)) g_object_unref(pixbuf); g_free(text); if (emblem) @@ -924,7 +917,6 @@ add_popular_statuses(PidginStatusBox *statusbox) { GList *list, *cur; - GdkPixbuf *pixbuf; list = purple_savedstatuses_get_popular(6); if (list == NULL) @@ -944,9 +936,6 @@ /* Get an appropriate status icon */ prim = purple_savedstatus_get_type(saved); - - pixbuf = pidgin_status_box_get_pixbuf(statusbox, prim); - if (purple_savedstatus_is_transient(saved)) { /* @@ -967,11 +956,9 @@ } pidgin_status_box_add(statusbox, type, - pixbuf, purple_savedstatus_get_title(saved), stripped, + NULL, purple_savedstatus_get_title(saved), stripped, GINT_TO_POINTER(purple_savedstatus_get_creation_time(saved))); g_free(stripped); - if (pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); } g_list_free(list); @@ -1032,7 +1019,6 @@ { /* Per-account */ GList *l; - GdkPixbuf *pixbuf; for (l = purple_account_get_status_types(account); l != NULL; l = l->next) { @@ -1045,22 +1031,17 @@ prim = purple_status_type_get_primitive(status_type); - pixbuf = pidgin_status_box_get_pixbuf(status_box, prim); - pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), - PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, + PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, purple_status_type_get_name(status_type), NULL, GINT_TO_POINTER(purple_status_type_get_primitive(status_type))); - if (pixbuf != NULL) - g_object_unref(pixbuf); } } static void pidgin_status_box_regenerate(PidginStatusBox *status_box) { - GdkPixbuf *pixbuf, *pixbuf2, *pixbuf3, *pixbuf4, *pixbuf5; GtkIconSize icon_size; icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); @@ -1075,8 +1056,6 @@ if (status_box->account == NULL) { - pixbuf = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AVAILABLE, - icon_size, "PidginStatusBox"); /* Do all the currently enabled accounts have the same statuses? * If so, display them instead of our global list. */ @@ -1084,25 +1063,11 @@ add_account_statuses(status_box, status_box->token_status_account); } else { /* Global */ - pixbuf2 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_AWAY, - icon_size, "PidginStatusBox"); - pixbuf3 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_OFFLINE, - icon_size, "PidginStatusBox"); - pixbuf4 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_INVISIBLE, - icon_size, "PidginStatusBox"); - pixbuf5 = gtk_widget_render_icon (GTK_WIDGET(status_box->vbox), PIDGIN_STOCK_STATUS_BUSY, - icon_size, "PidginStatusBox"); - - pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf, _("Available"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE)); - pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf2, _("Away"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AWAY)); - pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf5, _("Do not disturb"), NULL, GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE)); - pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf4, _("Invisible"), NULL, GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE)); - pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, pixbuf3, _("Offline"), NULL, GINT_TO_POINTER(PURPLE_STATUS_OFFLINE)); - - if (pixbuf2) g_object_unref(G_OBJECT(pixbuf2)); - if (pixbuf3) g_object_unref(G_OBJECT(pixbuf3)); - if (pixbuf4) g_object_unref(G_OBJECT(pixbuf4)); - if (pixbuf5) g_object_unref(G_OBJECT(pixbuf5)); + pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Available"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AVAILABLE)); + pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Away"), NULL, GINT_TO_POINTER(PURPLE_STATUS_AWAY)); + pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Do not disturb"), NULL, GINT_TO_POINTER(PURPLE_STATUS_UNAVAILABLE)); + pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Invisible"), NULL, GINT_TO_POINTER(PURPLE_STATUS_INVISIBLE)); + pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_PRIMITIVE, NULL, _("Offline"), NULL, GINT_TO_POINTER(PURPLE_STATUS_OFFLINE)); } add_popular_statuses(status_box); @@ -1110,7 +1075,6 @@ pidgin_status_box_add_separator(PIDGIN_STATUS_BOX(status_box)); pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_CUSTOM, NULL, _("New status..."), NULL, NULL); pidgin_status_box_add(PIDGIN_STATUS_BOX(status_box), PIDGIN_STATUS_BOX_TYPE_SAVED, NULL, _("Saved statuses..."), NULL, NULL); - if (pixbuf) g_object_unref(G_OBJECT(pixbuf)); status_menu_refresh_iter(status_box); pidgin_status_box_refresh(status_box); @@ -1202,7 +1166,7 @@ for (i = 0; i < G_N_ELEMENTS(status_box->connecting_pixbufs); i++) { if (status_box->connecting_pixbufs[i] != NULL) - gdk_pixbuf_unref(status_box->connecting_pixbufs[i]); + g_object_unref(G_OBJECT(status_box->connecting_pixbufs[i])); } status_box->connecting_index = 0; @@ -1225,7 +1189,7 @@ for (i = 0; i < G_N_ELEMENTS(status_box->typing_pixbufs); i++) { if (status_box->typing_pixbufs[i] != NULL) - gdk_pixbuf_unref(status_box->typing_pixbufs[i]); + g_object_unref(G_OBJECT(status_box->typing_pixbufs[i])); } status_box->typing_index = 0; @@ -1778,9 +1742,9 @@ status_box->vsep = gtk_vseparator_new(); status_box->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE); - status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, + status_box->store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_BOOLEAN); - status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, GDK_TYPE_PIXBUF, G_TYPE_STRING, + status_box->dropdown_store = gtk_list_store_new(NUM_COLUMNS, G_TYPE_INT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING, G_TYPE_BOOLEAN); gtk_cell_view_set_model(GTK_CELL_VIEW(status_box->cell_view), GTK_TREE_MODEL(status_box->store)); @@ -1855,7 +1819,7 @@ gtk_tree_view_column_pack_start(status_box->column, icon_rend, FALSE); gtk_tree_view_column_pack_start(status_box->column, text_rend, TRUE); gtk_tree_view_column_pack_start(status_box->column, emblem_rend, FALSE); - gtk_tree_view_column_set_attributes(status_box->column, icon_rend, "pixbuf", ICON_COLUMN, NULL); + gtk_tree_view_column_set_attributes(status_box->column, icon_rend, "pixbuf", ICON_COLUMN, "stock-id", ICON_STOCK_COLUMN, NULL); gtk_tree_view_column_set_attributes(status_box->column, text_rend, "markup", TEXT_COLUMN, NULL); gtk_tree_view_column_set_attributes(status_box->column, emblem_rend, "stock-id", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); gtk_container_add(GTK_CONTAINER(status_box->scrolled_window), status_box->tree_view); @@ -1874,7 +1838,7 @@ gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, FALSE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, TRUE); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, NULL); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->icon_rend, "pixbuf", ICON_COLUMN, "stock-id", ICON_STOCK_COLUMN, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), status_box->text_rend, "markup", TEXT_COLUMN, NULL); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(status_box->cell_view), emblem_rend, "pixbuf", EMBLEM_COLUMN, "visible", EMBLEM_VISIBLE_COLUMN, NULL); #if GTK_CHECK_VERSION(2, 6, 0) @@ -2133,7 +2097,8 @@ * * @param status_box The status box itself. * @param type A PidginStatusBoxItemType. - * @param pixbuf The icon to associate with this row in the menu. + * @param pixbuf The icon to associate with this row in the menu. The + * function will try to decide a pixbuf if none is given. * @param title The title of this item. For the primitive entries, * this is something like "Available" or "Away." For * the saved statuses, this is something like @@ -2149,10 +2114,12 @@ * creation timestamp. */ void -pidgin_status_box_add(PidginStatusBox *status_box, PidginStatusBoxItemType type, GdkPixbuf *pixbuf, const char *title, const char *desc, gpointer data) +pidgin_status_box_add(PidginStatusBox *status_box, PidginStatusBoxItemType type, GdkPixbuf *pixbuf, + const char *title, const char *desc, gpointer data) { GtkTreeIter iter; char *text; + const char *stock = NULL; if (desc == NULL) { @@ -2179,9 +2146,27 @@ g_free(escaped_desc); } + if (!pixbuf) { + PurpleStatusPrimitive prim = PURPLE_STATUS_UNSET; + if (type == PIDGIN_STATUS_BOX_TYPE_PRIMITIVE) { + prim = GPOINTER_TO_INT(data); + } else if (type == PIDGIN_STATUS_BOX_TYPE_SAVED_POPULAR || + type == PIDGIN_STATUS_BOX_TYPE_POPULAR) { + PurpleSavedStatus *saved = purple_savedstatus_find_by_creation_time(GPOINTER_TO_INT(data)); + if (saved) { + prim = purple_savedstatus_get_type(saved); + } + } + + stock = pidgin_stock_id_from_status_primitive(prim); + if (stock) + pixbuf = pidgin_status_box_get_pixbuf(status_box, stock); + } + gtk_list_store_append(status_box->dropdown_store, &iter); gtk_list_store_set(status_box->dropdown_store, &iter, TYPE_COLUMN, type, + ICON_STOCK_COLUMN, stock, ICON_COLUMN, pixbuf, TEXT_COLUMN, text, TITLE_COLUMN, title, diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkutils.c --- a/pidgin/gtkutils.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkutils.c Tue Apr 28 18:43:57 2009 +0000 @@ -358,7 +358,7 @@ } GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str, - GtkSignalFunc sf, gpointer data, gboolean checked) + GCallback cb, gpointer data, gboolean checked) { GtkWidget *menuitem; menuitem = gtk_check_menu_item_new_with_mnemonic(str); @@ -368,8 +368,8 @@ gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), checked); - if (sf) - g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); + if (cb) + g_signal_connect(G_OBJECT(menuitem), "activate", cb, data); gtk_widget_show_all(menuitem); @@ -439,7 +439,7 @@ } -GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str, const char *icon, GtkSignalFunc sf, gpointer data, guint accel_key, guint accel_mods, char *mod) +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) { GtkWidget *menuitem; /* @@ -456,8 +456,8 @@ if (menu) gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - if (sf) - g_signal_connect(G_OBJECT(menuitem), "activate", sf, data); + if (cb) + g_signal_connect(G_OBJECT(menuitem), "activate", cb, data); if (icon != NULL) { image = gtk_image_new_from_stock(icon, gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); @@ -1464,7 +1464,7 @@ str); g_free(str); - return; + break; } buddy = purple_find_buddy(data->account, data->who); @@ -1494,7 +1494,7 @@ g_error_free(err); g_free(str); - return; + break; } id = purple_imgstore_add_with_id(filedata, size, data->filename); @@ -1627,7 +1627,7 @@ _("Set as buddy icon"), DND_BUDDY_ICON, (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), NULL); - gdk_pixbuf_unref(pb); + g_object_unref(G_OBJECT(pb)); return; } @@ -1715,29 +1715,42 @@ { GtkIconSize icon_size = gtk_icon_size_from_name(size); GdkPixbuf *pixbuf = NULL; - - if (prim == PURPLE_STATUS_UNAVAILABLE) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_BUSY, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_AWAY) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_AWAY, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_EXTENDED_AWAY) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_XA, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_INVISIBLE) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_INVISIBLE, - icon_size, "GtkWidget"); - else if (prim == PURPLE_STATUS_OFFLINE) - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_OFFLINE, - icon_size, "GtkWidget"); - else - pixbuf = gtk_widget_render_icon (w, PIDGIN_STOCK_STATUS_AVAILABLE, - icon_size, "GtkWidget"); + const char *stock = pidgin_stock_id_from_status_primitive(prim); + + pixbuf = gtk_widget_render_icon (w, stock ? stock : PIDGIN_STOCK_STATUS_AVAILABLE, + icon_size, "GtkWidget"); return pixbuf; - } +const char * +pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim) +{ + const char *stock = NULL; + switch (prim) { + case PURPLE_STATUS_UNSET: + stock = NULL; + break; + case PURPLE_STATUS_UNAVAILABLE: + stock = PIDGIN_STOCK_STATUS_BUSY; + break; + case PURPLE_STATUS_AWAY: + stock = PIDGIN_STOCK_STATUS_AWAY; + break; + case PURPLE_STATUS_EXTENDED_AWAY: + stock = PIDGIN_STOCK_STATUS_XA; + break; + case PURPLE_STATUS_INVISIBLE: + stock = PIDGIN_STOCK_STATUS_INVISIBLE; + break; + case PURPLE_STATUS_OFFLINE: + stock = PIDGIN_STOCK_STATUS_OFFLINE; + break; + default: + stock = PIDGIN_STOCK_STATUS_AVAILABLE; + break; + } + return stock; +} GdkPixbuf * pidgin_create_prpl_icon(PurpleAccount *account, PidginPrplIconSize size) @@ -2943,7 +2956,7 @@ #endif } -GSList *minidialogs = NULL; +static GSList *minidialogs = NULL; static void * pidgin_utils_get_handle(void) diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkutils.h --- a/pidgin/gtkutils.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkutils.h Tue Apr 28 18:43:57 2009 +0000 @@ -233,14 +233,14 @@ * * @param menu The menu to which to append the check menu item. * @param str The title to use for the newly created menu item. - * @param sf A function to call when the menu item is activated. + * @param cb A function to call when the menu item is activated. * @param data Data to pass to the signal function. * @param checked The initial state of the check item * * @return The newly created menu item. */ GtkWidget *pidgin_new_check_item(GtkWidget *menu, const char *str, - GtkSignalFunc sf, gpointer data, gboolean checked); + GCallback cb, gpointer data, gboolean checked); /** * Creates a menu item. @@ -249,7 +249,7 @@ * @param str The title for the menu item. * @param icon An icon to place to the left of the menu item, * or @c NULL for no icon. - * @param sf A function to call when the menu item is activated. + * @param cb A function to call when the menu item is activated. * @param data Data to pass to the signal function. * @param accel_key Something. * @param accel_mods Something. @@ -258,7 +258,7 @@ * @return The newly created menu item. */ GtkWidget *pidgin_new_item_from_stock(GtkWidget *menu, const char *str, - const char *icon, GtkSignalFunc sf, + const char *icon, GCallback cb, gpointer data, guint accel_key, guint accel_mods, char *mod); @@ -569,6 +569,16 @@ */ GdkPixbuf * pidgin_create_status_icon(PurpleStatusPrimitive primitive, GtkWidget *w, const char *size); +/** + * Returns an appropriate stock-id for a status primitive. + * + * @param prim The status primitive + * + * @return The stock-id + * + * @since 2.6.0 + */ +const char *pidgin_stock_id_from_status_primitive(PurpleStatusPrimitive prim); /** * Append a PurpleMenuAction to a menu. diff -r de9816c970fe -r 3912f55a1633 pidgin/gtkwhiteboard.c --- a/pidgin/gtkwhiteboard.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/gtkwhiteboard.c Tue Apr 28 18:43:57 2009 +0000 @@ -624,7 +624,7 @@ update_rect.x, update_rect.y, update_rect.width, update_rect.height); - gdk_gc_unref(gfx_con); + g_object_unref(G_OBJECT(gfx_con)); } /* Uses Bresenham's algorithm (as provided by Wikipedia) */ diff -r de9816c970fe -r 3912f55a1633 pidgin/pidginstock.c --- a/pidgin/pidginstock.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/pidginstock.c Tue Apr 28 18:43:57 2009 +0000 @@ -320,7 +320,7 @@ } static gchar * -find_icon_file(PidginStatusIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl) +find_icon_file(PidginIconTheme *theme, const gchar *size, SizedStockIcon sized_icon, gboolean rtl) { const gchar *file, *dir; gchar *file_full = NULL; @@ -352,7 +352,7 @@ } static void -add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginStatusIconTheme *theme, +add_sized_icon(GtkIconSet *iconset, GtkIconSize sizeid, PidginIconTheme *theme, const char *size, SizedStockIcon sized_icon, gboolean translucent) { char *filename; @@ -409,6 +409,16 @@ } } +static void +reload_settings(void) +{ +#if GTK_CHECK_VERSION(2,4,0) + GtkSettings *setting = NULL; + setting = gtk_settings_get_default(); + gtk_rc_reset_styles(setting); +#endif +} + /***************************************************************************** * Public API functions *****************************************************************************/ @@ -447,9 +457,9 @@ translucent = gtk_icon_set_new(); #define ADD_SIZED_ICON(name, size) if (sized_status_icons[i].name) { \ - add_sized_icon(normal, name, theme, size, sized_status_icons[i], FALSE); \ + add_sized_icon(normal, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], FALSE); \ if (sized_status_icons[i].translucent_name) \ - add_sized_icon(translucent, name, theme, size, sized_status_icons[i], TRUE); \ + add_sized_icon(translucent, name, PIDGIN_ICON_THEME(theme), size, sized_status_icons[i], TRUE); \ } ADD_SIZED_ICON(microscopic, "11"); ADD_SIZED_ICON(extra_small, "16"); @@ -471,52 +481,45 @@ gtk_widget_destroy(win); g_object_unref(G_OBJECT(icon_factory)); + reload_settings(); } void -pidgin_stock_init(void) +pidgin_stock_load_stock_icon_theme(PidginStockIconTheme *theme) { GtkIconFactory *icon_factory; - size_t i; + gint i; GtkWidget *win; - PidginIconThemeLoader *loader; - const gchar *path = NULL; - - if (stock_initted) - return; - stock_initted = TRUE; + if (theme != NULL) { + purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", + purple_theme_get_name(PURPLE_THEME(theme))); + purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", + purple_theme_get_dir(PURPLE_THEME(theme))); + } + else { + purple_prefs_set_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", ""); + purple_prefs_set_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", ""); + } - /* Setup the status icon theme */ - loader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "status-icon", NULL); - purple_theme_manager_register_type(PURPLE_THEME_LOADER(loader)); - purple_prefs_add_string(PIDGIN_PREFS_ROOT "/status/icon-theme", ""); - purple_prefs_add_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", ""); - - /* Setup the icon factory. */ icon_factory = gtk_icon_factory_new(); gtk_icon_factory_add_default(icon_factory); - /* Er, yeah, a hack, but it works. :) */ win = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(win); /* All non-sized icons */ - for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) - { + for (i = 0; i < G_N_ELEMENTS(stock_icons); i++) { GtkIconSource *source; GtkIconSet *iconset; gchar *filename; - if (stock_icons[i].dir == NULL) - { + if (stock_icons[i].dir == NULL) { /* GTK+ Stock icon */ iconset = gtk_style_lookup_icon_set(gtk_widget_get_style(win), stock_icons[i].filename); - } - else - { + } else { filename = find_file(stock_icons[i].dir, stock_icons[i].filename); if (filename == NULL) @@ -540,21 +543,13 @@ gtk_icon_set_unref(iconset); } - /* register custom icon sizes */ - microscopic = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC, 11, 11); - extra_small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16); - small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22); - medium = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32); - large = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48); - huge = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64); - /* All non-status sized icons */ for (i = 0; i < G_N_ELEMENTS(sized_stock_icons); i++) { GtkIconSet *iconset = gtk_icon_set_new(); #define ADD_SIZED_ICON(name, size) if (sized_stock_icons[i].name) \ - add_sized_icon(iconset, name, NULL, size, sized_stock_icons[i], FALSE); + add_sized_icon(iconset, name, PIDGIN_ICON_THEME(theme), size, sized_stock_icons[i], FALSE); ADD_SIZED_ICON(microscopic, "11"); ADD_SIZED_ICON(extra_small, "16"); ADD_SIZED_ICON(small, "22"); @@ -569,6 +564,40 @@ gtk_widget_destroy(win); g_object_unref(G_OBJECT(icon_factory)); + reload_settings(); +} + +void +pidgin_stock_init(void) +{ + PidginIconThemeLoader *loader, *stockloader; + const gchar *path = NULL; + + if (stock_initted) + return; + + stock_initted = TRUE; + + /* Setup the status icon theme */ + loader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "status-icon", NULL); + purple_theme_manager_register_type(PURPLE_THEME_LOADER(loader)); + purple_prefs_add_string(PIDGIN_PREFS_ROOT "/status/icon-theme", ""); + purple_prefs_add_path(PIDGIN_PREFS_ROOT "/status/icon-theme-dir", ""); + + stockloader = g_object_new(PIDGIN_TYPE_ICON_THEME_LOADER, "type", "stock-icon", NULL); + purple_theme_manager_register_type(PURPLE_THEME_LOADER(stockloader)); + purple_prefs_add_string(PIDGIN_PREFS_ROOT "/stock/icon-theme", ""); + purple_prefs_add_path(PIDGIN_PREFS_ROOT "/stock/icon-theme-dir", ""); + + /* register custom icon sizes */ + microscopic = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC, 11, 11); + extra_small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, 16, 16); + small = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_SMALL, 22, 22); + medium = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_MEDIUM, 32, 32); + large = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_LARGE, 48, 48); + huge = gtk_icon_size_register(PIDGIN_ICON_SIZE_TANGO_HUGE, 64, 64); + + pidgin_stock_load_stock_icon_theme(NULL); /* Pre-load Status icon theme - this avoids a bug with displaying the correct icon in the tray, theme is destroyed after*/ if (purple_prefs_get_string(PIDGIN_PREFS_ROOT "/icon/status/theme") && @@ -583,3 +612,31 @@ /* Register the stock items. */ gtk_stock_add_static(stock_items, G_N_ELEMENTS(stock_items)); } + +static void +pidgin_stock_icon_theme_class_init(PidginStockIconThemeClass *klass) +{ +} + +GType +pidgin_stock_icon_theme_get_type(void) +{ + static GType type = 0; + if (type == 0) { + static const GTypeInfo info = { + sizeof (PidginStockIconThemeClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc)pidgin_stock_icon_theme_class_init, /* class_init */ + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (PidginStockIconTheme), + 0, /* n_preallocs */ + NULL, + NULL, /* value table */ + }; + type = g_type_register_static(PIDGIN_TYPE_ICON_THEME, + "PidginStockIconTheme", &info, 0); + } + return type; +} diff -r de9816c970fe -r 3912f55a1633 pidgin/pidginstock.h --- a/pidgin/pidginstock.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/pidginstock.h Tue Apr 28 18:43:57 2009 +0000 @@ -185,15 +185,54 @@ #define PIDGIN_ICON_SIZE_TANGO_HUGE "pidgin-icon-size-tango-huge" /** + * extends PidginIconTheme (gtkicon-theme.h) + * A pidgin stock icon theme. + * This object represents a Pidgin stock icon theme. + * + * PidginStockIconTheme is a PidginIconTheme Object. + */ +typedef struct _PidginStockIconTheme PidginStockIconTheme; +typedef struct _PidginStockIconThemeClass PidginStockIconThemeClass; + +#define PIDGIN_TYPE_STOCK_ICON_THEME (pidgin_stock_icon_theme_get_type ()) +#define PIDGIN_STOCK_ICON_THEME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIDGIN_TYPE_STOCK_ICON_THEME, PidginStockIconTheme)) +#define PIDGIN_STOCK_ICON_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIDGIN_TYPE_STOCK_ICON_THEME, PidginStockIconThemeClass)) +#define PIDGIN_IS_STOCK_ICON_THEME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIDGIN_TYPE_STOCK_ICON_THEME)) +#define PIDGIN_IS_STOCK_ICON_THEME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIDGIN_TYPE_STOCK_ICON_THEME)) +#define PIDGIN_STOCK_ICON_THEME_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIDGIN_TYPE_STOCK_ICON_THEME, PidginStockIconThemeClass)) + +struct _PidginStockIconTheme +{ + PidginIconTheme parent; +}; + +struct _PidginStockIconThemeClass +{ + PidginIconThemeClass parent_class; +}; + +G_BEGIN_DECLS + +/** + * GObject foo. + * @internal. + */ +GType pidgin_stock_icon_theme_get_type(void); + +/** * Loades all of the icons from the status icon theme into Pidgin stock * * @param theme the theme to load, or null to load all the default icons */ void pidgin_stock_load_status_icon_theme(PidginStatusIconTheme *theme); + +void pidgin_stock_load_stock_icon_theme(PidginStockIconTheme *theme); + /** * Sets up the purple stock repository. */ void pidgin_stock_init(void); +G_END_DECLS #endif /* _PIDGIN_STOCK_H_ */ diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/Makefile.am --- a/pidgin/plugins/Makefile.am Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/plugins/Makefile.am Tue Apr 28 18:43:57 2009 +0000 @@ -43,6 +43,7 @@ relnot_la_LDFLAGS = -module -avoid-version sendbutton_la_LDFLAGS = -module -avoid-version spellchk_la_LDFLAGS = -module -avoid-version +themeedit_la_LDFLAGS = -module -avoid-version timestamp_la_LDFLAGS = -module -avoid-version timestamp_format_la_LDFLAGS = -module -avoid-version xmppconsole_la_LDFLAGS = -module -avoid-version @@ -61,6 +62,7 @@ relnot.la \ sendbutton.la \ spellchk.la \ + themeedit.la \ timestamp.la \ timestamp_format.la \ xmppconsole.la @@ -82,6 +84,7 @@ relnot_la_SOURCES = relnot.c sendbutton_la_SOURCES = sendbutton.c spellchk_la_SOURCES = spellchk.c +themeedit_la_SOURCES = themeedit.c themeedit-icon.c themeedit-icon.h timestamp_la_SOURCES = timestamp.c timestamp_format_la_SOURCES = timestamp_format.c xmppconsole_la_SOURCES = xmppconsole.c @@ -99,6 +102,7 @@ relnot_la_LIBADD = $(GLIB_LIBS) sendbutton_la_LIBADD = $(GTK_LIBS) spellchk_la_LIBADD = $(GTK_LIBS) +themeedit_la_LIBADD = $(GTK_LIBS) timestamp_la_LIBADD = $(GTK_LIBS) timestamp_format_la_LIBADD = $(GTK_LIBS) xmppconsole_la_LIBADD = $(GTK_LIBS) diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/contact_priority.c --- a/pidgin/plugins/contact_priority.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/plugins/contact_priority.c Tue Apr 28 18:43:57 2009 +0000 @@ -31,7 +31,7 @@ select_account(GtkWidget *widget, PurpleAccount *account, gpointer data) { gtk_spin_button_set_value(GTK_SPIN_BUTTON(data), - (gdouble)purple_account_get_int(account, "score", 0)); + (gdouble)purple_account_get_int(account, "score", 0)); } static void @@ -142,18 +142,18 @@ spin = gtk_spin_button_new((GtkAdjustment *)adj, 1, 0); optmenu = pidgin_account_option_menu_new(NULL, TRUE, - G_CALLBACK(select_account), - NULL, spin); + G_CALLBACK(select_account), + NULL, spin); gtk_box_pack_start(GTK_BOX(hbox), optmenu, FALSE, FALSE, 0); /* this is where we set up the spin button we made above */ account = g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu))))), - "account"); + "account"); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), - (gdouble)purple_account_get_int(account, "score", 0)); + (gdouble)purple_account_get_int(account, "score", 0)); gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(spin), GTK_ADJUSTMENT(adj)); g_signal_connect(G_OBJECT(spin), "value-changed", - G_CALLBACK(account_update), optmenu); + G_CALLBACK(account_update), optmenu); gtk_box_pack_start(GTK_BOX(hbox), spin, FALSE, FALSE, 0); gtk_widget_show_all(ret); @@ -178,29 +178,29 @@ PURPLE_PLUGIN_MAGIC, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, - PURPLE_PLUGIN_STANDARD, /**< type */ + PURPLE_PLUGIN_STANDARD, /**< type */ PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ - 0, /**< flags */ - NULL, /**< dependencies */ - PURPLE_PRIORITY_DEFAULT, /**< priority */ + 0, /**< flags */ + NULL, /**< dependencies */ + PURPLE_PRIORITY_DEFAULT, /**< priority */ - CONTACT_PRIORITY_PLUGIN_ID, /**< id */ - N_("Contact Priority"), /**< name */ - DISPLAY_VERSION, /**< version */ + CONTACT_PRIORITY_PLUGIN_ID, /**< id */ + N_("Contact Priority"), /**< name */ + DISPLAY_VERSION, /**< version */ /**< summary */ N_("Allows for controlling the values associated with different buddy states."), /**< description */ N_("Allows for changing the point values of idle/away/offline states for buddies in contact priority computations."), - "Etan Reisner ", /**< author */ - PURPLE_WEBSITE, /**< homepage */ + "Etan Reisner ", /**< author */ + PURPLE_WEBSITE, /**< homepage */ - NULL, /**< load */ - NULL, /**< unload */ - NULL, /**< destroy */ - &ui_info, /**< ui_info */ - NULL, /**< extra_info */ - NULL, /**< prefs_info */ - NULL, /**< actions */ + NULL, /**< load */ + NULL, /**< unload */ + NULL, /**< destroy */ + &ui_info, /**< ui_info */ + NULL, /**< extra_info */ + NULL, /**< prefs_info */ + NULL, /**< actions */ /* padding */ NULL, diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/markerline.c --- a/pidgin/plugins/markerline.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/plugins/markerline.c Tue Apr 28 18:43:57 2009 +0000 @@ -84,7 +84,7 @@ gdk_gc_set_rgb_fg_color(gc, &red); gdk_draw_line(event->window, gc, 0, y, visible_rect.width, y); - gdk_gc_unref(gc); + g_object_unref(G_OBJECT(gc)); } return FALSE; } diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/themeedit-icon.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/plugins/themeedit-icon.c Tue Apr 28 18:43:57 2009 +0000 @@ -0,0 +1,312 @@ +/* Pidgin + * + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ +#include "internal.h" +#include "pidgin.h" +#include "debug.h" +#include "version.h" + +#include "theme-manager.h" + +#include "gtkblist.h" +#include "gtkblist-theme.h" +#include "gtkutils.h" +#include "gtkplugin.h" + +#include "pidginstock.h" +#include "themeedit-icon.h" + +typedef enum +{ + FLAG_SIZE_MICROSOPIC = 0, + FLAG_SIZE_EXTRA_SMALL, + FLAG_SIZE_SMALL, + FLAG_SIZE_MEDIUM, + FLAG_SIZE_LARGE, + FLAG_SIZE_HUGE, + FLAG_SIZE_NONE, +} SectionFlags; + +#define SECTION_FLAGS_ALL (0x3f) + +static const char *stocksizes [] = { + [FLAG_SIZE_MICROSOPIC] = PIDGIN_ICON_SIZE_TANGO_MICROSCOPIC, + [FLAG_SIZE_EXTRA_SMALL] = PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL, + [FLAG_SIZE_SMALL] = PIDGIN_ICON_SIZE_TANGO_SMALL, + [FLAG_SIZE_MEDIUM] = PIDGIN_ICON_SIZE_TANGO_MEDIUM, + [FLAG_SIZE_LARGE] = PIDGIN_ICON_SIZE_TANGO_LARGE, + [FLAG_SIZE_HUGE] = PIDGIN_ICON_SIZE_TANGO_HUGE, + [FLAG_SIZE_NONE] = NULL, +}; + +static const struct options { + const char *stockid; + const char *text; +} statuses[] = { + {PIDGIN_STOCK_STATUS_AVAILABLE, N_("Available")}, + {PIDGIN_STOCK_STATUS_AWAY, N_("Away")}, + {PIDGIN_STOCK_STATUS_XA, N_("Extended Away")}, + {PIDGIN_STOCK_STATUS_BUSY, N_("Busy")}, + {PIDGIN_STOCK_STATUS_OFFLINE, N_("Offline")}, + {PIDGIN_STOCK_STATUS_LOGIN, N_("Just logged in")}, + {PIDGIN_STOCK_STATUS_LOGOUT, N_("Just logged out")}, + {PIDGIN_STOCK_STATUS_PERSON, N_("Icon for Contact/\nIcon for Unknown person")}, + {PIDGIN_STOCK_STATUS_CHAT, N_("Icon for Chat")}, + {NULL, NULL} +}, chatemblems[] = { + {PIDGIN_STOCK_STATUS_IGNORED, N_("Ignored")}, + {PIDGIN_STOCK_STATUS_FOUNDER, N_("Founder")}, + {PIDGIN_STOCK_STATUS_OPERATOR, N_("Operator")}, + {PIDGIN_STOCK_STATUS_HALFOP, N_("Half Operator")}, + {PIDGIN_STOCK_STATUS_VOICE, N_("Voice")}, + {NULL, NULL} +}, dialogicons[] = { + {PIDGIN_STOCK_DIALOG_AUTH, N_("Authorization dialog")}, + {PIDGIN_STOCK_DIALOG_ERROR, N_("Error dialog")}, + {PIDGIN_STOCK_DIALOG_INFO, N_("Information dialog")}, + {PIDGIN_STOCK_DIALOG_MAIL, N_("Mail dialog")}, + {PIDGIN_STOCK_DIALOG_QUESTION, N_("Question dialog")}, + {PIDGIN_STOCK_DIALOG_WARNING, N_("Warning dialog")}, + {NULL, NULL}, + {PIDGIN_STOCK_DIALOG_COOL, N_("What kind of dialog is this?")}, +}; + +static const struct { + const char *heading; + const struct options *options; + SectionFlags flags; +} sections[] = { + {N_("Status Icons"), statuses, SECTION_FLAGS_ALL ^ (1 << FLAG_SIZE_HUGE)}, + {N_("Chatroom Emblems"), chatemblems, FLAG_SIZE_SMALL}, + {N_("Dialog Icons"), dialogicons, (1 << FLAG_SIZE_EXTRA_SMALL) | (1 << FLAG_SIZE_HUGE)}, + {NULL, NULL, 0} +}; + +static PidginStatusIconTheme * +create_icon_theme(GtkWidget *window) +{ + int s, i, j; + char *dirname = "/tmp"; /* FIXME */ + PidginStatusIconTheme *theme = g_object_new(PIDGIN_TYPE_STATUS_ICON_THEME, "type", "status-icon", + "author", getlogin(), + "directory", dirname, + NULL); + + for (s = 0; sections[s].heading; s++) { + GtkWidget *vbox = g_object_get_data(G_OBJECT(window), sections[s].heading); + for (i = 0; sections[s].options[i].stockid; i++) { + GtkWidget *image = g_object_get_data(G_OBJECT(vbox), sections[s].options[i].stockid); + GdkPixbuf *pixbuf = g_object_get_data(G_OBJECT(image), "pixbuf"); + if (!pixbuf) + continue; + pidgin_icon_theme_set_icon(PIDGIN_ICON_THEME(theme), sections[s].options[i].stockid, + sections[s].options[i].stockid); + for (j = 0; stocksizes[j]; j++) { + int width, height; + GtkIconSize iconsize; + char size[8]; + char *name; + GdkPixbuf *scale; + GError *error = NULL; + + if (!(sections[s].flags & (1 << j))) + continue; + + iconsize = gtk_icon_size_from_name(stocksizes[j]); + gtk_icon_size_lookup(iconsize, &width, &height); + g_snprintf(size, sizeof(size), "%d", width); + + if (i == 0) { + name = g_build_filename(dirname, size, NULL); + purple_build_dir(name, S_IRUSR | S_IWUSR | S_IXUSR); + g_free(name); + } + + name = g_build_filename(dirname, size, sections[s].options[i].stockid, NULL); + scale = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR); + gdk_pixbuf_save(scale, name, "png", &error, "compression", "9", NULL); + g_free(name); + g_object_unref(G_OBJECT(scale)); + if (error) + g_error_free(error); + } + } + } + return theme; +} + +static void +use_icon_theme(GtkWidget *w, GtkWidget *window) +{ + /* I don't quite understand the icon-theme stuff. For example, I don't + * know why PidginIconTheme needs to be abstract, or how PidginStatusIconTheme + * would be different from other PidginIconTheme's (e.g. PidginStockIconTheme) + * etc., but anyway, this works for now. + * + * Here's an interesting note: A PidginStatusIconTheme can be used for both + * stock and status icons. Like I said, I don't quite know how they could be + * different. So I am going to just keep it as it is, for now anyway, until I + * have the time to dig through this, or someone explains this stuff to me + * clearly. + * -- Sad + */ + PidginStatusIconTheme *theme = create_icon_theme(window); + pidgin_stock_load_status_icon_theme(PIDGIN_STATUS_ICON_THEME(theme)); + pidgin_stock_load_stock_icon_theme((PidginStockIconTheme *)theme); + pidgin_blist_refresh(purple_get_blist()); + g_object_unref(theme); +} + +#ifdef NOT_SADRUL +static void +save_icon_theme(GtkWidget *w, GtkWidget *window) +{ + /* TODO: SAVE! */ + gtk_widget_destroy(window); +} +#endif + +static void +close_icon_theme(GtkWidget *w, GtkWidget *window) +{ + gtk_widget_destroy(window); +} + +static void +stock_icon_selected(const char *filename, gpointer image) +{ + GError *error = NULL; + GdkPixbuf *scale; + int i; + GdkPixbuf *pixbuf; + + if (!filename) + return; + + pixbuf = gdk_pixbuf_new_from_file(filename, &error); + if (error || !pixbuf) { + purple_debug_error("theme-editor-icon", "Unable to load icon file '%s' (%s)\n", + filename, error ? error->message : "Reason unknown"); + if (error) + g_error_free(error); + return; + } + + scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(image), scale); + g_object_unref(G_OBJECT(scale)); + + /* Update the size previews */ + for (i = 0; stocksizes[i]; i++) { + int width, height; + GtkIconSize iconsize; + GtkWidget *prev = g_object_get_data(G_OBJECT(image), stocksizes[i]); + if (!prev) + continue; + iconsize = gtk_icon_size_from_name(stocksizes[i]); + gtk_icon_size_lookup(iconsize, &width, &height); + scale = gdk_pixbuf_scale_simple(pixbuf, width, height, GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf(GTK_IMAGE(prev), scale); + g_object_unref(G_OBJECT(scale)); + } + + /* Save the original pixbuf so we can use it for resizing later */ + g_object_set_data_full(G_OBJECT(image), "pixbuf", pixbuf, + (GDestroyNotify)g_object_unref); +} + +static gboolean +change_stock_image(GtkWidget *widget, GdkEventButton *event, GtkWidget *image) +{ + GtkWidget *win = pidgin_buddy_icon_chooser_new(GTK_WINDOW(gtk_widget_get_toplevel(widget)), + stock_icon_selected, image); + gtk_widget_show_all(win); + + return TRUE; +} + +void pidgin_icon_theme_edit(PurplePluginAction *unused) +{ + GtkWidget *dialog; + GtkWidget *box, *vbox; + GtkWidget *notebook; + GtkSizeGroup *sizegroup; + int s, i, j; + dialog = pidgin_create_dialog(_("Pidgin Icon Theme Editor"), 0, "theme-editor-icon", FALSE); + box = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(dialog), FALSE, PIDGIN_HIG_BOX_SPACE); + + notebook = gtk_notebook_new(); + gtk_box_pack_start(GTK_BOX(box), notebook, TRUE, TRUE, PIDGIN_HIG_BOX_SPACE); + sizegroup = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + + for (s = 0; sections[s].heading; s++) { + const char *heading = sections[s].heading; + + box = gtk_vbox_new(FALSE, 0); + gtk_notebook_append_page(GTK_NOTEBOOK(notebook), box, gtk_label_new(heading)); + + vbox = pidgin_make_frame(box, heading); + g_object_set_data(G_OBJECT(dialog), heading, vbox); + + for (i = 0; sections[s].options[i].stockid; i++) { + const char *id = sections[s].options[i].stockid; + const char *text = _(sections[s].options[i].text); + + GtkWidget *hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + GtkWidget *label = gtk_label_new(text); + GtkWidget *image = gtk_image_new_from_stock(id, + gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL)); + GtkWidget *ebox = gtk_event_box_new(); + gtk_container_add(GTK_CONTAINER(ebox), image); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + + g_signal_connect(G_OBJECT(ebox), "button-press-event", G_CALLBACK(change_stock_image), image); + g_object_set_data(G_OBJECT(image), "property-name", (gpointer)id); + + gtk_size_group_add_widget(sizegroup, label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(hbox), ebox, FALSE, FALSE, 0); + + for (j = 0; stocksizes[j]; j++) { + GtkWidget *sh; + + if (!(sections[s].flags & (1 << j))) + continue; + + sh = gtk_image_new_from_stock(id, gtk_icon_size_from_name(stocksizes[j])); + gtk_box_pack_start(GTK_BOX(hbox), sh, FALSE, FALSE, 0); + g_object_set_data(G_OBJECT(image), stocksizes[j], sh); + } + + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + g_object_set_data(G_OBJECT(vbox), id, image); + } + } + +#ifdef NOT_SADRUL + pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_SAVE, G_CALLBACK(save_icon_theme), dialog); +#endif + pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_APPLY, G_CALLBACK(use_icon_theme), dialog); + pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, G_CALLBACK(close_icon_theme), dialog); + gtk_widget_show_all(dialog); + g_object_unref(sizegroup); +} + diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/themeedit-icon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/plugins/themeedit-icon.h Tue Apr 28 18:43:57 2009 +0000 @@ -0,0 +1,2 @@ +void pidgin_icon_theme_edit(PurplePluginAction *); + diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/themeedit.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/pidgin/plugins/themeedit.c Tue Apr 28 18:43:57 2009 +0000 @@ -0,0 +1,362 @@ +/* Pidgin + * + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * source distribution. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA + */ +#include "internal.h" +#include "pidgin.h" +#include "version.h" + +#include "theme-manager.h" + +#include "gtkblist.h" +#include "gtkblist-theme.h" +#include "gtkutils.h" +#include "gtkplugin.h" + +#define PLUGIN_ID "gtk-theme-editor" + +#include "themeedit-icon.h" + +static gboolean +prop_type_is_color(PidginBlistTheme *theme, const char *prop) +{ + PidginBlistThemeClass *klass = PIDGIN_BLIST_THEME_GET_CLASS(theme); + GParamSpec *spec = g_object_class_find_property(G_OBJECT_CLASS(klass), prop); + + return G_IS_PARAM_SPEC_BOXED(spec); +} + +#ifdef NOT_SADRUL +static void +save_blist_theme(GtkWidget *w, GtkWidget *window) +{ + /* TODO: SAVE! */ + gtk_widget_destroy(window); +} +#endif + +static void +close_blist_theme(GtkWidget *w, GtkWidget *window) +{ + gtk_widget_destroy(window); +} + +static void +theme_color_selected(GtkDialog *dialog, gint response, const char *prop) +{ + if (response == GTK_RESPONSE_OK) { + GdkColor color; + PidginBlistTheme *theme; + + gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel), &color); + + theme = pidgin_blist_get_theme(); + + if (prop_type_is_color(theme, prop)) { + g_object_set(G_OBJECT(theme), prop, &color, NULL); + } else { + PidginThemeFont *font = NULL; + g_object_get(G_OBJECT(theme), prop, &font, NULL); + if (!font) { + font = pidgin_theme_font_new(NULL, &color); + g_object_set(G_OBJECT(theme), prop, font, NULL); + pidgin_theme_font_free(font); + } else { + pidgin_theme_font_set_color(font, &color); + } + } + pidgin_blist_set_theme(theme); + } + + gtk_widget_destroy(GTK_WIDGET(dialog)); +} + +static void +theme_font_face_selected(GtkWidget *dialog, gint response, gpointer font) +{ + if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) { + const char *fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(dialog)); + pidgin_theme_font_set_font_face(font, fontname); + pidgin_blist_refresh(purple_get_blist()); + } + gtk_widget_destroy(dialog); +} + +static void +theme_font_select_face(GtkWidget *widget, gpointer prop) +{ + GtkWidget *dialog; + PidginBlistTheme *theme; + PidginThemeFont *font = NULL; + const char *face; + + theme = pidgin_blist_get_theme(); + g_object_get(G_OBJECT(theme), prop, &font, NULL); + + if (!font) { + font = pidgin_theme_font_new(NULL, NULL); + g_object_set(G_OBJECT(theme), prop, font, NULL); + pidgin_theme_font_free(font); + g_object_get(G_OBJECT(theme), prop, &font, NULL); + } + + face = pidgin_theme_font_get_font_face(font); + dialog = gtk_font_selection_dialog_new(_("Select Font")); + if (face && *face) + gtk_font_selection_set_font_name(GTK_FONT_SELECTION(GTK_FONT_SELECTION_DIALOG(dialog)->fontsel), + face); + g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(theme_font_face_selected), + font); + gtk_widget_show_all(dialog); +} + +static void +theme_color_select(GtkWidget *widget, gpointer prop) +{ + GtkWidget *dialog; + PidginBlistTheme *theme; + const GdkColor *color = NULL; + + theme = pidgin_blist_get_theme(); + + if (prop_type_is_color(theme, prop)) { + g_object_get(G_OBJECT(theme), prop, &color, NULL); + } else { + PidginThemeFont *pair = NULL; + g_object_get(G_OBJECT(theme), prop, &pair, NULL); + if (pair) + color = pidgin_theme_font_get_color(pair); + } + + dialog = gtk_color_selection_dialog_new(_("Select Color")); + if (color) + gtk_color_selection_set_current_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel), + color); + g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(theme_color_selected), + prop); + + gtk_widget_show_all(dialog); +} + +static GtkWidget * +pidgin_theme_create_color_selector(const char *text, const char *blurb, const char *prop, + GtkSizeGroup *sizegroup) +{ + GtkWidget *color; + GtkWidget *hbox, *label; + + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + + label = gtk_label_new(_(text)); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_size_group_add_widget(sizegroup, label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2, 12, 0) + gtk_widget_set_tooltip_text(label, blurb); +#endif + + color = pidgin_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, + PIDGIN_BUTTON_HORIZONTAL); + g_signal_connect(G_OBJECT(color), "clicked", G_CALLBACK(theme_color_select), + (gpointer)prop); + gtk_box_pack_start(GTK_BOX(hbox), color, FALSE, FALSE, 0); + + return hbox; +} + +static GtkWidget * +pidgin_theme_create_font_selector(const char *text, const char *blurb, const char *prop, + GtkSizeGroup *sizegroup) +{ + GtkWidget *color, *font; + GtkWidget *hbox, *label; + + hbox = gtk_hbox_new(FALSE, PIDGIN_HIG_CAT_SPACE); + + label = gtk_label_new(_(text)); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); + gtk_size_group_add_widget(sizegroup, label); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); +#if GTK_CHECK_VERSION(2, 12, 0) + gtk_widget_set_tooltip_text(label, blurb); +#endif + + font = pidgin_pixbuf_button_from_stock("", GTK_STOCK_SELECT_FONT, + PIDGIN_BUTTON_HORIZONTAL); + g_signal_connect(G_OBJECT(font), "clicked", G_CALLBACK(theme_font_select_face), + (gpointer)prop); + gtk_box_pack_start(GTK_BOX(hbox), font, FALSE, FALSE, 0); + + color = pidgin_pixbuf_button_from_stock("", GTK_STOCK_SELECT_COLOR, + PIDGIN_BUTTON_HORIZONTAL); + g_signal_connect(G_OBJECT(color), "clicked", G_CALLBACK(theme_color_select), + (gpointer)prop); + gtk_box_pack_start(GTK_BOX(hbox), color, FALSE, FALSE, 0); + + return hbox; +} + +static void +pidgin_blist_theme_edit(PurplePluginAction *unused) +{ + GtkWidget *dialog; + GtkWidget *box; + GtkSizeGroup *group; + PidginBlistTheme *theme; + GObjectClass *klass; + int i, j; + static struct { + const char *header; + const char *props[12]; + } sections[] = { + {N_("Contact"), { + "contact-color", + "contact", + "online", + "away", + "offline", + "idle", + "message", + "message_nick_said", + "status", + NULL + } + }, + {N_("Group"), { + "expanded-color", + "expanded-text", + "collapsed-color", + "collapsed-text", + NULL + } + }, + { NULL, { } } + }; + + dialog = pidgin_create_dialog(_("Pidgin Buddylist Theme Editor"), 0, "theme-editor-blist", FALSE); + box = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(dialog), FALSE, PIDGIN_HIG_BOX_SPACE); + + theme = pidgin_blist_get_theme(); + if (!theme) { + theme = g_object_new(PIDGIN_TYPE_BLIST_THEME, "type", "blist", + "author", getlogin(), + NULL); + pidgin_blist_set_theme(theme); + } + klass = G_OBJECT_CLASS(PIDGIN_BLIST_THEME_GET_CLASS(theme)); + + group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); + for (i = 0; sections[i].header; i++) { + GtkWidget *vbox; + GtkWidget *hbox; + GParamSpec *spec; + + vbox = pidgin_make_frame(box, _(sections[i].header)); + for (j = 0; sections[i].props[j]; j++) { + const char *label; + const char *blurb; + spec = g_object_class_find_property(klass, sections[i].props[j]); + label = g_param_spec_get_nick(spec); + blurb = g_param_spec_get_blurb(spec); + if (G_IS_PARAM_SPEC_BOXED(spec)) { + hbox = pidgin_theme_create_color_selector(label, blurb, + sections[i].props[j], group); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + } else { + hbox = pidgin_theme_create_font_selector(label, blurb, + sections[i].props[j], group); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + } + } + } + + gtk_dialog_set_has_separator(GTK_DIALOG(dialog), TRUE); +#ifdef NOT_SADRUL + pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_SAVE, G_CALLBACK(save_blist_theme), dialog); +#endif + pidgin_dialog_add_button(GTK_DIALOG(dialog), GTK_STOCK_CLOSE, G_CALLBACK(close_blist_theme), dialog); + + gtk_widget_show_all(dialog); + + g_object_unref(group); +} + +static gboolean +plugin_load(PurplePlugin *plugin) +{ + return TRUE; +} + +static GList * +actions(PurplePlugin *plugin, gpointer context) +{ + GList *l = NULL; + PurplePluginAction *act = NULL; + + act = purple_plugin_action_new(_("Edit Buddylist Theme"), pidgin_blist_theme_edit); + l = g_list_append(l, act); + act = purple_plugin_action_new(_("Edit Icon Theme"), pidgin_icon_theme_edit); + l = g_list_append(l, act); + + return l; +} + +static PurplePluginInfo info = +{ + PURPLE_PLUGIN_MAGIC, + PURPLE_MAJOR_VERSION, + PURPLE_MINOR_VERSION, + PURPLE_PLUGIN_STANDARD, /**< type */ + PIDGIN_PLUGIN_TYPE, /**< ui_requirement */ + 0, /**< flags */ + NULL, /**< dependencies */ + PURPLE_PRIORITY_DEFAULT, /**< priority */ + + PLUGIN_ID, /**< id */ + N_("Pidgin Theme Editor"), /**< name */ + DISPLAY_VERSION, /**< version */ + /** summary */ + N_("Pidgin Theme Editor."), + /** description */ + N_("Pidgin Theme Editor"), + "Sadrul Habib Chowdhury ", /**< author */ + PURPLE_WEBSITE, /**< homepage */ + + plugin_load, /**< load */ + NULL, /**< unload */ + NULL, /**< destroy */ + + NULL, /**< ui_info */ + NULL, /**< extra_info */ + NULL, + actions, + + /* padding */ + NULL, + NULL, + NULL, + NULL +}; + +static void +init_plugin(PurplePlugin *plugin) +{ +} + +PURPLE_INIT_PLUGIN(themeeditor, init_plugin, info) diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/ticker/gtkticker.c --- a/pidgin/plugins/ticker/gtkticker.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/plugins/ticker/gtkticker.c Tue Apr 28 18:43:57 2009 +0000 @@ -41,7 +41,7 @@ gboolean include_internals, GtkCallback callback, gpointer callback_data); -static GtkType gtk_ticker_child_type (GtkContainer *container); +static GType gtk_ticker_child_type (GtkContainer *container); static GtkContainerClass *parent_class = NULL; @@ -97,7 +97,7 @@ widget_class = (GtkWidgetClass*) class; container_class = (GtkContainerClass*) class; - parent_class = gtk_type_class (GTK_TYPE_CONTAINER); + parent_class = g_type_class_ref (GTK_TYPE_CONTAINER); gobject_class->finalize = gtk_ticker_finalize; @@ -112,7 +112,7 @@ container_class->child_type = gtk_ticker_child_type; } -static GtkType gtk_ticker_child_type (GtkContainer *container) +static GType gtk_ticker_child_type (GtkContainer *container) { return GTK_TYPE_WIDGET; } diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/ticker/gtkticker.h --- a/pidgin/plugins/ticker/gtkticker.h Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/plugins/ticker/gtkticker.h Tue Apr 28 18:43:57 2009 +0000 @@ -33,11 +33,11 @@ extern "C" { #endif /* __cplusplus */ -#define GTK_TYPE_TICKER (gtk_ticker_get_type ()) -#define GTK_TICKER(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TICKER, GtkTicker)) -#define GTK_TICKER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TICKER, GtkTickerClass)) -#define GTK_IS_TICKER(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TICKER)) -#define GTK_IS_TICKER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TICKER)) +#define GTK_TYPE_TICKER (gtk_ticker_get_type()) +#define GTK_TICKER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_TICKER, GtkTicker)) +#define GTK_TICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_TICKER, GtkTickerClass)) +#define GTK_IS_TICKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_TICKER)) +#define GTK_IS_TICKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_TICKER)) typedef struct _GtkTicker GtkTicker; @@ -72,7 +72,7 @@ }; -GtkType gtk_ticker_get_type (void); +GType gtk_ticker_get_type (void); GtkWidget* gtk_ticker_new (void); void gtk_ticker_add (GtkTicker *ticker, GtkWidget *widget); diff -r de9816c970fe -r 3912f55a1633 pidgin/plugins/win32/transparency/win2ktrans.c --- a/pidgin/plugins/win32/transparency/win2ktrans.c Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/plugins/win32/transparency/win2ktrans.c Tue Apr 28 18:43:57 2009 +0000 @@ -182,7 +182,7 @@ /* On slider val change, update window's transparency level */ g_signal_connect(GTK_OBJECT(slider), "value-changed", - GTK_SIGNAL_FUNC(change_alpha), win); + G_CALLBACK(change_alpha), win); gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); @@ -563,7 +563,7 @@ button = pidgin_prefs_checkbox(_("_IM window transparency"), OPT_WINTRANS_IM_ENABLED, imtransbox); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(update_convs_wintrans), + G_CALLBACK(update_convs_wintrans), (gpointer) OPT_WINTRANS_IM_ENABLED); trans_box = gtk_vbox_new(FALSE, 18); @@ -572,12 +572,12 @@ gtk_widget_show(trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); + G_CALLBACK(pidgin_toggle_sensitive), trans_box); button = pidgin_prefs_checkbox(_("_Show slider bar in IM window"), OPT_WINTRANS_IM_SLIDER, trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(update_convs_wintrans), + G_CALLBACK(update_convs_wintrans), (gpointer) OPT_WINTRANS_IM_SLIDER); button = pidgin_prefs_checkbox( @@ -587,7 +587,7 @@ button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_IM_ONTOP, trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(update_convs_wintrans), + G_CALLBACK(update_convs_wintrans), (gpointer) OPT_WINTRANS_IM_ONTOP); gtk_box_pack_start(GTK_BOX(imtransbox), trans_box, FALSE, FALSE, 5); @@ -604,9 +604,9 @@ gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); g_signal_connect(GTK_OBJECT(slider), "value-changed", - GTK_SIGNAL_FUNC(alpha_change), NULL); + G_CALLBACK(alpha_change), NULL); g_signal_connect(GTK_OBJECT(slider), "focus-out-event", - GTK_SIGNAL_FUNC(alpha_pref_set_int), + G_CALLBACK(alpha_pref_set_int), (gpointer) OPT_WINTRANS_IM_ALPHA); gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); @@ -620,7 +620,7 @@ button = pidgin_prefs_checkbox(_("_Buddy List window transparency"), OPT_WINTRANS_BL_ENABLED, bltransbox); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(set_blist_trans), + G_CALLBACK(set_blist_trans), (gpointer) OPT_WINTRANS_BL_ENABLED); trans_box = gtk_vbox_new(FALSE, 18); @@ -628,14 +628,14 @@ gtk_widget_set_sensitive(GTK_WIDGET(trans_box), FALSE); gtk_widget_show(trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(pidgin_toggle_sensitive), trans_box); + G_CALLBACK(pidgin_toggle_sensitive), trans_box); button = pidgin_prefs_checkbox( _("Remove Buddy List window transparency on focus"), OPT_WINTRANS_BL_ONFOCUS, trans_box); button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_BL_ONTOP, trans_box); g_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(set_blist_trans), + G_CALLBACK(set_blist_trans), (gpointer) OPT_WINTRANS_BL_ONTOP); gtk_box_pack_start(GTK_BOX(bltransbox), trans_box, FALSE, FALSE, 5); @@ -652,9 +652,9 @@ gtk_widget_set_usize(GTK_WIDGET(slider), 200, -1); g_signal_connect(GTK_OBJECT(slider), "value-changed", - GTK_SIGNAL_FUNC(bl_alpha_change), NULL); + G_CALLBACK(bl_alpha_change), NULL); g_signal_connect(GTK_OBJECT(slider), "focus-out-event", - GTK_SIGNAL_FUNC(alpha_pref_set_int), + G_CALLBACK(alpha_pref_set_int), (gpointer) OPT_WINTRANS_BL_ALPHA); gtk_box_pack_start(GTK_BOX(hbox), slider, FALSE, TRUE, 5); diff -r de9816c970fe -r 3912f55a1633 pidgin/win32/nsis/pidgin-installer.nsi --- a/pidgin/win32/nsis/pidgin-installer.nsi Sat Apr 18 18:17:16 2009 +0000 +++ b/pidgin/win32/nsis/pidgin-installer.nsi Tue Apr 28 18:43:57 2009 +0000 @@ -813,6 +813,7 @@ ; Shortcuts.. Delete "$DESKTOP\Pidgin.lnk" + Delete "$SMPROGRAMS\Pidgin.lnk" Goto done diff -r de9816c970fe -r 3912f55a1633 po/de.po --- a/po/de.po Sat Apr 18 18:17:16 2009 +0000 +++ b/po/de.po Tue Apr 28 18:43:57 2009 +0000 @@ -11,10 +11,10 @@ msgstr "" "Project-Id-Version: de\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2009-04-16 16:28+0200\n" -"PO-Revision-Date: 2009-04-16 16:27+0200\n" -"Last-Translator: Björn Voigt \n" -"Language-Team: German \n" +"POT-Creation-Date: 2009-04-26 12:11+0200\n" +"PO-Revision-Date: 2009-04-26 12:11+0200\n" +"Last-Translator: Jochen Kemnade \n" +"Language-Team: Deutsch \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -902,6 +902,8 @@ #, c-format msgid "%s is trying to start an unsupported media session type with you." msgstr "" +"%s versucht, einen nicht unterstützten Typ von Medien-Sitzung mit Ihnen zu " +"starten." msgid "You have rejected the call." msgstr "Sie haben den Anruf abgelehnt." @@ -1564,22 +1566,25 @@ "\n" "Fetching TinyURL..." msgstr "" +"\n" +"Hole TinyURL..." msgid "Only create TinyURL for urls of this length or greater" -msgstr "" +msgstr "TinyURL nur für URLs mit mindestens dieser Länge generieren" msgid "TinyURL (or other) address prefix" msgstr "" -#, fuzzy msgid "TinyURL" -msgstr "URL anpassen" +msgstr "TinyURL" msgid "TinyURL plugin" -msgstr "" +msgstr "TinyURL-Plugin" msgid "When receiving a message with URL(s), TinyURL for easier copying" msgstr "" +"URLs aus erhaltenen Nachrichten zum einfacheren Kopieren in TinyURLs " +"umwandeln" msgid "accounts" msgstr "Konten" @@ -1829,9 +1834,8 @@ msgid "%s left the room (%s)." msgstr "%s hat den Raum verlassen (%s)." -#, fuzzy msgid "Invite to chat" -msgstr "Zur Konferenz einladen" +msgstr "Zum Chat einladen" #. Put our happy label in it. msgid "" @@ -3105,6 +3109,7 @@ msgid "Add to chat..." msgstr "Zum Chat hinzufügen..." +#. Global msgid "Available" msgstr "Verfügbar" @@ -3451,6 +3456,17 @@ "Ihr gewählter Kontoname wurde vom Server abgelehnt. Er enthält vermutlich " "ungültige Zeichen." +#. We only want to do the following dance if the connection +#. has not been successfully completed. If it has, just +#. notify the user that their /nick command didn't go. +#, c-format +msgid "The nickname \"%s\" is already being used." +msgstr "Der Spitzname \"%s\" existiert bereits." + +#, fuzzy +msgid "Nickname in use" +msgstr "Spitzname" + msgid "Cannot change nick" msgstr "Kann den Spitznamen nicht ändern" @@ -3797,9 +3813,8 @@ msgid "Operating System" msgstr "Betriebssystem" -#, fuzzy msgid "Local Time" -msgstr "Lokale Datei:" +msgstr "Lokale Zeit" msgid "Last Activity" msgstr "Letzte Aktivität" @@ -4546,36 +4561,38 @@ msgid "%s has buzzed you!" msgstr "%s hat bei Ihnen angeklopft!" -#, fuzzy, c-format +#, c-format msgid "Unable to initiate media with %s: invalid JID" -msgstr "Kann die Nachricht an %s nicht senden, ungültige JID" - -#, fuzzy, c-format +msgstr "Medien-Sitzung mit %s konnte nicht gestartet werden: ungültige JID" + +#, c-format msgid "Unable to initiate media with %s: user is not online" -msgstr "Kann die Datei nicht an %s senden, Benutzer ist nicht online" - -#, fuzzy, c-format +msgstr "" +"Medien-Sitzung mit %s konnte nicht gestartet werden: Benutzer ist nicht " +"online" + +#, c-format msgid "Unable to initiate media with %s: not subscribed to user presence" msgstr "" -"Kann die Datei nicht an %s senden, Anwesenheit des Benutzers nicht abonniert" - -#, fuzzy +"Medien-Sitzung mit %s konnte nicht gestartet werden: Anwesenheit des " +"Benutzers nicht abonniert" + msgid "Media Initiation Failed" -msgstr "Registrierung fehlgeschlagen" - -#, fuzzy, c-format +msgstr "Medien-Initiierung fehlgeschlagen" + +#, c-format msgid "" "Please select the resource of %s with which you would like to start a media " "session." msgstr "" -"Bitte wählen Sie die Ressource von %s, an die Sie eine Datei schicken möchten" +"Bitte wählen Sie die Ressource von %s, mir der Sie eine Medien-Sitzung " +"starten möchten" msgid "Select a Resource" msgstr "Wählen Sie eine Ressource" -#, fuzzy msgid "Initiate Media" -msgstr "Initiiere _Chat" +msgstr "Initiiere Medien" msgid "config: Configure a chat room." msgstr "config: Konfiguriere einen Chatraum." @@ -7392,9 +7409,8 @@ msgid "_Modify" msgstr "_Bearbeiten" -#, fuzzy msgid "Memo Modify" -msgstr "Bearbeiten" +msgstr "Memo bearbeiten" msgid "Server says:" msgstr "Server meldet:" @@ -10939,21 +10955,17 @@ msgid "/Conversation/Clea_r Scrollback" msgstr "/Unterhaltung/_Leeren" -#, fuzzy msgid "/Conversation/M_edia" -msgstr "/Unterhaltung/Me_hr" - -#, fuzzy +msgstr "/Unterhaltung/M_edien" + msgid "/Conversation/Media/_Audio Call" -msgstr "/Unterhaltung/Me_hr" - -#, fuzzy +msgstr "/Unterhaltung/Medien/_Audio-Anruf" + msgid "/Conversation/Media/_Video Call" -msgstr "/Unterhaltung/Me_hr" - -#, fuzzy +msgstr "/Unterhaltung/Medien/_Video-Anruf" + msgid "/Conversation/Media/Audio\\/Video _Call" -msgstr "/Unterhaltung/Betrachte _Mitschnitt" +msgstr "/Unterhaltung/Medien/A_udio-\\/Video-Anruf" msgid "/Conversation/Se_nd File..." msgstr "/Unterhaltung/Datei _senden..." @@ -11027,17 +11039,14 @@ msgid "/Conversation/View Log" msgstr "/Unterhaltung/Betrachte Mitschnitt" -#, fuzzy msgid "/Conversation/Media/Audio Call" -msgstr "/Unterhaltung/Mehr" - -#, fuzzy +msgstr "/Unterhaltung/Medien/Audio-Anruf" + msgid "/Conversation/Media/Video Call" -msgstr "/Unterhaltung/Betrachte Mitschnitt" - -#, fuzzy +msgstr "/Unterhaltung/Medien/Video-Anruf" + msgid "/Conversation/Media/Audio\\/Video Call" -msgstr "/Unterhaltung/Mehr" +msgstr "/Unterhaltung/Medien/Audio-\\/Video-Anruf" msgid "/Conversation/Send File..." msgstr "/Unterhaltung/Datei senden ..." @@ -12194,11 +12203,11 @@ #, c-format msgid "%s wishes to start an audio/video session with you." -msgstr "" +msgstr "%s möchte eine Audio-/Video-Sitzung mit Ihnen starten." #, c-format msgid "%s wishes to start a video session with you." -msgstr "" +msgstr "%s möchte eine Video-Sitzung mit Ihnen starten." #, c-format msgid "%s has %d new message." @@ -12949,16 +12958,14 @@ msgstr "_Bild:" #. Shortcut text -#, fuzzy msgid "S_hortcut text:" -msgstr "Tastenkombination" +msgstr "_Verknüpfter Text:" msgid "Smiley" msgstr "Smiley" -#, fuzzy msgid "Shortcut Text" -msgstr "Tastenkombination" +msgstr "Verknüpfter Text" msgid "Custom Smiley Manager" msgstr "Verwaltung für benutzerdefinierte Smileys"