libgimpbase/Makefile.am removed.

2007-10-31  Michael Natterer  <mitch@gimp.org>

	* libgimpbase/Makefile.am
	* libgimpbase/xdg-user-dir.[ch]: removed.

	* libgimpbase/gimpbaseenums.[ch]: deprecate enum GimpUserDirectory.

	* libgimpbase/gimpenv.[ch]: deprecate gimp_user_directory() and make
	the implementation call g_get_user_special_dir().

	* libgimp/Makefile.am: #undef GIMP_DISABLE_DEPRECATED in gimpenums.c

	* app/widgets/gimpfiledialog.c: use g_get_user_special_dir() instead.

	* plug-ins/pygimp/gimpmodule.c: #undef GIMP_DISABLE_DEPRECATED.


svn path=/trunk/; revision=24018
This commit is contained in:
Michael Natterer 2007-10-31 13:09:46 +00:00 committed by Michael Natterer
parent e728134240
commit 36bda892a9
11 changed files with 30 additions and 366 deletions

View File

@ -1,3 +1,19 @@
2007-10-31 Michael Natterer <mitch@gimp.org>
* libgimpbase/Makefile.am
* libgimpbase/xdg-user-dir.[ch]: removed.
* libgimpbase/gimpbaseenums.[ch]: deprecate enum GimpUserDirectory.
* libgimpbase/gimpenv.[ch]: deprecate gimp_user_directory() and make
the implementation call g_get_user_special_dir().
* libgimp/Makefile.am: #undef GIMP_DISABLE_DEPRECATED in gimpenums.c
* app/widgets/gimpfiledialog.c: use g_get_user_special_dir() instead.
* plug-ins/pygimp/gimpmodule.c: #undef GIMP_DISABLE_DEPRECATED.
2007-10-31 Michael Natterer <mitch@gimp.org>
* configure.in

View File

@ -335,7 +335,7 @@ gimp_file_dialog_new (Gimp *gimp,
g_object_set_data (G_OBJECT (dialog), "gimp-dialog-help-button", button);
}
pictures = gimp_user_directory (GIMP_USER_DIRECTORY_PICTURES);
pictures = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
if (pictures)
gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),

View File

@ -386,7 +386,7 @@ CLEANFILES = $(gen_sources)
gimpenums.c: $(srcdir)/gimpenums.h $(srcdir)/gimpenums.c.tail $(GIMP_MKENUMS)
$(GIMP_MKENUMS) \
--fhead "#include \"config.h\"\n#include <glib-object.h>\n#include \"libgimpbase/gimpbase.h\"\n#include \"gimpenums.h\"" \
--fhead "#include \"config.h\"\n#include <glib-object.h>\n#undef GIMP_DISABLE_DEPRECATED\n#include \"libgimpbase/gimpbase.h\"\n#include \"gimpenums.h\"" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static const G@Type@Value values[] =\n {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \

View File

@ -114,9 +114,7 @@ libgimpbase_sources = \
gimputils.h \
gimpwin32-io.h \
gimpwire.c \
gimpwire.h \
xdg-user-dir.c \
xdg-user-dir.h
gimpwire.h
libgimpbase_built_sources = \
gimpbaseenums.c
@ -188,7 +186,7 @@ CLEANFILES = $(EXTRA_PROGRAMS) $(gen_sources)
$(srcdir)/gimpbaseenums.c: $(srcdir)/gimpbaseenums.h $(GIMP_MKENUMS)
$(GIMP_MKENUMS) \
--fhead "#include \"config.h\"\n#include <glib-object.h>\n#include \"gimpbasetypes.h\"\n#include \"libgimp/libgimp-intl.h\"" \
--fhead "#include \"config.h\"\n#include <glib-object.h>\n#undef GIMP_DISABLE_DEPRECATED\n#include \"gimpbasetypes.h\"\n#include \"libgimp/libgimp-intl.h\"" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static const G@Type@Value values[] =\n {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \

View File

@ -3,6 +3,7 @@
#include "config.h"
#include <glib-object.h>
#undef GIMP_DISABLE_DEPRECATED
#include "gimpbasetypes.h"
#include "libgimp/libgimp-intl.h"

View File

@ -449,6 +449,7 @@ typedef enum
} GimpProgressCommand;
#ifndef GIMP_DISABLE_DEPRECATED
#define GIMP_TYPE_USER_DIRECTORY (gimp_user_directory_get_type ())
GType gimp_user_directory_get_type (void) G_GNUC_CONST;
@ -464,6 +465,7 @@ typedef enum
GIMP_USER_DIRECTORY_TEMPLATES,
GIMP_USER_DIRECTORY_VIDEOS
} GimpUserDirectory;
#endif /* !GIMP_DISABLE_DEPRECATED */
#define GIMP_TYPE_VECTORS_STROKE_TYPE (gimp_vectors_stroke_type_get_type ())

View File

@ -36,6 +36,7 @@
#define LIBGIMP_COMPILATION
#endif
#undef GIMP_DISABLE_DEPRECATED
#include "gimpbasetypes.h"
#include "gimpenv.h"
@ -64,16 +65,6 @@
#define getegid() 0
#endif
#ifndef G_OS_WIN32
#ifndef HAVE_CARBON
#include "xdg-user-dir.h"
#endif
#endif
#ifdef HAVE_CARBON
#include <CoreServices/CoreServices.h>
#endif
static gchar * gimp_env_get_dir (const gchar *gimp_env_name,
const gchar *env_dir);
@ -404,97 +395,11 @@ gimp_sysconf_directory (void)
return gimp_sysconf_dir;
}
#ifdef G_OS_WIN32
#undef DATADIR /* Collision otherwise */
#include <shlobj.h>
#ifndef CSIDL_MYDOCUMENTS
#define CSIDL_MYDOCUMENTS 0x000C
#endif
#ifndef CSIDL_MYMUSIC
#define CSIDL_MYMUSIC 0x000D
#endif
#ifndef CSIDL_MYVIDEO
#define CSIDL_MYVIDEO 0x000E
#endif
static gchar *
get_special_folder (int csidl)
{
union {
char c[MAX_PATH+1];
wchar_t wc[MAX_PATH+1];
} path;
HRESULT hr;
LPITEMIDLIST pidl = NULL;
BOOL b;
gchar *retval = NULL;
hr = SHGetSpecialFolderLocation (NULL, csidl, &pidl);
if (hr == S_OK)
{
b = SHGetPathFromIDListW (pidl, path.wc);
if (b)
retval = g_utf16_to_utf8 (path.wc, -1, NULL, NULL, NULL);
CoTaskMemFree (pidl);
}
return retval;
}
#endif
#ifdef HAVE_CARBON
static gchar *
find_folder (OSType type)
{
gchar *filename = NULL;
FSRef found;
if (FSFindFolder (kUserDomain, type, kDontCreateFolder, &found) == noErr)
{
CFURLRef url = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &found);
if (url)
{
CFStringRef path = CFURLCopyFileSystemPath (url, kCFURLPOSIXPathStyle);
if (path)
{
filename = g_strdup (CFStringGetCStringPtr (path, kCFStringEncodingUTF8));
if (! filename)
{
filename = g_new0 (gchar, CFStringGetLength (path) * 3 + 1);
CFStringGetCString (path, filename,
CFStringGetLength (path) * 3 + 1,
kCFStringEncodingUTF8);
}
CFRelease (path);
}
CFRelease (url);
}
}
return filename;
}
#endif
static gchar **gimp_user_directories = NULL;
/**
* gimp_user_directory:
* @type: the type of user directory to retrieve
*
* Identifies special folders used frequently by applications, but
* which may not have the same name or location on any given system.
* Plug-ins may want to use this function to add shortcuts to such
* folders to a file-chooser.
* This procedure is deprecated! Use gimp_image_get_colormap() instead.
*
* Returns: The path to the specified user directory, or %NULL if the
* logical ID was not found.
@ -504,79 +409,7 @@ static gchar **gimp_user_directories = NULL;
const gchar *
gimp_user_directory (GimpUserDirectory type)
{
g_return_val_if_fail (type >= GIMP_USER_DIRECTORY_DESKTOP &&
type <= GIMP_USER_DIRECTORY_VIDEOS, NULL);
if (G_UNLIKELY (gimp_user_directories == NULL))
{
gimp_user_directories = g_new0 (gchar *, GIMP_USER_DIRECTORY_VIDEOS + 1);
#ifdef G_OS_WIN32
gimp_user_directories[GIMP_USER_DIRECTORY_DESKTOP] =
get_special_folder (CSIDL_DESKTOPDIRECTORY);
gimp_user_directories[GIMP_USER_DIRECTORY_DOCUMENTS] =
get_special_folder (CSIDL_MYDOCUMENTS);
gimp_user_directories[GIMP_USER_DIRECTORY_DOWNLOAD] =
get_special_folder (CSIDL_DESKTOPDIRECTORY);
gimp_user_directories[GIMP_USER_DIRECTORY_MUSIC] =
get_special_folder (CSIDL_MYMUSIC);
gimp_user_directories[GIMP_USER_DIRECTORY_PICTURES] =
get_special_folder (CSIDL_MYPICTURES);
gimp_user_directories[GIMP_USER_DIRECTORY_PUBLIC_SHARE] =
get_special_folder (CSIDL_COMMON_DOCUMENTS);
gimp_user_directories[GIMP_USER_DIRECTORY_TEMPLATES] =
get_special_folder (CSIDL_TEMPLATES);
gimp_user_directories[GIMP_USER_DIRECTORY_VIDEOS] =
get_special_folder (CSIDL_MYVIDEO);
#elif HAVE_CARBON
gimp_user_directories[GIMP_USER_DIRECTORY_DESKTOP] =
find_folder (kDesktopFolderType);
gimp_user_directories[GIMP_USER_DIRECTORY_DOCUMENTS] =
find_folder (kDocumentsFolderType);
gimp_user_directories[GIMP_USER_DIRECTORY_DOWNLOAD] =
find_folder (kDesktopFolderType); /* ??? */
gimp_user_directories[GIMP_USER_DIRECTORY_MUSIC] =
find_folder (kMusicDocumentsFolderType);
gimp_user_directories[GIMP_USER_DIRECTORY_PICTURES] =
find_folder (kPictureDocumentsFolderType);
gimp_user_directories[GIMP_USER_DIRECTORY_PUBLIC_SHARE] = NULL;
gimp_user_directories[GIMP_USER_DIRECTORY_TEMPLATES] = NULL;
gimp_user_directories[GIMP_USER_DIRECTORY_VIDEOS] =
find_folder (kMovieDocumentsFolderType);
#else
gimp_user_directories[GIMP_USER_DIRECTORY_DESKTOP] =
_xdg_user_dir_lookup ("DESKTOP");
gimp_user_directories[GIMP_USER_DIRECTORY_DOCUMENTS] =
_xdg_user_dir_lookup ("DOCUMENTS");
gimp_user_directories[GIMP_USER_DIRECTORY_DOWNLOAD] =
_xdg_user_dir_lookup ("DOWNLOAD");
gimp_user_directories[GIMP_USER_DIRECTORY_MUSIC] =
_xdg_user_dir_lookup ("MUSIC");
gimp_user_directories[GIMP_USER_DIRECTORY_PICTURES] =
_xdg_user_dir_lookup ("PICTURES");
gimp_user_directories[GIMP_USER_DIRECTORY_PUBLIC_SHARE] =
_xdg_user_dir_lookup ("PUBLICSHARE");
gimp_user_directories[GIMP_USER_DIRECTORY_TEMPLATES] =
_xdg_user_dir_lookup ("TEMPLATES");
gimp_user_directories[GIMP_USER_DIRECTORY_VIDEOS] =
_xdg_user_dir_lookup ("VIDEOS");
#endif
/* Special-case desktop for historical compatibility */
if (gimp_user_directories[GIMP_USER_DIRECTORY_DESKTOP] == NULL)
{
gimp_user_directories[GIMP_USER_DIRECTORY_DESKTOP] =
g_build_filename (g_get_home_dir (), "Desktop", NULL);
}
}
return gimp_user_directories[type];
return g_get_user_special_dir (type);
}
/**

View File

@ -49,7 +49,10 @@ const gchar * gimp_data_directory (void) G_GNUC_CONST;
const gchar * gimp_locale_directory (void) G_GNUC_CONST;
const gchar * gimp_sysconf_directory (void) G_GNUC_CONST;
const gchar * gimp_plug_in_directory (void) G_GNUC_CONST;
#ifndef GIMP_DISABLE_DEPRECATED
const gchar * gimp_user_directory (GimpUserDirectory type) G_GNUC_CONST;
#endif /* !GIMP_DISABLE_DEPRECATED */
const gchar * gimp_gtkrc (void) G_GNUC_CONST;
gchar * gimp_personal_rc_file (const gchar *basename) G_GNUC_MALLOC;

View File

@ -1,163 +0,0 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* This code is a slightly modified copy of xdg-user-dir-lockup.c
* as written by Alexander Larsson.
*
* See http://www.freedesktop.org/wiki/Software/xdg-user-dirs
*/
/*
This file is not licenced under the GPL like the rest of the code.
Its is under the MIT license, to encourage reuse by cut-and-paste.
Copyright (c) 2007 Red Hat, inc
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "config.h"
#include <string.h>
#include <glib.h>
#include <glib/gstdio.h>
#include "xdg-user-dir.h"
/**
* xdg_user_dir_lookup_with_fallback:
* @type: a string specifying the type of directory
*
* Looks up a XDG user directory of the specified type.
* Example of types are "DESKTOP" and "DOWNLOAD".
*
* Return value: a newly allocated absolute pathname or %NULL
**/
gchar *
_xdg_user_dir_lookup (const gchar *type)
{
FILE *file;
const gchar *home_dir;
const gchar *config_home;
gchar buffer[512];
gchar *filename;
gchar *user_dir = NULL;
gchar *p, *d;
gint len;
gint relative;
home_dir = g_get_home_dir ();
if (! home_dir)
return NULL;
config_home = g_getenv ("XDG_CONFIG_HOME");
if (! config_home || ! *config_home)
{
filename = g_build_filename (home_dir, ".config", "user-dirs.dirs", NULL);
}
else
{
filename = g_build_filename (config_home, "user-dirs.dirs", NULL);
}
file = g_fopen (filename, "r");
g_free (filename);
if (! file)
return NULL;
while (fgets (buffer, sizeof (buffer), file))
{
/* Remove newline at end */
len = strlen (buffer);
if (len > 0 && buffer[len-1] == '\n')
buffer[len-1] = 0;
p = buffer;
while (*p == ' ' || *p == '\t')
p++;
if (strncmp (p, "XDG_", 4) != 0)
continue;
p += 4;
if (strncmp (p, type, strlen (type)) != 0)
continue;
p += strlen (type);
if (strncmp (p, "_DIR", 4) != 0)
continue;
p += 4;
while (*p == ' ' || *p == '\t')
p++;
if (*p != '=')
continue;
p++;
while (*p == ' ' || *p == '\t')
p++;
if (*p != '"')
continue;
p++;
relative = 0;
if (strncmp (p, "$HOME/", 6) == 0)
{
p += 6;
relative = 1;
}
else if (*p != '/')
continue;
if (relative)
{
user_dir = g_malloc (strlen (home_dir) + 1 + strlen (p) + 1);
strcpy (user_dir, home_dir);
strcat (user_dir, "/");
}
else
{
user_dir = g_malloc (strlen (p) + 1);
*user_dir = 0;
}
d = user_dir + strlen (user_dir);
while (*p && *p != '"')
{
if ((*p == '\\') && (*(p+1) != 0))
p++;
*d++ = *p++;
}
*d = 0;
}
fclose (file);
return user_dir;
}

View File

@ -1,27 +0,0 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __XDG_USER_DIR_H__
#define __XDG_USER_DIR_H__
G_GNUC_INTERNAL gchar * _xdg_user_dir_lookup (const gchar *type);
#endif /* __XDG_USER_DIR_H__ */

View File

@ -21,6 +21,7 @@
# include <config.h>
#endif
#undef GIMP_DISABLE_DEPRECATED
#include "pygimp.h"
#include "pygimpcolor-api.h"