gnome shell 扩展样式表未加载
我正在尝试开发一个 gnome shell 扩展,并且创建了“Hello World”扩展,该扩展是使用 gnome-shell-extension-tool --create-extension 自动创建的 它创建 3 个文件:example.js、metadata.json、stylesheet.css。
我重新加载 gnome-shell 并且扩展工作正常。问题是,样式文件根本不起作用;这是代码:
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'hello', text: "Hello, world!" });
let monitor = global.get_primary_monitor();
global.stage.add_actor(text);
text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2));
text.add_style_class_name("hello");
Mainloop.timeout_add(6000, function () { text.destroy(); });
}
// Put your extension initialization code here
function main() {
Main.panel.actor.reactive = true;
Main.panel.actor.connect('button-release-event', _showHello);
}
这里是 stylesheet.css:
/* Example stylesheet */
.hello {
font-size: 360px;
font-weight: bold;
color: #ffffff;
background-color: rgba(10,10,10,0.7);
border-radius: 5px;
}
我不知道如何获得有关此的更多信息......有什么想法吗?
i'm trying to develop a gnome shell extension and I've created the "Hello World" extension which is created automatically with gnome-shell-extension-tool --create-extension
It creates 3 files: example.js, metadata.json, stylesheet.css.
I reload gnome-shell and the extension works correcty. The problem is, the styling file is not working at all; here is the code:
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;
const Main = imports.ui.main;
function _showHello() {
let text = new St.Label({ style_class: 'hello', text: "Hello, world!" });
let monitor = global.get_primary_monitor();
global.stage.add_actor(text);
text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2));
text.add_style_class_name("hello");
Mainloop.timeout_add(6000, function () { text.destroy(); });
}
// Put your extension initialization code here
function main() {
Main.panel.actor.reactive = true;
Main.panel.actor.connect('button-release-event', _showHello);
}
And here stylesheet.css:
/* Example stylesheet */
.hello {
font-size: 360px;
font-weight: bold;
color: #ffffff;
background-color: rgba(10,10,10,0.7);
border-radius: 5px;
}
I didn't know how to even get more information about this....any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下样式表:
Try the following stylesheet:
我终于解决了:D
问题是我安装了“用户主题”扩展,它与 css 管理产生冲突
希望可以帮助
别人我使用的是ArchLinux 32位版本
I've finally worked it out :D
The problem was that I had installed the "user-theme" extension wich creates conficts with the css management
Hope can help someone
P.S. I'm using ArchLinux 32bit version