]> git.0d.be Git - recent.git/commitdiff
initial version, as posted on my blog
authorFrédéric Péters <fpeters@0d.be>
Wed, 3 Oct 2012 09:21:00 +0000 (11:21 +0200)
committerFrédéric Péters <fpeters@0d.be>
Thu, 12 Feb 2015 10:16:57 +0000 (11:16 +0100)
recent.c [new file with mode: 0644]

diff --git a/recent.c b/recent.c
new file mode 100644 (file)
index 0000000..4da9721
--- /dev/null
+++ b/recent.c
@@ -0,0 +1,49 @@
+/*
+ *  Copyright (c) 2012 Frederic Peters <fpeters@0d.be>
+ *                All Rights Reserved
+ *
+ *  This program is free software. It comes without any warranty, to
+ *  the extent permitted by applicable law. You can redistribute it
+ *  and/or modify it under the terms of the Do What The Fuck You Want
+ *  To Public License, Version 2, as published by Sam Hocevar. See
+ *  http://sam.zoy.org/wtfpl/COPYING for more details.
+ */
+
+#include <gtk/gtk.h>
+
+static GMainLoop *main_loop;
+
+void
+manager_changed(GtkRecentManager *manager)
+{
+       g_main_loop_quit(main_loop);
+}
+
+int
+main(int argc, char *argv[])
+{
+       GFile *file;
+       char *file_uri;
+       GtkRecentManager *manager;
+
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
+               return 1;
+       }
+
+       gtk_init_check(&argc, &argv);
+       main_loop = g_main_loop_new(NULL, FALSE);
+
+       file = g_file_new_for_path(argv[1]);
+       file_uri = g_file_get_uri(file);
+
+       manager = gtk_recent_manager_get_default();
+       gtk_recent_manager_add_item(manager, file_uri);
+       g_free(file_uri);
+
+       g_signal_connect(manager, "changed", G_CALLBACK(manager_changed), NULL);
+
+       g_main_loop_run(main_loop);
+
+       return 0;
+}