Gjsify LogoGjsify Logo

Index

Enumerations

Classes

Interfaces

Variables

Functions

Variables

UTILS_STYLE_PROVIDER_PRIORITY_LIBRARY: number

A priority that can be used when adding a #GtkStyleProvider for library-specific style information.

Has a higher priority than %GTK_STYLE_PROVIDER_PRIORITY_SETTINGS and a lower priority than %GTK_STYLE_PROVIDER_PRIORITY_APPLICATION.

The Tepl library uses this priority for its #GtkStyleProvider's.

Functions

  • finalize(): void
  • Free the resources allocated by Tepl. For example it unrefs the singleton objects.

    This function also calls amtk_finalize() and gtk_source_finalize().

    It is not mandatory to call this function, it's just to be friendlier to memory debugging tools. This function is meant to be called at the end of main(). It can be called several times.

    Returns void

  • init(): void
  • Initializes the Tepl library (e.g. for the internationalization).

    This function can be called several times, but is meant to be called at the beginning of main(), before any other Tepl function call.

    This function also calls amtk_init() and gtk_source_init().

    Returns void

  • When a %G_IO_ERROR_CANT_CREATE_BACKUP error occurs while saving location, offer two possible actions:

    • Save anyway: %GTK_RESPONSE_YES.
    • Don't save: %GTK_RESPONSE_CANCEL.

    Parameters

    • location: Gio.File

      the #GFile for which the backup failed to be created.

    • error: GLib.Error

      must be a %G_IO_ERROR_CANT_CREATE_BACKUP.

    Returns Tepl.InfoBar

  • io_error_info_bar_externally_modified(location: Gio.File, document_modified: boolean): Tepl.InfoBar
  • Creates a warning about location having changed on disk. The possible actions:

    • Depending on document_modified, "Reload" or "Drop changes and reload": %GTK_RESPONSE_OK.
    • A close button as added with gtk_info_bar_set_show_close_button().

    Parameters

    • location: Gio.File

      the #GFile for which there has been an external modification.

    • document_modified: boolean

      whether the document (e.g. the #GtkTextBuffer) has unsaved modifications.

    Returns Tepl.InfoBar

  • Creates a warning about location being already open in another window, offering two possible actions:

    • Edit anyway: %GTK_RESPONSE_YES.
    • Don't edit: %GTK_RESPONSE_CANCEL.

    Parameters

    • location: Gio.File

      the #GFile already open in another window.

    Returns Tepl.InfoBar

  • For file saving, creates a warning about invalid characters that can corrupt the file. Possible actions:

    • Save anyway: %GTK_RESPONSE_YES.
    • Don't save: %GTK_RESPONSE_CANCEL.

    Parameters

    • location: Gio.File

      where to save the document.

    Returns Tepl.InfoBar

  • Gets the indentation, as a string, of the line at iter. iter can be anywhere in the line.

    Possible use-case: to implement an action that inserts some text in a #GtkTextBuffer. If the text to insert spans multiple lines, it is usually desired to keep the same indentation level.

    Parameters

    Returns string

  • menu_shell_append_edit_actions(menu_shell: Gtk.MenuShell): void
  • Appends #GtkMenuItem's to menu_shell for the following #GAction's:

    • "win.tepl-cut"
    • "win.tepl-copy"
    • "win.tepl-paste"
    • "win.tepl-delete"
    • "win.tepl-select-all"

    See the [list of GActions implemented in TeplApplicationWindow][tepl-application-window-gactions]. This function correctly uses the %AMTK_FACTORY_IGNORE_ACCELS_FOR_APP flag to create the #GtkMenuItem's.

    Parameters

    Returns void

  • This function will generate CSS suitable for the GTK CSS engine based on the properties of the #PangoFontDescription.

    The returned string contains only the CSS declarations, it is not a complete CSS rule set. So the selector and curly braces are not present. Each declaration, including the last one, ends with a semicolon.

    See also tepl_utils_override_font().

    Parameters

    Returns string

  • utils_binding_transform_func_smart_bool(binding: Binding, from_value: any, to_value: any, user_data: object): boolean
  • A #GBindingTransformFunc to transform between these two #GValue types:

    • A #GValue of type #gboolean.
    • A #GValue of type #GVariant, with the #GVariant of type boolean.

    For convenience, this function works in both directions (hence the “smart”), it introspects the types of from_value and to_value.

    Note that if from_value and to_value are of the same #GValue type, this function won't work and you shouldn't use a custom #GBindingTransformFunc in the first place.

    Parameters

    • binding: Binding

      a #GBinding.

    • from_value: any

      the #GValue containing the value to transform.

    • to_value: any

      the #GValue in which to store the transformed value.

    • user_data: object

      data passed to the transform function.

    Returns boolean

  • Synchronously creates parent directories of file, so that file can be saved.

    Parameters

    Returns boolean

  • utils_decode_uri(uri: string): [boolean, string, string, string, string, string]
  • Parse and break an uri apart in its individual components like the uri scheme, user info, host, port and path. The return value pointer can be %NULL to ignore certain parts of the uri. If the function returns %TRUE, then all return value pointers should be freed using g_free().

    Parameters

    • uri: string

      the uri to decode

    Returns [boolean, string, string, string, string, string]

  • The asynchronous version of g_file_query_exists(). When the operation is finished, callback will be called. You can then call tepl_utils_file_query_exists_finish() to get the result of the operation.

    Parameters

    Returns void

  • Finishes the operation started with tepl_utils_file_query_exists_async(). There is no output #GError parameter, so you should check if the operation has been cancelled (in which case %FALSE will be returned).

    Parameters

    Returns boolean

  • utils_get_file_extension(filename: string): string
  • Examples:

    • "file.pdf" returns ".pdf".
    • "file.PDF" returns ".pdf".
    • "file.tar.gz" returns ".gz".
    • "path/to/file.pdf" returns ".pdf".
    • "file" (without an extension) returns "" (the empty string).

    Parameters

    • filename: string

      a filename.

    Returns string

  • utils_get_file_shortname(filename: string): string
  • Returns filename without its extension. With the “extension” having the same definition as in tepl_utils_get_file_extension(); in other words it returns the other part of filename.

    Parameters

    • filename: string

      a filename.

    Returns string

  • Gets an array of all the #GtkListBoxRow childen of list_box for which filter_func returns %TRUE. The elements in the array are sorted by increasing index order (as returned by gtk_list_box_row_get_index()).

    Parameters

    Returns [Gtk.ListBoxRow[] | null, number]

  • This function has the same semantics as gtk_list_box_get_row_at_index(), but it takes into account only the rows for which filter_func returns %TRUE.

    As an example, if index is 0, it returns the first #GtkListBoxRow for which filter_func returns %TRUE.

    Parameters

    • list_box: Gtk.ListBox

      a #GtkListBox.

    • index: number

      the index of the row, starting at 0. The index is among the filtered rows only.

    • filter_func: Gtk.ListBoxFilterFunc

      non-%NULL callback function.

    Returns Gtk.ListBoxRow | null

  • Scrolls to a specific #GtkListBoxRow.

    Before using this function, tepl_utils_list_box_setup_scrolling() must have been called.

    Parameters

    Returns void

  • utils_list_box_scroll_to_selected_row(list_box: Gtk.ListBox): void
  • Calls tepl_utils_list_box_scroll_to_row() on the row returned by gtk_list_box_get_selected_row(). This function assumes that there is either zero or one selected row.

    Before using this function, tepl_utils_list_box_setup_scrolling() must have been called.

    Parameters

    Returns void

  • Setup vertical scrolling between list_box and scrolled_window, to be able to use tepl_utils_list_box_scroll_to_row() afterwards.

    This function is intended to be called only once per #GtkListBox, when initializing the list_box and scrolled_window widgets.

    Parameters

    Returns void

  • utils_markup_escape_text(src: string): string | null
  • The same as g_markup_escape_text(), but with an implementation that fully supports round-trip integrity. I.e. when #GMarkupParser or any other XML parser will decode/unescape the string, the exact same string as src will be brought back. As long as src is a valid UTF-8 string.

    The other difference with g_markup_escape_text() is that the length parameter is not present for tepl_utils_markup_escape_text().

    g_markup_escape_text() doesn't fully support round-trip integrity

    In fact, g_markup_escape_text() doesn't escape the tabstop, newline and carriage return characters. And the #GMarkupParser correctly processes whitespace and line endings according to the XML rules for normalization of line endings and attribute values.

    For example "\t" (a tab) after a round-trip through g_markup_escape_text() and #GMarkupParser becomes a simple space.

    Parameters

    • src: string

      a nul-terminated UTF-8 string.

    Returns string | null

  • utils_override_font(widget: Gtk.Widget, font_str: string): void
  • A replacement for gtk_widget_override_font(). Because gtk_widget_override_font() is deprecated but was useful.

    See pango_font_description_from_string() for a description of the format of the string representation for font_str.

    This function uses tepl_pango_font_description_to_css() and applies the CSS to the #GtkStyleContext of widget.

    Parameters

    • widget: Gtk.Widget

      a #GtkWidget.

    • font_str: string

      a string representation of a #PangoFontDescription, or %NULL to undo the effect of previous calls to this function on widget.

    Returns void

  • utils_replace_home_dir_with_tilde(filename: string): string
  • Replaces the home directory with a tilde, if the home directory is present in the filename.

    Parameters

    • filename: string

      the filename.

    Returns string

  • utils_str_end_truncate(str: string, truncate_length: number): string
  • Like tepl_utils_str_middle_truncate() but the “…” character is at the end.

    Parameters

    • str: string

      a UTF-8 string.

    • truncate_length: number

      truncate the string at that length, in UTF-8 characters (not bytes).

    Returns string

  • utils_str_middle_truncate(str: string, truncate_length: number): string
  • If str is longer than truncate_length, then this function returns str truncated in the middle with a “…” character. Otherwise it just returns a copy of str.

    Parameters

    • str: string

      a UTF-8 string.

    • truncate_length: number

      truncate the string at that length, in UTF-8 characters (not bytes).

    Returns string

  • utils_str_replace(string: string, search: string, replacement: string): string
  • Replaces all occurences of search by replacement.

    The function does only one pass, for example: |[ tepl_utils_str_replace ("aaaa", "aa", "a");


    returns "aa", not "a".
    @param string a string
    @param search the search string
    @param replacement the replacement string

    Parameters

    • string: string
    • search: string
    • replacement: string

    Returns string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method