## gedit-utils gedit-utils |

## Functions

#define | GBOOLEAN_TO_POINTER()
#define | GPOINTER_TO_BOOLEAN()
#define | IS_VALID_BOOLEAN()
void | gedit_utils_menu_position_under_widget ()
void | gedit_utils_menu_position_under_tree_view ()
gchar * | gedit_utils_escape_underscores ()
gchar * | gedit_utils_str_middle_truncate ()
void | gedit_utils_set_atk_name_description ()
void | gedit_utils_set_atk_relation ()
void | gedit_warning ()
gchar * | gedit_utils_make_valid_utf8 ()
gchar * | gedit_utils_uri_get_dirname ()
gchar * | gedit_utils_replace_home_dir_with_tilde ()
guint | gedit_utils_get_current_workspace ()
guint | gedit_utils_get_window_workspace ()
gchar * | gedit_utils_make_canonical_uri_from_shell_arg ()
gchar * | gedit_utils_basename_for_display ()
gboolean | gedit_utils_decode_uri ()
gchar ** | gedit_utils_drop_get_uris ()
GtkSourceCompressionType | gedit_utils_get_compression_type_from_content_type ()
void | gedit_utils_get_current_viewport ()
gboolean | gedit_utils_get_ui_objects ()
gboolean | gedit_utils_get_ui_objects_with_translation_domain ()
gboolean | gedit_utils_is_valid_location ()
gchar * | gedit_utils_location_get_dirname_for_display ()
gchar * | gedit_utils_set_direct_save_filename ()
gchar * | gedit_utils_str_end_truncate ()
const gchar * | gedit_utils_newline_type_to_string ()

## Description

## Functions

### GBOOLEAN_TO_POINTER()

    #define GBOOLEAN_TO_POINTER(i) (GINT_TO_POINTER ((i) ? 2 : 1))

### GPOINTER_TO_BOOLEAN()

    #define GPOINTER_TO_BOOLEAN(i) ((gboolean) ((GPOINTER_TO_INT(i) == 2) ? TRUE : FALSE))

### IS_VALID_BOOLEAN()

    #define IS_VALID_BOOLEAN(v) (((v == TRUE) || (v == FALSE)) ? TRUE : FALSE)

`IS_VALID_BOOLEAN` has been deprecated since version 3.18 and should not be used in newly-written code.

#### Parameters

v | a gboolean. |

### gedit_utils_menu_position_under_widget ()

    void
    gedit_utils_menu_position_under_widget
                                   (GtkMenu *menu,
                                    gint *x,
                                    gint *y,
                                    gboolean *push_in,
                                    gpointer user_data);

### gedit_utils_menu_position_under_tree_view ()

    void
    gedit_utils_menu_position_under_tree_view
                                   (GtkMenu *menu,
                                    gint *x,
                                    gint *y,
                                    gboolean *push_in,
                                    gpointer user_data);

### gedit_utils_escape_underscores ()

    gchar *
    gedit_utils_escape_underscores (const gchar *text,
                                    gssize length);

`gedit_utils_escape_underscores` has been deprecated since version 3.18 and should not be used in newly-written code.

Doubles underscore to avoid spurious menu accels.

#### Parameters

text | some text. |
length | the length. |

#### Returns

the text escaped.

### gedit_utils_str_middle_truncate ()

    gchar *
    gedit_utils_str_middle_truncate (const gchar *string,
                                     guint truncate_length);

### gedit_utils_set_atk_name_description ()

    void
    gedit_utils_set_atk_name_description (GtkWidget *widget,
                                          const gchar *name,
                                          const gchar *description);

This function sets up name and description for a specified gtk widget.

#### Parameters

widget | The Gtk widget for which name/description to be set |
name | Atk name string |
description | Atk description string |

### gedit_utils_set_atk_relation ()

    void
    gedit_utils_set_atk_relation (GtkWidget *obj1,
                                  GtkWidget *obj2,
                                  AtkRelationType rel_type);

### gedit_warning ()

    void
    gedit_warning (GtkWindow *parent,
                   const gchar *format,
                   ...);

### gedit_utils_make_valid_utf8 ()

    gchar *
    gedit_utils_make_valid_utf8 (const char *name);

### gedit_utils_uri_get_dirname ()

    gchar *
    gedit_utils_uri_get_dirname (const char *uri);

`gedit_utils_uri_get_dirname` has been deprecated since version 3.18 and should not be used in newly-written code.

Note: this function replace home dir with ~.

#### Parameters

uri | the URI. |

#### Returns

the directory name.

### gedit_utils_replace_home_dir_with_tilde ()

    gchar *
    gedit_utils_replace_home_dir_with_tilde
                                   (const gchar *uri);

### gedit_utils_get_current_workspace ()

    guint
    gedit_utils_get_current_workspace (GdkScreen *screen);

Get the currently visible workspace for the GdkScreen.

If the X11 window property isn't found, 0 (the first workspace) is returned.

#### Parameters

screen | a GdkScreen |

### gedit_utils_get_window_workspace ()

    guint
    gedit_utils_get_window_workspace (GtkWindow *gtkwindow);

Get the workspace the window is on.

This function gets the workspace that the GtkWindow is visible on, it returns GEDIT_ALL_WORKSPACES if the window is sticky, or if the window manager doesn't support this function.

#### Parameters

gtkwindow | a GtkWindow. |

#### Returns

the workspace the window is on.

### gedit_utils_make_canonical_uri_from_shell_arg ()

    gchar *
    gedit_utils_make_canonical_uri_from_shell_arg
                                   (const gchar *str);

`gedit_utils_make_canonical_uri_from_shell_arg` has been deprecated since version 3.18 and should not be used in newly-written code.

#### Parameters

str | shell arg. |

#### Returns

canonical URI, or `NULL` if `str` is not a valid URI and/or filename.

### gedit_utils_basename_for_display ()

    gchar *
    gedit_utils_basename_for_display (GFile *location);

#### Parameters

location | location for which the basename should be displayed |

#### Returns

the basename of a file suitable for display to users.

[transfer full]

### gedit_utils_decode_uri ()

    gboolean
    gedit_utils_decode_uri (const gchar *uri,
                            gchar **scheme,
                            gchar **user,
                            gchar **port,
                            gchar **host,
                            gchar **path);

Parse and break an uri apart in its individual components like the uri scheme, user info, port, host 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 | the uri to decode |
scheme | return value pointer for the uri's scheme (e.g. http, sftp, ...), or `NULL`. | [out][allow-none]
user | return value pointer for the uri user info, or `NULL`. | [out][allow-none]
port | return value pointer for the uri port, or `NULL`. | [out][allow-none]
host | return value pointer for the uri host, or `NULL`. | [out][allow-none]
path | return value pointer for the uri path, or `NULL`. | [out][allow-none]

#### Returns

`TRUE` if the uri could be properly decoded, `FALSE` otherwise.

### gedit_utils_drop_get_uris ()

    gchar **
    gedit_utils_drop_get_uris (GtkSelectionData *selection_data);

Create a list of valid uri's from a uri-list drop.

#### Parameters

selection_data | the GtkSelectionData from drag_data_received |

#### Returns

a string array which will hold the uris or `NULL` if there were no valid uris. g_strfreev should be used when the string array is no longer used.

[transfer full]

### gedit_utils_get_compression_type_from_content_type ()

    GtkSourceCompressionType
    gedit_utils_get_compression_type_from_content_type
                                   (const gchar *content_type);

### gedit_utils_get_current_viewport ()

    void
    gedit_utils_get_current_viewport (GdkScreen *screen,
                                      gint *x,
                                      gint *y);

Get the currently visible viewport origin for the GdkScreen.

If the X11 window property isn't found, (0, 0) is returned.

#### Parameters

screen | a GdkScreen |
x | x-axis point. | [out]
y | y-axis point. | [out]

### gedit_utils_get_ui_objects ()

    gboolean
    gedit_utils_get_ui_objects (const gchar *filename,
                                gchar **root_objects,
                                GtkWidget **error_widget,
                                const gchar *object_name,
                                ...);

`gedit_utils_get_ui_objects` has been deprecated since version 3.18 and should not be used in newly-written code.

This function gets the requested objects from a GtkBuilder ui file. In case of error it returns `FALSE` and sets error_widget to a GtkLabel containing the error message to display.

#### Parameters

filename | the path to the gtk builder file |
root_objects | a `NULL` terminated list of root objects to load or NULL to load all objects |
error_widget | a pointer were a GtkLabel |
object_name | the name of the first object |
... | a pointer were the first object is returned, followed by more name / object pairs and terminated by `NULL`. |

#### Returns

`FALSE` if an error occurs, `TRUE` on success.

### gedit_utils_get_ui_objects_with_translation_domain ()

    gboolean
    gedit_utils_get_ui_objects_with_translation_domain
                                   (const gchar *filename,
                                    const gchar *translation_domain,
                                    gchar **root_objects,
                                    GtkWidget **error_widget,
                                    const gchar *object_name,
                                    ...);

`gedit_utils_get_ui_objects_with_translation_domain` has been deprecated since version 3.18 and should not be used in newly-written code.

This function gets the requested objects from a GtkBuilder ui file. In case of error it returns `FALSE` and sets error_widget to a GtkLabel containing the error message to display.

#### Parameters

filename | the path to the gtk builder file |
translation_domain | the specific translation domain |
root_objects | a `NULL` terminated list of root objects to load or NULL to load all objects |
error_widget | a pointer were a GtkLabel |
object_name | the name of the first object |
... | a pointer were the first object is returned, followed by more name / object pairs and terminated by `NULL`. |

#### Returns

`FALSE` if an error occurs, `TRUE` on success.

### gedit_utils_is_valid_location ()

    gboolean
    gedit_utils_is_valid_location (GFile *location);

### gedit_utils_location_get_dirname_for_display ()

    gchar *
    gedit_utils_location_get_dirname_for_display
                                   (GFile *location);

Returns a string suitable to be displayed in the UI indicating the name of the directory where the file is located. For remote files it may also contain the hostname etc. For local files it tries to replace the home dir with ~.

#### Parameters

location | the location |

#### Returns

a string to display the dirname.

[transfer full]

### gedit_utils_set_direct_save_filename ()

    gchar *
    gedit_utils_set_direct_save_filename (GdkDragContext *context);

### gedit_utils_str_end_truncate ()

    gchar *
    gedit_utils_str_end_truncate (const gchar *string,
                                  guint truncate_length);

### gedit_utils_newline_type_to_string ()

    const gchar *
    gedit_utils_newline_type_to_string (GtkSourceNewlineType newline_type);

## Types and Values