【问题标题】:How to start a GtkApplication from inside a gnome-shell-extension?如何从 gnome-shell-extension 中启动 GtkApplication?
【发布时间】:2015-08-12 11:28:27
【问题描述】:

我的目标是在用户按下 Gnome 顶部栏中的按钮时启动一个新的 GtkApplication。 顶部栏中的按钮可以通过 gnome-shell-extension 完成,但我无法打开 GtkApplication。

因此,现在下面的代码应该只是启动 GtkApplication。

在将代码放入 ~/.local/share/gnome-shell/extensions/test@test/extension.js 后启用此扩展始终会导致 SIGSEGV 信号为 gnome-shell

const Lang = imports.lang;
const Gtk = imports.gi.Gtk;
const TestApp = new Lang.Class({
    Name: 'TestApp',
    Extends: Gtk.Application,
    _init: function() {
        this.parent({ application_id: 'testapp.apptesttt' });
    },
    vfunc_activate: function() {
        //this.window.present();
    },
});
function init() {
}
let _app;
function enable() {
    _app = new TestApp();
    _app.register(null);
}
function disable() {
    _app.quit();
}

【问题讨论】:

  • 您是否考虑过在不同的进程中简单地启动应用程序,而不是运行GtkApplication
  • @meskobalazs 你的意思是分叉另一个进程?我将如何在 javascript 中做到这一点?
  • 如果我确切地知道,我会写一个答案 :) 但是 GLib 和 GIO 确实有一个 API。

标签: javascript gtk3 gnome-shell gnome-shell-extensions


【解决方案1】:

我可能有点迟到了,但万一其他人在这里结束:

答案很可能就在imports.misc.util

const Util = imports.misc.util;
Util.spawn()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-12
    • 2013-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-02
    相关资源
    最近更新 更多