Skip to content

Custom widgets

Alessandro Iepure edited this page Feb 25, 2023 · 4 revisions

Jump to

UtilityTitle

Description

This widget is used to show the title with a short description of each tool. A button is available to mark the tool as a favorite(not implemented yet).
GtkBuildable interface is provided by the UtilityTitle class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
title Title of the tool. string ""
description Description of the tool. string ""
tool-name Unique name used to identify the tool. Required. string ""

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
added-favorite source_widget Emited when the tool is added to the favorites list. Not implemented.
removed-favorite source_widget Emited when the tool is removed from the favorites list. Not implemented.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
set_title(title:str) Sets the value of the property title. -
get_title() Returns the value of the property title. string
set_description(description:str) Sets the value of the property description. -
get_description() Returns the value of the property description. string
set_tool_name(tool_name:str) Sets the value of the property tool-name. -
get_tool_name() Returns the value of the property tool-name string

⬆️ top

SidebarItem

Description

This widget is used as the row in the navigation sidebar to switch between tools in the same category.
GtkBuildable interface is provided by the SidebarItem class inside the <object> tag.

Properties

All the properties inherited from GtkListBoxRow plus the following:

Name Description Type Default value
tool-name Unique name of the tool associated. string ""
title Name to show in the sidebar. string ""
icon-name Name of the icon. string ""
tool-tip Text to display when hovering over with the cursor. string ""

Signals

All the signals are inherited from GtkListBoxRow](https://docs.gtk.org/gtk4/class.ListBoxRow.html#signals). This widget does not define custom signals.

Methods

All the methods inherited from GtkListBoxRow plus the following:

Name Description Return type
get_tool_name() Returns the value of the property tool-name. string
get_title() Returns the value of the property title. string
get_icon_name() Returns the value of the property icon name. string
get_tool_tip() Returns the value of the property tool-tip string

⬆️ top

EntryRow

Description

Same as AdwEntryRow with added copy, paste and clear buttons.
GtkBuildable interface is provided by the EntryRow class inside the <object> tag.

Properties

All the properties inherited from AdwEntryRow plus the following:

Name Description Type Default value
show-clear-btn Shows or hides the clear button. boolean False
show-copy-btn Shows or hides the copy button. boolean False
show-paste-btn Shows or hides the paste button. boolean False

Signals

All the signals inherited from AdwEntryRow plus the following:

Name Parameters Description
cleared source_widget Emited when the user clicks the clear button.

Methods

All the signals inherited from AdwEntryRow plus the following:

Name Description Return type
clear() Clears the text from the widget and removes additional css classes. -

⬆️ top

BinarySelector

Description

This widget contains 2 buttons of which one is always selected. Useful to make binary selections.
GtkBuildable interface is provided by the BinarySelector class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
left-lbl Label of the left button. string ""
right-lbl Label of the right button. string ""
left-btn-active Whether or not the left button is active. Only one button can be active, setting both left-btn-active and right-btn-active will enable the last written. boolean True
right-btn-active Whether or not the right button is active. Only one button can be active, setting both left-btn-active and right-btn-active will enable the last written. boolean False

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
toggled source_widget Emited when the user clicks the inactive button.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
get_left_btn_active() Returns the value of the property left-btn-active. boolean
get_right_btn_active() Returns the value of the property right-btn-active. boolean
get_left_btn() Returns the left button object. GtkButton
get_right_btn() Returns the right button object. GtkButton

⬆️ top

FileView

Description

This widget shows the path and size of a file graphically.
GtkBuildable interface is provided by the FileView class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
file-path Path of the represented file. string ""
file-size Size of the represented file in a human-readable format (i.e. 2GB). string ""

Signals

All the signals are inherited from AdwBin](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.2/class.Bin.html#signals). This widget does not define custom signals.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
get_file_path() Returns the value of the property file_path. string
set_file_path(file_path:str) Sets the value of the property file_path. -
get_file_size() Returns the value of the property file_size. string
set_file_size(file_size:str) Sets the value of the property file_size. -

⬆️ top

DateArea

Description

Widget containing a series of GtkSpinButton to show times and dates. A button to set the current time and date is also provided.
GtkBuildable interface is provided by the DateArea class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
name Title of the area string ""

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
now-clicked source_widget Emited when the user clicks the now button.
value-changed source_widget Emited when the user changes one of the GtkSpinButtons.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
get_date() Returns the time and date currently set in the GtkSpinButtons as separate pieces. (int, int, int, int, int, int)
set_date(year:int, month:int, day:int, hours:int, minutes:int, seconds:int) Sets the value of the GtkSpinButtons corresponding on the input given. -

⬆️ top

SpinArea

Description

Widget with a single large GtkSpinButton used to input numeric values. Buttons to copy and paste as well as a custom action button are provided.
GtkBuildable interface is provided by the SpinArea class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
name Title of the area. string ""
show-spinner Shows or hides the loading spinner next to the buttons. boolean False
show-copy-btn Shows or hides the copy button. boolean False
show-paste-btn Shows or hides the paste button. boolean False
show-action-btn Shows or hides the custom action button. boolean False
action-btn-name Label used as the text for the custom button. string ""
action-btn-tooltip Text to display when hovering over the custom action with the cursor. string ""

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
action-clicked source_widget Emited when the user clicks the custom action button.
value-changed source_widget Emited when the user changes the GtkSpinButton.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
get_value() Returns the current value of the GtkSpinButton. int
set_value(value:int) Sets the value of the GtkSpinButton. -

⬆️ top

TextArea

Description

Widget with the ability to display and accept text inside a GtkSourceView. Buttons to open files, copy, paste and clear are provided and are directly handled by the widget. A customizable action button is also available.
Text syntax highlighting is possible by setting the property text-syntax-highlight and by specifying the language to be used in text_language_highlight.
GtkBuildable interface is provided by the TextArea class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
name Title of the widget. string ""
show-spinner Shows or hides the loading spinner next to the buttons. boolean False
show-clear-btn Shows or hides the clear button. boolean False
show-copy-btn Shows or hides the copy button. boolean False
show-paste-btn Shows or hides the paste button. boolean False
show-open-btn Shows or hides the open file button. boolean False
show-action-btn Shows or hides the custom button. boolean False
action-btn-name Label used as the text for the custom button. string ""
text-editable Whether or not the textbox is editable. boolean True
text-show-line-numbers Shows or hides the left gutter with line numbers in the textbox. boolean False
text-highlight-current-line Whether or not to highlight the line where the cursor is located. boolean False
text-syntax-highlighting Whether or not to highlight the text according to the language set in text-language-highlight. boolean False
text-language-highlight Language used to syntax highlight the text. string ""
area-height Height of the textbox in pixels. integer 200
use-default-text-extensions Whether or not to use the default text extensions as supported ones in the open file dialog. At least one between this or use-custom-file-extensions must be enabled for the open file dialog to show any files. boolean False
use-custom-file-extensions Whether or not to use custom file extensions in the open file dialog. At least one between this or use-default-text-extensions must be enabled for the open file dialog to show any files. boolean False
custom-file-extensions List of file extensions without the leading . of the files to show in the open file dialog. As a GtkBuildable, the array items are specified as a newline-separated list:
<property name="custom-file-extensions">mp3
mp4
mkv
</property>
string array -
loading-label Label used for long operations blocking the use of the widget (i.e. File loading). string "Opening file..."
allow-drag-and-drop Whaether or not draging & dropping a file inside the widget opens it. boolean True

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
action-clicked source_widget Emited when the user clicks the custom action button.
text-changed source_widget Emited when the user causes a visible change in the text (i.e. types, pastes, deletes, etc.).
view-cleared source_widget Emited when the user clicks the clear button.
text-loaded source_widget Emited when the file chosen in the open file dialog is recognized as text and is finished loading.
big-file source_widget Emited when the file chosen in the open file dialog is larger than 512 Mb.
error source_widget
error_string
Emited when an error occurs inside the widget. The parameter error_string contains a description of the problem.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
get_text() Returns all the text currently present inside the widget. string
set_text(text:str) Sets the text inside the widget. -
get_buffer() Returns the buffer associated with the widget. GtkSourceBuffer
add_css_class(css_class_name:str) Wrapper around GtkWidget::add_css_class() to apply CSS classes only on the textbox. -
remove_css_class(css_class_name:str) Wrapper around GtkWidget::remove_css_class() to remove CSS classes only from the textbox. -
get_visible_view() Returns the name of the currently visible view. The only possible values are text-area and loading. string
set_visible_view(view_name:str) Sets the current visible view. The previous one is saved as _previous_view. The only possible values are text-area and loading. Values other than the ones specified will cause an error. -
set_text_language_highlight(language:str) Sets the value of the property text-language-highlight. -
set_loading_visible(enabled:bool, label:str) Sets the loading view directly without preserving the past state. The parameter label specifies the new label to show (loading-label). Use only when a change of the label is necessary, do not use it for normal view switching. -
set_spinner_spin(enabled:bool) Sets the value of the property show-spinner -
clear() Clears the text from the widget, removes additional CSS classes and sets the currently visible view to text-area. -

⬆️ top

TextFileArea

Description

Widget with the ability to display and accept text inside a GtkSourceView or to load a file from the file system. If the file is a supported image, a preview is shown instead of a generic icon.
Buttons to open files, copy, paste and clear are provided and are directly handled by the widget. A customizable action button is also available.
Text syntax highlighting is possible by setting the property text-syntax-highlight and by specifying the language to be used in text_language_highlight.
GtkBuildable interface is provided by the TextFileArea class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
name Title of the widget. string ""
show-spinner Shows or hides the loading spinner next to the buttons. boolean False
show-clear-btn Shows or hides the clear button. boolean False
show-copy-btn Shows or hides the copy button. boolean False
show-paste-btn Shows or hides the paste button. boolean False
show-open-btn Shows or hides the open file button. boolean False
show-save-btn Shows or hides the save file button. boolean False
show-action-btn Shows or hides the custom button. boolean False
action-btn-name Label used as the text for the custom button. string ""
text-editable Whether or not the textbox is editable. boolean True
text-show-line-numbers Shows or hides the left gutter with line numbers in the textbox. boolean False
text-highlight-current-line Whether or not to highlight the line where the cursor is located. boolean False
text-syntax-highlighting Whether or not to highlight the text according to the language set in text-language-highlight. boolean False
text-language-highlight Language used to syntax highlight the text. string ""
area-height Height of the textbox in pixels. integer 200
use-default-text-extensions Whether or not to use the default text extensions as supported ones in the open file dialog. At least one between this, use-default-image-extensions, use-all-file-extensions or use-custom-file-extensions must be enabled for the open file dialog to show any files. boolean False
use-default-image-extensions Whether or not to use the default image extensions as supported ones in the open file dialog. At least one between this, use-default-text-extensions, use-all-file-extensions or use-custom-file-extensions must be enabled for the open file dialog to show any files. boolean False
use-all-file-extensions Whether or not to show all files in the open file dialog. At least one between this, use-default-text-extensions, use-default-image-extensions or use-custom-file-extensions must be enabled for the open file dialog to show any files. boolean False
use-custom-file-extensions Whether or not to use custom file extensions in the open file dialog. At least one between this, use-default-text-extensions, use-default-image-extensions or use-all-file-extensions must be enabled for the open file dialog to show any files. boolean False
custom-file-extensions List of file extensions without the leading . of the files to show in the open file dialog. As a GtkBuildable, the array items are specified as a newline-separated list:
<property name="custom-file-extensions">mp3
mp4
mkv
</property>
string array -
loading-label Label used for long operations blocking the use of the widget (i.e. File loading). string "Opening file..."
allow-drag-and-drop Whaether or not draging & dropping a file inside the widget opens it. boolean True

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
action-clicked source_widget Emited when the user clicks the custom action button.
text-changed source_widget Emited when the user causes a visible change in the text (i.e. types, pastes, deletes, etc.).
view-cleared source_widget Emited when the user clicks the clear button.
text-loaded source_widget Emited when the file chosen in the open file dialog is recognized as text and is finished loading.
image-loaded source_widget Emited when the file chosen in the open file dialog is recognized as an image and is finished loading.
file-loaded source_widget Emited when the file chosen in the open file dialog is not recognized as text or an image and is finished loading as a generic file.
big-file source_widget Emited when the file chosen in the open file dialog is larger than 512 Mb. If this signal is emitted the file is always loaded as a generic one ignoring its content.
error source_widget
error_string
user_data
Emited when an error occurs inside the widget. The parameter error_string contains a description of the problem.
saved source_widget
saved_file_path
Emitted when the opened file is successfully saved. The parameter saved_file_path contains the path to the new file.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
get_text() Returns all the text currently present inside the widget. string
set_text(text:str) Sets the text inside the widget. -
get_buffer() Returns the buffer associated with the widget. GtkSourceBuffer
set_image(img_bytes:byte[]) Sets the image shown. -
set_opened_file(file_bytes:byte[], file_path:str) Sets the opened file and its content -
set_opened_file_path(file_path:str) Sets the opened file path -
get_opened_file_contents() Loads in memory all the content of the opened file. Large files might cause hangs or crashes. byte[]
get_opened_file_path() Returns the opened file path string
get_opened_file_size() Returns the opened file size in a human-readable format (i.e. 2GB). string
add_css_class(css_class_name:str) Wrapper around GtkWidget::add_css_class() to apply CSS classes only on the content of the area. -
remove_css_class(css_class_name:str) Wrapper around GtkWidget::remove_css_class() to remove CSS classes only from the content of the area. -
get_visible_view() Returns the name of the currently visible view. The only possible values are text-area and loading. string
set_visible_view(view_name:str) Sets the current visible view. The previous one is saved as _previous_view. The only possible values are text-area and loading. Values other than the ones specified will cause an error. -
set_text_language_highlight(language:str) Sets the value of the property text-language-highlight. -
set_loading_visible(enabled:bool, label:str) Sets the loading view directly without preserving the past state. The parameter label specifies the new label to show (loading-label). Use only when a change of the label is necessary, do not use it for normal view switching. -
set_spinner_spin(enabled:bool) Sets the value of the property show-spinner -
clear() Clears the text from the widget, removes additional css classes and sets the currently visible view to text-area. -

⬆️ top

ImageArea

Description

This widget is used to show an image. Buttons to open and clear are always shown. Save and view in an external program are available if enabled with show-save-btn and show-view-btn respectively. GtkBuildable interface is provided by the ImageArea class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
name Title of the widget. string ""
show-action-btn Shows or hides the custom button. boolean False
action-btn-name Label used as the text for the custom button. string ""
show-view-btn Shows or hides the button to open the image in an external program. boolean False
show-clear-btn Shows or hides the clear button. boolean False
show-save-btn Shows or hides the save file button. boolean False
show-open-btn Shows or hides the open file button. boolean False
loading-label Label used for long operations blocking the use of the widget (i.e. File loading). string "Opening file..."
allow-drag-and-drop Whaether or not draging & dropping a file inside the widget opens it. boolean True

Signals

All the signals inherited from AdwBin plus the following:

Name Parameters Description
action-clicked source_widget Emited when the user clicks the custom action button.
view-cleared source_widget Emited when the user clicks the clear button.
image-loaded source_widget Emited when the file chosen in the open file dialog is recognized as an image and is finished loading.
error source_widget
error_string
Emited when an error occurs inside the widget. The parameter error_string contains a description of the problem.
saved source_widget
saved_file_path
Emitted when the opened file is successfully saved. The parameter saved_file_path contains the path to the new file.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
clear() Clears the image and restores the widget to the initial state. -
set_file(file:GFile) Sets the file to be shown as the image. -
get_file() Gets the files shown as the image. GFile
set_visible_view(view_name:str) Sets the currently visible view. The only possible values are image and loading. Values other than the ones specified will cause an error. -
set_loading_lbl(loading_lbl:str) Sets the property loading-label. -
set_action_btn_sensitive(sensitive:bool) Sets if the custom action button is sensitive to user actions. -

⬆️ top

WebviewArea

Description

This widget is used to display a webkit webview to load HTML content. All user interactions are locked (context menu, reload, going backward/forward, file download, ecc.).

URLs pointing to sites other than the loaded one are opened in the system's default browser.
For example, if the loaded URL is https://www.example.com/homepage.html and the user clicks inside the page on a link to https://www.example.com/homepage.html#section1, this will be opened inside the webview, but if the user clicks a link pointing to https://another.link/, the default browser is going to handle it.

GtkBuildable interface is provided by the WebviewArea class inside the <object> tag.

Properties

All the properties inherited from AdwBin plus the following:

Name Description Type Default value
name Title of the widget. string ""
show-spinner Shows or hides the loading spinner on the widget's titlebar. boolean False

Signals

All the signals are inherited from AdwBin. This widget does not define custom signals.

Methods

All the methods inherited from AdwBin plus the following:

Name Description Return type
load_uri(uri:str) Loads the specified URI in the webview. -