3

How can I reorder widgets in the Glade widget tree?

For example, assume I have a Glade application that contains this partial tree:

box1 (GtkBox)
|--button1 (GtkButton)
|--button2 (GtkButton)
|--button3 (GtkButton)

How can I swap the position of e.g. button1 with e.g. button2, so that button2 will be above button1 in the UI?

strugee
  • 1,092

2 Answers2

1

Stumbled across this, and found that the accepted answer is incorrect, or at least is no longer correct in current versions of Glade.

From within Glade, you can adjust the Position property under the Packing tab, whose value determines the index of the widget within its parent.

So in OP's example:

box1 (GtkBox)
|--button1 (GtkButton) (Position: 0)
|--button2 (GtkButton) (Position: 1)
|--button3 (GtkButton) (Position: 2)

Each button would have a Position value of 0, 1, and 2 respectfully. If you were to change the Position value of button2 to 0, it would move it up and button1 would then have a Position value of 1, which changes the order both in the tree and how it is displayed in the designer and final application.

box1 (GtkBox)
|--button2 (GtkButton) (Position: 0)
|--button1 (GtkButton) (Position: 1)
|--button3 (GtkButton) (Position: 2)
1

Upon further investigation, it appears that you cannot modify the order from the widget tree panel. However, you can still modify order in the visual editor.

In the toolbar, there are a couple of buttons for selecting cursor modes. Click the button right after the cursor. It should have four arrows. Then click on the widget that you want to move, and drag it where you want to move it to.

strugee
  • 1,092