diff options
author | Sergios - Anestis Kefalidis <megistios@gmail.com> | 2021-07-24 13:34:25 +0000 |
---|---|---|
committer | Alexander Schwinn <alexxcons@xfce.org> | 2021-07-24 13:34:25 +0000 |
commit | a12e4164e1095aad9ca557c75887f1490f39f08b (patch) | |
tree | f748019eac2d938a055422147b6c2a90e042bcd3 /tumblerd | |
parent | 50555624288c9f4237fc7661ff15b8990afb7aab (diff) | |
download | tumbler-a12e4164e1095aad9ca557c75887f1490f39f08b.tar.gz |
Support shared thumbnail repositories of the freedesktop.org thumbnail spec
Related:
https://gitlab.xfce.org/xfce/libxfce4util/-/merge_requests/18
https://gitlab.xfce.org/xfce/thunar/-/merge_requests/126
https://gitlab.xfce.org/xfce/thunar/-/issues/262
Diffstat (limited to 'tumblerd')
-rw-r--r-- | tumblerd/Makefile.am | 2 | ||||
-rw-r--r-- | tumblerd/main.c | 120 |
2 files changed, 4 insertions, 118 deletions
diff --git a/tumblerd/Makefile.am b/tumblerd/Makefile.am index b1ac6a8..f649d9b 100644 --- a/tumblerd/Makefile.am +++ b/tumblerd/Makefile.am @@ -67,6 +67,7 @@ tumblerd_CFLAGS = \ $(GLIB_CFLAGS) \ $(GTHREAD_CFLAGS) \ $(PLATFORM_CFLAGS) \ + $(LIBXFCE4UTIL_CFLAGS) \ $(PLATFORM_CPPFLAGS) tumblerd_LDFLAGS = \ @@ -82,6 +83,7 @@ tumblerd_LDADD = \ $(GIO_UNIX_LIBS) \ $(GLIB_LIBS) \ $(GTHREAD_LIBS) \ + $(LIBXFCE4UTIL_LIBS) \ $(top_builddir)/tumbler/libtumbler-$(TUMBLER_VERSION_API).la servicedir = $(datadir)/dbus-1/services diff --git a/tumblerd/main.c b/tumblerd/main.c index e93c83b..c621acb 100644 --- a/tumblerd/main.c +++ b/tumblerd/main.c @@ -47,6 +47,8 @@ #include <tumblerd/tumbler-registry.h> #include <tumblerd/tumbler-service.h> +#include <libxfce4util/libxfce4util.h> + static void @@ -74,124 +76,6 @@ xfce_is_valid_tilde_prefix (const gchar *p) } -/* from libxfce4util */ -static gchar * -xfce_expand_variables (const gchar *command, - gchar **envp) -{ - GString *buf; - const gchar *start; - gchar *variable; - const gchar *p; - const gchar *value; - gchar **ep; - guint len; -#ifdef HAVE_GETPWNAM - struct passwd *pw; - gchar *username; -#endif - - if (G_UNLIKELY (command == NULL)) - return NULL; - - buf = g_string_sized_new (strlen (command)); - - for (p = command; *p != '\0'; ++p) - { - continue_without_increase: - - if (*p == '~' - && (p == command - || xfce_is_valid_tilde_prefix (p - 1))) - { - /* walk to the end of the string or to a directory separator */ - for (start = ++p; *p != '\0' && *p != G_DIR_SEPARATOR; ++p); - - if (G_LIKELY (start == p)) - { - /* add the current user directory */ - buf = g_string_append (buf, g_get_home_dir ()); - } - else - { -#ifdef HAVE_GETPWNAM - username = g_strndup (start, p - start); - pw = getpwnam (username); - g_free (username); - - /* add the users' home directory if found, fallback to the - * not-expanded string */ - if (pw != NULL && pw->pw_dir != NULL) - buf = g_string_append (buf, pw->pw_dir); - else -#endif - buf = g_string_append_len (buf, start - 1, p - start + 1); - } - - /* we are either at the end of the string or *p is a separator, - * so continue to add it to the result buffer */ - } - else if (*p == '$') - { - /* walk to the end of a valid variable name */ - for (start = ++p; *p != '\0' && (g_ascii_isalnum (*p) || *p == '_'); ++p); - - if (start < p) - { - value = NULL; - len = p - start; - - /* lookup the variable in the environment supplied by the user */ - if (envp != NULL) - { - /* format is NAME=VALUE */ - for (ep = envp; *ep != NULL; ++ep) - if (strncmp (*ep, start, len) == 0 - && (*ep)[len] == '=') - { - value = (*ep) + len + 1; - break; - } - } - - /* fallback to the environment */ - if (value == NULL) - { - variable = g_strndup (start, len); - value = g_getenv (variable); - g_free (variable); - } - - if (G_LIKELY (value != NULL)) - { - buf = g_string_append (buf, value); - } - else - { - /* the variable name was valid, but no value was - * found, insert nothing and continue */ - } - - /* *p is at the start of the charater after the variable, - * so continue scanning without advancing the string offset - * so two variables are replaced properly */ - goto continue_without_increase; - } - else - { - /* invalid variable format, add the - * $ character and continue */ - --p; - } - } - - buf = g_string_append_c (buf, *p); - } - - return g_string_free (buf, FALSE); -} - - static GSList * locations_from_strv (gchar **array) |