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

1

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 ?

Latin answered 2/5, 2016 at 14:31 Comment(0)
A
7

Response ID is the second option under Button Attributes.

Antipathy answered 3/5, 2016 at 12:46 Comment(4)
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?Latin
It looks like if you're using GTK 3.14+ you can. #18297882Antipathy
Yes but it looks like those nickname can not be set/used via Glade which manage only response ID as integer.Latin
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.Biogeochemistry

© 2022 - 2024 — McMap. All rights reserved.