1 /* Convenience functions for metadata handling in the MIdnight Commander
3 * Copyright (C) 1998 The Free Software Foundation
5 * Author: Federico Mena <federico@nuclecu.unam.mx>
10 #include <libgnome/libgnome.h>
11 #include "gmetadata.h"
13 #include "../vfs/vfs.h"
16 #define ICON_POSITION "icon-position"
21 * @filename: The file under ~/desktop for which to get the icon position
22 * @x: The x position will be stored here. Must be non-NULL.
23 * @y: The y position will be stored here. Must be non-NULL.
25 * Checks if the specified file has an icon position associated to it. If so, returns TRUE and
26 * fills in the x and y values. Otherwise it returns FALSE and x and y are not modified.
28 * Icon position information is expected to be saved using the gmeta_set_icon_pos() function.
31 gmeta_get_icon_pos (char *filename
, int *x
, int *y
)
37 g_return_val_if_fail (filename
!= NULL
, FALSE
);
38 g_return_val_if_fail (x
!= NULL
, FALSE
);
39 g_return_val_if_fail (y
!= NULL
, FALSE
);
41 if (gnome_metadata_get (filename
, ICON_POSITION
, &size
, &buf
) != 0)
45 g_warning ("Invalid metadata for \"%s\"'s icon position, using auto-placement", filename
);
50 if ((sscanf (buf
, "%d%d", &tx
, &ty
) != 2)) {
62 * @filename: The file for which to save icon position information
63 * @x: X position of the icon
64 * @y: Y position of the icon
66 * Saves the icon position information for the specified file. This is expected to be read back
67 * using the gmeta_get_icon_pos() function.
70 gmeta_set_icon_pos (char *filename
, int x
, int y
)
74 g_return_if_fail (filename
!= NULL
);
76 g_snprintf (buf
, sizeof (buf
), "%d %d", x
, y
);
78 if (gnome_metadata_set (filename
, ICON_POSITION
, strlen (buf
) + 1, buf
) != 0)
79 g_warning ("Error setting the icon position metadata for \"%s\"", filename
);
84 * @filename: A filename
86 * Deletes the icon position metadata for a file.
89 gmeta_del_icon_pos (char *filename
)
91 g_return_if_fail (filename
!= NULL
);
93 gnome_metadata_remove (filename
, ICON_POSITION
);