How can I set the label of a GtkLinkButton in Glade?

275 views Asked by At

I know how to do this in Python or C but I do not manage to do this in Glade:

self.reclamaTaAiciLinkButton =\
    self.get_object("reclamaTaAiciLinkButton")
self.reclamaTaAiciLinkButton.set_label("RECLAMA TA AICI")

This is a screenshot with all the available specific properties for the GtkLinkButton type in Glade:

Glade properties editor panel screenshot

If it is possible somehow by using the "Action Name" field, please give me an example. If it is possible by editing the Glade .ui file using a text editor, that would be better than nothing.

1

There are 1 answers

0
silviubogan On

I have found this pretty old bug in the official issue tracker of the Glade project which is entirely about this.

In the .ui file opened with a text editor you might have a fragment similar to this one, where a GtkLinkButton is declared and defined:

<object class="GtkLinkButton" id="reclamaTaAiciLinkButton">
    <property name="label" translatable="yes">button</property>
    <property name="visible">True</property>
    <property name="can_focus">True</property>
    <property name="receives_default">True</property>
    <property name="relief">none</property>
    <property name="uri">https://www.patreon.com/SilviuBogan</property>
    <style>
        <class name="reclamaTaAiciLinkButton"/>
    </style>
</object>

The important part is this:

<property name="label" translatable="yes">button</property>

If you close the .ui file in Glade, open the .ui file in a text editor (preferably an XML file editor) and then replace the contents of this <property> element from "button" to something else, then you save the file and reopen it in Glade, you see that in the Glade designer, the new label is visible. If you start the program that loads this .ui file, you will see that the changes are working.