shell-util: Shell Reference Manual

## shell-util shell-util |

## Functions

void | shell_util_set_hidden_from_pick ()
void | shell_util_get_transformed_allocation ()
int | shell_util_get_week_start ()
char * | shell_util_format_date ()
const char * | shell_util_translate_time_string ()
gboolean | shell_write_string_to_stream ()
char * | shell_get_file_contents_utf8_sync ()
gboolean | shell_util_wifexited ()
GdkPixbuf * | shell_util_create_pixbuf_from_data ()
void | shell_util_cursor_tracker_to_clutter ()
gboolean | shell_util_need_background_refresh ()
ClutterContent * | shell_util_get_content_for_window_actor ()
cairo_surface_t * | shell_util_composite_capture_images ()

## 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_transformed_allocation ()

    void
    shell_util_get_transformed_allocation (ClutterActor *actor,
                                           ClutterActorBox *box);

This function is similar to a combination of `clutter_actor_get_transformed_position()`, and `clutter_actor_get_transformed_size()`, but unlike `clutter_actor_get_transformed_size()`, it always returns a transform of the current allocation, while `clutter_actor_get_transformed_size()` returns bad values (the transform of the requested size) if a relayout has been queued.

This function is more convenient to use than `clutter_actor_get_abs_allocation_vertices()` if no transformation is in effect and also works around limitations in the GJS binding of arrays.

#### Parameters

actor | a ClutterActor |
box | location to store returned box in stage coordinates. | [out]

### 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_format_date ()

    char *
    shell_util_format_date (const char *format,
                            gint64 time_ms);

Formats a date for the current locale. This should be used instead of the Spidermonkey Date.toLocaleFormat() extension because Date.toLocaleFormat() is buggy for Unicode format strings: https://bugzilla.mozilla.org/show_bug.cgi?id=508783

#### Parameters

format | a strftime-style string format, as parsed by `g_date_time_format()` |
time_ms | milliseconds since 1970-01-01 00:00:00 UTC; the value returned by Date.getTime() |

#### Returns

the formatted date. If the date is outside of the range of a GDateTime (which contains any plausible dates we actually care about), will return an empty string.

### 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_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_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_cursor_tracker_to_clutter ()

    void
    shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
                                          ClutterTexture *texture);

### shell_util_need_background_refresh ()

    gboolean
    shell_util_need_background_refresh (void);

### shell_util_get_content_for_window_actor ()

    ClutterContent *
    shell_util_get_content_for_window_actor
                                   (MetaWindowActor *window_actor,
                                    MetaRectangle *window_rect);

#### Parameters

window_actor | a MetaWindowActor |
window_rect | a MetaRectangle |

#### Returns

a new ClutterContent.

[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 width,
                                         int height);

## Types and Values