1

一个月前,我听说了用于 GNOME 3 的 GJS,我想尝试一下。我想做什么?带有 GJS 的 GNOME 3 的简单媒体播放器。

所以,基地已经被编程,例如:

  • 创建 ListStore 并将其连接到 TreeView 对象
  • OpenFile 对话框 - 选择 MP3/OGG​​/WAV 文件
  • 从 OpenFile Dialog 获取文件名和 URI 并将其放入 Gtk.ListStore 对象
  • 当文件被选中(在 TreeView 对象中)时,Gst 对象从当前选定的行中获取 URI。

现在的问题是我想手动更改 TreeView 对象中选定的行(当用户按下前进或后退按钮时),我不知道如何执行此操作。

我在官方的 GNOME-Docs 和非官方的 Seed文档中查找了它,然后谷歌搜索了它,但没有任何结果。我试图用 GNOME 3 的 C-Docs 找到它,但仍然没有。

我希望有人可以帮我解决这个“小”问题。:)

简单音乐播放器的链接。

4

2 回答 2

1

好的,我刚刚找到了答案:

// Get the selection from the Gtk.TreeView Object
this.selection = this._soundList.get_selection ();
// Get the bool "isSelected", the model and the Iter from this.selection.get_selected()
let [ isSelected, model, iter ] = this.selection.get_selected();
// Get the previous row in the list (iter_next(iter) for the next row)
this._listStore.iter_previous(iter);
// The selection should get updated
this.selection.select_iter(iter);
// Get the URI from the Gtk.ListStore Object
this.sound.uri = this._listStore.get_value (iter, 1);

我希望这将帮助那些需要它的人。

于 2013-03-29T18:03:07.187 回答
1

有很好的例子: https ://github.com/optimisme/gjs-examples

使用“TreeView”的是 egList.js,但 egOpen.js 也有一个使用 Gtk.ListStore、Gtk.CellRendererTex 和 Gtk.TreeIter 的 Gtk.ComboBox 来自一个“更改”事件。

于 2015-02-26T07:29:08.140 回答