了解 *nix 图标'路径

发布于 2024-09-10 23:53:21 字数 212 浏览 1 评论 0原文

有人可以解释一下,为什么许多程序的图标路径是这样的: /usr/share/program/icons/hicolor/16x16/...

我不明白的是为什么 hicolor 以及为什么 16x16、32x32 等。

有什么功能吗(例如在 GTK 中)自动从此类路径中获取正确的图标?

谢谢你!

Could someone please explain, why many programs have their icons' paths this way:
/usr/share/program/icons/hicolor/16x16/...

What I don't understand is why hicolor and why 16x16, 32x32 etc.

Are there any functions (e.g. in GTK) that automatically get the proper icon from such kind of paths?

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南街女流氓 2024-09-17 23:53:21

这些图标路径由图标主题规范。原因是所有应用程序都可以将其默认图标安装到 hicolor 主题中(这是默认主题,这意味着如果另一个主题中缺少图标,则使用 hicolor 中的版本> 将被使用。)

此外,程序可以请求与提供的图标大小不同的图标大小,例如 37x37,系统将选择最合适的可用大小(例如 32x32)并缩放它到要求的尺寸。

如果有人想要覆盖应用程序的图标,例如为视力不好的用户制作一个高对比度的黑白版本,那么他们所要做的就是制作一个同名的图标并将其放在高位-对比黑白主题,它将覆盖hicolor图标。

你问的功能也是存在的。在 GTK 中,有些函数采用 const gchar *icon_name 参数,例如 gtk_image_new_from_icon_name()。这些将使用您从当前主题提供的名称加载图标,如果当前主题中不存在该图标,则从 hicolor 主题加载图标。

Those icon paths are standardized by the Icon Theme Specification. The reasoning is that all applications can install their default icons into the hicolor theme (which is the default theme, meaning that if an icon is missing from another theme, the version from hicolor will be used.)

Also, a program can request an icon size that is different from the ones provided, say 37x37, and the system will select the most appropriate available size (like 32x32) and scale it to the requested size.

If someone wants to override the application's icon, for example to make a high-contrast black-and-white version for users with poor eyesight, then all they have to do is to make an icon with the same name and put it in the high-contrast black-and-white theme, and it will override the hicolor icon.

The functions you ask about also exist. In GTK there are functions that take a const gchar *icon_name parameter, such as gtk_image_new_from_icon_name(). These will load the icon with the name you supply from the current theme, and if it doesn't exist in the current theme, then from the hicolor theme.

花期渐远 2024-09-17 23:53:21

术语“hicolor”是标准图标集的名称,它是所有其他图标集的后备,这意味着,如果在当前图标集中找不到应用程序的图标(例如 /usr/share/icons /oxygen) 接下来搜索 hicolor 目录。

16x16、32x32 意味着存储在该目录中的图像的大小,因为图标存储为简单的 PNG 文件,其中恰好包含一个图像(与 Mac 上的 .icns 等不同)。

The term "hicolor" is the name of the standard icon set which is the fallback for all other icon sets, which means, that if an application's icon is not found in the current icon set (e.g. /usr/share/icons/oxygen) the hicolor directory is searched next.

16x16, 32x32 is imply the size of the images, stored in that directory, as the icons are stored as simple PNG files, which contain exactly one image (unlike, e.g. .icns on mac).

回忆凄美了谁 2024-09-17 23:53:21

如果问题不是像其他人回答的那样“为什么'hicolor'?”而是“为什么使用文件系统作为树状数据库?”答案是大多数unix当目录中的条目超过 1000 个时,文件系统(所有旧的文件系统)就会陷入困境。

因为必须线性搜索这些文件系统中的目录。

一些更现代的文件系统支持 O(log N) 搜索,并且可以有效地处理更高的计数。

If the question is not "Why 'hicolor'?" as others have answered but "Why use the filesystem as a tree-like database?" the answer is that most unix filesystems (all the old ones) bog down when walking paths where there are more than ~1000 entries in a directory.

Because directories in those filesystems have to be searched linearly.

Some more modern filesystems support O(log N) searches and can deal with higher counts efficiently.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文