Mercurial > pidgin.yaz
comparison pidgin/gtkblist.c @ 19540:712a448722b6
If a conversation doesn't have UI-data, consider it a hidden conversation.
Also, make the code a little more readable.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 31 Aug 2007 17:25:45 +0000 |
parents | 6575ec8e1a97 |
children | f902cd0dc925 |
comparison
equal
deleted
inserted
replaced
19539:4ce45c227f10 | 19540:712a448722b6 |
---|---|
3207 GdkPixbuf * | 3207 GdkPixbuf * |
3208 pidgin_blist_get_status_icon(PurpleBlistNode *node, PidginStatusIconSize size) | 3208 pidgin_blist_get_status_icon(PurpleBlistNode *node, PidginStatusIconSize size) |
3209 { | 3209 { |
3210 GdkPixbuf *ret; | 3210 GdkPixbuf *ret; |
3211 const char *protoname = NULL; | 3211 const char *protoname = NULL; |
3212 const char *icon = NULL; | |
3212 struct _pidgin_blist_node *gtknode = node->ui_data; | 3213 struct _pidgin_blist_node *gtknode = node->ui_data; |
3213 struct _pidgin_blist_node *gtkbuddynode = NULL; | 3214 struct _pidgin_blist_node *gtkbuddynode = NULL; |
3214 PurpleBuddy *buddy = NULL; | 3215 PurpleBuddy *buddy = NULL; |
3215 PurpleChat *chat = NULL; | 3216 PurpleChat *chat = NULL; |
3216 GtkIconSize icon_size = gtk_icon_size_from_name((size == PIDGIN_STATUS_ICON_LARGE) ? PIDGIN_ICON_SIZE_TANGO_SMALL : | 3217 GtkIconSize icon_size = gtk_icon_size_from_name((size == PIDGIN_STATUS_ICON_LARGE) ? PIDGIN_ICON_SIZE_TANGO_SMALL : |
3255 if(buddy) { | 3256 if(buddy) { |
3256 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, | 3257 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, |
3257 purple_buddy_get_name(buddy), | 3258 purple_buddy_get_name(buddy), |
3258 purple_buddy_get_account(buddy)); | 3259 purple_buddy_get_account(buddy)); |
3259 PurplePresence *p; | 3260 PurplePresence *p; |
3261 gboolean trans; | |
3262 | |
3260 if(conv != NULL) { | 3263 if(conv != NULL) { |
3261 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); | 3264 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
3262 if(gtkconv != NULL && pidgin_conv_is_hidden(gtkconv) && size == PIDGIN_STATUS_ICON_SMALL) { | 3265 if((gtkconv == NULL || pidgin_conv_is_hidden(gtkconv)) && size == PIDGIN_STATUS_ICON_SMALL) { |
3263 return gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_MESSAGE, | 3266 return gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_MESSAGE, |
3264 icon_size, "GtkTreeView"); | 3267 icon_size, "GtkTreeView"); |
3265 } | 3268 } |
3266 } | 3269 } |
3270 | |
3267 p = purple_buddy_get_presence(buddy); | 3271 p = purple_buddy_get_presence(buddy); |
3272 trans = (purple_presence_is_idle(p) && size == PIDGIN_STATUS_ICON_SMALL); | |
3268 | 3273 |
3269 if (PURPLE_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) | 3274 if (PURPLE_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) |
3270 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_LOGIN, | 3275 icon = PIDGIN_STOCK_STATUS_LOGIN; |
3271 icon_size, "GtkTreeView"); | |
3272 else if (gtkbuddynode && gtkbuddynode->recent_signonoff) | 3276 else if (gtkbuddynode && gtkbuddynode->recent_signonoff) |
3273 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_LOGOUT, | 3277 icon = PIDGIN_STOCK_STATUS_LOGOUT; |
3274 icon_size, "GtkTreeView"); | |
3275 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) | 3278 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) |
3276 if (purple_presence_is_idle(p) && size == PIDGIN_STATUS_ICON_SMALL) | 3279 if (trans) |
3277 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_BUSY_I, | 3280 icon = PIDGIN_STOCK_STATUS_BUSY_I; |
3278 icon_size, "GtkTreeView"); | |
3279 else | 3281 else |
3280 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_BUSY, | 3282 icon = PIDGIN_STOCK_STATUS_BUSY; |
3281 icon_size, "GtkTreeView"); | |
3282 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) | 3283 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) |
3283 if (purple_presence_is_idle(p) && size == PIDGIN_STATUS_ICON_SMALL) | 3284 if (trans) |
3284 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_AWAY_I, | 3285 icon = PIDGIN_STOCK_STATUS_AWAY_I; |
3285 icon_size, "GtkTreeView"); | |
3286 else | 3286 else |
3287 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_AWAY, | 3287 icon = PIDGIN_STOCK_STATUS_AWAY; |
3288 icon_size, "GtkTreeView"); | |
3289 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_EXTENDED_AWAY)) | 3288 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_EXTENDED_AWAY)) |
3290 if (purple_presence_is_idle(p) && size == PIDGIN_STATUS_ICON_SMALL) | 3289 if (trans) |
3291 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_XA_I, | 3290 icon = PIDGIN_STOCK_STATUS_XA_I; |
3292 icon_size, "GtkTreeView"); | |
3293 else | 3291 else |
3294 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_XA, | 3292 icon = PIDGIN_STOCK_STATUS_XA; |
3295 icon_size, "GtkTreeView"); | |
3296 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_OFFLINE)) | 3293 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_OFFLINE)) |
3297 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_OFFLINE, | 3294 icon = PIDGIN_STOCK_STATUS_OFFLINE; |
3298 icon_size, "GtkTreeView"); | 3295 else if (trans) |
3299 else if (purple_presence_is_idle(p) && size == PIDGIN_STATUS_ICON_SMALL) | 3296 icon = PIDGIN_STOCK_STATUS_AVAILABLE_I; |
3300 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_AVAILABLE_I, | |
3301 icon_size, "GtkTreeView"); | |
3302 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_INVISIBLE)) | 3297 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_INVISIBLE)) |
3303 ret = gtk_widget_render_icon(GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_INVISIBLE, | 3298 icon = PIDGIN_STOCK_STATUS_INVISIBLE; |
3304 icon_size, "GtkTreeView"); | |
3305 else | 3299 else |
3306 ret = gtk_widget_render_icon(GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_AVAILABLE, | 3300 icon = PIDGIN_STOCK_STATUS_AVAILABLE; |
3307 icon_size, "GtkTreeView"); | |
3308 } else if (chat) { | 3301 } else if (chat) { |
3309 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_CHAT, | 3302 icon = PIDGIN_STOCK_STATUS_CHAT; |
3310 icon_size, "GtkTreeView"); | |
3311 } else { | 3303 } else { |
3312 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), PIDGIN_STOCK_STATUS_PERSON, | 3304 icon = PIDGIN_STOCK_STATUS_PERSON; |
3313 icon_size, "GtkTreeView"); | 3305 } |
3314 } | 3306 |
3315 | 3307 ret = gtk_widget_render_icon (GTK_WIDGET(gtkblist->treeview), icon, |
3308 icon_size, "GtkTreeView"); | |
3316 return ret; | 3309 return ret; |
3317 } | 3310 } |
3318 | 3311 |
3319 gchar *pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected, gboolean aliased) | 3312 gchar *pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected, gboolean aliased) |
3320 { | 3313 { |
3333 PidginConversation *gtkconv; | 3326 PidginConversation *gtkconv; |
3334 gboolean hidden_conv = FALSE; | 3327 gboolean hidden_conv = FALSE; |
3335 | 3328 |
3336 if(conv != NULL) { | 3329 if(conv != NULL) { |
3337 gtkconv = PIDGIN_CONVERSATION(conv); | 3330 gtkconv = PIDGIN_CONVERSATION(conv); |
3338 if(gtkconv != NULL && pidgin_conv_is_hidden(gtkconv)) { | 3331 if(gtkconv == NULL || pidgin_conv_is_hidden(gtkconv)) { |
3339 hidden_conv = TRUE; | 3332 hidden_conv = TRUE; |
3340 } | 3333 } |
3341 } | 3334 } |
3342 | 3335 |
3343 /* XXX Good luck cleaning up this crap */ | 3336 /* XXX Good luck cleaning up this crap */ |