## Glade Utils

Glade Utils — Welcome to the zoo.

## Functions

GType | glade_util_get_type_from_name ()
GParamSpec * | glade_utils_get_pspec_from_funcname ()
gboolean | glade_util_ui_message ()
void | glade_util_flash_message ()
gint | glade_util_compare_stock_labels ()
GtkWidget * | glade_util_file_dialog_new ()
void | glade_util_replace ()
gchar * | glade_util_read_prop_name ()
gchar * | glade_util_duplicate_underscores ()
GList * | glade_util_container_get_all_children ()
gint | glade_util_count_placeholders ()
GtkTreeIter * | glade_util_find_iter_by_widget ()
GList * | glade_util_purify_list ()
GList * | glade_util_added_in_list ()
GList * | glade_util_removed_from_list ()
gchar * | glade_util_canonical_path ()
GModule * | glade_util_load_library ()
gboolean | glade_util_file_is_writeable ()
gboolean | glade_util_have_devhelp ()
GtkWidget * | glade_util_get_devhelp_icon ()
void | glade_util_search_devhelp ()
GtkWidget * | glade_util_get_placeholder_from_pointer ()
gboolean | glade_util_object_is_loading ()
gboolean | glade_util_url_show ()
time_t | glade_util_get_file_mtime ()
gboolean | glade_util_check_and_warn_scrollable ()
gchar * | glade_util_filename_to_icon_name ()
gchar * | glade_util_icon_name_to_filename ()
void | glade_util_remove_scroll_events ()
gboolean | glade_utils_boolean_from_string ()
void | glade_utils_cairo_draw_line ()
void | glade_utils_cairo_draw_rectangle ()
gchar * | glade_utils_enum_string_from_value ()
gchar * | glade_utils_enum_string_from_value_displayable ()
gint | glade_utils_enum_value_from_string ()
gchar * | glade_utils_flags_string_from_value ()
gchar * | glade_utils_flags_string_from_value_displayable ()
gint | glade_utils_flags_value_from_string ()
void | glade_utils_get_pointer ()
gint | glade_utils_hijack_key_press ()
GtkListStore * | glade_utils_liststore_from_enum_type ()
GdkPixbuf * | glade_utils_pointer_mode_render_icon ()
gchar * | glade_utils_replace_home_dir_with_tilde ()
gchar * | glade_utils_string_from_value ()
GValue * | glade_utils_value_from_string ()
gchar * | glade_get_displayable_value ()
gchar * | glade_get_value_from_displayable ()
gboolean | glade_type_has_displayable_values ()
void | glade_register_displayable_value ()
void | glade_register_translated_value ()
gboolean | glade_displayable_value_is_disabled ()
void | glade_displayable_value_set_disabled ()

## Types and Values

enum | GladeUIMessageType
enum | GladeUtilFileDialogType
cairo_path_t | glade_path
#define | glade_path_HEIGHT
#define | glade_path_WIDTH

## Description

This is where all of that really usefull miscalanious stuff lands up.

## Functions

### glade_util_get_type_from_name ()

    GType
    glade_util_get_type_from_name (const gchar *name,
                                   gboolean have_func);

Returns the type using the "get type" function name based on `name` . If the `have_func` flag is true,`name` is used directly, otherwise the get-type function is contrived from `name` then used.

#### Parameters

name | the name of the GType - like 'GtkWidget' or a "get-type" function. |
have_func | function-name flag -- true if the name is a "get-type" function. |

#### Returns

the new GType

### glade_utils_get_pspec_from_funcname ()

    GParamSpec *
    glade_utils_get_pspec_from_funcname (const gchar *funcname);

#### Parameters

funcname | the symbol name of a function to generate a GParamSpec |

#### Returns

A GParamSpec created by the delegate function specified by `funcname` .

[nullable][transfer full]

### glade_util_ui_message ()

    gboolean
    glade_util_ui_message (GtkWidget *parent,
                           GladeUIMessageType type,
                           GtkWidget *widget,
                           const gchar *format,
                           ...);

Creates a new warning dialog window as a child of `parent` containing the text of `format` , runs it, then destroys it on close. Depending on `type` , a cancel button may appear or the icon may change.

#### Parameters

parent | a GtkWindow cast as a GtkWidget |
type | a GladeUIMessageType |
widget | a GtkWidget to append to the dialog vbox |
format | a printf style format string |
... | args for the format. |

#### Returns

True if the `type` was GLADE_UI_ARE_YOU_SURE and the user selected "OK", True if the `type` was GLADE_UI_YES_OR_NO and the user selected "YES"; False otherwise.

### glade_util_flash_message ()

    void
    glade_util_flash_message (GtkWidget *statusbar,
                              guint context_id,
                              gchar *format,
                              ...);

### glade_util_compare_stock_labels ()

    gint
    glade_util_compare_stock_labels (gconstpointer a,
                                     gconstpointer b);

This is a GCompareFunc that compares the labels of two stock items, ignoring any '_' characters. It isn't particularly efficient.

#### Parameters

a | a gconstpointer to a GtkStockItem |
b | a gconstpointer to a GtkStockItem |

#### Returns

negative value if `a` < `b` ; zero if `a` = `b` ; positive value if `a` > `b`

### glade_util_file_dialog_new ()

    GtkWidget *
    glade_util_file_dialog_new (const gchar *title,
                                GladeProject *project,
                                GtkWindow *parent,
                                GladeUtilFileDialogType action);

#### Parameters

title | dialog title |
project | a GladeProject used when saving |
parent | a parent GtkWindow for the dialog |
action | a GladeUtilFileDialogType to say if the dialog will open or save |

#### Returns

a "glade file" file chooser dialog. The caller is responsible for showing the dialog.

[transfer full]

### glade_util_replace ()

    void
    glade_util_replace (gchar *str,
                        gchar a,
                        gchar b);

Replaces each occurrence of the character `a` in `str` to `b` .

#### Parameters

str | a string |
a | a gchar |
b | a gchar |

### glade_util_read_prop_name ()

    gchar *
    glade_util_read_prop_name (const gchar *str);

Return a usable version of a property identifier as found in a freshly parserd GladeInterface

#### Parameters

str | a string |

### glade_util_duplicate_underscores ()

    gchar *
    glade_util_duplicate_underscores (const gchar *name);

Duplicates `name` , but the copy has two underscores in place of any single underscore in the original.

#### Parameters

name | a string |

#### Returns

a newly allocated string

### glade_util_container_get_all_children ()

    GList *
    glade_util_container_get_all_children (GtkContainer *container);

Use this to itterate over all children in a GtkContainer, as it used `_forall()` instead of `_foreach()` (and the GTK+ version of this function is simply not exposed).

#### Parameters

container | a GtkContainer |

#### Returns

a GList giving the contents of `container` .

[element-type GtkWidget][transfer container]

### glade_util_count_placeholders ()

    gint
    glade_util_count_placeholders (GladeWidget *parent);

#### Parameters

parent | a GladeWidget |

#### Returns

the amount of GladePlaceholders parented by `parent`

### glade_util_find_iter_by_widget ()

    GtkTreeIter *
    glade_util_find_iter_by_widget (GtkTreeModel *model,
                                    GladeWidget *findme,
                                    gint column);

Looks through `model` for the GtkTreeIter corresponding to `findme` under `column` .

#### Parameters

model | a GtkTreeModel |
findme | a GladeWidget |
column | a gint |

#### Returns

a newly allocated GtkTreeIter from `model` corresponding to `findme` which should be freed with `gtk_tree_iter_free()`

### glade_util_purify_list ()

    GList *
    glade_util_purify_list (GList *list);

[skip]

#### Parameters

list | A GList. | [transfer full]

#### Returns

A newly allocated version of `list` with no duplicate data entries.

[transfer full]

### glade_util_added_in_list ()

    GList *
    glade_util_added_in_list (GList *old_list,
                              GList *new_list);

[skip]

#### Parameters

old_list | the old GList |
new_list | the new GList |

#### Returns

A newly allocated GList of elements that are in `new` but not in `old` .

[transfer container]

### glade_util_removed_from_list ()

    GList *
    glade_util_removed_from_list (GList *old_list,
                                  GList *new_list);

[skip]

#### Parameters

old_list | the old GList |
new_list | the new GList |

#### Returns

A newly allocated GList of elements that are in `old` no longer in `new` .

[transfer container]

### glade_util_canonical_path ()

    gchar *
    glade_util_canonical_path (const gchar *path);

#### Parameters

path | any path that may contain ".." or "." components |

#### Returns

an absolute path to the specified file or directory that contains no ".." or "." components (this does not call readlink like `realpath()` does).

### glade_util_load_library ()

    GModule *
    glade_util_load_library (const gchar *library_name);

Loads the named library from the Glade modules and lib directory or failing that from the standard platform specific directories. (Including /usr/local/lib for unices)

The `library_name` should not include any platform specifix prefix or suffix, those are automatically added, if needed, by `g_module_build_path()`

#### Parameters

library_name | name of the library |

#### Returns

a GModule on success, or `NULL` on failure.

### glade_util_file_is_writeable ()

    gboolean
    glade_util_file_is_writeable (const gchar *path);

Checks whether the file at `path` is writeable

#### Parameters

path | the path to the file |

#### Returns

TRUE if file is writeable

### glade_util_have_devhelp ()

    gboolean
    glade_util_have_devhelp (void);

#### Returns

whether the devhelp module is loaded

### glade_util_get_devhelp_icon ()

    GtkWidget *
    glade_util_get_devhelp_icon (GtkIconSize size);

Creates an image displaying the devhelp icon.

#### Parameters

size | the preferred icon size |

#### Returns

a GtkImage.

[transfer full]

### glade_util_search_devhelp ()

    void
    glade_util_search_devhelp (const gchar *book,
                               const gchar *page,
                               const gchar *search);

### glade_util_get_placeholder_from_pointer ()

    GtkWidget *
    glade_util_get_placeholder_from_pointer
                                   (GtkContainer *container);

#### Parameters

container | a GtkContainer |

#### Returns

a GtkWidget.

[transfer none]

### glade_util_object_is_loading ()

    gboolean
    glade_util_object_is_loading (GObject *object);

#### Parameters

object | A GObject |

#### Returns

Whether the object's project is being loaded or not.

### glade_util_url_show ()

    gboolean
    glade_util_url_show (const gchar *url);

Portable function for showing an URL `url` in a web browser.

#### Parameters

url | An URL to display |

#### Returns

TRUE if a web browser was successfully launched, or FALSE

### glade_util_get_file_mtime ()

    time_t
    glade_util_get_file_mtime (const gchar *filename,
                               GError **error);

Gets the UTC modification time of file `filename` .

#### Parameters

filename | A filename |
error | return location for errors |

#### Returns

The mtime of the file, or `0` if the file attributes could not be read.

### glade_util_check_and_warn_scrollable ()

    gboolean
    glade_util_check_and_warn_scrollable (GladeWidget *parent,
                                          GladeWidgetAdaptor *child_adaptor,
                                          GtkWidget *parent_widget);

### glade_util_filename_to_icon_name ()

    gchar *
    glade_util_filename_to_icon_name (const gchar *value);

### glade_util_icon_name_to_filename ()

    gchar *
    glade_util_icon_name_to_filename (const gchar *value);

### glade_util_remove_scroll_events ()

    void
    glade_util_remove_scroll_events (GtkWidget *widget);

### glade_utils_boolean_from_string ()

    gboolean
    glade_utils_boolean_from_string (const gchar *string,
                                     gboolean *value);

Parse a boolean value

#### Parameters

string | the string to convert |
value | return location. | [out][optional]

#### Returns

`TRUE` if there was an error on the conversion, `FALSE` otherwise.

### glade_utils_cairo_draw_line ()

    void
    glade_utils_cairo_draw_line (cairo_t *cr,
                                 GdkColor *color,
                                 gint x1,
                                 gint y1,
                                 gint x2,
                                 gint y2);

### glade_utils_cairo_draw_rectangle ()

    void
    glade_utils_cairo_draw_rectangle (cairo_t *cr,
                                      GdkColor *color,
                                      gboolean filled,
                                      gint x,
                                      gint y,
                                      gint width,
                                      gint height);

### glade_utils_enum_string_from_value ()

    gchar *
    glade_utils_enum_string_from_value (GType enum_type,
                                        gint value);

### glade_utils_enum_string_from_value_displayable ()

    gchar *
    glade_utils_enum_string_from_value_displayable
                                   (GType flags_type,
                                    gint value);

### glade_utils_enum_value_from_string ()

    gint
    glade_utils_enum_value_from_string (GType enum_type,
                                        const gchar *strval);

### glade_utils_flags_string_from_value ()

    gchar *
    glade_utils_flags_string_from_value (GType enum_type,
                                         gint value);

### glade_utils_flags_string_from_value_displayable ()

    gchar *
    glade_utils_flags_string_from_value_displayable
                                   (GType flags_type,
                                    gint value);

### glade_utils_flags_value_from_string ()

    gint
    glade_utils_flags_value_from_string (GType enum_type,
                                         const gchar *strval);

### glade_utils_get_pointer ()

    void
    glade_utils_get_pointer (GtkWidget *widget,
                             GdkWindow *window,
                             GdkDevice *device,
                             gint *x,
                             gint *y);

Get's the pointer position relative to `widget` , while `window` and `device` are not absolutely needed, they should be passed wherever possible.

#### Parameters

widget | The widget to get the mouse position relative for |
window | The window of the current event, or `NULL` |
device | The device, if not specified, the current event will be expected to have a `device` . |
x | The location to store the mouse pointer X position |
y | The location to store the mouse pointer Y position |

### glade_utils_hijack_key_press ()

    gint
    glade_utils_hijack_key_press (GtkWindow *win,
                                  GdkEventKey *event,
                                  gpointer user_data);

This function is meant to be attached to key-press-event of a toplevel, it simply allows the window contents to treat key events /before/ accelerator keys come into play (this way widgets dont get deleted when cutting text in an entry etc.). Creates a liststore suitable for comboboxes and such to chose from a variety of types.

#### Parameters

win | a GtkWindow |
event | the GdkEventKey |
user_data | unused |

#### Returns

whether the event was handled

### glade_utils_liststore_from_enum_type ()

    GtkListStore *
    glade_utils_liststore_from_enum_type (GType enum_type,
                                          gboolean include_empty);

Creates a liststore suitable for comboboxes and such to chose from a variety of types.

#### Parameters

enum_type | A GType |
include_empty | whether to prepend an "Unset" slot |

#### Returns

A new GtkListStore.

[transfer full]

### glade_utils_pointer_mode_render_icon ()

    GdkPixbuf *
    glade_utils_pointer_mode_render_icon (GladePointerMode mode,
                                          GtkIconSize size);

Render an icon representing the pointer mode. Best view with sizes bigger than GTK_ICON_SIZE_LARGE_TOOLBAR.

#### Parameters

mode | the GladePointerMode to render as icon |
size | icon size |

#### Returns

the rendered GdkPixbuf.

[transfer full]

### glade_utils_replace_home_dir_with_tilde ()

    gchar *
    glade_utils_replace_home_dir_with_tilde
                                   (const gchar *path);

### glade_utils_string_from_value ()

    gchar *
    glade_utils_string_from_value (const GValue *value);

Serializes GValue into a string (using glade conversion routines)

#### Parameters

value | a GValue to convert |

#### Returns

A newly allocated string

### glade_utils_value_from_string ()

    GValue *
    glade_utils_value_from_string (GType type,
                                   const gchar *string,
                                   GladeProject *project);

Allocates and sets a GValue of type `type` set to `string` (using glade conversion routines)

#### Parameters

type | a GType to convert with |
string | the string to convert |
project | the GladeProject to look for formats of object names when needed |

#### Returns

A newly allocated and set GValue

### glade_get_displayable_value ()

    gchar *
    glade_get_displayable_value (GType type,
                                 const gchar *value);

### glade_get_value_from_displayable ()

    gchar *
    glade_get_value_from_displayable (GType type,
                                      const gchar *displayabe);

### glade_type_has_displayable_values ()

    gboolean
    glade_type_has_displayable_values (GType type);

### glade_register_displayable_value ()

    void
    glade_register_displayable_value (GType type,
                                      const gchar *value,
                                      const gchar *domain,
                                      const gchar *string);

### glade_register_translated_value ()

    void
    glade_register_translated_value (GType type,
                                     const gchar *value,
                                     const gchar *string);

### glade_displayable_value_is_disabled ()

    gboolean
    glade_displayable_value_is_disabled (GType type,
                                         const gchar *value);

### glade_displayable_value_set_disabled ()

    void
    glade_displayable_value_set_disabled (GType type,
                                          const gchar *value,
                                          gboolean disabled);

## Types and Values

### enum GladeUIMessageType

#### Members

GLADE_UI_INFO |  |
GLADE_UI_WARN |  |
GLADE_UI_ERROR |  |
GLADE_UI_ARE_YOU_SURE |  |
GLADE_UI_YES_OR_NO |  |

### enum GladeUtilFileDialogType

#### Members

GLADE_FILE_DIALOG_ACTION_OPEN |  |
GLADE_FILE_DIALOG_ACTION_SAVE |  |

### glade_path

    cairo_path_t glade_path = {0, glade_path_data, 397};

### glade_path_HEIGHT

    #define glade_path_HEIGHT 398.937500

### glade_path_WIDTH

    #define glade_path_WIDTH 408.781250