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.
This commit is contained in:
Přemysl Eric Janouch 2021-11-02 10:56:46 +01:00
parent 7499f92811
commit baaca4c58f
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 9 additions and 2 deletions

View File

@ -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;