Comment 8 for bug 1610508

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

Yes, I think the following code would work for any audio file.

One could set the mime-type more correctly, but I think "audio" is enough.
$ xdg-mime query filetype audio2.ogg

static void saveToXBel(GtkWidget *widget, gpointer data) {
  g_print ("Saving to xbel.\n");

  // Make URI (file:///....) of a filename
  // Some audio file with complete path ! NOTICE !
  const gchar *file = "/home/moma/RR/audio2.ogg";

  GError *error = NULL;
  gchar *uri = g_filename_to_uri(file, NULL, &error);

  if (error) {
    g_print("Cannot make file uri of %s.\n", file);
    g_error_free(error);
    return;
  }

  GtkRecentManager *manager = gtk_recent_manager_get_default();
  GtkRecentData *recent_data = g_slice_new0 (GtkRecentData);

  // $ xdg-mime query filetype audio1.mp3
  // Set correct mime type
  recent_data->mime_type = "audio";

  recent_data->app_name = "Audio recorder";
  recent_data->is_private = FALSE;
  recent_data->app_exec = "xdg-open %u";
  gboolean ret = gtk_recent_manager_add_full (manager, uri, recent_data);

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

  g_slice_free(GtkRecentData, recent_data);
  g_free(uri);

}

On Sun, Aug 7, 2016 at 10:34 AM, Robert Orzanna <email address hidden> wrote:

> Hi Osmo,
>
> So, now I compiled and tested the following attached test1.c file and
> yes, the mp3 file does show up in xbel! :-)
>
> Does the same also occur then for ogg files?
>
> Sunny greetings from Poland,
>
> ~Robert
>
> ** Attachment added: "test1.c"
> https://bugs.launchpad.net/audio-recorder/+bug/1610508/+
> attachment/4715904/+files/test1.c
>
> --
> You received this bug notification because you are subscribed to Audio
> Recorder.
> https://bugs.launchpad.net/bugs/1610508
>
> Title:
> Feature request: Always ask where to save file?
>
> Status in Audio Recorder:
> New
>
> Bug description:
> Dear all,
>
> My request origins from a discussion on AskUbuntu [1]. Currently,
> Audio Recorder doesn't write to the xbel file upon creation of a new
> file.
>
> This problem could be solved, I think, by a new optional setting to
> ask the user each time where to save the file. It would then write to
> xbel by prompting the GTK File Dialog window.
>
> What do you think of this request?
>
> Would you consider it useful?
>
> Thankfully,
>
> ~Robert
>
>
> [1] https://askubuntu.com/questions/803869/is-there-an-
> indicator-to-quickly-access-recently-used-files/804533?
> noredirect=1#comment1221806_804533
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/audio-recorder/+bug/1610508/+subscriptions
>

--
Sent from my PC, laptop or phone with Ubuntu-Linux.