简体   繁体   English

如何在GTK中向应用程序添加图标#

[英]How do you add icons to application in GTK#

I have this very basic GTK# window, but it seems that there are missing icons on title bar. 我有这个非常基本的GTK#窗口,但似乎标题栏上缺少图标。 I believe there should be icons for closing, maximizing and minimizing window. 我相信应该有关闭,最大化和最小化窗口的图标。

截图

My question is: how do you add icons in GTK 3.22.7? 我的问题是:你如何在GTK 3.22.7中添加图标? How GTK determines where icons are going to be searched for? GTK如何确定要搜索图标的位置?

I suppose the answer would be similiar for GTK# and GTK. 我想答案与GTK#和GTK类似。 If you don't know how it's done in C#, can you please write answer for pure GTK? 如果您不知道它是如何在C#中完成的,那么请您为纯GTK写答案吗? I might be able to figure out how to port it to C#. 我或许可以弄清楚如何将它移植到C#。

Self-answer: 自答案:

You need to have icons directory structured like that: 你需要有像这样结构的图标目录:

icons/
├── Adwaita
│   ├── 16x16
│   ├── 22x22
│   ├── 24x24
│   ├── 256x256
│   ├── 32x32
│   ├── 48x48
│   ├── 512x512
│   ├── 64x64
│   ├── 8x8
│   ├── 96x96
│   ├── cursors
│   ├── icon-theme.cache
│   ├── index.theme
│   ├── scalable
│   └── scalable-up-to-32
└── hicolor
    ├── 128x128
    ├── 16x16
    ├── 192x192
    ├── 22x22
    ├── 24x24
    ├── 256x256
    ├── 32x32
    ├── 36x36
    ├── 48x48
    ├── 512x512
    ├── 64x64
    ├── 72x72
    ├── 96x96
    ├── icon-theme.cache
    ├── index.theme
    ├── scalable
    └── symbolic

Then, you have to specify path to icons/ 然后,你必须指定图标的路径/

Gtk.IconTheme.Default.AppendSearchPath(@"D:\dev\git\GtkApp1\bin\Debug\icons");

You can also choose desired icon theme to use 您还可以选择要使用的所需图标主题

Gtk.Settings.Default.IconThemeName = "Adwaita";

有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM