Feature request: Always ask where to save file?

Bug #1610508 reported by Or Schiro
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Audio Recorder
New
Undecided
Andrey Novikov

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

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

Hello,
Thanks for your report.

GTK3 has a GtkRecentManager class that can manage the xbel file.
https://developer.gnome.org/gtk3/stable/GtkRecentManager.html

It would be easy to add this to the audio-recorder (no need for GTK
open-file dialog).

BTW: I have not worked on the audio-recorder for a long time.
Maybe the team (at https://launchpad.net/~audio-recorder ) will continue to
maintain it.
Let us see what happens.

Cumprimentos
   Osmo (moma) Antero

On Sat, Aug 6, 2016 at 8:30 AM, Robert Orzanna <email address hidden> wrote:

> Public bug reported:
>
> 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
>
> ** Affects: audio-recorder
> Importance: Undecided
> Status: New
>
> --
> 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.

Revision history for this message
moma (osmoma) wrote :

Re-hi,
If you make a sample code (with GtkRecentManager) I will bake it to audio-recoder for Ubuntu 16.04+.

Revision history for this message
Or Schiro (orschiro) wrote :

Thank you Osmo!

You're referring to something like this?

GtkRecentManager *manager;
GtkRecentInfo *info;
GError *error = NULL;

manager = gtk_recent_manager_get_default ();
info = gtk_recent_manager_lookup_item (manager, file_uri, &error);
if (error)
  {
    g_warning ("Could not find the file: %s", error->message);
    g_error_free (error);
  }
else
 {
   // Use the info object
   gtk_recent_info_unref (info);
 }

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

Yes, very good start, but make a complete sample code, like shown in
test1.c. You may continue from it.
I like to use "gedit" editor and a terminal window.

Look for the audio-recorder/debian/control file to see what -dev packages
you might need. For example:
sudo apt install autotools-dev gettext intltool pkg-config libgtk-3-dev
libglib2.0-dev libdbus-1-dev libappindicator3-dev

// test1.c
#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>

// Ref: https://developer.gnome.org/gtk3/stable/gtk-getting-started.html
// https://developer.gnome.org/gtk3/stable/GtkRecentManager.html

// Compile:
// gcc $(pkg-config --cflags gtk+-3.0) -o test1 test1.c $(pkg-config
--libs gtk+-3.0)
//
// Run:
// ./test1

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

  const gchar *file_uri = "test1.c";

  GtkRecentManager *manager = gtk_recent_manager_get_default();
  gtk_recent_manager_add_item(manager, file_uri);

  // Notice: It is better to call gtk_recent_manager_add_full with correct
GtkRecentData; mime type, exec app name, etc..
  //
  // Ref:
https://developer.gnome.org/gtk3/stable/GtkRecentManager.html#GtkRecentData

  // gboolean gtk_recent_manager_add_full (GtkRecentManager *manager,
  // const gchar *uri,
  // const GtkRecentData *recent_data);

}

static void activateApp(GtkApplication* app, gpointer user_data) {
 GtkWidget *window;
  GtkWidget *button;
  GtkWidget *button_box;

  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);

  button_box = gtk_button_box_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_container_add (GTK_CONTAINER (window), button_box);

  button = gtk_button_new_with_label ("Save to recent files...");
  g_signal_connect (button, "clicked", G_CALLBACK (saveToXBel), NULL);
  g_signal_connect_swapped (button, "clicked", G_CALLBACK
(gtk_widget_destroy), window);
  gtk_container_add (GTK_CONTAINER (button_box), button);

  gtk_widget_show_all (window);
}

int main(int argc, char **argv) {
  GtkApplication *app;
  int status;

  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activateApp), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);

  return status;
}

On Sat, Aug 6, 2016 at 10:11 AM, Robert Orzanna <email address hidden> wrote:

> Thank you Osmo!
>
> You're referring to something like this?
>
> GtkRecentManager *manager;
> GtkRecentInfo *info;
> GError *error = NULL;
>
> manager = gtk_recent_manager_get_default ();
> info = gtk_recent_manager_lookup_item (manager, file_uri, &error);
> if (error)
> {
> g_warning ("Could not find the file: %s", error->message);
> g_error_free (error);
> }
> else
> {
> // Use the info object
> gtk_recent_info_unref (info);
> }
>
> --
> 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 Recor...

Read more...

Revision history for this message
Or Schiro (orschiro) wrote :

Hi Osmo,

Thank you really for your guidance!

I will try to continue from here.

That's a good exercise. :-)

What should the final sample code actually look like?

What is it supposed to be doing?

Should I basically adapt test1.c to the code base of Audio Recorder?

~Robert

Revision history for this message
moma (osmoma) wrote :

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

Revision history for this message
Or Schiro (orschiro) 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

Revision history for this message
moma (osmoma) wrote :

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.

Revision history for this message
Or Schiro (orschiro) wrote :

Great! So, how do we proceed from here to bake the code into? :-)

~Robert

Revision history for this message
moma (osmoma) wrote :

Ok, very good.

1) Download the source of audio-recorder to your computer.
Ref: https://code.launchpad.net/audio-recorder

Read README and INSTALL files.
http://bazaar.launchpad.net/~audio-recorder/audio-recorder/trunk/view/head:/INSTALL

Learn to compile and run the program.
Remember to kill the existing audio-recorder before testing your local copy
from .../src/

$ pkill audio-recorder
------

2) Find a suitable place to add the new code.
http://bazaar.launchpad.net/~audio-recorder/audio-recorder/trunk/files/head:/src/

See gst-recorder.c file and function

void rec_stop_recording(gboolean delete_file) {
...
}
Add the code there.
--------

3) The code must check if the recorded file is valid (if it exists and its
size is > 0)
The code must check if the lastly recorded audio file is already in the
xbel recent list. Do not add duplicates.
Ref: https://developer.gnome.org/gtk3/stable/GtkRecentManager.html

gtk_recent_manager_has_item ()

Let me know about your results.
Good luck.

Kindly
  Moma

On Sun, Aug 7, 2016 at 12:28 PM, Robert Orzanna <email address hidden> wrote:

> Great! So, how do we proceed from here to bake the code into? :-)
>
> ~Robert
>
> --
> 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.

Revision history for this message
moma (osmoma) wrote :

Re-hi Robert,

(this is optional)

You may also a new option to [Additional settings] dialog.
http://bazaar.launchpad.net/~audio-recorder/audio-recorder/trunk/view/head:/src/settings.c

New option could be a checkbox with text:
 [x] Add new recordings to recent files list.

Some users may not want to add recordings to the xbel recent files.

The new option can be of type BOOLEAN. See
http://bazaar.launchpad.net/~audio-recorder/audio-recorder/trunk/view/head:/data/org.gnome.audio-recorder.gschema.xml

Cumprimentos
  Moma
  Portugal

On Sun, Aug 7, 2016 at 7:20 PM, Osmo Antero <email address hidden> wrote:

> Ok, very good.
>
> 1) Download the source of audio-recorder to your computer.
> Ref: https://code.launchpad.net/audio-recorder
>
> Read README and INSTALL files.
> http://bazaar.launchpad.net/~audio-recorder/audio-recorder/
> trunk/view/head:/INSTALL
>
> Learn to compile and run the program.
> Remember to kill the existing audio-recorder before testing your local
> copy from .../src/
>
> $ pkill audio-recorder
> ------
>
> 2) Find a suitable place to add the new code.
> http://bazaar.launchpad.net/~audio-recorder/audio-recorder/
> trunk/files/head:/src/
>
> See gst-recorder.c file and function
>
> void rec_stop_recording(gboolean delete_file) {
> ...
> }
> Add the code there.
> --------
>
> 3) The code must check if the recorded file is valid (if it exists and its
> size is > 0)
> The code must check if the lastly recorded audio file is already in the
> xbel recent list. Do not add duplicates.
> Ref: https://developer.gnome.org/gtk3/stable/GtkRecentManager.html
>
> gtk_recent_manager_has_item ()
>
> Let me know about your results.
> Good luck.
>
> Kindly
> Moma
>
>
>
>
>
>
>
> On Sun, Aug 7, 2016 at 12:28 PM, Robert Orzanna <email address hidden>
> wrote:
>
>> Great! So, how do we proceed from here to bake the code into? :-)
>>
>> ~Robert
>>
>> --
>> 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.
>

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

Revision history for this message
Or Schiro (orschiro) wrote :

Thank you Moma!

Just to let you know that I am on it but need some more time to understand the details. :-)

Warmly,

~Robert

Revision history for this message
Or Schiro (orschiro) wrote :

Dear Moma,

I feel this is going beyond my scope of skills.

I did what you told me and:

- Added the function below the function rec_stop_recording(gboolean delete_file) {
- Integrated the gtk_recent_manager_has_item part into the function saveToXBel

Am I doing it right at this stage?

I would appreciate your short feedback!

Thankfully,

~Robert

Revision history for this message
Or Schiro (orschiro) wrote :

My updated gst-recorder.c

Revision history for this message
moma (osmoma) wrote :

Re-hi,
Very good, but first, you must learn to compile and run the program. You can add modifications later on and I will help you. Your code (in gst-recorder.c) WILL NOT COMPILE! It is not complete.

Step 0)
Install these -dev packages. Run each sudo apt-get install... command separately in a terminal window (notice the long line)

sudo apt install autotools-dev gettext intltool pkg-config libgtk-3-dev libglib2.0-dev libgstreamer1.0-dev libdbus-1-dev libappindicator3-dev libgstreamer-plugins-base1.0-dev

sudo apt install pulseaudio gstreamer1.0-pulseaudio gstreamer1.0-plugins-base gstreamer1.0-plugins-good

sudo apt install build-essential autotools-dev automake autoconf intltool gettext libtool devscripts

------------
Step 1) Learn to ./configure and compile the program.

# Move into your audio-recorder folder
cd audio-recorder

make clean
./configure
make
------------

Step 2) If your code has no errors, test it

pkill audio-recorder
src/audio-recorder

src/audio-recorder --help
------------

Step 3)
Next time you make changes, just run "make" again. It will re-compile your code.

make
# pkill audio-recorder
src/audio-recorder
------------

Please tell me how you're doing.

Revision history for this message
moma (osmoma) wrote :

Notice.
You may need to run "sudo make install" at least once in the step 1. You just need to run it once after first successful make.

make clean
./configure
make
sudo make install

Very good Robert. Go on!

Revision history for this message
Or Schiro (orschiro) wrote :

Thanks Moma!

I finally got it compiled and now know how to recompile it after making changes to the code. :-)

What do you advise as a next step?

Thankfully,

-Robert

Revision history for this message
moma (osmoma) wrote :

Re-hi,

0) Create a new c-function in the gst-recorder.c module that takes a filename (of the recorded file) as argument. See the previous examples and postings in this thread.

You must check if the filename is valid, it exists, its size is > 0, etc.

If the file is not valid: then bail out.
If the file is valid: Save it to the xbel recent list. Fill the GtkRecentData structure with correct values.

Also check if the file has already been added to the recent-files list. Do not add duplicates.
----

1) Call your new function from rec_stop_recording(...) function.
Add it to the very end.

You can obtain the recorded filename by:

gchar *filename = NULL;
conf_get_string_value("track/last-file-name", &filename);

Then call
your-new-function(filename);
g_free(filename);

Use g_print("xxxx") as help to debug your code.
----
Please PM me (send a private message) if you need help.

Revision history for this message
Andrey Novikov (andreynovikov) wrote :

 audio-recorder 1.9.7-1 don't work with skype for linux 5.3.0.1 in archlinux
$ audio-recorder

(audio-recorder:31171): Gdk-CRITICAL **: gdk_window_thaw_toplevel_updates: assertion 'window->update_and_descendants_freeze_count > 0' failed
Error:Cannot create element "pulsesrc" ((null)).
Error:Cannot create element "level" (level).

(audio-recorder:31171): GStreamer-CRITICAL **: gst_bin_add_many: assertion 'GST_IS_ELEMENT (element_1)' failed

(audio-recorder:31171): GStreamer-CRITICAL **: gst_element_link_many: assertion 'GST_IS_ELEMENT (element_1)' failed
Error:Невозможно создать звуковой конвейер. Cannot link..

Changed in audio-recorder:
assignee: nobody → Андрей (cooking95)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.