【问题标题】:gnome shell extension stylesheet not loadinggnome shell 扩展样式表未加载
【发布时间】: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


【解决方案1】:

试试下面的样式表:

.hello {
   font-size: 36px;
   font-weight: bold;
   color: #ffffff;
   background-color: rgba(10,10,10,0.7);
   border-radius: 15px;
   margin: 50px;
   padding: 50px;
}

【讨论】:

  • 感谢您的更新。用户主题扩展是邪恶的。很多人似乎对这个特定的 shell 扩展有问题。
【解决方案2】:

我终于解决了 :D 问题是我安装了“用户主题”扩展,它与 css 管理产生了冲突 希望可以帮助别人

附:我使用的是 ArchLinux 32 位版本

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-01
    • 1970-01-01
    • 2021-12-24
    • 2017-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多