GTK3笔记 - 设置icon

392 阅读1分钟

废话不说,直接上代码。

static GdkPixbuf *_new_pixbuf(const gchar *filename) {
    GError *error = NULL;
    GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file(filename, &error);

    if (!pixbuf) {
        g_warning("%s\n", error->message);
        g_error_free(error);
    }   
    return pixbuf;
}

// 设置图标
gtk_window_set_icon(GTK_WINDOW(window), _new_pixbuf("./img/icon.png"));