简体   繁体   中英

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. 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? How GTK determines where icons are going to be searched for?

I suppose the answer would be similiar for GTK# and GTK. If you don't know how it's done in C#, can you please write answer for pure GTK? I might be able to figure out how to port it to 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";

有用

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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