Comment 6 for bug 1610508

Revision history for this message
moma (osmoma) wrote : Re: [Bug 1610508] Re: Feature request: Always ask where to save file?

Re-hi,

I do not think gtk_recent_manager_add_item() can handle an AUDIO (such as
.mp3) files automatically.
You may need to use gtk_recent_manager_add_full() and fill the GtkRecentData
structure with values.
Here are 2 tests; test a and b.

// Test a) Does this work?

// Put a valid audio1.mp3 file in the current directory.
const gchar *file_uri = "audio1.mp3";
GtkRecentManager *manager = gtk_recent_manager_get_default();
gboolean ret = gtk_recent_manager_add_item(manager, file_uri);

  if (!ret) {
    g_print("Error, cannot add to recent files: %s\n", file_uri);
  }

// Check the $HOME/.local/share/recently-used.xbel file.
$ cat $HOME/.local/share/recently-used.xbel
-------------------------------

// Test b) Is this better?

  GtkRecentData *recent_data;
  recent_data = g_slice_new0 (GtkRecentData);
  recent_data->mime_type = "video/mpeg";
  recent_data->app_name = "Audio recorder";
  recent_data->is_private = FALSE;
  recent_data->app_exec = "xxxxxx %u"; // This could be totem or rhythmbox
  gboolean ret = gtk_recent_manager_add_full (manager, file_uri,
recent_data);
  g_slice_free (GtkRecentData, recent_data);

  if (!ret) {
    g_print("Error, cannot add to recent files: %s\n", file_uri);
  }
-----------------------------------

Notice.
You may need to clear the $HOME/.local/share/recently-used.xbel file
between tests. Truncate it with.
$ echo "" > $HOME/.local/share/recently-used.xbel

I can add & bake your code to audio-recorder when it is tested.

Muito bem Robert,
 Até logo,
 Osmo (Moma) Antero
 Portugal