Mercurial > pidgin
changeset 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 | ba042caf722a |
children | 553dc65bf3a6 |
files | pidgin/gtkblist.c pidgin/gtkblist.h pidgin/gtkconv.c pidgin/gtkconv.h |
diffstat | 4 files changed, 72 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/pidgin/gtkblist.c Mon Jun 18 19:24:10 2007 +0000 +++ b/pidgin/gtkblist.c Tue Jun 19 02:11:50 2007 +0000 @@ -3282,7 +3282,7 @@ return ret; } -static gchar *pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected) +gchar *pidgin_blist_get_name_markup(PurpleBuddy *b, gboolean selected) { const char *name; char *esc, *text = NULL;
--- a/pidgin/gtkblist.h Mon Jun 18 19:24:10 2007 +0000 +++ b/pidgin/gtkblist.h Tue Jun 19 02:11:50 2007 +0000 @@ -360,4 +360,13 @@ void pidgin_blist_set_headline(const char *text, GdkPixbuf *pixbuf, GCallback callback, gpointer user_data, GDestroyNotify destroy); +/** + * Returns a buddy's Pango markup appropriate for setting in a GtkCellRenderer. + * + * @param buddy The buddy to return markup from + * @param selected Whether this buddy is selected. If TRUE, the markup will not change the color. + * @return The markup for this buddy + */ +gchar *pidgin_blist_get_name_markup(PurpleBuddy *buddy, gboolean selected); + #endif /* _PIDGINBLIST_H_ */
--- a/pidgin/gtkconv.c Mon Jun 18 19:24:10 2007 +0000 +++ b/pidgin/gtkconv.c Tue Jun 19 02:11:50 2007 +0000 @@ -82,6 +82,12 @@ PIDGIN_CONV_COLORIZE_TITLE = 1 << 6 }PidginConvFields; +enum { + ICON_COLUMN, + TEXT_COLUMN, + NUM_COLUMNS +} PidginInfopaneColumns; + #define PIDGIN_CONV_ALL ((1 << 7) - 1) #define SEND_COLOR "#204a87" @@ -2350,6 +2356,9 @@ gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); + gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter), + ICON_COLUMN, status, -1); + if (status != NULL) g_object_unref(status); @@ -2409,11 +2418,7 @@ PURPLE_ICON_SCALE_DISPLAY, &scale_width, &scale_height); /* this code is ugly, and scares me */ - scale = gdk_pixbuf_scale_simple(buf, - MAX(gdk_pixbuf_get_width(buf) * scale_width / - gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), - MAX(gdk_pixbuf_get_height(buf) * scale_height / - gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), + scale = gdk_pixbuf_scale_simple(buf, 32, 32, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->u.im->icon), scale); @@ -4378,6 +4383,8 @@ setup_common_pane(PidginConversation *gtkconv) { GtkWidget *paned, *vbox, *frame, *imhtml_sw; + GtkCellRenderer *rend; + GtkTreePath *path; PurpleConversation *conv = gtkconv->active_conv; gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); GtkPolicyType imhtml_sw_hscroll; @@ -4390,6 +4397,35 @@ gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); gtk_widget_show(vbox); + /* Setup the info pane */ + gtkconv->infopane_hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), gtkconv->infopane_hbox, FALSE, FALSE, 0); + gtk_widget_show(gtkconv->infopane_hbox); + + gtkconv->infopane = gtk_cell_view_new(); + gtkconv->infopane_model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); + gtk_cell_view_set_model(GTK_CELL_VIEW(gtkconv->infopane), gtkconv->infopane_model); + gtk_list_store_append(gtkconv->infopane_model, &(gtkconv->infopane_iter)); + gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), gtkconv->infopane, TRUE, TRUE, 0); + path = gtk_tree_path_new_from_string("0"); + gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(gtkconv->infopane), path); + gtk_widget_set_size_request(gtkconv->infopane, -1, 32); + gtk_widget_show(gtkconv->infopane); + + 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", ICON_COLUMN, NULL); + g_object_set(rend, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL); + + rend = gtk_cell_renderer_text_new(); + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkconv->infopane), rend, TRUE); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkconv->infopane), rend, "markup", TEXT_COLUMN, NULL); + g_object_set(rend, "ypad", 0, "yalign", 0.5, NULL); + +#if GTK_CHECK_VERSION(2, 6, 0) + g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); +#endif + /* Setup the gtkimhtml widget */ frame = pidgin_create_imhtml(FALSE, >kconv->imhtml, NULL, &imhtml_sw); if (chat) { @@ -6122,6 +6158,8 @@ char *title; PurpleConvIm *im = NULL; PurpleAccount *account = purple_conversation_get_account(conv); + PurpleBuddy *buddy; + char *markup; AtkObject *accessibility_obj; /* I think this is a little longer than it needs to be but I'm lazy. */ char style[51]; @@ -6137,6 +6175,17 @@ else title = g_strdup(purple_conversation_get_title(conv)); + buddy = purple_find_buddy(account, conv->name); + if (buddy) + markup = pidgin_blist_get_name_markup(buddy, FALSE); + else + markup = title; + gtk_list_store_set(gtkconv->infopane_model, &(gtkconv->infopane_iter), + TEXT_COLUMN, markup, -1); + + if (title != markup) + g_free(markup); + *style = '\0'; if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) @@ -6296,7 +6345,6 @@ GdkPixbuf *buf; GtkWidget *event; - GtkWidget *frame; GdkPixbuf *scale; int scale_width, scale_height; @@ -6405,24 +6453,13 @@ start_anim(NULL, gtkconv); } - pidgin_buddy_icon_get_scale_size(buf, &prpl_info->icon_spec, - PURPLE_ICON_SCALE_DISPLAY, &scale_width, &scale_height); - scale = gdk_pixbuf_scale_simple(buf, - MAX(gdk_pixbuf_get_width(buf) * scale_width / - gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), - MAX(gdk_pixbuf_get_height(buf) * scale_height / - gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), + scale = gdk_pixbuf_scale_simple(buf, 32, 32, GDK_INTERP_BILINEAR); gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); - frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE); - gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, - FALSE, FALSE, 0); - event = gtk_event_box_new(); - gtk_container_add(GTK_CONTAINER(frame), event); + gtk_container_add(GTK_CONTAINER(gtkconv->u.im->icon_container), event); g_signal_connect(G_OBJECT(event), "button-press-event", G_CALLBACK(icon_menu), gtkconv); gtk_widget_show(event); @@ -6430,19 +6467,16 @@ gtkconv->u.im->icon = gtk_image_new_from_pixbuf(scale); gtkconv->auto_resize = TRUE; /* Reset the size request to allow the buddy icon to resize */ - gtk_widget_set_size_request(gtkconv->lower_hbox, -1, -1); g_idle_add(reset_auto_resize_cb, gtkconv); - gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); gtk_widget_show(gtkconv->u.im->icon); g_object_unref(G_OBJECT(scale)); - gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), + gtk_box_pack_start(GTK_BOX(gtkconv->infopane_hbox), gtkconv->u.im->icon_container, FALSE, FALSE, 0); gtk_widget_show(gtkconv->u.im->icon_container); - gtk_widget_show(frame); /* The buddy icon code needs badly to be fixed. */ if(pidgin_conv_window_is_active_conversation(conv)) @@ -8415,7 +8449,7 @@ gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); /* show the widgets */ - gtk_widget_show(gtkconv->icon); +/* XXX gtk_widget_show(gtkconv->icon); */ gtk_widget_show(gtkconv->tab_label); if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/close_on_tabs")) gtk_widget_show(gtkconv->close);