Comment 4 for bug 1610508

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

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 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.