## GladeProject

GladeProject — The Glade document hub and Load/Save interface.

## Functions

GladeProject * | glade_project_new ()
GladeProjectFormat | glade_project_get_format ()
void | glade_project_set_format ()
gboolean | glade_project_load_from_file ()
GladeProject * | glade_project_load ()
gboolean | glade_project_save ()
const gchar * | glade_project_get_path ()
gchar * | glade_project_get_name ()
void | glade_project_undo ()
void | glade_project_redo ()
GladeCommand * | glade_project_next_undo_item ()
GladeCommand * | glade_project_next_redo_item ()
void | glade_project_push_undo ()
GtkWidget * | glade_project_undo_items ()
GtkWidget * | glade_project_redo_items ()
void | glade_project_reset_path ()
gboolean | glade_project_get_readonly ()
const GList * | glade_project_get_objects ()
void | glade_project_add_object ()
void | glade_project_remove_object ()
gboolean | glade_project_has_object ()
GladeWidget * | glade_project_get_widget_by_name ()
gchar * | glade_project_new_widget_name ()
gboolean | glade_project_is_selected ()
void | glade_project_selection_set ()
void | glade_project_selection_add ()
void | glade_project_selection_remove ()
void | glade_project_selection_clear ()
void | glade_project_selection_changed ()
GList * | glade_project_selection_get ()
gboolean | glade_project_get_has_selection ()
gchar * | glade_project_resource_fullpath ()
gboolean | glade_project_is_loading ()
time_t | glade_project_get_file_mtime ()
gboolean | glade_project_get_modified ()

## Properties

gint | format | Read
gboolean | has-selection | Read
gboolean | modified | Read
gchar * | path | Read
gboolean | read-only | Read

## Signals

void | add-widget | Run Last
void | changed | Run First
void | close | Run Last
void | convert-finished | Run First
void | load-progress | Run First
void | parse-began | Run First
void | parse-finished | Run First
void | remove-widget | Run Last
void | selection-changed | Run Last
void | targets-changed | Run First
void | widget-name-changed | Run Last

## Types and Values

| GladeProject
enum | GladeProjectFormat

## Object Hierarchy

        GObject
        ╰── GladeProject

## Implemented Interfaces

GladeProject implements GtkTreeModel.

## Description

This object owns all project objects and is responsable for loading and saving the glade document, you can monitor the project state via this object and its signals.

## Functions

### glade_project_new ()

    GladeProject *
    glade_project_new (void);

Creates a new GladeProject.

#### Returns

a new GladeProject

### glade_project_get_format ()

    GladeProjectFormat
    glade_project_get_format (GladeProject *project);

### glade_project_set_format ()

    void
    glade_project_set_format (GladeProject *project,
                              GladeProjectFormat format);

Sets `project` format to `format` , used internally to set the actual format state; note that conversions should be done through the glade-command api.

#### Parameters

project | a GladeProject |
format | the GladeProjectFormat |

### glade_project_load_from_file ()

    gboolean
    glade_project_load_from_file (GladeProject *project,
                                  const gchar *path);

### glade_project_load ()

    GladeProject *
    glade_project_load (const gchar *path);

Opens a project at the given path.

#### Returns

a new GladeProject for the opened project on success, `NULL` on failure

### glade_project_save ()

    gboolean
    glade_project_save (GladeProject *project,
                        const gchar *path,
                        GError **error);

Saves `project` to the given path.

#### Parameters

project | a GladeProject |
path | location to save glade file |
error | an error from the G_FILE_ERROR domain. |

#### Returns

`TRUE` on success, `FALSE` on failure

### glade_project_get_path ()

    const gchar *
    glade_project_get_path (GladeProject *project);

### glade_project_get_name ()

    gchar *
    glade_project_get_name (GladeProject *project);

### glade_project_undo ()

    void
    glade_project_undo (GladeProject *project);

Redoes a GladeCommand in this project.

#### Parameters

project | a GladeProject |

### glade_project_redo ()

    void
    glade_project_redo (GladeProject *project);

### glade_project_next_undo_item ()

    GladeCommand *
    glade_project_next_undo_item (GladeProject *project);

Gets the next undo item on `project` 's command stack.

#### Parameters

project | a GladeProject |

#### Returns

the GladeCommand

### glade_project_next_redo_item ()

    GladeCommand *
    glade_project_next_redo_item (GladeProject *project);

Gets the next redo item on `project` 's command stack.

#### Parameters

project | a GladeProject |

#### Returns

the GladeCommand

### glade_project_push_undo ()

    void
    glade_project_push_undo (GladeProject *project,
                             GladeCommand *cmd);

Pushes a newly created GladeCommand onto `projects` stack.

#### Parameters

project | a GladeProject |
cmd | the GladeCommand |

### glade_project_undo_items ()

    GtkWidget *
    glade_project_undo_items (GladeProject *project);

Creates a menu of the undo items in the project stack

#### Parameters

project | A GladeProject |

#### Returns

A newly created menu

### glade_project_redo_items ()

    GtkWidget *
    glade_project_redo_items (GladeProject *project);

Creates a menu of the undo items in the project stack

#### Parameters

project | A GladeProject |

#### Returns

A newly created menu

### glade_project_reset_path ()

    void
    glade_project_reset_path (GladeProject *project);

### glade_project_get_readonly ()

    gboolean
    glade_project_get_readonly (GladeProject *project);

Gets whether the project is read only or not

#### Parameters

project | a GladeProject |

#### Returns

TRUE if project is read only

### glade_project_get_objects ()

    const GList *
    glade_project_get_objects (GladeProject *project);

### glade_project_add_object ()

    void
    glade_project_add_object (GladeProject *project,
                              GladeProject *old_project,
                              GObject *object);

Adds an object to the project.

#### Parameters

project | the GladeProject the widget is added to |
old_project | the GladeProject the widget was previously in (or `NULL` for the clipboard) |
object | the GObject to add |

### glade_project_remove_object ()

    void
    glade_project_remove_object (GladeProject *project,
                                 GObject *object);

Removes `object` from `project` .

Note that when removing the GObject from the project we don't change ->project in the associated GladeWidget; this way UNDO can work.

#### Parameters

project | a GladeProject |
object | the GObject to remove |

### glade_project_has_object ()

    gboolean
    glade_project_has_object (GladeProject *project,
                              GObject *object);

#### Parameters

project | the GladeProject the widget is added to |
object | the GObject to search |

#### Returns

whether this object is in this project.

### glade_project_get_widget_by_name ()

    GladeWidget *
    glade_project_get_widget_by_name (GladeProject *project,
                                      GladeWidget *ancestor,
                                      const gchar *name);

Searches under `ancestor` in `project` looking for a GladeWidget named `name` .

#### Parameters

project | a GladeProject |
ancestor | The toplevel project object to search under |
name | The user visible name of the widget we are looking for |

#### Returns

a pointer to the widget, `NULL` if the widget does not exist

### glade_project_new_widget_name ()

    gchar *
    glade_project_new_widget_name (GladeProject *project,
                                   GladeWidget *widget,
                                   const gchar *base_name);

Creates a new name for a widget that doesn't collide with any of the names already in `project` . This name will start with `base_name` .

#### Parameters

project | a GladeProject |
widget | the GladeWidget intended to recieve a new name |
base_name | base name of the widget to create |

#### Returns

a string containing the new name, `NULL` if there is not enough memory for this string

### glade_project_is_selected ()

    gboolean
    glade_project_is_selected (GladeProject *project,
                               GObject *object);

#### Parameters

project | a GladeProject |
object | a GObject |

#### Returns

whether `object` is in `project` selection

### glade_project_selection_set ()

    void
    glade_project_selection_set (GladeProject *project,
                                 GObject *object,
                                 gboolean emit_signal);

Set the selection in `project` to `object`

If `emit_signal` is `TRUE`, calls `glade_project_selection_changed()`.

#### Parameters

project | a GladeProject |
object | a GObject in `project` |
emit_signal | whether or not to emit a signal indicating a selection change |

### glade_project_selection_add ()

    void
    glade_project_selection_add (GladeProject *project,
                                 GObject *object,
                                 gboolean emit_signal);

Adds `object` to the selection chain of `project`

If `emit_signal` is `TRUE`, calls `glade_project_selection_changed()`.

#### Parameters

project | a GladeProject |
object | a GObject in `project` |
emit_signal | whether or not to emit a signal indicating a selection change |

### glade_project_selection_remove ()

    void
    glade_project_selection_remove (GladeProject *project,
                                    GObject *object,
                                    gboolean emit_signal);

Removes `object` from the selection chain of `project`

If `emit_signal` is `TRUE`, calls `glade_project_selection_changed()`.

#### Parameters

project | a GladeProject |
object | a GObject in `project` |
emit_signal | whether or not to emit a signal indicating a selection change |

### glade_project_selection_clear ()

    void
    glade_project_selection_clear (GladeProject *project,
                                   gboolean emit_signal);

Clears `project` 's selection chain

If `emit_signal` is `TRUE`, calls `glade_project_selection_changed()`.

#### Parameters

project | a GladeProject |
emit_signal | whether or not to emit a signal indication a selection change |

### glade_project_selection_changed ()

    void
    glade_project_selection_changed (GladeProject *project);

Causes `project` to emit a "selection_changed" signal.

#### Parameters

project | a GladeProject |

### glade_project_selection_get ()

    GList *
    glade_project_selection_get (GladeProject *project);

#### Parameters

project | a GladeProject |

#### Returns

a GList containing the GtkWidget items currently selected in `project`

### glade_project_get_has_selection ()

    gboolean
    glade_project_get_has_selection (GladeProject *project);

#### Parameters

project | a GladeProject |

#### Returns

whether `project` currently has a selection

### glade_project_resource_fullpath ()

    gchar *
    glade_project_resource_fullpath (GladeProject *project,
                                     const gchar *resource);

Project resource strings may be relative or fullpaths, but glade always expects a copy in the glade file directory, this function is used to make a local path to the file.

#### Parameters

project | The GladeProject. |
resource | The resource basename |

#### Returns

A newly allocated string holding the local path the the project resource.

### glade_project_is_loading ()

    gboolean
    glade_project_is_loading (GladeProject *project);

#### Parameters

project | A GladeProject |

#### Returns

Whether the project is being loaded or not

### glade_project_get_file_mtime ()

    time_t
    glade_project_get_file_mtime (GladeProject *project);

### glade_project_get_modified ()

    gboolean
    glade_project_get_modified (GladeProject *project);

Get's whether the project has been modified since it was last saved.

#### Parameters

project | a GladeProject |

#### Returns

TRUE if the project has been modified since it was last saved

## Types and Values

### GladeProject

    typedef struct _GladeProject GladeProject;

### enum GladeProjectFormat

#### Members

GLADE_PROJECT_FORMAT_LIBGLADE |  |
GLADE_PROJECT_FORMAT_GTKBUILDER |  |

## Property Details

### The `“format”` property

      “format”                   gint

The project file format.

Flags: Read

Allowed values: [0,1]

Default value: 1

### The `“has-selection”` property

      “has-selection”            gboolean

Whether project has a selection.

Flags: Read

Default value: FALSE

### The `“modified”` property

      “modified”                 gboolean

Whether project has been modified since it was last saved.

Flags: Read

Default value: FALSE

### The `“path”` property

      “path”                     gchar *

The filesystem path of the project.

Flags: Read

Default value: NULL

### The `“read-only”` property

      “read-only”                gboolean

Whether project is read-only.

Flags: Read

Default value: FALSE

## Signal Details

### The `“add-widget”` signal

    void
    user_function (GladeProject *gladeproject,
                   GladeWidget  *arg1,
                   gpointer      user_data)

Emitted when a widget is added to a project.

#### Parameters

gladeproject | the GladeProject which received the signal. |
arg1 | the GladeWidget that was added to `gladeproject` . |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“changed”` signal

    void
    user_function (GladeProject *gladeproject,
                   GladeCommand *arg1,
                   gboolean      arg2,
                   gpointer      user_data)

Emitted when a `gladeproject` 's state changes via a GladeCommand.

#### Parameters

gladeproject | the GladeProject which received the signal. |
arg1 | the GladeCommand that was executed |
arg2 | whether the command was executed or undone. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“close”` signal

    void
    user_function (GladeProject *gladeproject,
                   gpointer      user_data)

Emitted when a project is closing (a good time to clean up any associated resources).

#### Parameters

gladeproject | the GladeProject which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“convert-finished”` signal

    void
    user_function (GladeProject *gladeproject,
                   gpointer      user_data)

Emitted when `gladeproject` format conversion has finished.

NOTE: Some properties are internally handled differently when the project is in a said format, this signal is fired after the new format is in effect to allow the backend access to both before and after.

#### Parameters

gladeproject | the GladeProject which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“load-progress”` signal

    void
    user_function (GladeProject *gladeproject,
                   gint          objects_total,
                   gint          objects_loaded,
                   gpointer      user_data)

Emitted while `project` is loading.

#### Parameters

gladeproject | the GladeProject which received the signal. |
objects_total | the total amount of objects to load |
objects_loaded | the current amount of loaded objects |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“parse-began”` signal

    void
    user_function (GladeProject *gladeproject,
                   gpointer      user_data)

Emitted when `gladeproject` parsing starts.

#### Parameters

gladeproject | the GladeProject which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“parse-finished”` signal

    void
    user_function (GladeProject *gladeproject,
                   gpointer      user_data)

Emitted when `gladeproject` parsing has finished.

#### Parameters

gladeproject | the GladeProject which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“remove-widget”` signal

    void
    user_function (GladeProject *gladeproject,
                   GladeWidget  *arg1,
                   gpointer      user_data)

Emitted when a widget is removed from a project.

#### Parameters

gladeproject | the GladeProject which received the signal. |
arg1 | the GladeWidget that was removed from `gladeproject` . |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“selection-changed”` signal

    void
    user_function (GladeProject *gladeproject,
                   gpointer      user_data)

Emitted when `gladeproject` selection list changes.

#### Parameters

gladeproject | the GladeProject which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“targets-changed”` signal

    void
    user_function (GladeProject *gladeproject,
                   gpointer      user_data)

Emitted when `gladeproject` target versions change.

#### Parameters

gladeproject | the GladeProject which received the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

### The `“widget-name-changed”` signal

    void
    user_function (GladeProject *gladeproject,
                   GladeWidget  *arg1,
                   gpointer      user_data)

Emitted when `gwidget` 's name changes.

#### Parameters

gladeproject | the GladeProject which received the signal. |
arg1 | the GladeWidget who's name changed. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last