pidgin/gtkconv.c

changeset 15794
64e650906485
parent 15760
209681319cac
child 15795
5d8c5f87264b
equal deleted inserted replaced
15793:4eaaf87a9a24 15794:64e650906485
144 static GtkWidget *warn_close_dialog = NULL; 144 static GtkWidget *warn_close_dialog = NULL;
145 145
146 static PidginWindow *hidden_convwin = NULL; 146 static PidginWindow *hidden_convwin = NULL;
147 static GList *window_list = NULL; 147 static GList *window_list = NULL;
148 148
149 /* Lists of status icons at all available sizes for use as window icons */
150 static GList *available_list = NULL;
151 static GList *away_list = NULL;
152 static GList *busy_list = NULL;
153 static GList *xa_list = NULL;
154 static GList *login_list = NULL;
155 static GList *logout_list = NULL;
156 static GList *offline_list = NULL;
149 157
150 static gboolean update_send_to_selection(PidginWindow *win); 158 static gboolean update_send_to_selection(PidginWindow *win);
151 static void generate_send_to_items(PidginWindow *win); 159 static void generate_send_to_items(PidginWindow *win);
152 160
153 /* Prototypes. <-- because Paco-Paco hates this comment. */ 161 /* Prototypes. <-- because Paco-Paco hates this comment. */
2202 } 2210 }
2203 2211
2204 /************************************************************************** 2212 /**************************************************************************
2205 * A bunch of buddy icon functions 2213 * A bunch of buddy icon functions
2206 **************************************************************************/ 2214 **************************************************************************/
2207 GdkPixbuf * 2215 const GList *
2208 pidgin_conv_get_tab_icon(GaimConversation *conv, gboolean small_icon) 2216 pidgin_conv_get_tab_icons(GaimConversation *conv)
2209 { 2217 {
2218 GList *l = NULL;
2210 GaimAccount *account = NULL; 2219 GaimAccount *account = NULL;
2211 const char *name = NULL; 2220 const char *name = NULL;
2212 GdkPixbuf *status = NULL; 2221 GdkPixbuf *status = NULL;
2213 GaimBlistUiOps *ops = gaim_blist_get_ui_ops(); 2222 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
2214 2223
2222 2231
2223 /* Use the buddy icon, if possible */ 2232 /* Use the buddy icon, if possible */
2224 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { 2233 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) {
2225 GaimBuddy *b = gaim_find_buddy(account, name); 2234 GaimBuddy *b = gaim_find_buddy(account, name);
2226 if (b != NULL) { 2235 if (b != NULL) {
2227 /* I hate this hack. It fixes a bug where the pending message icon 2236 GaimPresence *p;
2228 * displays in the conv tab even though it shouldn't. 2237 p = gaim_buddy_get_presence(b);
2229 * A better solution would be great. */ 2238 if (gaim_presence_is_status_primitive_active(p, GAIM_STATUS_AWAY))
2230 if (ops && ops->update) 2239 return away_list;
2231 ops->update(NULL, (GaimBlistNode*)b); 2240 if (gaim_presence_is_status_primitive_active(p, GAIM_STATUS_UNAVAILABLE))
2232 2241 return busy_list;
2233 status = pidgin_blist_get_status_icon((GaimBlistNode*)b, 2242 if (gaim_presence_is_status_primitive_active(p, GAIM_STATUS_EXTENDED_AWAY))
2234 (small_icon ? PIDGIN_STATUS_ICON_SMALL : PIDGIN_STATUS_ICON_LARGE)); 2243 return xa_list;
2244 if (gaim_presence_is_status_primitive_active(p, GAIM_STATUS_OFFLINE))
2245 return offline_list;
2246 else
2247 return available_list;
2235 } 2248 }
2236 } 2249 }
2237 2250
2238 /* If they don't have a buddy icon, then use the PRPL icon */ 2251 status = pidgin_create_prpl_icon(account, PIDGIN_PRPL_ICON_LARGE);
2239 if (status == NULL) 2252 l = g_list_append(l, status);
2240 status = pidgin_create_prpl_icon(account, small_icon ? PIDGIN_PRPL_ICON_SMALL : PIDGIN_PRPL_ICON_LARGE); 2253 return l;
2241 2254 }
2242 return status; 2255
2243 } 2256 GdkPixbuf *
2257 pidgin_conv_get_tab_icon(GaimConversation *conv, gboolean small_icon)
2258 {
2259 GaimAccount *account = NULL;
2260 const char *name = NULL;
2261 GdkPixbuf *status = NULL;
2262 GaimBlistUiOps *ops = gaim_blist_get_ui_ops();
2263
2264 g_return_val_if_fail(conv != NULL, NULL);
2265
2266 account = gaim_conversation_get_account(conv);
2267 name = gaim_conversation_get_name(conv);
2268
2269 g_return_val_if_fail(account != NULL, NULL);
2270 g_return_val_if_fail(name != NULL, NULL);
2271
2272 /* Use the buddy icon, if possible */
2273 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) {
2274 GaimBuddy *b = gaim_find_buddy(account, name);
2275 if (b != NULL) {
2276 /* I hate this hack. It fixes a bug where the pending message icon
2277 * displays in the conv tab even though it shouldn't.
2278 * A better solution would be great. */
2279 if (ops && ops->update)
2280 ops->update(NULL, (GaimBlistNode*)b);
2281
2282 status = pidgin_blist_get_status_icon((GaimBlistNode*)b,
2283 (small_icon ? PIDGIN_STATUS_ICON_SMALL : PIDGIN_STATUS_ICON_LARGE));
2284 }
2285 }
2286
2287 /* If they don't have a buddy icon, then use the PRPL icon */
2288 if (status == NULL)
2289 status = pidgin_create_prpl_icon(account, small_icon ? PIDGIN_PRPL_ICON_SMALL : PIDGIN_PRPL_ICON_LARGE);
2290
2291 return status;
2292 }
2293
2244 2294
2245 static void 2295 static void
2246 update_tab_icon(GaimConversation *conv) 2296 update_tab_icon(GaimConversation *conv)
2247 { 2297 {
2248 PidginConversation *gtkconv; 2298 PidginConversation *gtkconv;
2249 PidginWindow *win; 2299 PidginWindow *win;
2300 GList *l;
2250 GdkPixbuf *status = NULL; 2301 GdkPixbuf *status = NULL;
2251 2302
2252 g_return_if_fail(conv != NULL); 2303 g_return_if_fail(conv != NULL);
2253 2304
2254 gtkconv = PIDGIN_CONVERSATION(conv); 2305 gtkconv = PIDGIN_CONVERSATION(conv);
2268 2319
2269 if (pidgin_conv_window_is_active_conversation(conv) && 2320 if (pidgin_conv_window_is_active_conversation(conv) &&
2270 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || 2321 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM ||
2271 gtkconv->u.im->anim == NULL)) 2322 gtkconv->u.im->anim == NULL))
2272 { 2323 {
2273 status = pidgin_conv_get_tab_icon(conv, FALSE); 2324 l = pidgin_conv_get_tab_icons(conv);
2274 2325
2275 gtk_window_set_icon(GTK_WINDOW(win->window), status); 2326 gtk_window_set_icon_list(GTK_WINDOW(win->window), l);
2276 2327
2277 if (status != NULL) 2328 if (status != NULL)
2278 g_object_unref(status); 2329 g_object_unref(status);
2279 } 2330 }
2280 } 2331 }
5743 /* 5794 /*
5744 * Update the window's icon 5795 * Update the window's icon
5745 */ 5796 */
5746 if (pidgin_conv_window_is_active_conversation(conv)) 5797 if (pidgin_conv_window_is_active_conversation(conv))
5747 { 5798 {
5799 GList *l = NULL;
5748 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && 5800 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) &&
5749 (gtkconv->u.im->anim)) 5801 (gtkconv->u.im->anim))
5750 { 5802 {
5751 window_icon = 5803 window_icon =
5752 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); 5804 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim);
5753 g_object_ref(window_icon); 5805 g_object_ref(window_icon);
5806 l = g_list_append(l, window_icon);
5754 } else { 5807 } else {
5755 window_icon = pidgin_conv_get_tab_icon(conv, FALSE); 5808 l = pidgin_conv_get_tab_icons(conv);
5756 } 5809 }
5757 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); 5810 gtk_window_set_icon_list(GTK_WINDOW(win->window), l);
5758 if (window_icon != NULL) 5811 if (window_icon != NULL)
5759 g_object_unref(G_OBJECT(window_icon)); 5812 g_object_unref(G_OBJECT(window_icon));
5760 } 5813 }
5761 } 5814 }
5762 5815
7651 pidgin_conv_windows_get_list() 7704 pidgin_conv_windows_get_list()
7652 { 7705 {
7653 return window_list; 7706 return window_list;
7654 } 7707 }
7655 7708
7709 static GList*
7710 make_status_icon_list(const char *stock, GtkWidget *w)
7711 {
7712 GList *l = NULL;
7713 l = g_list_append(l, gtk_widget_render_icon (w, stock,
7714 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL), "GtkWindow"));
7715 l = g_list_append(l, gtk_widget_render_icon (w, stock,
7716 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL), "GtkWindow"));
7717 l = g_list_append(l, gtk_widget_render_icon (w, stock,
7718 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_MEDIUM), "GtkWindow"));
7719 l = g_list_append(l, gtk_widget_render_icon (w, stock,
7720 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_LARGE), "GtkWindow"));
7721 return l;
7722 }
7723
7724 static void
7725 create_icon_lists(GtkWidget *w)
7726 {
7727 available_list = make_status_icon_list(PIDGIN_STOCK_STATUS_AVAILABLE, w);
7728 busy_list = make_status_icon_list(PIDGIN_STOCK_STATUS_BUSY, w);
7729 xa_list = make_status_icon_list(PIDGIN_STOCK_STATUS_XA, w);
7730 login_list = make_status_icon_list(PIDGIN_STOCK_STATUS_LOGIN, w);
7731 logout_list = make_status_icon_list(PIDGIN_STOCK_STATUS_LOGOUT, w);
7732 offline_list = make_status_icon_list(PIDGIN_STOCK_STATUS_OFFLINE, w);
7733 away_list = make_status_icon_list(PIDGIN_STOCK_STATUS_AWAY, w);
7734 }
7735
7656 PidginWindow * 7736 PidginWindow *
7657 pidgin_conv_window_new() 7737 pidgin_conv_window_new()
7658 { 7738 {
7659 PidginWindow *win; 7739 PidginWindow *win;
7660 GtkPositionType pos; 7740 GtkPositionType pos;
7669 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 7749 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
7670 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); 7750 gtk_window_set_role(GTK_WINDOW(win->window), "conversation");
7671 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); 7751 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE);
7672 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); 7752 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0);
7673 GTK_WINDOW(win->window)->allow_shrink = TRUE; 7753 GTK_WINDOW(win->window)->allow_shrink = TRUE;
7754
7755 if (available_list == NULL) {
7756 create_icon_lists(win->window);
7757 }
7674 7758
7675 g_signal_connect(G_OBJECT(win->window), "delete_event", 7759 g_signal_connect(G_OBJECT(win->window), "delete_event",
7676 G_CALLBACK(close_win_cb), win); 7760 G_CALLBACK(close_win_cb), win);
7677 7761
7678 g_signal_connect(G_OBJECT(win->window), "focus_in_event", 7762 g_signal_connect(G_OBJECT(win->window), "focus_in_event",

mercurial