I'm trying to set an emblem using gio
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdio.h>
int main (int argc, char *argv[])
{
GFile *gfile = NULL;
g_type_init();
gfile = g_file_new_for_path("./foo.txt");
if (g_file_set_attribute_string(gfile,
"metadata::emblems",
"favorite",
G_FILE_QUERY_INFO_NONE,
NULL, NULL) == TRUE) {
puts("Success");
} else {
puts("Fail");
}
return 0;
}
if the file exists, the function returns TRUE, which, according the docs means the metadata was set, but Nautilus (GNOME) doesn't display the favorite
emblem. There are not many example on the net, so I'm kind of stuck.
It looks like metadata::emblems needs an array of strings even if you are only setting one value. This seems to work:
char *value[] = {"favorite", '\0'};
[...]
g_file_set_attribute(file, "metadata::emblems",
G_FILE_ATTRIBUTE_TYPE_STRINGV,
&value[0],
G_FILE_QUERY_INFO_NONE,
NULL, NULL);