Difference between revisions of "Builder Files"
Line 12: | Line 12: | ||
* Changing "True" to "1", "False" to "0" | * Changing "True" to "1", "False" to "0" | ||
* Changing '"' to &quot; and <nowiki>'''</nowiki> to '. | * Changing '"' to &quot; and <nowiki>'''</nowiki> to &apos;. | ||
* Removing properties with default values, e.g.: | * Removing properties with default values, e.g.: | ||
** "can-focus" == False | ** "can-focus" == False |
Revision as of 07:24, 18 August 2023
Gtk allows one to define the UI interface using "Builder" files. "Builder" files are XML files that describe widget layout, menus, etc.
Builder files should end with .ui but many of ours end with .glade as the UI creater program Glade was used to create them. Glade works only with Gtk3. Cambalache is a Glade replacement that works with both Gtk3 and Gtk4.
Tools
gtk-builder-tool
Allows one to simplify or examine Gtk3 builder files. Using the simplify option over our builder files results in:
- Changing "True" to "1", "False" to "0"
- Changing '"' to " and ''' to '.
- Removing properties with default values, e.g.:
- "can-focus" == False
- "label-xalign" == 0
- "receives-default" == False
- "expand" == False
- "fill" == True
- "position" == 0
- Removing unneeded <packing>...</packing> (where all properties are default).
- Removing <child><placeholder/></child> and <placeholder/>
- Moving <!-- n-columns=x n-rows=y --> comment to before <child>.
- Replacing underscores by hyphens in property names.
gtk-builder-tool does not understand the "child" property (in GtkScrolledWindow, GtkViewPort).
gtk-builder-tool also removes a few necessary 'xalign' properties.
One can use a script to restore "True", "False", '"', and ''' (the latter to avoid changing translatable strings). It works except for the property 'active' which can be a boolean (CheckButton) or an 'int' (ComboBox).
gtk4-builder-tool
In addition to the uses of gtk-builder-tool, gtk4-bulder-tool has a --3to4 option that converts gtk3 builder files to gtk4 builder files, the conversion is not perfect. In particular, it does not remove properties it doesn't recognize.
Using the --3to4 results in:
- Replacing <requires lib="gtk+" version="3.24"/> with <requires lib="gtk" version="4.0"/>
- Changes <attribute name='xxx'... to <attribute name="xxx"...
- Removing the property "visible" when its value is "True" (widgets are visible by default in Gtk4).
- Replacing the property "can-focus" with value "True" by the property "focusable" with value 1.
- Removing <packing>...</packing> for GtkBox.
- Replacing <object>...</object><packing>...</packing> by <object>...<layout>...</layout></object> for GtkGrid.
- Changing <child>...</child> to <property name="child">...</property> for child of GtkFlowBoxChild and GtkViewPort.
- Changing the property "margin" to the four properties "margin-start", "margin-end", "margin-top", and "margin-bottom".
- Adding the property "draw-value" with value 1 for GtkScale.
- Adding the property "visible" with value 0 to GtkFlowBoxChild.
Properties not supported in Gtk4 and not replaced:
- GtkAspectFrame::label-xalign
- GtkAspectFrame::shadow-type
- GtkBox::double-buffered
- GtkBox::events
- GtkBox::no-show-all
- GtkButton::always-show-image
- GtkButtonBox::can-focus
- GtkButtonBox::hexpand
- GtkButtonBox::layout-style
- GtkButtonBox::visible
- GtkButton::can-default
- GtkButton::image
- GtkButton::image-position
- GtkButton::no-show-all
- GtkButton::relief
- GtkButton::use-stock
- GtkCellRendererPixbuf::stock_size
- GtkCheckButton::image
- GtkCheckButton::no-show-all
- GtkDialog::gravity
- GtkDialog::has-resize-grip
- GtkDialog::skip-taskbar-hint
- GtkDialog::type-hint
- GtkDialog::type_hint
- GtkDialog::window-position
- GtkEntry::caps-lock-warning
- GtkEntry::no_show_all
- GtkEventBox::can-focus
- GtkEventBox::can_focus
- GtkEventBox::halign
- GtkEventBox::hexpand
- GtkEventBox::name
- GtkEventBox::no-show-all
- GtkEventBox::valign
- GtkEventBox::visible
- GtkEventBox::visible-window
- GtkExpander::label-fill
- GtkFlowBox::no-show-all
- GtkFrame::shadow-type
- GtkGrid::no-show-all
- GtkImage::no-show-all
- GtkImage::stock
- GtkLabel::no-show-all
- GtkLabel::no_show_all
- GtkLabel::ypad
- GtkLinkButton::relief
- GtkMenuButton::draw-indicator
- GtkMenuButton::image
- GtkMenuButton::no-show-all
- GtkMenuButton::popup
- GtkMenuButton::relief
- GtkMenuButton::use-popover
- GtkMenu::can-focus
- GtkMenuItem::can-focus
- GtkMenuItem::use-underline
- GtkMenuItem::visible
- GtkMenu::reserve-toggle-size
- GtkMenu::visible
- GtkModelButton::action-name
- GtkModelButton::action-target
- GtkModelButton::can-focus
- GtkModelButton::halign
- GtkModelButton::inverted
- GtkModelButton::receives-default
- GtkModelButton::visible
- GtkNotebook::double-buffered
- GtkNotebook::no-show-all
- GtkPopover::constrain-to
- GtkPopover::no-show-all
- GtkPopover::relative-to
- GtkPopover::transitions-enabled
- GtkRadioMenuItem::can-focus
- GtkRadioMenuItem::draw-as-radio
- GtkRadioMenuItem::group
- GtkRadioMenuItem::use-underline
- GtkRadioMenuItem::visible
- GtkScrolledWindow::double-buffered
- GtkScrolledWindow::no-show-all
- GtkScrolledWindow::shadow-type
- GtkScrolledWindow::shadow_type
- GtkScrolledWindow::window-placement-set
- GtkSearchEntry::can-default
- GtkSearchEntry::caps-lock-warning
- GtkSearchEntry::completion
- GtkSearchEntry::is-focus
- GtkSearchEntry::primary-icon-activatable
- GtkSearchEntry::primary-icon-name
- GtkSearchEntry::primary-icon-sensitive
- GtkSeparatorMenuItem::can-focus
- GtkSeparatorMenuItem::margin-bottom
- GtkSeparatorMenuItem::margin-top
- GtkSeparatorMenuItem::visible
- GtkSpinButton::caps-lock-warning
- GtkSpinButton::input-purpose
- GtkSpinner::active
- GtkToggleButton::always-show-image
- GtkToggleButton::image
- GtkToggleButton::no-show-all
- GtkToggleButton::relief
- GtkToggleButton::use-action-appearance
- GtkToolItem::can-focus
- GtkToolItem::visible
- GtkTreeView::no_show_all
- GtkViewport::shadow-type
- GtkWindow::can_default
- GtkWindow::gravity
- GtkWindow::is_focus
- GtkWindow::urgency_hint
- GtkWindow::window-position
- GtkWindow::window_position