Did you know that you can navigate the posts by swiping left and right?

¿how to save/load metadata in PiTiVi? (non-recommended)

18 Apr 2012 . category: . Comments

typedef struct
{
        gchar *key;
        gchar *value;
} ProjectSettingsDic;

void ges_pitivi_formatter_set_metadata (GESPitiviFormatter * formatter, const gchar * uri, gchar * author, gchar * name, gchar * year)
{
  xmlNodePtr nodo, metadata;
  xmlDocPtr doc = NULL;

  doc = xmlParseFile(uri);
  nodo = xmlDocGetRootElement(doc);
  metadata = xmlNewChild(nodo, NULL, BAD_CAST "metadata", NULL);
  xmlSetProp(metadata,BAD_CAST "author",BAD_CAST author);
  xmlSetProp(metadata,BAD_CAST "name",BAD_CAST name);
  xmlSetProp(metadata,BAD_CAST "year",BAD_CAST year);
  xmlSaveFile(uri, doc);

}

GHashTable * ges_pitivi_formatter_get_metadata (GESPitiviFormatter * formatter, const gchar * uri) {

  xmlDocPtr doc;
  xmlNodePtr root;
  xmlNodePtr node;

  GHashTable *hashTable;
  ProjectSettingsDic *author;
  ProjectSettingsDic *name;
  ProjectSettingsDic *year;
  ProjectSettingsDic *recalledObject;

  doc = xmlParseFile (uri);
  root = xmlDocGetRootElement (doc);
  node = root->xmlChildrenNode;
  
  while (( node != NULL) && (g_strcmp0((gchar *)node->name, "metadata") != 0)) {
    node = node->next;
  }

  hashTable = g_hash_table_new(g_str_hash, g_str_equal);

  // Create author
  author = g_new0(ProjectSettingsDic, 1);
  author->key = g_strdup("author");
  author->value = g_strdup((char *)xmlGetProp(node, BAD_CAST "author"));

  g_hash_table_insert(hashTable, author, author);

  // Create name
  name = g_new0(ProjectSettingsDic, 1);
  name->key = g_strdup("name");
  name->value = g_strdup((char *)xmlGetProp(node, BAD_CAST "name"));

  g_hash_table_insert(hashTable, name, name);

  // Create year
  year = g_new0(ProjectSettingsDic, 1);
  year->key = g_strdup("year");
  year->value = g_strdup((char *)xmlGetProp(node, BAD_CAST "year"));

  g_hash_table_insert(hashTable, year, year);

  return hashTable;
}

Me

Fabián Orccón is an awesome person. He lives in Perú, the land of the Incas.