7

How do you link the buttons of a dialog window (GtkDialog for example) with a response Gtk::ResponseType value with Glade?.

I know how to do it programmatically but I can not find out how to do it with Glade.

In short I have to create the ui file with a GtkDialog and with two buttons in the actions area with the ids button_ok and button_cancel for example. And after that I edit the file and add those lines :

<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkDialog" id="dialog1">
  <!-- the objects added by Glade -->

  <!-- What I need to add -->
  <action-widgets>
      <action-widget response="cancel">button_cancel</action-widget>
      <action-widget response="ok" default="true">button_ok</action-widget>
  </action-widgets>
  <!-- What I need to add -->

  </object>
</interface>

Is there a way to do this through the interface of Glade ?

cedlemo
  • 3,205
  • 3
  • 32
  • 50

1 Answers1

7

Response ID is the second option under Button Attributes.

Blake
  • 368
  • 1
  • 11
  • That works even if a question remains (before I accept your answer): why in the GtkDialog documentation they use response="cancel" whereas you only can use numbers in Glade? – cedlemo May 03 '16 at 13:06
  • It looks like if you're using GTK 3.14+ you can. http://stackoverflow.com/questions/18297382/using-a-predefined-response-id-in-a-gtkdialog-in-a-gtkbuilder-xml – Blake May 03 '16 at 14:17
  • Yes but it looks like those nickname can not be set/used via Glade which manage only response ID as integer. – cedlemo May 03 '16 at 16:04
  • Hello @cedlemo, I realized I would have really liked a mechanism where, similarly to the arbitrary names I give to my widgets in glade and that I can later access with the gtk builder, I could give arbitrary names to the dialog responses and test those names in my code rather than those obscure ints that I am currently using. Did you find a way to do this since 2016? Thanks. – gameboo Dec 18 '17 at 01:53