|
|
51e881a |
--- gnome-screensaver-2.18.0/savers/personal-slideshow.desktop.in.user-dirs 2007-03-30 22:35:28.000000000 -0400
|
|
|
51e881a |
+++ gnome-screensaver-2.18.0/savers/personal-slideshow.desktop.in 2007-03-30 22:37:33.000000000 -0400
|
|
|
51e881a |
@@ -2,7 +2,7 @@
|
|
|
51e881a |
Encoding=UTF-8
|
|
|
51e881a |
_Name=Pictures folder
|
|
|
51e881a |
_Comment=Display a slideshow from your Pictures folder
|
|
|
51e881a |
-Exec=slideshow --location=Pictures
|
|
|
51e881a |
+Exec=slideshow
|
|
|
51e881a |
TryExec=slideshow
|
|
|
51e881a |
StartupNotify=false
|
|
|
51e881a |
Terminal=false
|
|
|
51e881a |
--- gnome-screensaver-2.18.0/savers/slideshow.c.user-dirs 2007-02-22 23:39:09.000000000 -0500
|
|
|
9e97bb3 |
+++ gnome-screensaver-2.18.0/savers/slideshow.c 2007-04-01 09:17:56.000000000 -0400
|
|
|
51e881a |
@@ -34,6 +34,8 @@
|
|
|
51e881a |
#include "gs-theme-engine.h"
|
|
|
51e881a |
#include "gste-slideshow.h"
|
|
|
51e881a |
|
|
|
51e881a |
+#include "xdg-user-dir-lookup.c"
|
|
|
51e881a |
+
|
|
|
51e881a |
int
|
|
|
51e881a |
main (int argc, char **argv)
|
|
|
51e881a |
{
|
|
|
9e97bb3 |
@@ -79,6 +81,16 @@
|
|
|
51e881a |
G_CALLBACK (gtk_main_quit), NULL);
|
|
|
51e881a |
|
|
|
51e881a |
engine = g_object_new (GSTE_TYPE_SLIDESHOW, NULL);
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (location == NULL) {
|
|
|
51e881a |
+ location = xdg_user_dir_lookup ("PICTURES");
|
|
|
9e97bb3 |
+ if (strcmp (location, "/tmp") == 0 ||
|
|
|
9e97bb3 |
+ strcmp (location, g_get_home_dir ()) == 0) {
|
|
|
9e97bb3 |
+ free (location);
|
|
|
9e97bb3 |
+ location = g_build_filename (g_get_home_dir (), "Pictures", NULL);
|
|
|
9e97bb3 |
+ }
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+
|
|
|
51e881a |
if (location != NULL) {
|
|
|
51e881a |
g_object_set (engine, "images-location", location, NULL);
|
|
|
51e881a |
}
|
|
|
9e97bb3 |
--- /dev/null 2007-04-01 08:32:00.119333847 -0400
|
|
|
51e881a |
+++ gnome-screensaver-2.18.0/savers/xdg-user-dir-lookup.c 2007-03-30 22:13:17.000000000 -0400
|
|
|
51e881a |
@@ -0,0 +1,167 @@
|
|
|
51e881a |
+/*
|
|
|
51e881a |
+ This file is not licenced under the GPL like the rest of the code.
|
|
|
51e881a |
+ Its is under the MIT license, to encourage reuse by cut-and-paste.
|
|
|
51e881a |
+
|
|
|
51e881a |
+ Copyright (c) 2007 Red Hat, inc
|
|
|
51e881a |
+
|
|
|
51e881a |
+ Permission is hereby granted, free of charge, to any person
|
|
|
51e881a |
+ obtaining a copy of this software and associated documentation files
|
|
|
51e881a |
+ (the "Software"), to deal in the Software without restriction,
|
|
|
51e881a |
+ including without limitation the rights to use, copy, modify, merge,
|
|
|
51e881a |
+ publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
51e881a |
+ and to permit persons to whom the Software is furnished to do so,
|
|
|
51e881a |
+ subject to the following conditions:
|
|
|
51e881a |
+
|
|
|
51e881a |
+ The above copyright notice and this permission notice shall be
|
|
|
51e881a |
+ included in all copies or substantial portions of the Software.
|
|
|
51e881a |
+
|
|
|
51e881a |
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
51e881a |
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
51e881a |
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
51e881a |
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
|
51e881a |
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
|
51e881a |
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
51e881a |
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
51e881a |
+ SOFTWARE.
|
|
|
51e881a |
+*/
|
|
|
51e881a |
+
|
|
|
51e881a |
+#include <stdio.h>
|
|
|
51e881a |
+#include <stdlib.h>
|
|
|
51e881a |
+#include <string.h>
|
|
|
51e881a |
+
|
|
|
51e881a |
+
|
|
|
51e881a |
+static char *
|
|
|
51e881a |
+xdg_user_dir_lookup (const char *type)
|
|
|
51e881a |
+{
|
|
|
51e881a |
+ FILE *file;
|
|
|
51e881a |
+ char *home_dir, *config_home, *config_file;
|
|
|
51e881a |
+ char buffer[512];
|
|
|
51e881a |
+ char *user_dir;
|
|
|
51e881a |
+ char *p, *d;
|
|
|
51e881a |
+ int len;
|
|
|
51e881a |
+ int relative;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ home_dir = getenv ("HOME");
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (home_dir == NULL)
|
|
|
51e881a |
+ return strdup ("/tmp");
|
|
|
51e881a |
+
|
|
|
51e881a |
+ config_home = getenv ("XDG_CONFIG_HOME");
|
|
|
51e881a |
+ if (config_home == NULL || config_home[0] == 0)
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
|
|
|
51e881a |
+ strcpy (config_file, home_dir);
|
|
|
51e881a |
+ strcat (config_file, "/.config/user-dirs.dirs");
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+ else
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
|
|
|
51e881a |
+ strcpy (config_file, config_home);
|
|
|
51e881a |
+ strcat (config_file, "/user-dirs.dirs");
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+
|
|
|
51e881a |
+ file = fopen (config_file, "r");
|
|
|
51e881a |
+ free (config_file);
|
|
|
51e881a |
+ if (file == NULL)
|
|
|
51e881a |
+ goto error;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ user_dir = NULL;
|
|
|
51e881a |
+ while (fgets (buffer, sizeof (buffer), file))
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ /* Remove newline at end */
|
|
|
51e881a |
+ len = strlen (buffer);
|
|
|
51e881a |
+ if (len > 0 && buffer[len-1] == '\n')
|
|
|
51e881a |
+ buffer[len-1] = 0;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ p = buffer;
|
|
|
51e881a |
+ while (*p == ' ' || *p == '\t')
|
|
|
51e881a |
+ p++;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (strncmp (p, "XDG_", 4) != 0)
|
|
|
51e881a |
+ continue;
|
|
|
51e881a |
+ p += 4;
|
|
|
51e881a |
+ if (strncmp (p, type, strlen (type)) != 0)
|
|
|
51e881a |
+ continue;
|
|
|
51e881a |
+ p += strlen (type);
|
|
|
51e881a |
+ if (strncmp (p, "_DIR", 4) != 0)
|
|
|
51e881a |
+ continue;
|
|
|
51e881a |
+ p += 4;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ while (*p == ' ' || *p == '\t')
|
|
|
51e881a |
+ p++;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (*p != '=')
|
|
|
51e881a |
+ continue;
|
|
|
51e881a |
+ p++;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ while (*p == ' ' || *p == '\t')
|
|
|
51e881a |
+ p++;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (*p != '"')
|
|
|
51e881a |
+ continue;
|
|
|
51e881a |
+ p++;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ relative = 0;
|
|
|
51e881a |
+ if (strncmp (p, "$HOME/", 6) == 0)
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ p += 6;
|
|
|
51e881a |
+ relative = 1;
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+ else if (*p != '/')
|
|
|
51e881a |
+ continue;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (relative)
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
|
|
|
51e881a |
+ strcpy (user_dir, home_dir);
|
|
|
51e881a |
+ strcat (user_dir, "/");
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+ else
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ user_dir = malloc (strlen (p) + 1);
|
|
|
51e881a |
+ *user_dir = 0;
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+
|
|
|
51e881a |
+ d = user_dir + strlen (user_dir);
|
|
|
51e881a |
+ while (*p && *p != '"')
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ if ((*p == '\\') && (*(p+1) != 0))
|
|
|
51e881a |
+ p++;
|
|
|
51e881a |
+ *d++ = *p++;
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+ *d = 0;
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+ fclose (file);
|
|
|
51e881a |
+
|
|
|
51e881a |
+ if (user_dir)
|
|
|
51e881a |
+ return user_dir;
|
|
|
51e881a |
+
|
|
|
51e881a |
+ error:
|
|
|
51e881a |
+ /* Special case desktop for historical compatibility */
|
|
|
51e881a |
+ if (strcmp (type, "DESKTOP") == 0)
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
|
|
|
51e881a |
+ strcpy (user_dir, home_dir);
|
|
|
51e881a |
+ strcat (user_dir, "/Desktop");
|
|
|
51e881a |
+ return user_dir;
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+ else
|
|
|
51e881a |
+ return strdup (home_dir);
|
|
|
51e881a |
+}
|
|
|
51e881a |
+
|
|
|
51e881a |
+#ifdef STANDALONE
|
|
|
51e881a |
+
|
|
|
51e881a |
+int
|
|
|
51e881a |
+main (int argc, char *argv[])
|
|
|
51e881a |
+{
|
|
|
51e881a |
+ if (argc != 2)
|
|
|
51e881a |
+ {
|
|
|
51e881a |
+ fprintf (stderr, "Usage %s <dir-type>\n", argv[0]);
|
|
|
51e881a |
+ exit (1);
|
|
|
51e881a |
+ }
|
|
|
51e881a |
+
|
|
|
51e881a |
+ printf ("%s\n", xdg_user_dir_lookup (argv[1]));
|
|
|
51e881a |
+ return 0;
|
|
|
51e881a |
+}
|
|
|
51e881a |
+
|
|
|
51e881a |
+#endif
|