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().
When a %G_IO_ERROR_CANT_CREATE_BACKUP error occurs while saving location,
offer two possible actions:
the #GFile for which the backup failed to be created.
must be a %G_IO_ERROR_CANT_CREATE_BACKUP.
Creates a warning about location
having changed on disk. The possible
actions:
document_modified,
"Reload" or "Drop changes and reload":
%GTK_RESPONSE_OK.the #GFile for which there has been an external modification.
whether the document (e.g. the #GtkTextBuffer) has unsaved modifications.
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.
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.
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.
a #PangoFontDescription.
A #GBindingTransformFunc to transform between these two #GValue types:
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.
a #GBinding.
the #GValue containing the value to transform.
the #GValue in which to store the transformed value.
data passed to the transform function.
Synchronously creates parent directories of file,
so that file
can be
saved.
a file
optional #GCancellable object, %NULL to ignore.
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().
the uri to decode
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.
a #GFile.
a #GCancellable.
the callback to call when the operation is finished.
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).
a #GFile.
a #GAsyncResult.
Examples:
a filename.
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
.
a filename.
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()).
a #GtkListBox.
non-%NULL callback function.
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.
a #GtkListBox.
the index of the row, starting at 0. The index is among the filtered rows only.
non-%NULL callback function.
Scrolls to a specific #GtkListBoxRow.
Before using this function, tepl_utils_list_box_setup_scrolling() must have been called.
a #GtkListBox.
a #GtkListBoxRow.
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.
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.
a #GtkListBox.
a #GtkScrolledWindow.
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().
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.
a nul-terminated UTF-8 string.
Replaces the home directory with a tilde, if the home directory is present in
the filename
.
the filename.
Like tepl_utils_str_middle_truncate() but the “…” character is at the end.
a UTF-8 string.
truncate the string at that length, in UTF-8 characters (not bytes).
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
.
a UTF-8 string.
truncate the string at that length, in UTF-8 characters (not bytes).
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
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.