Search code examples
gtkgtk3glade

With Glade in a dialog window, how do you add response for buttons


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 ?


Solution

  • Response ID is the second option under Button Attributes.