From baaca4c58f92115676638599fa50c35b50351f9c Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Tue, 2 Nov 2021 10:56:46 +0100 Subject: Add all opened files to the recent list The GTK+ file open/save dialog has already been adding them, but opening files from the command line would circumvent that path. --- src/ld-window-main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ld-window-main.c b/src/ld-window-main.c index cbf9fd9..51769f6 100644 --- a/src/ld-window-main.c +++ b/src/ld-window-main.c @@ -712,9 +712,10 @@ diagram_save (LdWindowMain *self, GtkWindow *dialog_parent, static gboolean diagram_open (LdWindowMain *self, const gchar *filename) { - GError *error; + GError *error = NULL; + GFile *file; + gchar *uri; - error = NULL; ld_diagram_load_from_file (self->priv->diagram, filename, &error); if (error) { @@ -748,6 +749,12 @@ diagram_open (LdWindowMain *self, const gchar *filename) return FALSE; } + file = g_file_new_for_path (filename); + uri = g_file_get_uri (file); + g_object_unref (file); + gtk_recent_manager_add_item (gtk_recent_manager_get_default (), uri); + g_free (uri); + ld_diagram_set_modified (self->priv->diagram, FALSE); diagram_set_filename (self, g_strdup (filename)); return TRUE; -- cgit v1.2.3-70-g09d2