2013-08-18 6 views
5

Gibt es eine Möglichkeit, eine vordefinierte Antwort (z. B. GTK_RESPONSE_OK) in einer GtkDialog zu verwenden, ohne die ID fest zu codieren? Glade erzeugt dort standardmäßig XML mit "0" und gibt mir eine numerische Eingabe. Während ich annehmen könnte, dass ich -5 eingeben könnte, scheint das den Punkt zu besiegen, eine Konstante zu haben.Verwenden einer vordefinierten Antwort-ID in einem GtkDialog in einem GtkBuilder XML?

Die Glade XML sieht wie folgt aus:

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

Auch 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> 

(was etwas ist komisch, da sie verwenden -5 (GTK_RESPONSE_OK) für "button_cancel" ...)

+0

Ich weiß nicht, ob es ist, aber wenn es nicht der Fall ist, das sieht aus wie Feature-Request-Material. – OdraEncoded

+0

siehe auch http://stackoverflow.com/questions/2725810/glade-3-standard-button-layout – GutenYe

Antwort

1

Seit GTK 3.12 können Sie nck-Namen für die Antwort verwenden.

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. 

so können Sie jetzt

tun
<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