GwyResourceEditor — Base/helper class for resource editors
GwyResource * | gwy_resource_editor_get_edited () |
void | gwy_resource_editor_queue_commit () |
gboolean | gwy_resource_editor_commit () |
void | gwy_resource_editor_setup () |
void | gwy_resource_editor_class_setup () |
struct | GwyResourceEditor |
struct | GwyResourceEditorClass |
GObject ╰── GInitiallyUnowned ╰── GtkObject ╰── GtkWidget ╰── GtkContainer ╰── GtkBin ╰── GtkWindow ╰── GwyResourceEditor
GwyResourceEditor implements AtkImplementorIface and GtkBuildable.
#include <app/gwyapp.h>
The base class contains all the methods that handle the resource list, set defaults, or sync resource list with disk. Particular editors (subclasses) have to override (in fact, to fill, because GwyResourceEditor does not define them) the methods and class data in their class init methods. Then they generally only need to care about widgets inside their edit windows.
GwyResource *
gwy_resource_editor_get_edited (GwyResourceEditor *editor
);
Gets the currently edited resource.
It is an error to call this method when no resource is being edited.
editor |
A resource editor. |
The currently edited resource.
void
gwy_resource_editor_queue_commit (GwyResourceEditor *editor
);
Queues commit of resource changes, marking the currently edited resource `dirty'.
Call this method in particular resource editor subclass whenever user changes some editor property.
To flush pending commit, call gwy_resource_editor_commit()
. To immediately
commit a change, call this method and then gwy_resource_editor_commit()
.
editor |
A resource editor. |
gboolean
gwy_resource_editor_commit (GwyResourceEditor *editor
);
Commits pending resource changes, if there are any.
It calls apply_changes
method first (if it exists), then saves resource to
disk.
Changes are always immediately committed (if there are any pending): before the editor is destroyed, when a resource stops being edited, before a resource is deleted, before a resource is renamed. When a resource is newly created, it is immediately created on disk too.
editor |
A resource editor. |
Always FALSE
(to be usable as GSourceFunc).
void
gwy_resource_editor_setup (GwyResourceEditor *editor
);
Sets up particular resource editor.
Helper method only intended for resource editor implementation. To be called in particular resource initialization methods.
editor |
A resource editor. |
void
gwy_resource_editor_class_setup (GwyResourceEditorClass *klass
);
Sets up particular resource editor class.
Helper class method only intended for resource editor implementation. To be called in particular class initialization methods.
klass |
A resource editor class. |
struct GwyResourceEditor;
struct GwyResourceEditorClass { GtkWindowClass parent_class; GType resource_type; const gchar *base_resource; const gchar *window_title; const gchar *editor_title; gchar *settings_prefix; GtkWidget* (*construct_treeview)(GCallback callback, gpointer cbdata, const gchar *active); void (*construct_editor)(GwyResourceEditor *editor); void (*apply_changes)(GwyResourceEditor *editor); void (*switch_resource)(GwyResourceEditor *editor); void (*reserved1)(void); void (*reserved2)(void); GwyResourceEditor *instance; };
The resource editor class.
The GType of edited resources. It must be a type derived from GwyResource. |
||
The name of vanilla, default resource. The `New' button creates a new resource as a copy of this one. |
||
Resource list window title. It should be already translated. |
||
Editor window title template. It must contain one
|
||
Settings prefix for saved state, filled by
|
||
Method to create the resource list widget, it is
of the |
||
Method to construct editor window contents (the window itself is managed by GwyResourceEditor, its contents by a particular editor). |
||
Method called on commit (before resource is written to disk). It should obtain values from the editor widgets and actually update the resource. |
||
Method to update editor window widgets to display another resource. |
||
GwyResourceEditor * |
Editor instance. Resource editors are singletons so if an instance exists, pointer to it is kept here. |