void hybrid_head_bind_to_account(HybridAccount *account) { GtkTreeModel *model; GtkTreePath *path; GdkPixbuf *pixbuf; GdkPixbuf *status_icon; gchar *text; model = gtk_cell_view_get_model(GTK_CELL_VIEW(hybrid_head->cellview)); if (!account) { pixbuf = hybrid_create_default_icon(32); text = g_strdup(_("No account was enabled.")); status_icon = NULL; } else { pixbuf = hybrid_create_round_pixbuf(account->icon_data, account->icon_data_len, 32); text = g_strdup_printf(_("<b>%s</b> [%s]\n<small>%s</small>"), account->nickname, hybrid_get_presence_name(account->state), account->status_text ? account->status_text : ""); status_icon = hybrid_create_presence_pixbuf(account->state, 16); } gtk_list_store_set(GTK_LIST_STORE(model), &hybrid_head->iter, HYBRID_HEAD_PIXBUF_COLUMN, pixbuf, HYBRID_HEAD_NAME_COLUMN, text, HYBRID_HEAD_STATUS_ICON_COLUMN, status_icon, -1); path = gtk_tree_path_new_from_string("0"); gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(hybrid_head->cellview), path); gtk_tree_path_free(path); g_object_unref(pixbuf); if (status_icon) { g_object_unref(status_icon); } g_free(text); }
/** * Create the buddy tips panel. We implement it with GtkCellView. * The layout is: * * ----------------------------------------------------- * | | Name | Proto | Status | * | Icon |--------------(markup)-| Icon | Icon | * | (32×32) | Mood phrase | (16×16)| (16×16)| * ----------------------------------------------------- */ static void create_buddy_tips_panel(GtkWidget *vbox, HybridChatWindow *chat) { GtkWidget *cellview; GtkListStore *store; GtkCellRenderer *renderer; GtkTreePath *path; HybridAccount *account; HybridModule *proto; HybridBuddy *buddy; gchar *name_text; gchar *mood_text; GdkPixbuf *icon_pixbuf; GdkPixbuf *proto_pixbuf; GdkPixbuf *presence_pixbuf; GtkWidget *eventbox; g_return_if_fail(vbox != NULL); cellview = gtk_cell_view_new(); store = gtk_list_store_new(LABEL_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF); gtk_cell_view_set_model(GTK_CELL_VIEW(cellview), GTK_TREE_MODEL(store)); /* * GtkCellView doesn't have a GdkWindow, we wrap it with an EventBox, * and then setup tooltip on the EventBox. */ eventbox = gtk_event_box_new(); gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventbox), FALSE); gtk_container_add(GTK_CONTAINER(eventbox), cellview); /* buddy icon renderer */ renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cellview), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cellview), renderer, "pixbuf", BUDDY_ICON_COLUMN, NULL); g_object_set(renderer, "yalign", 0.5, "xpad", 3, "ypad", 0, NULL); /* buddy name renderer */ renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cellview), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cellview), renderer, "markup", BUDDY_NAME_COLUMN, NULL); g_object_set(renderer, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL); g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); /* protocol icon renderer */ renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cellview), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cellview), renderer, "pixbuf", BUDDY_PROTO_ICON_COLUMN, NULL); g_object_set(renderer, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL); /* status icon renderer */ renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(cellview), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(cellview), renderer, "pixbuf", BUDDY_STATUS_ICON_COLUMN, NULL); g_object_set(renderer, "xalign", 0.0, "xpad", 6, "ypad", 0, NULL); gtk_list_store_append(store, &chat->tipiter); path = gtk_tree_path_new_from_string("0"); gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(cellview), path); gtk_tree_path_free(path); chat->tiplabel = cellview; if (IS_SYSTEM_CHAT(chat)) { buddy = chat->data; hybrid_tooltip_setup(eventbox, NULL, NULL, init_tooltip, buddy); icon_pixbuf = hybrid_create_round_pixbuf(buddy->icon_data, buddy->icon_data_length, 32); presence_pixbuf = hybrid_create_presence_pixbuf(buddy->state, 16); mood_text = g_markup_escape_text(buddy->mood ? buddy->mood : "", -1); name_text = g_strdup_printf( "<b>%s</b>\n<small><span font=\"#8f8f8f\">%s</span></small>", buddy->name && *(buddy->name) != '\0' ? buddy->name : buddy->id, mood_text); gtk_list_store_set(store, &chat->tipiter, BUDDY_ICON_COLUMN, icon_pixbuf, BUDDY_NAME_COLUMN, name_text, BUDDY_STATUS_ICON_COLUMN, presence_pixbuf, -1); g_object_unref(icon_pixbuf); g_object_unref(presence_pixbuf); g_free(name_text); g_free(mood_text); } account = chat->account; proto = account->proto; proto_pixbuf = hybrid_create_proto_icon(proto->info->name, 16); gtk_list_store_set(store, &chat->tipiter, BUDDY_PROTO_ICON_COLUMN, proto_pixbuf, -1); g_object_unref(proto_pixbuf); gtk_box_pack_start(GTK_BOX(vbox), eventbox, FALSE, FALSE, 5); }
/** * Create the tab label widget for the GtkNotebook. * The layout is: * * ----------------------------------------------------- * | Status | | Close Button | * | Icon | buddy name (markup) | | * | (16×16) | | (16×16) | * ----------------------------------------------------- * |- GtkEventBox -> GtkCellView -|--- GtkEventBox ---| */ static GtkWidget* create_note_label(HybridChatWindow *chat) { GtkWidget *hbox; GtkWidget *eventbox; GtkWidget *close_image; GtkWidget *label; GtkListStore *store; GtkCellRenderer *renderer; GtkTreePath *path; HybridBuddy *buddy; GdkPixbuf *icon_pixbuf; g_return_val_if_fail(chat != NULL, NULL); hbox = gtk_hbox_new(FALSE, 0); label = gtk_cell_view_new(); store = gtk_list_store_new(TAB_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING); gtk_cell_view_set_model(GTK_CELL_VIEW(label), GTK_TREE_MODEL(store)); g_object_unref(store); /* buddy icon renderer */ renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(label), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(label), renderer, "pixbuf", TAB_STATUS_ICON_COLUMN, NULL); g_object_set(renderer, "yalign", 0.5, "xpad", 3, "ypad", 0, NULL); /* buddy name renderer */ renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(label), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(label), renderer, "markup", TAB_NAME_COLUMN, NULL); g_object_set(renderer, "xalign", 0.5, "xpad", 6, "ypad", 0, NULL); g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); chat->tablabel = label; gtk_list_store_append(store, &chat->tabiter); path = gtk_tree_path_new_from_string("0"); gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(label), path); gtk_tree_path_free(path); if (IS_SYSTEM_CHAT(chat)) { buddy = chat->data; icon_pixbuf = hybrid_create_presence_pixbuf(buddy->state, 16); gtk_list_store_set(store, &chat->tabiter, TAB_STATUS_ICON_COLUMN, icon_pixbuf, TAB_NAME_COLUMN, buddy->name && *(buddy->name) != '\0' ? buddy->name : buddy->id, -1); g_object_unref(icon_pixbuf); } eventbox = gtk_event_box_new(); gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventbox), FALSE); gtk_container_add(GTK_CONTAINER(eventbox), label); gtk_box_pack_start(GTK_BOX(hbox), eventbox, TRUE, TRUE, 0); gtk_widget_add_events(eventbox, GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); g_signal_connect(G_OBJECT(eventbox), "button-press-event", G_CALLBACK(tab_press_cb), chat); /* close button */ eventbox = gtk_event_box_new(); gtk_event_box_set_visible_window(GTK_EVENT_BOX(eventbox), FALSE); close_image = gtk_image_new_from_file(PIXMAPS_DIR"menus/close.png"); g_signal_connect(G_OBJECT(eventbox), "button-press-event", G_CALLBACK(tab_close_press_cb), chat); gtk_container_add(GTK_CONTAINER(eventbox), close_image); gtk_box_pack_start(GTK_BOX(hbox), eventbox, FALSE, FALSE, 0); gtk_widget_show_all(hbox); return hbox; }