问题标签 [gjs]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
608 浏览

gnome-shell-extensions - GJS:global.window_manager.get_workspaces() 未定义

我的扩展程序有这样的代码

for (let i = 0; i < screen.get_n_workspaces(); ++i) { let w = screen.get_workspace_by_index(i); //Do something }

由于 gjs 将 c 函数映射到 javascript,meta_screen_get_n_workspaces因此成为get_n_workspaces. 但是,当我尝试这样做时meta_screen_get_workspaces

screen.get_workspaces().forEach(w => { //Do someting })

它说“get_workspaces 不是函数”。这里有什么问题?

0 投票
0 回答
344 浏览

centos7 - 在 GNOME shell 应用程序窗口中动态更改标题的颜色

我正在用 gjs (JavaScript) 编写一个 GNOME shell 扩展,它根据文本内容改变 GNOME shell 应用程序窗口中标题的颜色。

现在,我正试图让它为文本编辑器工作。当标题(这是当前焦点文件的名称)以 .js 结尾时,我想将标题颜色更改为红色,以 .txt 结尾时更改为蓝色,否则为绿色。这是一个微不足道的程序,但我希望最终将它扩展到其他应用程序以实现更有意义的目的。

例如,在文本编辑器中查看 .css 文件会使标题变为绿色:

绿色标题

到目前为止,我可以获得当前焦点窗口的标题并对其进行解析以获取其扩展名。

我坚持的是改变标题的颜色。我不确定最好的方法是什么。我尝试过的一些想法是:

  • 直接更改标题的 CSS 属性
  • 动态更改和更新 GTK 主题

即使其中一种方法是可能的,我也无法在线找到任何示例或文档。有人可以指出我正确的方向吗?

0 投票
1 回答
1442 浏览

javascript - 如何在ckeditor中将图像上传到亚马逊s3

我正在尝试使用 ck-editor 将图像上传到亚马逊 s3 存储桶并使用'gjs-plugin-s3,我使用了正确的凭据,但仍然显示“403 Forbidden error”。

我对此感到厌烦,有人可以帮助我解决这个问题吗?

为此,我正在使用以下内容:

我是否正确使用了这些参数?

提前致谢。

0 投票
1 回答
283 浏览

javascript - 如何通过按下按钮 [javascript] [Gjs] 从 St.ScrollView 中删除演员并添加其他演员

我有以下代码:在 St.ScrollView 我添加了一个 St.BoxLayout 。St.Scrollview 添加在 menu.box 中。现在我想创建一个 St.Button,从 St.ScrollView 中删除 St.BoxLayout 并在那里添加另一个 St.BoxLayout。我试图让一个函数“单击”与按钮连接,然后执行以下操作:

但它不起作用。代码片段如下:

换句话说,我想删除 vbox 并添加 vbox1 按下按钮通知。任何帮助将不胜感激。提前致谢。

0 投票
1 回答
63 浏览

javascript - 如何在 gjs 中的小部件之间共享内容

我正在尝试创建一个简单的网络编辑器演示。我想要一个 Web 视图小部件来呈现 gtk 源视图小部件的内容...我绘制了小部件,但我无法从源视图中获取内容以将其提供给 Web 视图。我以为我应该使用缓冲区,但我无法让他们共享缓冲区。那应该如何工作?任何指针将不胜感激。

我在想这样的事情:

然后在 upDateWebView() 方法中,调用

0 投票
1 回答
279 浏览

gnome - how to send email (spawn mail) from gjs gtk app

I am trying to write a gjs app that needs to send emails. The way I have found to do this is using spawn_async_with_pipes() to call mail. The app seems to spawn mail, and I don't get an error, but I don't get any useful output nor do I get the test emails...

I have been at this for a while now and have found little to no useful up to date documentation. I am working with gtk3 and gjs (and glib). I have also tried spawning a shell script that in turn calls mail. This resulted in "could not resolve host" errors and a dead letter queue. So I know that I am spawning my command. I am not concerned about the "could not resolve host command", but by the fact that I can't get it by spawning mail directly.

I am spawning mail like this:

err is 0, and res is just true

I don't know what the output should be, but I'm not getting a recognizable error, and no email is being delivered... How can I get my app to send emails? Is spawning mail not the way to go? Thanks in advance for any pointers you can give me.

0 投票
1 回答
787 浏览

gtk - How do I add a "save" button to the gtk filechooser dialog?

I have a Gjs app that will need to save files. I can open the file chooser dialog just fine from my menu, and I have added a "save" and "cancel" button, but I can't get the "save" button to trigger anything.

I know I'm supposed to pass it a response_id, but I'm not sure what that's supposed to look like nor what I'm supposed to do with it afterwards. I read that part here: https://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.FileChooserDialog.html#expand

I can catch res and fire the associated little logging action when I close the dialog, but both the "save" and "cancel" buttons just close the dialog without doing or saying anything.

My question is, what are GTK_RESPONSE_ACCEPT and GTK_RESPONSE_CANCEL supposed to be (look like) in GJS and how do I use them?

0 投票
1 回答
653 浏览

gtk - 当文件加载到我的 GJS 应用程序中时,如何发送和接收信号?

我有一个应用程序需要打开一个文件并相应地更新 UI 元素。我可以选择并打开文件(并记录文件内容),但我不能告诉 UI 元素更新。

我试过读到我可以为几乎任何对象创建和添加信号,但我需要从导入库中的函数发出信号。

我正在尝试做这样的事情:(在我从磁盘读取文件的函数中)

(在主应用程序类中)

运行应用程序时我没有收到任何错误,但从未调用更新函数。我怎样才能让信号通过?

这是 main.js 文件中应该捕获信号的代码:

这是发出信号的标题栏文件:

它不是一个类,只是一个静态库......它是由 main.js 文件导入的,所以我认为范围是相同的,但可能不是......

0 投票
1 回答
271 浏览

gtk - GJS/GTK Why can't I replace gtk treeview model (columns)?

I am starting off with an empty table (liststore with one column)

beginning state with empty table

I want users to be able to import a CSV file and have the contents displayed. Importing the file works and the CSV data is indeed displayed, but the original column (titled "No Data") stays. How do I get rid of it?

Table with retained

I have tried removing the tree view element and even the containers (but when I do that I can't get them to display again...

I saw in the gtk docs that replacing treeView.set_model(listStore) should completely replace the existing model and columns, but it doesn't seem to...

what I'm doing now is this:

Then, when the csv file is uploaded I try to update the table with something like this:

Why is that initial column still there? how do I get rid of it?

Thanks in advance for any help or pointers.

0 投票
1 回答
159 浏览

javascript - 未知选项 -D Gjs

Gjs 文档说gjs -D -S example.js将启动一个调试器,但是当我执行相同的操作时会出现以下错误

我正在使用带有 gnome 3.28.2 和 Gjs 1.52.5 的 Ubuntu 18.10。