3

私は gnome シェル拡張機能を開発しようとしており、自動的に作成される「Hello World」拡張機能を作成しました。gnome-shell-extension-tool --create-extension これにより、example.js、metadata.json、stylesheet.css の 3 つのファイルが作成されます。

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;
}

これについてさらに情報を得る方法さえ知りませんでした....何か考えはありますか?

4

2 に答える 2

0

次のスタイルシートを試してください。

.hello {
   font-size: 36px;
   font-weight: bold;
   color: #ffffff;
   background-color: rgba(10,10,10,0.7);
   border-radius: 15px;
   margin: 50px;
   padding: 50px;
}
于 2011-05-17T03:06:19.553 に答える
0

私はついにそれを解決しました:D 問題は、css管理との競合を引き起こす「ユーザーテーマ」拡張機能をインストールしたことでした

PS私はArchLinux 32ビット版を使用しています

于 2011-05-17T14:45:39.367 に答える