From 751a83132061902154cb2eacc3cc53bd63d542bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 3 Oct 2012 11:21:00 +0200 Subject: [PATCH] initial version, as posted on my blog --- recent.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 recent.c diff --git a/recent.c b/recent.c new file mode 100644 index 0000000..4da9721 --- /dev/null +++ b/recent.c @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2012 Frederic Peters + * 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 + +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; +} -- 2.39.2