diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c index 4940a14..4e590cd 100644 --- a/mousepad/mousepad-window.c +++ b/mousepad/mousepad-window.c @@ -2447,13 +2447,19 @@ mousepad_window_menu_templates (GtkWidget *item, /* schedule the idle build of the recent menu */ mousepad_window_recent_menu (window); - /* get the home directory */ - homedir = g_getenv ("HOME"); - if (G_UNLIKELY (homedir == NULL)) - homedir = g_get_home_dir (); - /* get the templates path */ - templates_path = g_build_filename (homedir, "Templates", NULL); + templates_path = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_TEMPLATES)); + + /* check if the templates directory is valid */ + if (G_UNLIKELY (templates_path == NULL)) + { + /* if not, fall back to "~/Templates" */ + homedir = g_getenv ("HOME"); + if (G_UNLIKELY (homedir == NULL)) + homedir = g_get_home_dir (); + + templates_path = g_build_filename (homedir, "Templates", NULL); + } /* create submenu */ submenu = gtk_menu_new ();