static void attachment_button_update_cell_view (EAttachmentButton *button) { GtkCellView *cell_view; EAttachment *attachment; GtkTreeRowReference *reference; GtkTreeModel *model = NULL; GtkTreePath *path = NULL; cell_view = GTK_CELL_VIEW (button->priv->cell_view); attachment = e_attachment_button_get_attachment (button); if (attachment == NULL) goto exit; reference = e_attachment_get_reference (attachment); if (reference == NULL) goto exit; model = gtk_tree_row_reference_get_model (reference); path = gtk_tree_row_reference_get_path (reference); exit: gtk_cell_view_set_model (cell_view, model); if (model) gtk_cell_view_set_displayed_row (cell_view, path); if (path != NULL) gtk_tree_path_free (path); }
static VALUE cview_set_displayed_row(VALUE self, VALUE path) { gtk_cell_view_set_displayed_row(_SELF(self), NIL_P(path) ? (GtkTreePath*)NULL : RVAL2GTKTREEPATH(path)); return self; }
static void displayed_row_changed (GtkComboBox *combo, GtkCellView *cell) { gint row; GtkTreePath *path; row = gtk_combo_box_get_active (combo); path = gtk_tree_path_new_from_indices (row, -1); gtk_cell_view_set_displayed_row (cell, path); gtk_tree_path_free (path); }
/** * Initialize the head cellview, create list store and set the cell renderers. */ static void cell_view_init(HybridHead *head) { GtkListStore *store; GtkCellRenderer *renderer; GtkTreePath *path; g_return_if_fail(head != NULL); store = gtk_list_store_new(HYBRID_HEAD_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, GDK_TYPE_PIXBUF); gtk_cell_view_set_model(GTK_CELL_VIEW(head->cellview), 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(head->cellview), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(head->cellview), renderer, "pixbuf", HYBRID_HEAD_PIXBUF_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(head->cellview), renderer, TRUE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(head->cellview), renderer, "markup", HYBRID_HEAD_NAME_COLUMN, NULL); g_object_set(renderer, "xalign", 0.0, "yalign", 0.0, "xpad", 6, "ypad", 0, NULL); g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); /* status icon renderer */ renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(head->cellview), renderer, FALSE); gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(head->cellview), renderer, "pixbuf", HYBRID_HEAD_STATUS_ICON_COLUMN, NULL); g_object_set(renderer, "yalign", 0.5, "xpad", 10, "ypad", 0, NULL); gtk_list_store_append(store, &head->iter); path = gtk_tree_path_new_from_string("0"); gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(head->cellview), path); gtk_tree_path_free(path); }
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); }
void hybrid_chat_window_update_tips(HybridChatWindow *window) { GtkTreeModel *model; GtkTreePath *path; HybridConversation *conv; HybridBuddy *buddy; gchar *markup; g_return_if_fail(window != NULL); if (!IS_SYSTEM_CHAT(window)) { return; } conv = window->parent; buddy = window->data; model = gtk_cell_view_get_model(GTK_CELL_VIEW(window->tablabel)); if (window->unread) { markup = g_strdup_printf("<span color=\"blue\"><b>%s (%d)</b></span>", buddy->name, window->unread); } else { markup = g_strdup(buddy->name); } gtk_list_store_set(GTK_LIST_STORE(model), &window->tabiter, TAB_NAME_COLUMN, markup, -1); g_free(markup); path = gtk_tree_path_new_from_string("0"); gtk_cell_view_set_displayed_row(GTK_CELL_VIEW(window->tablabel), path); gtk_tree_path_free(path); }
/** * 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; }