comparison pidgin/gtkconv.c @ 18181:a8c701d877aa

Start work on blist pane in conversation. Looks like: http://pidgin.im/~seanegan/infopane.png Certainly much to be done yet.
author Sean Egan <seanegan@gmail.com>
date Tue, 19 Jun 2007 02:11:50 +0000
parents b8b475f31008
children 84b577372b90
comparison
equal deleted inserted replaced
18180:ba042caf722a 18181:a8c701d877aa
79 PIDGIN_CONV_TAB_ICON = 1 << 3, 79 PIDGIN_CONV_TAB_ICON = 1 << 3,
80 PIDGIN_CONV_TOPIC = 1 << 4, 80 PIDGIN_CONV_TOPIC = 1 << 4,
81 PIDGIN_CONV_SMILEY_THEME = 1 << 5, 81 PIDGIN_CONV_SMILEY_THEME = 1 << 5,
82 PIDGIN_CONV_COLORIZE_TITLE = 1 << 6 82 PIDGIN_CONV_COLORIZE_TITLE = 1 << 6
83 }PidginConvFields; 83 }PidginConvFields;
84
85 enum {
86 ICON_COLUMN,
87 TEXT_COLUMN,
88 NUM_COLUMNS
89 } PidginInfopaneColumns;
84 90
85 #define PIDGIN_CONV_ALL ((1 << 7) - 1) 91 #define PIDGIN_CONV_ALL ((1 << 7) - 1)
86 92
87 #define SEND_COLOR "#204a87" 93 #define SEND_COLOR "#204a87"
88 #define RECV_COLOR "#cc0000" 94 #define RECV_COLOR "#cc0000"
2348 g_return_if_fail(status != NULL); 2354 g_return_if_fail(status != NULL);
2349 2355
2350 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); 2356 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status);
2351 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); 2357 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status);
2352 2358
2359 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter),
2360 ICON_COLUMN, status, -1);
2361
2353 if (status != NULL) 2362 if (status != NULL)
2354 g_object_unref(status); 2363 g_object_unref(status);
2355 2364
2356 if (pidgin_conv_window_is_active_conversation(conv) && 2365 if (pidgin_conv_window_is_active_conversation(conv) &&
2357 (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM || 2366 (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM ||
2407 2416
2408 pidgin_buddy_icon_get_scale_size(buf, &prpl_info->icon_spec, 2417 pidgin_buddy_icon_get_scale_size(buf, &prpl_info->icon_spec,
2409 PURPLE_ICON_SCALE_DISPLAY, &scale_width, &scale_height); 2418 PURPLE_ICON_SCALE_DISPLAY, &scale_width, &scale_height);
2410 2419
2411 /* this code is ugly, and scares me */ 2420 /* this code is ugly, and scares me */
2412 scale = gdk_pixbuf_scale_simple(buf, 2421 scale = gdk_pixbuf_scale_simple(buf, 32, 32,
2413 MAX(gdk_pixbuf_get_width(buf) * scale_width /
2414 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1),
2415 MAX(gdk_pixbuf_get_height(buf) * scale_height /
2416 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1),
2417 GDK_INTERP_BILINEAR); 2422 GDK_INTERP_BILINEAR);
2418 2423
2419 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->u.im->icon), scale); 2424 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->u.im->icon), scale);
2420 g_object_unref(G_OBJECT(scale)); 2425 g_object_unref(G_OBJECT(scale));
2421 gtk_widget_queue_draw(gtkconv->u.im->icon); 2426 gtk_widget_queue_draw(gtkconv->u.im->icon);
4376 4381
4377 static GtkWidget * 4382 static GtkWidget *
4378 setup_common_pane(PidginConversation *gtkconv) 4383 setup_common_pane(PidginConversation *gtkconv)
4379 { 4384 {
4380 GtkWidget *paned, *vbox, *frame, *imhtml_sw; 4385 GtkWidget *paned, *vbox, *frame, *imhtml_sw;
4386 GtkCellRenderer *rend;
4387 GtkTreePath *path;
4381 PurpleConversation *conv = gtkconv->active_conv; 4388 PurpleConversation *conv = gtkconv->active_conv;
4382 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); 4389 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT);
4383 GtkPolicyType imhtml_sw_hscroll; 4390 GtkPolicyType imhtml_sw_hscroll;
4384 4391
4385 paned = gtk_vpaned_new(); 4392 paned = gtk_vpaned_new();
4387 4394
4388 /* Setup the top part of the pane */ 4395 /* Setup the top part of the pane */
4389 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 4396 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
4390 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); 4397 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE);
4391 gtk_widget_show(vbox); 4398 gtk_widget_show(vbox);
4399
4400 /* Setup the info pane */
4401 gtkconv->infopane_hbox = gtk_hbox_new(FALSE, 0);
4402 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->infopane_hbox, FALSE, FALSE, 0);
4403 gtk_widget_show(gtkconv->infopane_hbox);
4404
4405 gtkconv->infopane = gtk_cell_view_new();
4406 gtkconv->infopane_model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING);
4407 gtk_cell_view_set_model(GTK_CELL_VIEW(gtkconv->infopane), gtkconv->infopane_model);
4408 gtk_list_store_append(gtkconv->infopane_model, &(gtkconv->infopane_iter));
4409 gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), gtkconv->infopane, TRUE, TRUE, 0);
4410 path = gtk_tree_path_new_from_string("0");
4411 gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(gtkconv->infopane), path);
4412 gtk_widget_set_size_request(gtkconv->infopane, -1, 32);
4413 gtk_widget_show(gtkconv->infopane);
4414
4415 rend = gtk_cell_renderer_pixbuf_new();
4416 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, FALSE);
4417 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "pixbuf", ICON_COLUMN, NULL);
4418 g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL);
4419
4420 rend = gtk_cell_renderer_text_new();
4421 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, TRUE);
4422 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "markup", TEXT_COLUMN, NULL);
4423 g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL);
4424
4425 #if GTK_CHECK_VERSION(2, 6, 0)
4426 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
4427 #endif
4392 4428
4393 /* Setup the gtkimhtml widget */ 4429 /* Setup the gtkimhtml widget */
4394 frame = pidgin_create_imhtml(FALSE, &gtkconv->imhtml, NULL, &imhtml_sw); 4430 frame = pidgin_create_imhtml(FALSE, &gtkconv->imhtml, NULL, &imhtml_sw);
4395 if (chat) { 4431 if (chat) {
4396 GtkWidget *hpaned; 4432 GtkWidget *hpaned;
6120 (fields & PIDGIN_CONV_SET_TITLE)) 6156 (fields & PIDGIN_CONV_SET_TITLE))
6121 { 6157 {
6122 char *title; 6158 char *title;
6123 PurpleConvIm *im = NULL; 6159 PurpleConvIm *im = NULL;
6124 PurpleAccount *account = purple_conversation_get_account(conv); 6160 PurpleAccount *account = purple_conversation_get_account(conv);
6161 PurpleBuddy *buddy;
6162 char *markup;
6125 AtkObject *accessibility_obj; 6163 AtkObject *accessibility_obj;
6126 /* I think this is a little longer than it needs to be but I'm lazy. */ 6164 /* I think this is a little longer than it needs to be but I'm lazy. */
6127 char style[51]; 6165 char style[51];
6128 6166
6129 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 6167 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
6134 ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) 6172 ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
6135 && purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)))) 6173 && purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv))))
6136 title = g_strdup_printf("(%s)", purple_conversation_get_title(conv)); 6174 title = g_strdup_printf("(%s)", purple_conversation_get_title(conv));
6137 else 6175 else
6138 title = g_strdup(purple_conversation_get_title(conv)); 6176 title = g_strdup(purple_conversation_get_title(conv));
6177
6178 buddy = purple_find_buddy(account, conv->name);
6179 if (buddy)
6180 markup = pidgin_blist_get_name_markup(buddy, FALSE);
6181 else
6182 markup = title;
6183 gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter),
6184 TEXT_COLUMN, markup, -1);
6185
6186 if (title != markup)
6187 g_free(markup);
6139 6188
6140 *style = '\0'; 6189 *style = '\0';
6141 6190
6142 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) 6191 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label))
6143 gtk_widget_realize(gtkconv->tab_label); 6192 gtk_widget_realize(gtkconv->tab_label);
6294 size_t len; 6343 size_t len;
6295 6344
6296 GdkPixbuf *buf; 6345 GdkPixbuf *buf;
6297 6346
6298 GtkWidget *event; 6347 GtkWidget *event;
6299 GtkWidget *frame;
6300 GdkPixbuf *scale; 6348 GdkPixbuf *scale;
6301 int scale_width, scale_height; 6349 int scale_width, scale_height;
6302 6350
6303 PurpleAccount *account; 6351 PurpleAccount *account;
6304 PurplePluginProtocolInfo *prpl_info = NULL; 6352 PurplePluginProtocolInfo *prpl_info = NULL;
6403 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); 6451 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter);
6404 if (gtkconv->u.im->animate) 6452 if (gtkconv->u.im->animate)
6405 start_anim(NULL, gtkconv); 6453 start_anim(NULL, gtkconv);
6406 } 6454 }
6407 6455
6408 pidgin_buddy_icon_get_scale_size(buf, &prpl_info->icon_spec, 6456 scale = gdk_pixbuf_scale_simple(buf, 32, 32,
6409 PURPLE_ICON_SCALE_DISPLAY, &scale_width, &scale_height);
6410 scale = gdk_pixbuf_scale_simple(buf,
6411 MAX(gdk_pixbuf_get_width(buf) * scale_width /
6412 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1),
6413 MAX(gdk_pixbuf_get_height(buf) * scale_height /
6414 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1),
6415 GDK_INTERP_BILINEAR); 6457 GDK_INTERP_BILINEAR);
6416 6458
6417 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); 6459 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0);
6418 6460
6419 frame = gtk_frame_new(NULL);
6420 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
6421 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame,
6422 FALSE, FALSE, 0);
6423
6424 event = gtk_event_box_new(); 6461 event = gtk_event_box_new();
6425 gtk_container_add(GTK_CONTAINER(frame), event); 6462 gtk_container_add(GTK_CONTAINER(gtkconv->u.im->icon_container), event);
6426 g_signal_connect(G_OBJECT(event), "button-press-event", 6463 g_signal_connect(G_OBJECT(event), "button-press-event",
6427 G_CALLBACK(icon_menu), gtkconv); 6464 G_CALLBACK(icon_menu), gtkconv);
6428 gtk_widget_show(event); 6465 gtk_widget_show(event);
6429 6466
6430 gtkconv->u.im->icon = gtk_image_new_from_pixbuf(scale); 6467 gtkconv->u.im->icon = gtk_image_new_from_pixbuf(scale);
6431 gtkconv->auto_resize = TRUE; 6468 gtkconv->auto_resize = TRUE;
6432 /* Reset the size request to allow the buddy icon to resize */ 6469 /* Reset the size request to allow the buddy icon to resize */
6433 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, -1);
6434 g_idle_add(reset_auto_resize_cb, gtkconv); 6470 g_idle_add(reset_auto_resize_cb, gtkconv);
6435 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height);
6436 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); 6471 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon);
6437 gtk_widget_show(gtkconv->u.im->icon); 6472 gtk_widget_show(gtkconv->u.im->icon);
6438 6473
6439 g_object_unref(G_OBJECT(scale)); 6474 g_object_unref(G_OBJECT(scale));
6440 6475
6441 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), 6476 gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox),
6442 gtkconv->u.im->icon_container, FALSE, FALSE, 0); 6477 gtkconv->u.im->icon_container, FALSE, FALSE, 0);
6443 6478
6444 gtk_widget_show(gtkconv->u.im->icon_container); 6479 gtk_widget_show(gtkconv->u.im->icon_container);
6445 gtk_widget_show(frame);
6446 6480
6447 /* The buddy icon code needs badly to be fixed. */ 6481 /* The buddy icon code needs badly to be fixed. */
6448 if(pidgin_conv_window_is_active_conversation(conv)) 6482 if(pidgin_conv_window_is_active_conversation(conv))
6449 { 6483 {
6450 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); 6484 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim);
8413 } 8447 }
8414 8448
8415 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); 8449 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START);
8416 8450
8417 /* show the widgets */ 8451 /* show the widgets */
8418 gtk_widget_show(gtkconv->icon); 8452 /* XXX gtk_widget_show(gtkconv->icon); */
8419 gtk_widget_show(gtkconv->tab_label); 8453 gtk_widget_show(gtkconv->tab_label);
8420 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs")) 8454 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs"))
8421 gtk_widget_show(gtkconv->close); 8455 gtk_widget_show(gtkconv->close);
8422 gtk_widget_show(gtkconv->tabby); 8456 gtk_widget_show(gtkconv->tabby);
8423 gtk_widget_show(ebox); 8457 gtk_widget_show(ebox);