2013-08-18 16 views
5

是否有任何的方式來使用在GtkDialog一個預定義的響應(例如,GTK_RESPONSE_OK),而無需硬編碼ID? Glade默認生成帶有「0」的XML,並給我一個數字輸入。雖然我想我可以輸入-5,但這似乎打破了常數。在GtkBuilder XML的GtkDialog中使用預定義的響應ID?

林間空地XML看起來是這樣的:

<action-widgets> 
    <action-widget response="0">cancel-button</action-widget> 
    <action-widget response="0">connect-button</action-widget> 
</action-widgets> 

即使the example in the docs

<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

我不知道是否有,但如果沒有,這看起來像功能要求的材料。 – OdraEncoded

+0

也參見http://stackoverflow.com/questions/2725810/glade-3-standard-button-layout – GutenYe

回答

1

因爲GTK 3.12可以爲響應使用NCK-名。

commit baa471ec130c360a5c4ae314769bc7b858814219 
Author: Jasper St. Pierre <[email protected]> 
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> 
+0

https://developer.gnome.org/gtk3/stable/GtkDialog.html – AAAfarmclub

相關問題