有没有办法在GTK_RESPONSE_OK
中使用预定义的响应(例如GtkDialog
),而无需对ID进行硬编码?默认情况下,Glade会在那里生成带“0”的XML,并为我提供一个数字条目。虽然我想我可以输入-5,但这似乎打败了一个常数。
Glade XML看起来像这样:
<action-widgets>
<action-widget response="0">cancel-button</action-widget>
<action-widget response="0">connect-button</action-widget>
</action-widgets>
<action-widgets>
<action-widget response="3">button_ok</action-widget>
<action-widget response="-5">button_cancel</action-widget>
</action-widgets>
(这有点搞笑,因为他们使用-5(GTK_RESPONSE_OK
)代表“button_cancel
”......)
答案 0 :(得分:1)
从GTK 3.12开始,您可以使用nck-names作为响应。
commit baa471ec130c360a5c4ae314769bc7b858814219
Author: Jasper St. Pierre <jstpierre@mecheye.net>
Date: Mon Oct 28 11:19:43 2013 -0400
gtkdialog: Allow specifying response IDs by nick in <action-widgets>
This makes it a lot more convenient for developers, as they don't
have to look up the numeric value of response IDs.
所以你现在可以做到
<action-widgets>
<action-widget response="ok">button_ok</action-widget>
<action-widget response="cancel">button_cancel</action-widget>
</action-widgets>