[Xfce4-commits] [apps/mousepad] 01/01: Use g_get_user_dir to get Templates directory (Bug #11048)

noreply at xfce.org noreply at xfce.org
Tue Dec 10 17:07:28 CET 2019


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/mousepad.

commit ea1f76b7afb3592c5eb5fa2c5c9ea0d64c8d2e55
Author: Andre Miranda <andreldm at xfce.org>
Date:   Sun Dec 8 18:12:32 2019 -0300

    Use g_get_user_dir to get Templates directory (Bug #11048)
---
 mousepad/mousepad-window.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 4940a14..44cd736 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -2447,13 +2447,17 @@ 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 and is not home */
+  homedir = g_get_home_dir ();
+
+  if (G_UNLIKELY (templates_path == NULL) || g_strcmp0 (templates_path, homedir) == 0)
+    {
+      /* if not, fall back to "~/Templates" */
+      templates_path = g_build_filename (homedir, "Templates", NULL);
+    }
 
   /* create submenu */
   submenu = gtk_menu_new ();

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list