Пример #1
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);
}
Пример #2
0
GtkWidget*
hybrid_create_window(const gchar *title, GdkPixbuf *icon,
		GtkWindowPosition pos, gboolean resizable)
{
	GtkWidget *window;

	window = gtk_window_new(GTK_WINDOW_TOPLEVEL);

	if (!icon) {
		icon = hybrid_create_default_icon(0);
	}

	gtk_window_set_icon(GTK_WINDOW(window), icon);

	gtk_window_set_resizable(GTK_WINDOW(window), resizable);
	gtk_window_set_title(GTK_WINDOW(window), title);
	gtk_window_set_position(GTK_WINDOW(window), pos);
	g_object_unref(icon);

	return window;
}
Пример #3
0
HybridConfirm*
hybrid_confirm_show(const gchar *title, const gchar *text,
		const gchar *btn_text, confirm_cb btn_callback, gpointer user_data)
{
	GtkWidget *window;
	GtkWidget *vbox;
	GtkWidget *hbox;
	GtkWidget *action_area;
	GdkPixbuf *pixbuf;
	GtkWidget *image;
	GtkWidget *label;
	GtkWidget *button;
	HybridConfirm *confirm;

	g_return_val_if_fail(title != NULL, NULL);
	g_return_val_if_fail(text != NULL, NULL);

	confirm = g_new0(HybridConfirm, 1);
	confirm->btn_callback = btn_callback;
	confirm->user_data = user_data;

	window = hybrid_create_window(title, NULL, GTK_WIN_POS_CENTER, TRUE);
	gtk_container_set_border_width(GTK_CONTAINER(window), 8);
	g_signal_connect(window, "destroy", G_CALLBACK(confirm_destroy), confirm);

	confirm->window = window;

	vbox = gtk_vbox_new(FALSE, 0);
	gtk_container_add(GTK_CONTAINER(window), vbox);

	hbox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);

	pixbuf = hybrid_create_default_icon(64);
	image = gtk_image_new_from_pixbuf(pixbuf);
	g_object_unref(pixbuf);

	gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 5);

	label = gtk_label_new(NULL);
	gtk_label_set_markup(GTK_LABEL(label), text);

	gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5);

	action_area = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 0);

	button = gtk_button_new_with_label(btn_text);
	gtk_widget_set_size_request(button, 100, 30);
	gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
	g_signal_connect(button, "clicked",
			G_CALLBACK(confirm_user_btn_cb), confirm);

	button = gtk_button_new_with_label(_("Cancel"));
	gtk_widget_set_size_request(button, 100, 30);
	gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
	g_signal_connect(button, "clicked",
			G_CALLBACK(confirm_cancel_btn_cb), confirm);

	gtk_widget_show_all(confirm->window);

	return confirm;
}
Пример #4
0
HybridInfo*
hybrid_info_create(HybridBuddy *buddy)
{
    HybridInfo *info;
    GdkPixbuf *pixbuf;
    GtkWidget *vbox;
    GtkWidget *scroll;
    GtkWidget *label;
    GtkWidget *halign;
    GtkWidget *action_area;
    GtkWidget *close_button;
    GtkListStore *store;
    gchar *title;

    GSList *pos;

    g_return_val_if_fail(buddy != NULL, NULL);

    for (pos = info_list; pos; pos = pos->next) {
        info = (HybridInfo*)pos->data;

        if (info->buddy == buddy) {
            return (HybridInfo*)pos->data;
        }
    }

    info = g_new0(HybridInfo, 1);
    info->buddy = buddy;

    info_list = g_slist_append(info_list, info);

    info->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_object_set(info->window, "border-width", 10, NULL);
    pixbuf = hybrid_create_default_icon(0);
    title = g_strdup_printf(_("%s's information"),
            buddy->name && *(buddy->name) != '\0' ? buddy->name : buddy->id);

    gtk_window_set_icon(GTK_WINDOW(info->window), pixbuf);
    gtk_window_set_position(GTK_WINDOW(info->window), GTK_WIN_POS_CENTER);
    gtk_window_set_title(GTK_WINDOW(info->window), title);
    gtk_widget_set_size_request(info->window, 400, 350);
    gtk_window_set_resizable(GTK_WINDOW(info->window), FALSE);
    g_signal_connect(info->window, "destroy", G_CALLBACK(window_destroy_cb),
                            info);

    g_free(title);
    g_object_unref(pixbuf);

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(info->window), vbox);

    /* label */
    label = gtk_label_new(NULL);
    halign = gtk_alignment_new(0, 0, 0, 0);
    gtk_container_add(GTK_CONTAINER(halign), label);
    gtk_box_pack_start(GTK_BOX(vbox), halign, FALSE, FALSE, 5);

    title = g_strdup_printf(_("<b>Information of %s</b>"),
            buddy->name && *(buddy->name) != '\0' ? buddy->name : buddy->id);
    gtk_label_set_markup(GTK_LABEL(label), title);
    g_free(title);

    /* scroll -> treeview */
    scroll = gtk_scrolled_window_new(NULL, NULL);
    gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
            GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll),
            GTK_SHADOW_ETCHED_IN);

    store = gtk_list_store_new(HYBRID_INFO_COLUMNS,
                    G_TYPE_STRING,
                    G_TYPE_STRING,
                    GDK_TYPE_PIXBUF,
                    G_TYPE_BOOLEAN,
                    G_TYPE_BOOLEAN);

    info->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
    //gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(info->treeview), TRUE);
    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(info->treeview), FALSE);
    g_object_unref(store);
    gtk_container_add(GTK_CONTAINER(scroll), info->treeview);

    /* close button */
    action_area = gtk_hbox_new(FALSE, 0);
    halign = gtk_alignment_new(1, 0, 0, 0);
    gtk_container_add(GTK_CONTAINER(halign), action_area);
    gtk_box_pack_start(GTK_BOX(vbox), halign, FALSE, FALSE, 5);

    close_button = gtk_button_new_with_label(_("Close"));
    gtk_widget_set_size_request(close_button, 100, 30);
    gtk_box_pack_start(GTK_BOX(action_area), close_button, FALSE, TRUE, 0);
    g_signal_connect(close_button, "clicked", G_CALLBACK(close_click_cb), info);

    render_column(info);

    gtk_widget_show_all(info->window);

    return info;
}
Пример #5
0
static void
groupadd_window_init(HybridGroupAddWindow *window)
{
    GtkWidget       *vbox;
    GtkWidget       *fixed;
    GtkWidget       *action_area;
    GtkWidget       *label;
    GtkTreeModel    *model;
    GtkCellRenderer *renderer;
    GtkWidget       *button;
    GdkPixbuf       *pixbuf;
    GtkWidget       *image;

    vbox = gtk_vbox_new(FALSE, 0);
    gtk_container_add(GTK_CONTAINER(window->window), vbox);

    fixed = gtk_fixed_new();
    gtk_box_pack_start(GTK_BOX(vbox), fixed, TRUE, TRUE, 0);

    pixbuf = hybrid_create_default_icon(64);
    image = gtk_image_new_from_pixbuf(pixbuf);
    g_object_unref(pixbuf);

    gtk_fixed_put(GTK_FIXED(fixed), image, 20, 40);

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Please choose an account:</b>"));
    gtk_fixed_put(GTK_FIXED(fixed), label, 110, 20);

    model = create_account_model();
    window->account_combo = gtk_combo_box_new_with_model(model);
    renderer = gtk_cell_renderer_pixbuf_new ();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, FALSE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, "pixbuf", 0, NULL);
    renderer = gtk_cell_renderer_text_new();
    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, FALSE);
    gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(window->account_combo),
                                renderer, "text", 1, NULL);
    gtk_combo_box_set_active(GTK_COMBO_BOX(window->account_combo), 0);

    gtk_widget_set_size_request(window->account_combo, 270, 30);
    g_object_unref(model);
    gtk_fixed_put(GTK_FIXED(fixed), window->account_combo, 110, 45);

    label = gtk_label_new(NULL);
    gtk_label_set_markup(GTK_LABEL(label), _("<b>Please input the group name:</b>"));
    gtk_fixed_put(GTK_FIXED(fixed), label, 110, 80);

    window->name_entry = gtk_entry_new();
    gtk_widget_set_size_request(window->name_entry, 270, 30);
    gtk_fixed_put(GTK_FIXED(fixed), window->name_entry, 110, 105);

    action_area = gtk_hbox_new(FALSE, 0);
    gtk_box_pack_start(GTK_BOX(vbox), action_area, FALSE, FALSE, 0);

    button = gtk_button_new_with_label(_("Save"));
    gtk_widget_set_size_request(button, 100, 30);
    gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
    g_signal_connect(button, "clicked", G_CALLBACK(save_cb), window);

    button = gtk_button_new_with_label(_("Cancel"));
    gtk_widget_set_size_request(button, 100, 30);
    gtk_box_pack_end(GTK_BOX(action_area), button, FALSE, FALSE, 5);
    g_signal_connect(button, "clicked", G_CALLBACK(cancel_cb), window);
}