Exemple #1
0
/**
 * Callback funtion for initializing the data in the tooltip window.
 */
static gboolean
tooltip_init(HybridTooltipData *tip_data)
{
	HybridAccount *account;
	HybridModule *module;

	
	if ((account = hybrid_blist_get_current_account())) {

		module = account->proto;

		if (tip_data->icon) {
			g_object_unref(tip_data->icon);
		}

		tip_data->icon = hybrid_create_round_pixbuf(
							account->icon_data,
							account->icon_data_len, PORTRAIT_WIDTH);

		if (module->info->account_tooltip) {
			if (!module->info->account_tooltip(account, tip_data)){

				return FALSE;
			}

			return TRUE;
		}
	}

	return FALSE;
}
Exemple #2
0
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);
}
Exemple #3
0
/**
 * 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);
}
Exemple #4
0
void
hybrid_conv_got_message(HybridAccount *account,
                const gchar *buddy_id, const gchar *message,
                time_t time)
{
    HybridConversation *conv;
    HybridChatWindow   *chat;
    HybridBuddy        *buddy;
    gchar              *msg;
    gchar              *notify_msg;
    GdkPixbuf          *pixbuf;

    gint current_page;
    gint chat_page;

    msg = hybrid_strip_html(message);

    g_return_if_fail(account != NULL);
    g_return_if_fail(buddy_id != NULL);
    g_return_if_fail(message != NULL);

    if (!(buddy = hybrid_blist_find_buddy(account, buddy_id))) {

        hybrid_debug_error("conv", "buddy doesn't exist.");
        g_free(msg);

        return;
    }

    if (!(chat = hybrid_conv_find_chat(buddy_id))) {

        /* Well, we haven't find an existing chat panel so far, so create one. */
        chat = hybrid_chat_window_create(account, buddy->id,
                HYBRID_CHAT_PANEL_SYSTEM);
    }

    /* check whether the chat window is active. */
    conv = chat->parent;
    if (gtk_window_is_active(GTK_WINDOW(conv->window))) {

        current_page = gtk_notebook_current_page(GTK_NOTEBOOK(conv->notebook));
        chat_page = gtk_notebook_page_num(GTK_NOTEBOOK(conv->notebook), chat->vbox);

        if (current_page == chat_page) {
            goto just_show_msg;
        }
    }

    /* change the callback function of the status icon's activate signal. */
    hybrid_status_icon_blinking(buddy);

    /* notify. */
    notify_msg = g_strdup_printf(_("%s said:"),
            buddy->name && *buddy->name ? buddy->name : buddy->id);
    pixbuf = hybrid_create_round_pixbuf(buddy->icon_data,
                                  buddy->icon_data_length, 48);

    hybrid_notify_popup(pixbuf, notify_msg, msg);

    g_object_unref(pixbuf);
    g_free(notify_msg);

    chat->unread ++;

    hybrid_chat_window_update_tips(chat);

just_show_msg:

    hybrid_sound_play_file(SOUND_DIR"newmessage.wav");

    text_ops->append(chat->textview, buddy->account, buddy, msg, time);
    hybrid_logs_write(chat->logs, buddy->name, msg, FALSE);

    g_free(msg);
}