GimpData

GimpData

Synopsis

                    GimpData;
enum                GimpDataError;
gboolean            gimp_data_save                      (GimpData *data,
                                                         GError **error);
void                gimp_data_dirty                     (GimpData *data);
void                gimp_data_clean                     (GimpData *data);
gboolean            gimp_data_is_dirty                  (GimpData *data);
void                gimp_data_freeze                    (GimpData *data);
void                gimp_data_thaw                      (GimpData *data);
gboolean            gimp_data_is_frozen                 (GimpData *data);
gboolean            gimp_data_delete_from_disk          (GimpData *data,
                                                         GError **error);
const gchar *       gimp_data_get_extension             (GimpData *data);
void                gimp_data_set_filename              (GimpData *data,
                                                         const gchar *filename,
                                                         gboolean writable,
                                                         gboolean deletable);
void                gimp_data_create_filename           (GimpData *data,
                                                         const gchar *dest_dir);
const gchar *       gimp_data_get_filename              (GimpData *data);
void                gimp_data_set_folder_tags           (GimpData *data,
                                                         const gchar *top_directory);
const gchar *       gimp_data_get_mime_type             (GimpData *data);
gboolean            gimp_data_is_writable               (GimpData *data);
gboolean            gimp_data_is_deletable              (GimpData *data);
void                gimp_data_set_mtime                 (GimpData *data,
                                                         time_t mtime);
time_t              gimp_data_get_mtime                 (GimpData *data);
GimpData *          gimp_data_duplicate                 (GimpData *data);
void                gimp_data_make_internal             (GimpData *data,
                                                         const gchar *identifier);
gboolean            gimp_data_is_internal               (GimpData *data);
gint                gimp_data_compare                   (GimpData *data1,
                                                         GimpData *data2);
#define             GIMP_DATA_ERROR
GQuark              gimp_data_error_quark               (void);

Object Hierarchy

  GObject
   +----GimpObject
         +----GimpViewable
               +----GimpData
                     +----GimpBrush
                     +----GimpCurve
                     +----GimpDynamics
                     +----GimpGradient
                     +----GimpPalette
                     +----GimpPattern
                     +----GimpToolPreset

Implemented Interfaces

GimpData implements GimpConfigInterface and GimpTaggedInterface.

Properties

  "deletable"                gboolean              : Read / Write
  "filename"                 gchar*                : Read / Write
  "mime-type"                gchar*                : Read / Write / Construct Only
  "writable"                 gboolean              : Read / Write

Signals

  "dirty"                                          : Run First

Description

Details

GimpData

typedef struct _GimpData GimpData;


enum GimpDataError

typedef enum {
  GIMP_DATA_ERROR_OPEN,   /*  opening data file failed   */
  GIMP_DATA_ERROR_READ,   /*  reading data file failed   */
  GIMP_DATA_ERROR_WRITE,  /*  writing data file failed   */
  GIMP_DATA_ERROR_DELETE  /*  deleting data file failed  */
} GimpDataError;

GIMP_DATA_ERROR_OPEN

GIMP_DATA_ERROR_READ

GIMP_DATA_ERROR_WRITE

GIMP_DATA_ERROR_DELETE


gimp_data_save ()

gboolean            gimp_data_save                      (GimpData *data,
                                                         GError **error);

Save the object. If the object is marked as "internal", nothing happens. Otherwise, it is saved to disk, using the file name set by gimp_data_set_filename(). If the save is successful, the object is marked as not dirty. If not, an error message is returned using the error argument.

data :

object whose contents are to be saved.

error :

return location for errors or NULL

Returns :

TRUE if the object is internal or the save is successful.

gimp_data_dirty ()

void                gimp_data_dirty                     (GimpData *data);

Marks data as dirty. Unless the object is frozen, this causes its preview to be invalidated, and emits a "dirty" signal. If the object is frozen, the function has no effect.

data :

a GimpData object.

gimp_data_clean ()

void                gimp_data_clean                     (GimpData *data);


gimp_data_is_dirty ()

gboolean            gimp_data_is_dirty                  (GimpData *data);


gimp_data_freeze ()

void                gimp_data_freeze                    (GimpData *data);

Increments the freeze count for the object. A positive freeze count prevents the object from being treated as dirty. Any call to this function must be followed eventually by a call to gimp_data_thaw().

data :

a GimpData object.

gimp_data_thaw ()

void                gimp_data_thaw                      (GimpData *data);

Decrements the freeze count for the object. If the freeze count drops to zero, the object is marked as dirty, and the "dirty" signal is emitted. It is an error to call this function without having previously called gimp_data_freeze().

data :

a GimpData object.

gimp_data_is_frozen ()

gboolean            gimp_data_is_frozen                 (GimpData *data);


gimp_data_delete_from_disk ()

gboolean            gimp_data_delete_from_disk          (GimpData *data,
                                                         GError **error);

Deletes the object from disk. If the object is marked as "internal", nothing happens. Otherwise, if the file exists whose name has been set by gimp_data_set_filename(), it is deleted. Obviously this is a potentially dangerous function, which should be used with care.

data :

a GimpData object.

error :

return location for errors or NULL

Returns :

TRUE if the object is internal to Gimp, or the deletion is successful.

gimp_data_get_extension ()

const gchar *       gimp_data_get_extension             (GimpData *data);


gimp_data_set_filename ()

void                gimp_data_set_filename              (GimpData *data,
                                                         const gchar *filename,
                                                         gboolean writable,
                                                         gboolean deletable);

This function assigns a file name to data, and sets some flags according to the properties of the file. If writable is TRUE, and the user has permission to write or overwrite the requested file name, and a "save" method exists for data's object type, then data is marked as writable.

data :

A GimpData object

filename :

File name to assign to data.

writable :

TRUE if we want to be able to write to this file.

deletable :

TRUE if we want to be able to delete this file.

gimp_data_create_filename ()

void                gimp_data_create_filename           (GimpData *data,
                                                         const gchar *dest_dir);

This function creates a unique file name to be used for saving a representation of data in the directory dest_dir. If the user does not have write permission in dest_dir, then data is marked as "not writable", so you should check on this before assuming that data can be saved.

data :

a Gimpdata object.

dest_dir :

directory in which to create a file name.

gimp_data_get_filename ()

const gchar *       gimp_data_get_filename              (GimpData *data);


gimp_data_set_folder_tags ()

void                gimp_data_set_folder_tags           (GimpData *data,
                                                         const gchar *top_directory);

Sets tags based on all folder names below top_directory. So if the data's filename is /home/foo/.gimp/brushes/Flowers/Roses/rose.gbr, it will add "Flowers" and "Roses" tags.

if the top directory (as passed, or as derived from the data's filename) does not end with one of the default data directory names (brushes, patterns etc), its name will be added as tag too.

data :

a Gimpdata object.

top_directory :

the top directory of the currently processed data hierarchy, or NULL if that top directory is currently processed itself

gimp_data_get_mime_type ()

const gchar *       gimp_data_get_mime_type             (GimpData *data);


gimp_data_is_writable ()

gboolean            gimp_data_is_writable               (GimpData *data);


gimp_data_is_deletable ()

gboolean            gimp_data_is_deletable              (GimpData *data);


gimp_data_set_mtime ()

void                gimp_data_set_mtime                 (GimpData *data,
                                                         time_t mtime);


gimp_data_get_mtime ()

time_t              gimp_data_get_mtime                 (GimpData *data);


gimp_data_duplicate ()

GimpData *          gimp_data_duplicate                 (GimpData *data);

Creates a copy of data, if possible. Only the object data is copied: the newly created object is not automatically given an object name, file name, preview, etc.

data :

a GimpData object

Returns :

the newly created copy, or NULL if data cannot be copied.

gimp_data_make_internal ()

void                gimp_data_make_internal             (GimpData *data,
                                                         const gchar *identifier);

Mark data as "internal" to Gimp, which means that it will not be saved to disk. Note that if you do this, later calls to gimp_data_save() and gimp_data_delete_from_disk() will automatically return successfully without giving any warning.

The identifier name shall be an untranslated globally unique string that identifies the internal object across sessions.

data :

a GimpData object.

gimp_data_is_internal ()

gboolean            gimp_data_is_internal               (GimpData *data);


gimp_data_compare ()

gint                gimp_data_compare                   (GimpData *data1,
                                                         GimpData *data2);

Compares two data objects for use in sorting. Objects marked as "internal" come first, then user-writable objects, then system data files. In these three groups, the objects are sorted alphabetically by name, using gimp_object_name_collate().

data1 :

a GimpData object.

data2 :

another GimpData object.

Returns :

-1 if data1 compares before data2, 0 if they compare equal, 1 if data1 compares after data2.

GIMP_DATA_ERROR

#define GIMP_DATA_ERROR (gimp_data_error_quark ())


gimp_data_error_quark ()

GQuark              gimp_data_error_quark               (void);

This function is used to implement the GIMP_DATA_ERROR macro. It shouldn't be called directly.

Returns :

the GQuark to identify error in the GimpData error domain.

Property Details

The "deletable" property

  "deletable"                gboolean              : Read / Write

Default value: FALSE


The "filename" property

  "filename"                 gchar*                : Read / Write

Default value: NULL


The "mime-type" property

  "mime-type"                gchar*                : Read / Write / Construct Only

Default value: NULL


The "writable" property

  "writable"                 gboolean              : Read / Write

Default value: FALSE

Signal Details

The "dirty" signal

void                user_function                      (GimpData *gimpdata,
                                                        gpointer  user_data)      : Run First

gimpdata :

the object which received the signal.

user_data :

user data set when the signal handler was connected.