From: Frédéric Péters Date: Wed, 3 Oct 2012 09:21:00 +0000 (+0200) Subject: initial version, as posted on my blog X-Git-Url: https://git.0d.be/?p=recent.git;a=commitdiff_plain;h=751a83132061902154cb2eacc3cc53bd63d542bd initial version, as posted on my blog --- 751a83132061902154cb2eacc3cc53bd63d542bd 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; +}