[glibmm] Add Glib::get_user_special_dir(UserDirectory)



commit 6df99849edfc372edad25b102fe20458cc0b36cb
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Wed Apr 15 17:03:21 2015 +0200

    Add Glib::get_user_special_dir(UserDirectory)
    
    * glib/src/miscutils.[hg|ccg]: Add _WRAP_ENUM(UserDirectory,...) and
    Glib::get_user_special_dir(UserDirectory directory).
    Deprecate get_user_special_dir(GUserDirectory directory). Bug #747311.

 glib/src/miscutils.ccg |    7 +++++++
 glib/src/miscutils.hg  |   34 +++++++++++++++++++++++++++++-----
 2 files changed, 36 insertions(+), 5 deletions(-)
---
diff --git a/glib/src/miscutils.ccg b/glib/src/miscutils.ccg
index d87936d..3beabc9 100644
--- a/glib/src/miscutils.ccg
+++ b/glib/src/miscutils.ccg
@@ -103,10 +103,17 @@ std::string get_current_dir()
   return convert_return_gchar_ptr_to_stdstring(g_get_current_dir());
 }
 
+#ifndef GLIBMM_DISABLE_DEPRECATED
 std::string get_user_special_dir(GUserDirectory directory)
 {
   return convert_const_gchar_ptr_to_stdstring(g_get_user_special_dir(directory));
 }
+#endif // GLIBMM_DISABLE_DEPRECATED
+
+std::string get_user_special_dir(UserDirectory directory)
+{
+  return convert_const_gchar_ptr_to_stdstring(g_get_user_special_dir((GUserDirectory)directory));
+}
 
 std::string get_user_data_dir()
 {
diff --git a/glib/src/miscutils.hg b/glib/src/miscutils.hg
index 9f3fecf..f4833f5 100644
--- a/glib/src/miscutils.hg
+++ b/glib/src/miscutils.hg
@@ -22,6 +22,7 @@ _DEFS(glibmm,glib)
 
 namespace Glib
 {
+_WRAP_ENUM(UserDirectory, GUserDirectory, NO_GTYPE)
 _WRAP_ENUM(FormatSizeFlags, GFormatSizeFlags, NO_GTYPE)
 
 /** @defgroup MiscUtils Miscellaneous Utility Functions
@@ -164,23 +165,46 @@ std::string get_tmp_dir();
  */
 std::string get_current_dir();
 
-//TODO: We could create a C++ enum to wrap the C GUserDirectory enum,
-//but we would have to either be very careful, or define the enum
-//values in terms of the C enums anyway.
+#ifndef GLIBMM_DISABLE_DEPRECATED
 /** Returns the full path of a special directory using its logical id.
  *
  * On Unix this is done using the XDG special user directories.
+ * For compatibility with existing practise, G_USER_DIRECTORY_DESKTOP
+ * falls back to `$HOME/Desktop` when XDG special user directories have
+ * not been set up.
  *
  * Depending on the platform, the user might be able to change the path
  * of the special directory without requiring the session to restart; GLib
  * will not reflect any change once the special directories are loaded.
  *
- * Return value: the path to the specified special directory.
- * @param directory Te logical id of special directory
+ * @param directory The logical id of special directory.
+ * @return The path to the specified special directory, or an empty string
+ *         if the logical id was not found.
  *
  * @newin{2,14}
+ * @deprecated Use get_user_special_dir(Glib::UserDirectory directory) instead.
  */
 std::string get_user_special_dir(GUserDirectory directory);
+#endif // GLIBMM_DISABLE_DEPRECATED
+
+/** Returns the full path of a special directory using its logical id.
+ *
+ * On Unix this is done using the XDG special user directories.
+ * For compatibility with existing practise, Glib::USER_DIRECTORY_DESKTOP
+ * falls back to `$HOME/Desktop` when XDG special user directories have
+ * not been set up.
+ *
+ * Depending on the platform, the user might be able to change the path
+ * of the special directory without requiring the session to restart; GLib
+ * will not reflect any change once the special directories are loaded.
+ *
+ * @param directory The logical id of special directory.
+ * @return The path to the specified special directory, or an empty string
+ *         if the logical id was not found.
+ *
+ * @newin{2,46}
+ */
+std::string get_user_special_dir(UserDirectory directory);
 
 /** Returns a base directory in which to access application data such as icons
  * that is customized for a particular user.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]