gnome - 如何在Gnome Shell扩展中为St.Icon设置PNG文件

标签 gnome gnome-shell gnome-shell-extensions

我的Gnome Shell扩展名为“icons”的文件夹,并且内部有一个名为“MyIcon.png”的图标文件。我想将其作为St.Icon对象的参数。

let icon = new St.Icon({ /* I need what to code here*/ });

谢谢你的帮助。

塞尔丘克

最佳答案

这是GnomeShell v3.8.4的解决方案:

const St = imports.gi.St;
const Me = imports.misc.extensionUtils.getCurrentExtension();
const Gio = imports.gi.Gio;
let gicon = Gio.icon_new_for_string(Me.path + "/icons/my_icon.png");
icon = new St.Icon({ gicon });

关于gnome - 如何在Gnome Shell扩展中为St.Icon设置PNG文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20394840/

相关文章:

gnome-shell - 如何向 gnome-shell 菜单中的链接添加参数

javascript - 开发 Gnome Shell 和扩展时应该使用 ES6 还是 Lang 类?

gnome-shell-extensions - 我的 GNOME Shell 扩展如何检测 GNOME 版本?

debian - 如何在 Gnome Shell 3.16.2 中显示 gnome-shell 扩展的堆栈跟踪?

gnome - 如何重新禁用 gnome-shell 40 中的热角?

linux - Gnome Shell 扩展键绑定(bind)

gnome - JHBuild 中的 after 元素有什么用?

c++ - 如何获取与 Linux 桌面中的文件关联的图标、MIME 类型和应用程序?

linux - 如何在 Linux 中不同进程的全屏应用程序顶部弹出 GTK 窗口/小部件?

linux - 从 Gnome 管理 DNS 服务器