标签: libgee

包含方法作为值的Gee HashMap

我正在尝试填充一个Libgee HashMap,其中每个条目都有一个字符串作为键,一个函数作为值.这可能吗?我想要这样的事情:

var keybindings = new Gee.HashMap<string, function> ();
keybindings.set ("<control>h", this.show_help ());
keybindings.set ("<control>q", this.explode ());
Run Code Online (Sandbox Code Playgroud)

所以我最终可以这样做:

foreach (var entry in keybindings.entries) {
    uint key_code;
    Gdk.ModifierType accelerator_mods;
    Gtk.accelerator_parse((string) entry.key, out key_code, out accelerator_mods);      
   accel_group.connect(key_code, accelerator_mods, Gtk.AccelFlags.VISIBLE, entry.value);
}
Run Code Online (Sandbox Code Playgroud)

但也许这不是最好的方法?

vala genie libgee

6
推荐指数
1
解决办法
816
查看次数

试图制作一个清单:名称"Gee"不存在

我正试图在Genie中列出一个列表并且它似乎不起作用.编译代码:

[indent=2]
init
  var l = new list of string
Run Code Online (Sandbox Code Playgroud)

产生这些错误:

someone@someone-UBook:~/Documents$ valac helloworld.gs helloworld.gs:2.10-2.24: error: The name `Gee' does not exist in the context of `main'
    var l = new list of int
            ^^^^^^^^^^^^^^^
helloworld.gs:2.8-2.24: error: var declaration not allowed with non-typed initializer
    var l = new list of int
          ^^^^^^^^^^^^^^^^^
Compilation failed: 2 error(s), 0 warning(s)
Run Code Online (Sandbox Code Playgroud)

我已经安装了libgee2(通过sudo apt-get install libgee2),没有任何改变.有任何想法吗?

vala genie libgee

2
推荐指数
1
解决办法
519
查看次数

标签 统计

genie ×2

libgee ×2

vala ×2