shell-util

shell-util

Functions

Description

Functions

shell_util_set_hidden_from_pick ()

void
shell_util_set_hidden_from_pick (ClutterActor *actor,
                                 gboolean hidden);

If hidden is TRUE, hide actor from pick even with a mode of CLUTTER_PICK_ALL; if hidden is FALSE, unhide actor .

Parameters

actor

A ClutterActor

 

hidden

Whether actor should be hidden from pick

 

shell_util_get_week_start ()

int
shell_util_get_week_start (void);

Gets the first week day for the current locale, expressed as a number in the range 0..6, representing week days from Sunday to Saturday.

Returns

A number representing the first week day for the current locale


shell_util_translate_time_string ()

const char *
shell_util_translate_time_string (const char *str);

Translate str according to the locale defined by LC_TIME; unlike dcgettext(), the translations is still taken from the LC_MESSAGES catalogue and not the LC_TIME one.

Parameters

str

String to translate

 

Returns

the translated string


shell_util_regex_escape ()

char *
shell_util_regex_escape (const char *str);

A wrapper around g_regex_escape_string() that takes its argument as \0-terminated string rather than a byte-array that confuses gjs.

Parameters

str

a UTF-8 string to escape

 

Returns

str with all regex-special characters escaped


shell_write_string_to_stream ()

gboolean
shell_write_string_to_stream (GOutputStream *stream,
                              const char *str,
                              GError **error);

Write a string to a GOutputStream as UTF-8. This is a workaround for not having binary buffers in GJS.

Parameters

stream

a GOutputStream

 

str

a UTF-8 string to write to stream

 

error

location to store GError

 

Returns

TRUE if write succeeded


shell_get_file_contents_utf8_sync ()

char *
shell_get_file_contents_utf8_sync (const char *path,
                                   GError **error);

Synchronously load the contents of a file as a NUL terminated string, validating it as UTF-8. Embedded NUL characters count as invalid content.

Parameters

path

UTF-8 encoded filename path

 

error

a GError

 

Returns

File contents.

[transfer full]


shell_util_touch_file_async ()

void
shell_util_touch_file_async (GFile *file,
                             GAsyncReadyCallback callback,
                             gpointer user_data);

shell_util_touch_file_finish ()

gboolean
shell_util_touch_file_finish (GFile *file,
                              GAsyncResult *res,
                              GError **error);

shell_util_wifexited ()

gboolean
shell_util_wifexited (int status,
                      int *exit);

Implements libc standard WIFEXITED, that cannot be used JS code.

Parameters

status

the status returned by wait() or waitpid()

 

exit

the actual exit status of the process.

[out]

Returns

TRUE if the process exited normally, FALSE otherwise


shell_util_create_pixbuf_from_data ()

GdkPixbuf *
shell_util_create_pixbuf_from_data (const guchar *data,
                                    gsize len,
                                    GdkColorspace colorspace,
                                    gboolean has_alpha,
                                    int bits_per_sample,
                                    int width,
                                    int height,
                                    int rowstride);

Workaround for non-introspectability of gdk_pixbuf_from_data().

Parameters

data

.

[array length=len][element-type guint8][transfer full]

Returns

.

[transfer full]


shell_util_composite_capture_images ()

cairo_surface_t *
shell_util_composite_capture_images (ClutterCapture *captures,
                                     int n_captures,
                                     int x,
                                     int y,
                                     int target_width,
                                     int target_height,
                                     float target_scale);

shell_util_check_cloexec_fds ()

void
shell_util_check_cloexec_fds (void);

Walk over all open file descriptors. Check them for the FD_CLOEXEC flag. If this flag is not set, log the offending file descriptor number.

It is important that gnome-shell's file descriptors are all marked CLOEXEC, so that the shell's open file descriptors are not passed to child processes that we launch.


shell_util_start_systemd_unit ()

void
shell_util_start_systemd_unit (const char *unit,
                               const char *mode,
                               GCancellable *cancellable,
                               GAsyncReadyCallback callback,
                               gpointer user_data);

shell_util_start_systemd_unit_finish ()

gboolean
shell_util_start_systemd_unit_finish (GAsyncResult *res,
                                      GError **error);

shell_util_stop_systemd_unit ()

void
shell_util_stop_systemd_unit (const char *unit,
                              const char *mode,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data);

shell_util_stop_systemd_unit_finish ()

gboolean
shell_util_stop_systemd_unit_finish (GAsyncResult *res,
                                     GError **error);

shell_util_systemd_unit_exists ()

void
shell_util_systemd_unit_exists (const gchar *unit,
                                GCancellable *cancellable,
                                GAsyncReadyCallback callback,
                                gpointer user_data);

shell_util_systemd_unit_exists_finish ()

gboolean
shell_util_systemd_unit_exists_finish (GAsyncResult *res,
                                       GError **error);

shell_util_sd_notify ()

void
shell_util_sd_notify (void);

shell_util_has_x11_display_extension ()

gboolean
shell_util_has_x11_display_extension (MetaDisplay *display,
                                      const char *extension);

If the corresponding X11 display provides the passed extension, return TRUE, otherwise FALSE. If there is no X11 display, FALSE is passed.

Parameters

display

A MetaDisplay

 

extension

An X11 extension

 

shell_util_get_translated_folder_name ()

char *
shell_util_get_translated_folder_name (const char *name);

Attempts to translate the folder name using translations provided by .directory files.

Parameters

name

the untranslated folder name

 

Returns

a translated string or NULL.

[nullable]


shell_util_get_uid ()

gint
shell_util_get_uid (void);

A wrapper around getuid() so that it can be used from JavaScript. This function will always succeed.

Returns

the real user ID of the calling process