Top |
gchar * tepl_utils_str_middle_truncate (const gchar *str
,guint truncate_length
);
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
.
str |
a UTF-8 string. |
|
truncate_length |
truncate the string at that length, in UTF-8 characters (not bytes). |
Since: 4.4
gchar * tepl_utils_str_end_truncate (const gchar *str
,guint truncate_length
);
Like tepl_utils_str_middle_truncate()
but the “…” character is at the end.
str |
a UTF-8 string. |
|
truncate_length |
truncate the string at that length, in UTF-8 characters (not bytes). |
Since: 4.4
gchar * tepl_utils_str_replace (const gchar *string
,const gchar *search
,const gchar *replacement
);
Replaces all occurences of search
by replacement
.
The function does only one pass, for example:
1 |
tepl_utils_str_replace ("aaaa", "aa", "a"); |
returns "aa", not "a".
Since: 4.4
gchar *
tepl_utils_markup_escape_text (const gchar *src
);
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 newly allocated string with the
escaped text, or NULL
if src
is not a valid UTF-8 string. Free with
g_free()
when no longer needed.
[transfer full][nullable]
Since: 5.0
gchar *
tepl_utils_get_file_extension (const gchar *filename
);
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).
Since: 4.4
gchar *
tepl_utils_get_file_shortname (const gchar *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
.
Since: 4.4
gchar *
tepl_utils_replace_home_dir_with_tilde
(const gchar *filename
);
Replaces the home directory with a tilde, if the home directory is present in
the filename
.
Since: 4.4
gboolean tepl_utils_decode_uri (const gchar *uri
,gchar **scheme
,gchar **user
,gchar **host
,gchar **port
,gchar **path
);
This function is deprecated, use the GUri functions instead.
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()
.
uri |
the uri to decode |
|
scheme |
return value pointer for the uri's
scheme (e.g. http, sftp, ...), or |
[out][optional] |
user |
return value pointer for the uri user info, or |
[out][optional] |
host |
return value pointer for the uri host, or |
[out][optional] |
port |
return value pointer for the uri port, or |
[out][optional] |
path |
return value pointer for the uri path, or |
[out][optional] |
Since: 5.0
gboolean tepl_utils_create_parent_directories (GFile *file
,GCancellable *cancellable
,GError **error
);
Synchronously creates parent directories of file
, so that file
can be
saved.
file |
a file |
|
cancellable |
optional GCancellable object, |
[nullable] |
error |
[out][optional] |
Since: 5.0
void tepl_utils_file_query_exists_async (GFile *file
,GCancellable *cancellable
,GAsyncReadyCallback callback
,gpointer user_data
);
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.
file |
a GFile. |
|
cancellable |
a GCancellable. |
|
callback |
the callback to call when the operation is finished. |
|
user_data |
the data to pass to the callback function. |
Since: 5.0
gboolean tepl_utils_file_query_exists_finish (GFile *file
,GAsyncResult *result
);
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).
Since: 5.0
void tepl_utils_show_warning_dialog (GtkWindow *parent
,const gchar *format
,...
);
Shows a GtkDialog with the provided warning message.
parent |
the GtkWindow issuing the warning. |
[nullable] |
format |
format string, as with |
|
... |
parameters to insert into the format string. |
Since: 5.0
void
tepl_utils_list_box_clear (GtkListBox *list_box
);
Removes all rows of list_box
, to obtain an empty GtkListBox.
Since: 6.0
void tepl_utils_list_box_setup_scrolling (GtkListBox *list_box
,GtkScrolledWindow *scrolled_window
);
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.
Since: 6.0
void tepl_utils_list_box_scroll_to_row (GtkListBox *list_box
,GtkListBoxRow *row
);
Scrolls to a specific GtkListBoxRow.
Before using this function, tepl_utils_list_box_setup_scrolling()
must have
been called.
Since: 6.0
void
tepl_utils_list_box_scroll_to_selected_row
(GtkListBox *list_box
);
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.
Since: 6.0
GtkListBoxRow * tepl_utils_list_box_get_row_at_index_with_filter (GtkListBox *list_box
,gint index
,GtkListBoxFilterFunc filter_func
,gpointer user_data
);
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
.
list_box |
a GtkListBox. |
|
index |
the index of the row, starting at 0. The index is among the filtered rows only. |
|
filter_func |
non- |
[scope call] |
user_data |
user data passed to |
Since: 6.0
GtkListBoxRow ** tepl_utils_list_box_get_filtered_children (GtkListBox *list_box
,GtkListBoxFilterFunc filter_func
,gpointer user_data
,gint *n_filtered_children
);
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()
).
list_box |
a GtkListBox. |
|
filter_func |
non- |
[scope call] |
user_data |
user data passed to |
|
n_filtered_children |
location to store the number of
GtkListBoxRow's present in the returned array, without counting the
terminating |
[out][optional] |
a NULL
-terminated array of GtkListBoxRow objects, or NULL
. Free with
g_free()
when no longer needed.
[array zero-terminated=1][element-type GtkListBoxRow][transfer container][nullable]
Since: 6.0
void tepl_utils_override_font_description (GtkWidget *widget
,const PangoFontDescription *font_desc
);
A replacement for gtk_widget_override_font()
. Because
gtk_widget_override_font()
is deprecated but was useful.
See also tepl_pango_font_description_to_css()
.
Since: 6.2
void tepl_utils_override_font_string (GtkWidget *widget
,const gchar *font_str
);
A convenience function that calls tepl_utils_override_font_description()
.
See pango_font_description_from_string()
for a description of the format of
the string representation for font_str
.
Since: 6.2
GtkWidget * tepl_utils_get_titled_component (const gchar *title
,GtkWidget *component
);
To add a title to a GUI component.
Useful for example in a GtkDialog window, when there are several components, or logical groups.
The title will be in bold, left-aligned, and the component
will have a left
margin.
Since: 6.2
void
tepl_utils_setup_statusbar (GtkStatusbar *statusbar
);
To better configure a GtkStatusbar (to make it smaller).
Since: 6.8
void tepl_utils_set_widget (GtkWidget **widget_ptr
,GtkWidget *new_widget
);
Like g_set_object()
but for a GtkWidget and without the return value.
It connects and disconnects the “destroy” signal.
Since: 6.11
gboolean tepl_utils_binding_transform_func_smart_bool (GBinding *binding
,const GValue *from_value
,GValue *to_value
,gpointer user_data
);
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.
Since: 5.0
gboolean
tepl_utils_can_use_gsettings_schema (const gchar *schema_id
);
Checks that a GSettings schema exists.
Especially useful for external GSettings (provided by another application for instance).
TRUE
if a GSettings instance can be created with schema_id
.
FALSE
otherwise (in that case the program would crash).
Since: 6.2
gboolean tepl_utils_can_use_gsettings_key (GSettings *settings
,const gchar *key
);
Especially useful for external GSettings (provided by another application for instance).
See also: tepl_utils_can_use_gsettings_schema()
which is typically used
before this function.
Since: 6.2
#define TEPL_UTILS_STYLE_PROVIDER_PRIORITY_LIBRARY (GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1)
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.
Since: 6.0