【发布时间】:2011-05-05 13:24:41
【问题描述】:
我正在尝试开发一个 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;
}
我什至不知道如何获得有关此的更多信息....有什么想法吗?
【问题讨论】:
-
你试过用Looking Glass调试它吗?
-
哎呀,我不知道该怎么做。如果我只看“错误”选项卡,我会看到“加载扩展 test@archtop”没有问题。如果你能给我一些关于如何调试它的提示,那就太好了:D
-
其实用 lg 我可以得到 CSS 类设置正确,但它不起作用
标签: gnome gnome-3 gnome-shell