2003-11-15 20:35:55 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
2003-12-08 23:13:14 +00:00
|
|
|
* gtkfilesystemwin32.c: Default implementation of GtkFileSystem for Windows
|
2003-11-15 20:35:55 +00:00
|
|
|
* Copyright (C) 2003, Red Hat, Inc.
|
2004-05-08 16:25:15 +00:00
|
|
|
* Copyright (C) 2004, Hans Breuer
|
2007-03-07 23:41:05 +00:00
|
|
|
* Copyright (C) 2007, Novell, Inc.
|
|
|
|
* Copyright (C) 2007, Mathias Hasselmann
|
2003-11-15 20:35:55 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Lesser 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.
|
|
|
|
*/
|
|
|
|
|
2006-08-23 08:17:09 +00:00
|
|
|
/* #define this if you want the program to crash when a file system gets
|
|
|
|
* finalized while async handles are still outstanding.
|
|
|
|
*/
|
|
|
|
#undef HANDLE_ME_HARDER
|
|
|
|
|
2004-03-06 03:38:59 +00:00
|
|
|
#include <config.h>
|
2006-05-21 23:48:49 +00:00
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
#include "gtkfilesystem.h"
|
2003-12-08 23:13:14 +00:00
|
|
|
#include "gtkfilesystemwin32.h"
|
2006-05-21 23:48:49 +00:00
|
|
|
#include "gtkicontheme.h"
|
2003-11-15 20:35:55 +00:00
|
|
|
#include "gtkintl.h"
|
|
|
|
#include "gtkstock.h"
|
2003-12-14 19:03:02 +00:00
|
|
|
#include "gtkiconfactory.h"
|
2005-03-20 07:01:23 +00:00
|
|
|
#include "gtkalias.h"
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2004-12-12 21:09:13 +00:00
|
|
|
#include <glib/gstdio.h>
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2004-02-28 23:36:11 +00:00
|
|
|
#include <ctype.h>
|
2003-11-15 20:35:55 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
#define STRICT
|
2005-07-05 22:50:54 +00:00
|
|
|
#include "gdk/win32/gdkwin32.h"
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
#undef STRICT
|
|
|
|
#include <shlobj.h>
|
|
|
|
#include <shellapi.h>
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
#define BOOKMARKS_FILENAME ".gtk-bookmarks"
|
|
|
|
|
|
|
|
#define FOLDER_CACHE_LIFETIME 2 /* seconds */
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
typedef struct _GtkFileSystemWin32Class GtkFileSystemWin32Class;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
#define GTK_FILE_SYSTEM_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_WIN32, GtkFileSystemWin32Class))
|
|
|
|
#define GTK_IS_FILE_SYSTEM_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_WIN32))
|
|
|
|
#define GTK_FILE_SYSTEM_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_WIN32, GtkFileSystemWin32Class))
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
struct _GtkFileSystemWin32Class
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
};
|
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
struct _GtkFileSystemWin32
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
GObject parent_instance;
|
2004-03-24 17:22:36 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
guint32 drives; /* bitmask as returned by GetLogicalDrives() */
|
2004-03-24 17:22:36 +00:00
|
|
|
GHashTable *folder_hash;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
guint timeout;
|
2006-08-23 08:17:09 +00:00
|
|
|
|
|
|
|
GHashTable *handles;
|
2006-09-02 21:42:42 +00:00
|
|
|
|
|
|
|
guint execute_callbacks_idle_id;
|
|
|
|
GSList *callbacks;
|
2003-11-15 20:35:55 +00:00
|
|
|
};
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/* Icon type, supplemented by MIME type
|
|
|
|
*/
|
|
|
|
typedef enum {
|
|
|
|
ICON_UNDECIDED, /* Only used while we have not yet computed the icon in a struct stat_info_entry */
|
|
|
|
ICON_NONE, /* "Could not compute the icon type" */
|
|
|
|
ICON_REGULAR, /* Use mime type for icon */
|
|
|
|
ICON_DIRECTORY,
|
2007-03-07 23:17:38 +00:00
|
|
|
ICON_EXECUTABLE,
|
|
|
|
ICON_VOLUME
|
2006-05-21 23:48:49 +00:00
|
|
|
} IconType;
|
|
|
|
|
|
|
|
|
|
|
|
#define GTK_TYPE_FILE_FOLDER_WIN32 (_gtk_file_folder_win32_get_type ())
|
2003-12-08 23:13:14 +00:00
|
|
|
#define GTK_FILE_FOLDER_WIN32(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER_WIN32, GtkFileFolderWin32))
|
|
|
|
#define GTK_IS_FILE_FOLDER_WIN32(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER_WIN32))
|
|
|
|
#define GTK_FILE_FOLDER_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_FOLDER_WIN32, GtkFileFolderWin32Class))
|
|
|
|
#define GTK_IS_FILE_FOLDER_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_FOLDER_WIN32))
|
|
|
|
#define GTK_FILE_FOLDER_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_FOLDER_WIN32, GtkFileFolderWin32Class))
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
typedef struct _GtkFileFolderWin32 GtkFileFolderWin32;
|
|
|
|
typedef struct _GtkFileFolderWin32Class GtkFileFolderWin32Class;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
struct _GtkFileFolderWin32Class
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
GObjectClass parent_class;
|
|
|
|
};
|
|
|
|
|
2003-12-08 23:13:14 +00:00
|
|
|
struct _GtkFileFolderWin32
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
GObject parent_instance;
|
|
|
|
|
2004-03-24 17:22:36 +00:00
|
|
|
GtkFileSystemWin32 *system_win32;
|
2003-11-15 20:35:55 +00:00
|
|
|
GtkFileInfoType types;
|
|
|
|
gchar *filename;
|
2006-05-21 23:48:49 +00:00
|
|
|
GHashTable *stat_info;
|
|
|
|
guint load_folder_id;
|
|
|
|
guint have_stat : 1;
|
|
|
|
guint have_mime_type : 1;
|
|
|
|
guint is_network_dir : 1;
|
|
|
|
guint is_finished_loading : 1;
|
|
|
|
time_t asof;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct stat_info_entry {
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
|
|
|
char *mime_type;
|
|
|
|
IconType icon_type;
|
|
|
|
gboolean hidden;
|
2003-11-15 20:35:55 +00:00
|
|
|
};
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static const GtkFileInfoType STAT_NEEDED_MASK = (GTK_FILE_INFO_IS_FOLDER |
|
|
|
|
GTK_FILE_INFO_MODIFICATION_TIME |
|
|
|
|
GTK_FILE_INFO_SIZE |
|
|
|
|
GTK_FILE_INFO_ICON);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
static void gtk_file_system_win32_iface_init (GtkFileSystemIface *iface);
|
|
|
|
static void gtk_file_system_win32_dispose (GObject *object);
|
|
|
|
static void gtk_file_system_win32_finalize (GObject *object);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static GSList * gtk_file_system_win32_list_volumes (GtkFileSystem *file_system);
|
2004-01-28 21:46:02 +00:00
|
|
|
static GtkFileSystemVolume *gtk_file_system_win32_get_volume_for_path (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path);
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static GtkFileSystemHandle *gtk_file_system_win32_get_folder (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFileInfoType types,
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemGetFolderCallback callback,
|
|
|
|
gpointer data);
|
|
|
|
static GtkFileSystemHandle *gtk_file_system_win32_get_info (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFileInfoType types,
|
|
|
|
GtkFileSystemGetInfoCallback callback,
|
|
|
|
gpointer data);
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static GtkFileSystemHandle *gtk_file_system_win32_create_folder (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemCreateFolderCallback callback,
|
|
|
|
gpointer data);
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static void gtk_file_system_win32_cancel_operation (GtkFileSystemHandle *handle);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
|
|
|
static void gtk_file_system_win32_volume_free (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume);
|
|
|
|
static GtkFilePath *gtk_file_system_win32_volume_get_base_path (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume);
|
|
|
|
static gboolean gtk_file_system_win32_volume_get_is_mounted (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume);
|
2006-05-21 23:48:49 +00:00
|
|
|
static GtkFileSystemHandle *gtk_file_system_win32_volume_mount (GtkFileSystem *file_system,
|
2004-01-04 15:45:56 +00:00
|
|
|
GtkFileSystemVolume *volume,
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemVolumeMountCallback callback,
|
|
|
|
gpointer data);
|
2004-01-04 15:45:56 +00:00
|
|
|
static gchar * gtk_file_system_win32_volume_get_display_name (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume);
|
2006-05-21 23:48:49 +00:00
|
|
|
static gchar * gtk_file_system_win32_volume_get_icon_name (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume,
|
|
|
|
GError **error);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static gboolean gtk_file_system_win32_get_parent (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFilePath **parent,
|
|
|
|
GError **error);
|
|
|
|
static GtkFilePath * gtk_file_system_win32_make_path (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *base_path,
|
|
|
|
const gchar *display_name,
|
|
|
|
GError **error);
|
|
|
|
static gboolean gtk_file_system_win32_parse (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *base_path,
|
|
|
|
const gchar *str,
|
|
|
|
GtkFilePath **folder,
|
|
|
|
gchar **file_part,
|
|
|
|
GError **error);
|
|
|
|
|
|
|
|
static gchar * gtk_file_system_win32_path_to_uri (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path);
|
|
|
|
static gchar * gtk_file_system_win32_path_to_filename (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path);
|
|
|
|
static GtkFilePath *gtk_file_system_win32_uri_to_path (GtkFileSystem *file_system,
|
|
|
|
const gchar *uri);
|
|
|
|
static GtkFilePath *gtk_file_system_win32_filename_to_path (GtkFileSystem *file_system,
|
|
|
|
const gchar *filename);
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean gtk_file_system_win32_insert_bookmark (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
2004-02-28 15:09:27 +00:00
|
|
|
gint position,
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
GError **error);
|
|
|
|
static gboolean gtk_file_system_win32_remove_bookmark (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GError **error);
|
|
|
|
static GSList * gtk_file_system_win32_list_bookmarks (GtkFileSystem *file_system);
|
|
|
|
static gchar * gtk_file_system_win32_get_bookmark_label (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path);
|
2006-05-21 23:48:49 +00:00
|
|
|
static void gtk_file_system_win32_set_bookmark_label (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
const gchar *label);
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static void gtk_file_folder_win32_iface_init (GtkFileFolderIface *iface);
|
|
|
|
static void gtk_file_folder_win32_finalize (GObject *object);
|
|
|
|
|
|
|
|
static GtkFileInfo *gtk_file_folder_win32_get_info (GtkFileFolder *folder,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GError **error);
|
|
|
|
static gboolean gtk_file_folder_win32_list_children (GtkFileFolder *folder,
|
|
|
|
GSList **children,
|
|
|
|
GError **error);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static gboolean gtk_file_folder_win32_is_finished_loading (GtkFileFolder *folder);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static GtkFilePath *filename_to_path (const gchar *filename);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static gboolean filename_is_root (const char *filename);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static gboolean filename_is_drive_root (const char *filename);
|
|
|
|
static gboolean filename_is_some_root (const char *filename);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static gboolean stat_with_error (const char *filename,
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA *wfad,
|
|
|
|
GError **error);
|
|
|
|
static GtkFileInfo *create_file_info (GtkFileFolderWin32 *folder_win32,
|
|
|
|
const char *filename,
|
|
|
|
GtkFileInfoType types,
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA *wfad,
|
|
|
|
const char *mime_type);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
2006-12-22 19:10:43 +00:00
|
|
|
static gboolean execute_callbacks (gpointer data);
|
2006-09-02 21:42:42 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static gboolean fill_in_names (GtkFileFolderWin32 *folder_win32,
|
|
|
|
GError **error);
|
|
|
|
static void fill_in_stats (GtkFileFolderWin32 *folder_win32);
|
|
|
|
static void fill_in_mime_type (GtkFileFolderWin32 *folder_win32);
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static gboolean cb_fill_in_stats (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer user_data);
|
|
|
|
static gboolean cb_fill_in_mime_type (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer user_data);
|
2003-12-08 23:13:14 +00:00
|
|
|
|
2004-01-04 15:45:56 +00:00
|
|
|
/* some info kept together for volumes */
|
|
|
|
struct _GtkFileSystemVolume
|
|
|
|
{
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
gchar *drive;
|
|
|
|
int drive_type;
|
2004-01-04 15:45:56 +00:00
|
|
|
};
|
2003-11-15 20:35:55 +00:00
|
|
|
|
|
|
|
/*
|
2003-12-08 23:13:14 +00:00
|
|
|
* GtkFileSystemWin32
|
2003-11-15 20:35:55 +00:00
|
|
|
*/
|
2006-05-21 23:48:49 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkFileSystemWin32, gtk_file_system_win32, G_TYPE_OBJECT,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_SYSTEM,
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
gtk_file_system_win32_iface_init))
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/*
|
|
|
|
* GtkFileFolderWin32
|
|
|
|
*/
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GtkFileFolderWin32, _gtk_file_folder_win32, G_TYPE_OBJECT,
|
|
|
|
G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_FOLDER,
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
gtk_file_folder_win32_iface_init))
|
2003-11-15 20:35:55 +00:00
|
|
|
|
|
|
|
/**
|
2003-12-08 23:13:14 +00:00
|
|
|
* gtk_file_system_win32_new:
|
2007-03-07 23:17:38 +00:00
|
|
|
*
|
2003-12-08 23:13:14 +00:00
|
|
|
* Creates a new #GtkFileSystemWin32 object. #GtkFileSystemWin32
|
2003-11-15 20:35:55 +00:00
|
|
|
* implements the #GtkFileSystem interface with direct access to
|
2003-12-08 23:13:14 +00:00
|
|
|
* the filesystem using Windows API calls
|
2007-03-07 23:17:38 +00:00
|
|
|
*
|
2003-12-08 23:13:14 +00:00
|
|
|
* Return value: the new #GtkFileSystemWin32 object
|
2003-11-15 20:35:55 +00:00
|
|
|
**/
|
|
|
|
GtkFileSystem *
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_new (void)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2003-12-08 23:13:14 +00:00
|
|
|
return g_object_new (GTK_TYPE_FILE_SYSTEM_WIN32, NULL);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_class_init (GtkFileSystemWin32Class *class)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
gobject_class->dispose = gtk_file_system_win32_dispose;
|
2003-12-08 23:13:14 +00:00
|
|
|
gobject_class->finalize = gtk_file_system_win32_finalize;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_iface_init (GtkFileSystemIface *iface)
|
|
|
|
{
|
2004-01-04 15:45:56 +00:00
|
|
|
iface->list_volumes = gtk_file_system_win32_list_volumes;
|
2004-01-28 21:46:02 +00:00
|
|
|
iface->get_volume_for_path = gtk_file_system_win32_get_volume_for_path;
|
2003-12-08 23:13:14 +00:00
|
|
|
iface->get_folder = gtk_file_system_win32_get_folder;
|
2006-05-21 23:48:49 +00:00
|
|
|
iface->get_info = gtk_file_system_win32_get_info;
|
2003-12-08 23:13:14 +00:00
|
|
|
iface->create_folder = gtk_file_system_win32_create_folder;
|
2006-05-21 23:48:49 +00:00
|
|
|
iface->cancel_operation = gtk_file_system_win32_cancel_operation;
|
2004-01-04 15:45:56 +00:00
|
|
|
iface->volume_free = gtk_file_system_win32_volume_free;
|
|
|
|
iface->volume_get_base_path = gtk_file_system_win32_volume_get_base_path;
|
|
|
|
iface->volume_get_is_mounted = gtk_file_system_win32_volume_get_is_mounted;
|
|
|
|
iface->volume_mount = gtk_file_system_win32_volume_mount;
|
|
|
|
iface->volume_get_display_name = gtk_file_system_win32_volume_get_display_name;
|
2006-05-21 23:48:49 +00:00
|
|
|
iface->volume_get_icon_name = gtk_file_system_win32_volume_get_icon_name;
|
2003-12-08 23:13:14 +00:00
|
|
|
iface->get_parent = gtk_file_system_win32_get_parent;
|
|
|
|
iface->make_path = gtk_file_system_win32_make_path;
|
|
|
|
iface->parse = gtk_file_system_win32_parse;
|
|
|
|
iface->path_to_uri = gtk_file_system_win32_path_to_uri;
|
|
|
|
iface->path_to_filename = gtk_file_system_win32_path_to_filename;
|
|
|
|
iface->uri_to_path = gtk_file_system_win32_uri_to_path;
|
|
|
|
iface->filename_to_path = gtk_file_system_win32_filename_to_path;
|
2004-02-28 15:09:27 +00:00
|
|
|
iface->insert_bookmark = gtk_file_system_win32_insert_bookmark;
|
2003-12-08 23:13:14 +00:00
|
|
|
iface->remove_bookmark = gtk_file_system_win32_remove_bookmark;
|
|
|
|
iface->list_bookmarks = gtk_file_system_win32_list_bookmarks;
|
2006-05-21 23:48:49 +00:00
|
|
|
iface->get_bookmark_label = gtk_file_system_win32_get_bookmark_label;
|
|
|
|
iface->set_bookmark_label = gtk_file_system_win32_set_bookmark_label;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
static gboolean
|
|
|
|
check_volumes (gpointer data)
|
|
|
|
{
|
|
|
|
GtkFileSystemWin32 *system_win32 = GTK_FILE_SYSTEM_WIN32 (data);
|
|
|
|
|
|
|
|
g_return_val_if_fail (system_win32, FALSE);
|
|
|
|
|
|
|
|
if (system_win32->drives != GetLogicalDrives())
|
2006-12-22 19:10:43 +00:00
|
|
|
{
|
|
|
|
g_signal_emit_by_name (system_win32, "volumes-changed", 0);
|
|
|
|
}
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
static guint
|
|
|
|
casefolded_hash (gconstpointer v)
|
|
|
|
{
|
|
|
|
const gchar *p = (const gchar *) v;
|
|
|
|
guint32 h = 0;
|
|
|
|
|
|
|
|
while (*p)
|
|
|
|
{
|
|
|
|
h = (h << 5) - h + g_unichar_toupper (g_utf8_get_char (p));
|
|
|
|
p = g_utf8_next_char (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean casefolded_equal (gconstpointer v1,
|
|
|
|
gconstpointer v2)
|
|
|
|
{
|
|
|
|
return (_gtk_file_system_win32_path_compare ((const gchar *) v1, (const gchar *) v2) == 0);
|
|
|
|
}
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
static void
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_init (GtkFileSystemWin32 *system_win32)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
system_win32->folder_hash = g_hash_table_new (casefolded_hash, casefolded_equal);
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/* Set up an idle handler for volume changes. Once a second should
|
|
|
|
* be enough.
|
|
|
|
*/
|
2006-12-22 19:10:43 +00:00
|
|
|
system_win32->timeout = gdk_threads_add_timeout_full (0, 1000, check_volumes, system_win32, NULL);
|
2006-08-23 08:17:09 +00:00
|
|
|
|
|
|
|
system_win32->handles = g_hash_table_new (g_direct_hash, g_direct_equal);
|
2006-09-02 21:42:42 +00:00
|
|
|
|
|
|
|
system_win32->execute_callbacks_idle_id = 0;
|
|
|
|
system_win32->callbacks = NULL;
|
2006-08-23 08:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_handle_fn (gpointer key, gpointer value, gpointer data)
|
|
|
|
{
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
int *num_live_handles;
|
|
|
|
|
|
|
|
handle = key;
|
|
|
|
num_live_handles = data;
|
|
|
|
|
|
|
|
(*num_live_handles)++;
|
|
|
|
|
|
|
|
g_warning ("file_system_win32=%p still has handle=%p at finalization which is %s!",
|
|
|
|
handle->file_system,
|
|
|
|
handle,
|
|
|
|
handle->cancelled ? "CANCELLED" : "NOT CANCELLED");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
check_handles_at_finalization (GtkFileSystemWin32 *system_win32)
|
|
|
|
{
|
|
|
|
int num_live_handles;
|
|
|
|
|
|
|
|
num_live_handles = 0;
|
|
|
|
|
|
|
|
g_hash_table_foreach (system_win32->handles, check_handle_fn, &num_live_handles);
|
|
|
|
#ifdef HANDLE_ME_HARDER
|
|
|
|
g_assert (num_live_handles == 0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
g_hash_table_destroy (system_win32->handles);
|
2006-09-02 21:42:42 +00:00
|
|
|
system_win32->handles = NULL;
|
2006-08-23 08:17:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define GTK_TYPE_FILE_SYSTEM_HANDLE_WIN32 (_gtk_file_system_handle_win32_get_type ())
|
|
|
|
|
|
|
|
typedef struct _GtkFileSystemHandle GtkFileSystemHandleWin32;
|
|
|
|
typedef struct _GtkFileSystemHandleClass GtkFileSystemHandleWin32Class;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkFileSystemHandleWin32, _gtk_file_system_handle_win32, GTK_TYPE_FILE_SYSTEM_HANDLE)
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_file_system_handle_win32_init (GtkFileSystemHandleWin32 *handle)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
static void
|
2006-08-23 08:17:09 +00:00
|
|
|
_gtk_file_system_handle_win32_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkFileSystemHandleWin32 *handle;
|
|
|
|
GtkFileSystemWin32 *system_win32;
|
|
|
|
|
|
|
|
handle = (GtkFileSystemHandleWin32 *)object;
|
|
|
|
|
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (GTK_FILE_SYSTEM_HANDLE (handle)->file_system);
|
|
|
|
|
|
|
|
g_assert (g_hash_table_lookup (system_win32->handles, handle) != NULL);
|
|
|
|
g_hash_table_remove (system_win32->handles, handle);
|
|
|
|
|
|
|
|
if (G_OBJECT_CLASS (_gtk_file_system_handle_win32_parent_class)->finalize)
|
|
|
|
G_OBJECT_CLASS (_gtk_file_system_handle_win32_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_file_system_handle_win32_class_init (GtkFileSystemHandleWin32Class *class)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *) class;
|
|
|
|
|
|
|
|
gobject_class->finalize = _gtk_file_system_handle_win32_finalize;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
static void
|
|
|
|
gtk_file_system_win32_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkFileSystemWin32 *system_win32;
|
|
|
|
|
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (object);
|
|
|
|
|
|
|
|
if (system_win32->execute_callbacks_idle_id)
|
|
|
|
{
|
|
|
|
g_source_remove (system_win32->execute_callbacks_idle_id);
|
|
|
|
system_win32->execute_callbacks_idle_id = 0;
|
|
|
|
|
|
|
|
/* call pending callbacks */
|
2006-10-01 20:10:26 +00:00
|
|
|
execute_callbacks (system_win32);
|
2006-09-02 21:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_file_system_win32_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
static void
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_finalize (GObject *object)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-03-24 17:22:36 +00:00
|
|
|
GtkFileSystemWin32 *system_win32;
|
|
|
|
|
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (object);
|
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
g_source_remove (system_win32->timeout);
|
|
|
|
|
2006-08-23 08:17:09 +00:00
|
|
|
check_handles_at_finalization (system_win32);
|
|
|
|
|
2004-03-24 17:22:36 +00:00
|
|
|
/* FIXME: assert that the hash is empty? */
|
|
|
|
g_hash_table_destroy (system_win32->folder_hash);
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
G_OBJECT_CLASS (gtk_file_system_win32_parent_class)->finalize (object);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
/* Lifted from GLib */
|
2004-11-30 22:56:35 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
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)
|
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
b = SHGetPathFromIDListW (pidl, path.wc);
|
|
|
|
if (b)
|
|
|
|
retval = g_utf16_to_utf8 (path.wc, -1, NULL, NULL, NULL);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
CoTaskMemFree (pidl);
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
2004-11-30 22:56:35 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
gchar *
|
|
|
|
_gtk_file_system_win32_get_desktop (void)
|
|
|
|
{
|
|
|
|
return get_special_folder (CSIDL_DESKTOPDIRECTORY);
|
2004-11-30 22:56:35 +00:00
|
|
|
}
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
static GSList *
|
2004-01-04 15:45:56 +00:00
|
|
|
gtk_file_system_win32_list_volumes (GtkFileSystem *file_system)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-03-22 21:28:07 +00:00
|
|
|
DWORD drives;
|
|
|
|
gchar drive[4] = "A:\\";
|
2003-11-15 20:35:55 +00:00
|
|
|
GSList *list = NULL;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
GtkFileSystemWin32 *system_win32 = (GtkFileSystemWin32 *)file_system;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2004-03-22 21:28:07 +00:00
|
|
|
drives = GetLogicalDrives();
|
2003-11-15 20:35:55 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
system_win32->drives = drives;
|
2004-03-22 21:28:07 +00:00
|
|
|
if (!drives)
|
|
|
|
g_warning ("GetLogicalDrives failed.");
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2004-03-22 21:28:07 +00:00
|
|
|
while (drives && drive[0] <= 'Z')
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-03-22 21:28:07 +00:00
|
|
|
if (drives & 1)
|
|
|
|
{
|
|
|
|
GtkFileSystemVolume *vol = g_new0 (GtkFileSystemVolume, 1);
|
|
|
|
vol->drive = g_strdup (drive);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
vol->drive_type = GetDriveType (drive);
|
2004-03-22 21:28:07 +00:00
|
|
|
list = g_slist_append (list, vol);
|
|
|
|
}
|
|
|
|
drives >>= 1;
|
|
|
|
drive[0]++;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2004-01-28 21:46:02 +00:00
|
|
|
static GtkFileSystemVolume *
|
|
|
|
gtk_file_system_win32_get_volume_for_path (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2004-01-28 21:46:02 +00:00
|
|
|
GtkFileSystemVolume *vol = g_new0 (GtkFileSystemVolume, 1);
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
const gchar *p;
|
2004-01-04 15:45:56 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
g_return_val_if_fail (path != NULL, NULL);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
p = gtk_file_path_get_string (path);
|
2004-01-04 15:45:56 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
if (!g_path_is_absolute (p))
|
|
|
|
{
|
|
|
|
if (g_ascii_isalpha (p[0]) && p[1] == ':')
|
|
|
|
vol->drive = g_strdup_printf ("%c:\\", p[0]);
|
|
|
|
else
|
|
|
|
vol->drive = g_strdup ("\\");
|
|
|
|
vol->drive_type = GetDriveType (vol->drive);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const gchar *q = g_path_skip_root (p);
|
|
|
|
vol->drive = g_strndup (p, q - p);
|
|
|
|
if (!G_IS_DIR_SEPARATOR (q[-1]))
|
|
|
|
{
|
|
|
|
/* Make sure "drive" always ends in a slash */
|
|
|
|
gchar *tem = vol->drive;
|
|
|
|
vol->drive = g_strconcat (vol->drive, "\\", NULL);
|
|
|
|
g_free (tem);
|
|
|
|
}
|
2007-03-07 23:17:38 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
if (filename_is_drive_root (vol->drive))
|
|
|
|
{
|
|
|
|
vol->drive[0] = g_ascii_toupper (vol->drive[0]);
|
|
|
|
vol->drive_type = GetDriveType (vol->drive);
|
|
|
|
}
|
2006-05-21 23:48:49 +00:00
|
|
|
else
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
{
|
|
|
|
wchar_t *wdrive = g_utf8_to_utf16 (vol->drive, -1, NULL, NULL, NULL);
|
|
|
|
vol->drive_type = GetDriveTypeW (wdrive);
|
|
|
|
g_free (wdrive);
|
|
|
|
}
|
|
|
|
}
|
2004-01-28 21:46:02 +00:00
|
|
|
return vol;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static char *
|
|
|
|
remove_trailing_slash (const char *filename)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
int root_len, len;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
len = strlen (filename);
|
2004-03-24 17:22:36 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
if (g_path_is_absolute (filename))
|
|
|
|
root_len = g_path_skip_root (filename) - filename;
|
|
|
|
else
|
|
|
|
root_len = 1;
|
|
|
|
if (len > root_len && G_IS_DIR_SEPARATOR (filename[len - 1]))
|
2006-05-21 23:48:49 +00:00
|
|
|
return g_strndup (filename, len - 1);
|
|
|
|
else
|
|
|
|
return g_memdup (filename, len + 1);
|
|
|
|
}
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/* Delay callback dispatching
|
|
|
|
*/
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
enum callback_types
|
|
|
|
{
|
|
|
|
CALLBACK_GET_INFO,
|
|
|
|
CALLBACK_GET_FOLDER,
|
|
|
|
CALLBACK_CREATE_FOLDER,
|
|
|
|
CALLBACK_VOLUME_MOUNT
|
|
|
|
};
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
static void queue_callback (GtkFileSystemWin32 *system_win32, enum callback_types type, gpointer data);
|
2004-03-24 16:50:56 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
struct get_info_callback
|
|
|
|
{
|
|
|
|
GtkFileSystemGetInfoCallback callback;
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
GtkFileInfo *file_info;
|
|
|
|
GError *error;
|
|
|
|
gpointer data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
dispatch_get_info_callback (struct get_info_callback *info)
|
|
|
|
{
|
|
|
|
(* info->callback) (info->handle, info->file_info, info->error, info->data);
|
|
|
|
|
|
|
|
if (info->file_info)
|
|
|
|
gtk_file_info_free (info->file_info);
|
2004-03-24 16:50:56 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (info->error)
|
|
|
|
g_error_free (info->error);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_object_unref (info->handle);
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (info);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static inline void
|
|
|
|
queue_get_info_callback (GtkFileSystemGetInfoCallback callback,
|
|
|
|
GtkFileSystemHandle *handle,
|
|
|
|
GtkFileInfo *file_info,
|
|
|
|
GError *error,
|
|
|
|
gpointer data)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
struct get_info_callback *info;
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
info = g_new (struct get_info_callback, 1);
|
|
|
|
info->callback = callback;
|
|
|
|
info->handle = handle;
|
|
|
|
info->file_info = file_info;
|
|
|
|
info->error = error;
|
|
|
|
info->data = data;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_GET_INFO, info);
|
2006-05-21 23:48:49 +00:00
|
|
|
}
|
2004-03-24 17:33:09 +00:00
|
|
|
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
struct get_folder_callback
|
|
|
|
{
|
|
|
|
GtkFileSystemGetFolderCallback callback;
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
GtkFileFolder *folder;
|
|
|
|
GError *error;
|
|
|
|
gpointer data;
|
|
|
|
};
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static inline void
|
|
|
|
dispatch_get_folder_callback (struct get_folder_callback *info)
|
|
|
|
{
|
|
|
|
(* info->callback) (info->handle, info->folder, info->error, info->data);
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (info->error)
|
|
|
|
g_error_free (info->error);
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_object_unref (info->handle);
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (info);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static inline void
|
|
|
|
queue_get_folder_callback (GtkFileSystemGetFolderCallback callback,
|
|
|
|
GtkFileSystemHandle *handle,
|
|
|
|
GtkFileFolder *folder,
|
|
|
|
GError *error,
|
|
|
|
gpointer data)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
struct get_folder_callback *info;
|
|
|
|
|
|
|
|
info = g_new (struct get_folder_callback, 1);
|
|
|
|
info->callback = callback;
|
|
|
|
info->handle = handle;
|
|
|
|
info->folder = folder;
|
|
|
|
info->error = error;
|
|
|
|
info->data = data;
|
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_GET_FOLDER, info);
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
struct create_folder_callback
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemCreateFolderCallback callback;
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
GtkFilePath *path;
|
|
|
|
GError *error;
|
|
|
|
gpointer data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
dispatch_create_folder_callback (struct create_folder_callback *info)
|
|
|
|
{
|
|
|
|
(* info->callback) (info->handle, info->path, info->error, info->data);
|
|
|
|
|
|
|
|
if (info->error)
|
|
|
|
g_error_free (info->error);
|
|
|
|
|
|
|
|
if (info->path)
|
|
|
|
gtk_file_path_free (info->path);
|
|
|
|
|
|
|
|
g_object_unref (info->handle);
|
|
|
|
|
|
|
|
g_free (info);
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static inline void
|
|
|
|
queue_create_folder_callback (GtkFileSystemCreateFolderCallback callback,
|
|
|
|
GtkFileSystemHandle *handle,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GError *error,
|
|
|
|
gpointer data)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
struct create_folder_callback *info;
|
|
|
|
|
|
|
|
info = g_new (struct create_folder_callback, 1);
|
|
|
|
info->callback = callback;
|
|
|
|
info->handle = handle;
|
|
|
|
info->path = gtk_file_path_copy (path);
|
|
|
|
info->error = error;
|
|
|
|
info->data = data;
|
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_CREATE_FOLDER, info);
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
struct volume_mount_callback
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemVolumeMountCallback callback;
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
GtkFileSystemVolume *volume;
|
|
|
|
GError *error;
|
|
|
|
gpointer data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
dispatch_volume_mount_callback (struct volume_mount_callback *info)
|
|
|
|
{
|
|
|
|
(* info->callback) (info->handle, info->volume, info->error, info->data);
|
|
|
|
|
|
|
|
if (info->error)
|
|
|
|
g_error_free (info->error);
|
|
|
|
|
|
|
|
g_object_unref (info->handle);
|
|
|
|
|
|
|
|
g_free (info);
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static inline void
|
|
|
|
queue_volume_mount_callback (GtkFileSystemVolumeMountCallback callback,
|
|
|
|
GtkFileSystemHandle *handle,
|
|
|
|
GtkFileSystemVolume *volume,
|
|
|
|
GError *error,
|
|
|
|
gpointer data)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
struct volume_mount_callback *info;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
info = g_new (struct volume_mount_callback, 1);
|
|
|
|
info->callback = callback;
|
|
|
|
info->handle = handle;
|
|
|
|
info->volume = volume;
|
|
|
|
info->error = error;
|
|
|
|
info->data = data;
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
queue_callback (GTK_FILE_SYSTEM_WIN32 (handle->file_system), CALLBACK_VOLUME_MOUNT, info);
|
2006-05-21 23:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct callback_info
|
|
|
|
{
|
|
|
|
enum callback_types type;
|
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct get_info_callback *get_info;
|
|
|
|
struct get_folder_callback *get_folder;
|
|
|
|
struct create_folder_callback *create_folder;
|
|
|
|
struct volume_mount_callback *volume_mount;
|
|
|
|
} info;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-12-22 19:10:43 +00:00
|
|
|
static gboolean
|
2006-10-01 20:10:26 +00:00
|
|
|
execute_callbacks (gpointer data)
|
2006-05-21 23:48:49 +00:00
|
|
|
{
|
|
|
|
GSList *l;
|
2006-09-02 21:42:42 +00:00
|
|
|
gboolean unref_file_system = TRUE;
|
|
|
|
GtkFileSystemWin32 *system_win32 = GTK_FILE_SYSTEM_WIN32 (data);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
if (!system_win32->execute_callbacks_idle_id)
|
|
|
|
unref_file_system = FALSE;
|
|
|
|
else
|
|
|
|
g_object_ref (system_win32);
|
|
|
|
|
|
|
|
for (l = system_win32->callbacks; l; l = l->next)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
struct callback_info *info = l->data;
|
|
|
|
|
|
|
|
switch (info->type)
|
2005-04-25 00:47:31 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
case CALLBACK_GET_INFO:
|
|
|
|
dispatch_get_info_callback (info->info.get_info);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLBACK_GET_FOLDER:
|
|
|
|
dispatch_get_folder_callback (info->info.get_folder);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLBACK_CREATE_FOLDER:
|
|
|
|
dispatch_create_folder_callback (info->info.create_folder);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLBACK_VOLUME_MOUNT:
|
|
|
|
dispatch_volume_mount_callback (info->info.volume_mount);
|
|
|
|
break;
|
2005-04-25 00:47:31 +00:00
|
|
|
}
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
g_free (info);
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
2004-03-22 21:28:07 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
g_slist_free (system_win32->callbacks);
|
|
|
|
system_win32->callbacks = NULL;
|
|
|
|
|
|
|
|
if (unref_file_system)
|
|
|
|
g_object_unref (system_win32);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
system_win32->execute_callbacks_idle_id = 0;
|
2006-10-01 20:10:26 +00:00
|
|
|
|
2006-12-27 15:40:37 +00:00
|
|
|
return FALSE;
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static void
|
2006-09-02 21:42:42 +00:00
|
|
|
queue_callback (GtkFileSystemWin32 *system_win32,
|
|
|
|
enum callback_types type,
|
|
|
|
gpointer data)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
struct callback_info *info;
|
2004-01-04 15:45:56 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
info = g_new (struct callback_info, 1);
|
|
|
|
info->type = type;
|
|
|
|
|
|
|
|
switch (type)
|
2004-01-04 15:45:56 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
case CALLBACK_GET_INFO:
|
|
|
|
info->info.get_info = data;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLBACK_GET_FOLDER:
|
|
|
|
info->info.get_folder = data;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLBACK_CREATE_FOLDER:
|
|
|
|
info->info.create_folder = data;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CALLBACK_VOLUME_MOUNT:
|
|
|
|
info->info.volume_mount = data;
|
|
|
|
break;
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
system_win32->callbacks = g_slist_append (system_win32->callbacks, info);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
2006-09-02 21:42:42 +00:00
|
|
|
if (!system_win32->execute_callbacks_idle_id)
|
2006-12-22 19:10:43 +00:00
|
|
|
system_win32->execute_callbacks_idle_id = gdk_threads_add_idle (execute_callbacks, system_win32);
|
2004-01-04 15:45:56 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static GtkFileSystemHandle *
|
|
|
|
create_handle (GtkFileSystem *file_system)
|
|
|
|
{
|
2006-08-23 08:17:09 +00:00
|
|
|
GtkFileSystemWin32 *system_win32;
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
|
2006-08-23 08:17:09 +00:00
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (file_system);
|
|
|
|
|
|
|
|
handle = g_object_new (GTK_TYPE_FILE_SYSTEM_HANDLE_WIN32, NULL);
|
2006-05-21 23:48:49 +00:00
|
|
|
handle->file_system = file_system;
|
|
|
|
|
2006-08-23 08:17:09 +00:00
|
|
|
g_assert (g_hash_table_lookup (system_win32->handles, handle) == NULL);
|
|
|
|
g_hash_table_insert (system_win32->handles, handle, handle);
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
get_mime_type_for_file (const char *filename,
|
|
|
|
const WIN32_FILE_ATTRIBUTE_DATA *wfad)
|
2006-05-21 23:48:49 +00:00
|
|
|
{
|
|
|
|
const char *extension;
|
|
|
|
HKEY key = NULL;
|
|
|
|
DWORD type, nbytes = 0;
|
|
|
|
char *value = NULL;
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
if (wfad->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
return g_strdup ("x-directory/normal");
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
extension = strrchr (filename, '.');
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
if (extension != NULL &&
|
|
|
|
(stricmp (extension, ".exe") == 0 ||
|
|
|
|
stricmp (extension, ".com") == 0))
|
|
|
|
return g_strdup ("application/x-executable");
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (extension != NULL &&
|
|
|
|
extension[1] != '\0' &&
|
|
|
|
RegOpenKeyEx (HKEY_CLASSES_ROOT, extension, 0,
|
|
|
|
KEY_QUERY_VALUE, &key) == ERROR_SUCCESS &&
|
|
|
|
RegQueryValueEx (key, "Content Type", 0,
|
|
|
|
&type, NULL, &nbytes) == ERROR_SUCCESS &&
|
|
|
|
type == REG_SZ &&
|
|
|
|
(value = g_try_malloc (nbytes + 1)) &&
|
|
|
|
RegQueryValueEx (key, "Content Type", 0,
|
|
|
|
&type, value, &nbytes) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
value[nbytes] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
value = g_strdup ("application/octet-stream");
|
|
|
|
if (key != NULL)
|
|
|
|
RegCloseKey (key);
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFileSystemHandle *
|
|
|
|
gtk_file_system_win32_get_info (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFileInfoType types,
|
|
|
|
GtkFileSystemGetInfoCallback callback,
|
|
|
|
gpointer data)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
GError *error = NULL;
|
|
|
|
GtkFileSystemWin32 *system_win32;
|
|
|
|
GtkFileSystemHandle *handle;
|
2004-04-22 05:08:19 +00:00
|
|
|
const char *filename;
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileInfo *info;
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
|
|
|
const char *mime_type;
|
|
|
|
|
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (file_system);
|
|
|
|
handle = create_handle (file_system);
|
2004-04-22 05:08:19 +00:00
|
|
|
|
|
|
|
filename = gtk_file_path_get_string (path);
|
2007-04-30 16:18:54 +00:00
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
|
|
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (!stat_with_error (filename, &wfad, &error))
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
g_object_ref (handle);
|
|
|
|
queue_get_info_callback (callback, handle, NULL, error, data);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((types & GTK_FILE_INFO_MIME_TYPE) != 0)
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
mime_type = get_mime_type_for_file (filename, &wfad);
|
2006-05-21 23:48:49 +00:00
|
|
|
else
|
|
|
|
mime_type = NULL;
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
info = create_file_info (NULL, filename, types, &wfad, mime_type);
|
2006-05-21 23:48:49 +00:00
|
|
|
g_object_ref (handle);
|
|
|
|
queue_get_info_callback (callback, handle, info, NULL, data);
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
load_folder (gpointer data)
|
|
|
|
{
|
|
|
|
GtkFileFolderWin32 *folder_win32 = data;
|
|
|
|
GSList *children;
|
|
|
|
|
|
|
|
if ((folder_win32->types & STAT_NEEDED_MASK) != 0)
|
|
|
|
fill_in_stats (folder_win32);
|
|
|
|
|
|
|
|
if ((folder_win32->types & GTK_FILE_INFO_MIME_TYPE) != 0)
|
|
|
|
fill_in_mime_type (folder_win32);
|
|
|
|
|
|
|
|
if (gtk_file_folder_win32_list_children (GTK_FILE_FOLDER (folder_win32), &children, NULL))
|
|
|
|
{
|
|
|
|
folder_win32->is_finished_loading = TRUE;
|
|
|
|
g_signal_emit_by_name (folder_win32, "files-added", children);
|
|
|
|
gtk_file_paths_free (children);
|
|
|
|
}
|
|
|
|
|
|
|
|
folder_win32->load_folder_id = 0;
|
|
|
|
|
|
|
|
g_signal_emit_by_name (folder_win32, "finished-loading", 0);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFileSystemHandle *
|
|
|
|
gtk_file_system_win32_get_folder (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFileInfoType types,
|
|
|
|
GtkFileSystemGetFolderCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GtkFileSystemWin32 *system_win32;
|
|
|
|
GtkFileFolderWin32 *folder_win32;
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
const gchar *filename;
|
|
|
|
char *filename_copy;
|
|
|
|
gboolean set_asof = FALSE;
|
|
|
|
|
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (file_system);
|
|
|
|
|
|
|
|
filename = gtk_file_path_get_string (path);
|
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
|
|
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
|
|
|
|
|
|
|
handle = create_handle (file_system);
|
|
|
|
|
|
|
|
filename_copy = remove_trailing_slash (filename);
|
|
|
|
folder_win32 = g_hash_table_lookup (system_win32->folder_hash, filename_copy);
|
|
|
|
|
|
|
|
if (folder_win32)
|
|
|
|
{
|
|
|
|
g_free (filename_copy);
|
|
|
|
if (folder_win32->stat_info &&
|
|
|
|
time (NULL) - folder_win32->asof >= FOLDER_CACHE_LIFETIME)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
g_print ("Cleaning out cached directory %s\n", filename);
|
|
|
|
#endif
|
|
|
|
g_hash_table_destroy (folder_win32->stat_info);
|
|
|
|
folder_win32->stat_info = NULL;
|
|
|
|
folder_win32->have_mime_type = FALSE;
|
|
|
|
folder_win32->have_stat = FALSE;
|
|
|
|
set_asof = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_ref (folder_win32);
|
|
|
|
folder_win32->types |= types;
|
|
|
|
types = folder_win32->types;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
|
|
|
|
|
|
|
if (!stat_with_error (filename, &wfad, &error))
|
|
|
|
{
|
|
|
|
g_object_ref (handle);
|
|
|
|
queue_get_folder_callback (callback, handle, NULL, error, data);
|
|
|
|
|
|
|
|
g_free (filename_copy);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
{
|
|
|
|
gchar *display_name = g_filename_display_name (filename);
|
|
|
|
|
|
|
|
g_set_error (&error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_NOT_FOLDER,
|
|
|
|
_("Path is not a folder: '%s'"),
|
|
|
|
display_name);
|
|
|
|
|
|
|
|
g_object_ref (handle);
|
|
|
|
queue_get_folder_callback (callback, handle, NULL, error, data);
|
|
|
|
|
|
|
|
g_free (display_name);
|
|
|
|
g_free (filename_copy);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
folder_win32 = g_object_new (GTK_TYPE_FILE_FOLDER_WIN32, NULL);
|
|
|
|
folder_win32->system_win32 = system_win32;
|
|
|
|
folder_win32->filename = filename_copy;
|
|
|
|
folder_win32->types = types;
|
|
|
|
folder_win32->stat_info = NULL;
|
|
|
|
folder_win32->load_folder_id = 0;
|
|
|
|
folder_win32->have_mime_type = FALSE;
|
|
|
|
folder_win32->have_stat = FALSE;
|
|
|
|
folder_win32->is_finished_loading = FALSE;
|
|
|
|
set_asof = TRUE;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/* Browsing for shares not yet implemented */
|
|
|
|
folder_win32->is_network_dir = FALSE;
|
|
|
|
|
|
|
|
g_hash_table_insert (system_win32->folder_hash,
|
|
|
|
folder_win32->filename,
|
|
|
|
folder_win32);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (set_asof)
|
|
|
|
folder_win32->asof = time (NULL);
|
|
|
|
|
|
|
|
g_object_ref (handle);
|
|
|
|
queue_get_folder_callback (callback, handle, GTK_FILE_FOLDER (folder_win32), NULL, data);
|
|
|
|
|
|
|
|
/* Start loading the folder contents in an idle */
|
2006-09-02 21:42:42 +00:00
|
|
|
if (!folder_win32->load_folder_id)
|
|
|
|
folder_win32->load_folder_id =
|
2006-12-22 19:10:43 +00:00
|
|
|
gdk_threads_add_idle ((GSourceFunc) load_folder, folder_win32);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFileSystemHandle *
|
|
|
|
gtk_file_system_win32_create_folder (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFileSystemCreateFolderCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GtkFileSystemWin32 *system_win32;
|
|
|
|
GtkFileSystemHandle *handle;
|
|
|
|
const char *filename;
|
|
|
|
gboolean result;
|
|
|
|
char *parent, *tmp;
|
|
|
|
int save_errno;
|
|
|
|
|
|
|
|
system_win32 = GTK_FILE_SYSTEM_WIN32 (file_system);
|
|
|
|
|
|
|
|
filename = gtk_file_path_get_string (path);
|
2007-04-30 16:18:54 +00:00
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
2006-05-21 23:48:49 +00:00
|
|
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
|
|
|
|
|
|
|
handle = create_handle (file_system);
|
|
|
|
|
|
|
|
tmp = remove_trailing_slash (filename);
|
|
|
|
result = g_mkdir (tmp, 0777) == 0;
|
|
|
|
save_errno = errno;
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
gchar *display_filename = g_filename_display_name (filename);
|
|
|
|
g_set_error (&error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
|
2007-01-02 19:52:48 +00:00
|
|
|
_("Error creating folder '%s': %s"),
|
2006-05-21 23:48:49 +00:00
|
|
|
display_filename,
|
|
|
|
g_strerror (save_errno));
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_object_ref (handle);
|
|
|
|
queue_create_folder_callback (callback, handle, path, error, data);
|
|
|
|
|
|
|
|
g_free (display_filename);
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!filename_is_some_root (filename))
|
|
|
|
{
|
|
|
|
parent = g_path_get_dirname (filename);
|
|
|
|
if (parent)
|
|
|
|
{
|
|
|
|
GtkFileFolderWin32 *folder_win32;
|
|
|
|
|
|
|
|
folder_win32 = g_hash_table_lookup (system_win32->folder_hash, parent);
|
|
|
|
if (folder_win32)
|
|
|
|
{
|
|
|
|
GSList *paths;
|
|
|
|
char *basename;
|
|
|
|
struct stat_info_entry *entry;
|
|
|
|
|
|
|
|
/* Make sure the new folder exists in the parent's folder */
|
|
|
|
entry = g_new0 (struct stat_info_entry, 1);
|
|
|
|
if (folder_win32->is_network_dir)
|
|
|
|
{
|
|
|
|
entry->wfad.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
entry->mime_type = g_strdup ("x-directory/normal");
|
|
|
|
}
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
basename = g_path_get_basename (filename);
|
|
|
|
g_hash_table_insert (folder_win32->stat_info,
|
|
|
|
basename,
|
|
|
|
entry);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (folder_win32->have_stat)
|
|
|
|
{
|
|
|
|
/* Cheating */
|
|
|
|
if ((folder_win32->types & STAT_NEEDED_MASK) != 0)
|
|
|
|
cb_fill_in_stats (basename, entry, folder_win32);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if ((folder_win32->types & GTK_FILE_INFO_MIME_TYPE) != 0)
|
|
|
|
cb_fill_in_mime_type (basename, entry, folder_win32);
|
|
|
|
}
|
|
|
|
|
|
|
|
paths = g_slist_append (NULL, (GtkFilePath *) path);
|
|
|
|
g_signal_emit_by_name (folder_win32, "files-added", paths);
|
|
|
|
g_slist_free (paths);
|
|
|
|
}
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free(parent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_file_system_win32_cancel_operation (GtkFileSystemHandle *handle)
|
|
|
|
{
|
|
|
|
/* We don't set "cancelled" to TRUE here, since the actual operation
|
|
|
|
* is executed in the function itself and not in a callback. So
|
|
|
|
* the operations can never be cancelled (since they will be already
|
|
|
|
* completed at this point.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_file_system_win32_volume_free (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume)
|
|
|
|
{
|
|
|
|
GtkFilePath *path;
|
|
|
|
|
|
|
|
g_free (volume->drive);
|
|
|
|
path = (GtkFilePath *) volume;
|
|
|
|
gtk_file_path_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFilePath *
|
|
|
|
gtk_file_system_win32_volume_get_base_path (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume)
|
|
|
|
{
|
|
|
|
return (GtkFilePath *) g_strdup (volume->drive);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_file_system_win32_volume_get_is_mounted (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFileSystemHandle *
|
2007-03-07 23:17:38 +00:00
|
|
|
gtk_file_system_win32_volume_mount (GtkFileSystem *file_system,
|
2006-05-21 23:48:49 +00:00
|
|
|
GtkFileSystemVolume *volume,
|
|
|
|
GtkFileSystemVolumeMountCallback callback,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
GtkFileSystemHandle *handle = create_handle (file_system);
|
|
|
|
|
|
|
|
g_set_error (&error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_FAILED,
|
|
|
|
_("This file system does not support mounting"));
|
|
|
|
|
|
|
|
g_object_ref (handle);
|
|
|
|
queue_volume_mount_callback (callback, handle, volume, error, data);
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gtk_file_system_win32_volume_get_display_name (GtkFileSystem *file_system,
|
|
|
|
GtkFileSystemVolume *volume)
|
|
|
|
{
|
|
|
|
gchar *real_display_name;
|
|
|
|
|
|
|
|
g_return_val_if_fail (volume->drive != NULL, NULL);
|
|
|
|
|
|
|
|
if (filename_is_drive_root (volume->drive) &&
|
|
|
|
volume->drive_type == DRIVE_REMOTE)
|
|
|
|
real_display_name = g_strdup_printf (_("Network Drive (%s)"), volume->drive);
|
|
|
|
else if ((filename_is_drive_root (volume->drive) && volume->drive[0] >= 'C') ||
|
|
|
|
volume->drive_type != DRIVE_REMOVABLE)
|
|
|
|
{
|
|
|
|
gchar *name = NULL;
|
|
|
|
gunichar2 *wdrive = g_utf8_to_utf16 (volume->drive, -1, NULL, NULL, NULL);
|
|
|
|
gunichar2 wname[80];
|
|
|
|
|
|
|
|
if (GetVolumeInformationW (wdrive,
|
2007-03-07 23:17:38 +00:00
|
|
|
wname, G_N_ELEMENTS(wname),
|
2006-05-21 23:48:49 +00:00
|
|
|
NULL, /* serial number */
|
|
|
|
NULL, /* max. component length */
|
|
|
|
NULL, /* fs flags */
|
|
|
|
NULL, 0) /* fs type like FAT, NTFS */ &&
|
|
|
|
wname[0])
|
|
|
|
{
|
|
|
|
name = g_utf16_to_utf8 (wname, -1, NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
g_free (wdrive);
|
|
|
|
|
|
|
|
if (name != NULL)
|
|
|
|
{
|
|
|
|
real_display_name = g_strdup_printf (_("%s (%s)"), name, volume->drive);
|
|
|
|
g_free (name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
real_display_name = g_strdup (volume->drive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
real_display_name = g_strdup (volume->drive);
|
|
|
|
|
|
|
|
return real_display_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static IconType
|
|
|
|
get_icon_type_from_stat (WIN32_FILE_ATTRIBUTE_DATA *wfad)
|
|
|
|
{
|
|
|
|
if (wfad->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
|
|
return ICON_DIRECTORY;
|
|
|
|
else
|
|
|
|
return ICON_REGULAR;
|
|
|
|
}
|
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
/* Computes our internal icon type based on a path name; also returns the MIME
|
|
|
|
* type in case we come up with ICON_REGULAR.
|
|
|
|
*/
|
|
|
|
static IconType
|
|
|
|
get_icon_type_from_path (GtkFileFolderWin32 *folder_win32,
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA *wfad,
|
|
|
|
const char *filename)
|
|
|
|
{
|
|
|
|
IconType icon_type;
|
|
|
|
|
|
|
|
if (folder_win32 && folder_win32->have_stat)
|
|
|
|
{
|
|
|
|
char *basename;
|
|
|
|
struct stat_info_entry *entry;
|
|
|
|
|
|
|
|
g_assert (folder_win32->stat_info != NULL);
|
|
|
|
|
|
|
|
basename = g_path_get_basename (filename);
|
|
|
|
entry = g_hash_table_lookup (folder_win32->stat_info, basename);
|
|
|
|
g_free (basename);
|
|
|
|
if (entry)
|
|
|
|
{
|
|
|
|
if (entry->icon_type == ICON_UNDECIDED)
|
|
|
|
{
|
|
|
|
entry->icon_type = get_icon_type_from_stat (&entry->wfad);
|
|
|
|
g_assert (entry->icon_type != ICON_UNDECIDED);
|
|
|
|
}
|
|
|
|
icon_type = entry->icon_type;
|
|
|
|
if (icon_type == ICON_REGULAR)
|
|
|
|
{
|
|
|
|
fill_in_mime_type (folder_win32);
|
|
|
|
}
|
|
|
|
|
|
|
|
return icon_type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
icon_type = get_icon_type_from_stat (wfad);
|
|
|
|
|
|
|
|
return icon_type;
|
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static const gchar *
|
|
|
|
get_fallback_icon_name (IconType icon_type)
|
|
|
|
{
|
|
|
|
switch (icon_type)
|
|
|
|
{
|
2007-03-07 23:17:38 +00:00
|
|
|
case ICON_VOLUME:
|
|
|
|
return GTK_STOCK_HARDDISK;
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
case ICON_DIRECTORY:
|
2007-03-07 23:17:38 +00:00
|
|
|
return GTK_STOCK_DIRECTORY;
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
case ICON_EXECUTABLE:
|
2007-03-07 23:17:38 +00:00
|
|
|
return GTK_STOCK_EXECUTE;
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
default:
|
2007-03-07 23:17:38 +00:00
|
|
|
return GTK_STOCK_FILE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
get_icon_path (const gchar *filename,
|
|
|
|
IconType icon_type,
|
|
|
|
gint *index)
|
|
|
|
{
|
|
|
|
gchar *path = NULL;
|
2007-03-09 21:30:32 +00:00
|
|
|
SHFILEINFOW shfi;
|
|
|
|
wchar_t *wfn;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (NULL != filename, NULL);
|
|
|
|
g_return_val_if_fail ('\0' != *filename, NULL);
|
|
|
|
g_return_val_if_fail (NULL != index, NULL);
|
|
|
|
|
|
|
|
wfn = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
if (SHGetFileInfoW (wfn, 0, &shfi, sizeof (shfi), SHGFI_ICONLOCATION))
|
|
|
|
{
|
|
|
|
path = g_utf16_to_utf8 (shfi.szDisplayName, -1, NULL, NULL, NULL);
|
|
|
|
*index = shfi.iIcon;
|
2006-05-21 23:48:49 +00:00
|
|
|
}
|
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
g_free (wfn);
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
create_builtin_icon (const gchar *filename,
|
|
|
|
const gchar *icon_name,
|
|
|
|
IconType icon_type)
|
|
|
|
{
|
|
|
|
static const DWORD attributes[] =
|
|
|
|
{
|
|
|
|
SHGFI_ICON | SHGFI_LARGEICON,
|
|
|
|
SHGFI_ICON | SHGFI_SMALLICON,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
GdkPixbuf *pixbuf = NULL;
|
|
|
|
SHFILEINFOW shfi;
|
|
|
|
DWORD_PTR rc;
|
|
|
|
wchar_t *wfn;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (NULL != filename, FALSE);
|
|
|
|
g_return_val_if_fail ('\0' != *filename, FALSE);
|
|
|
|
|
|
|
|
wfn = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
for(i = 0; attributes[i]; ++i)
|
|
|
|
{
|
|
|
|
rc = SHGetFileInfoW (wfn, 0, &shfi, sizeof (shfi), attributes[i]);
|
|
|
|
|
|
|
|
if (rc && shfi.hIcon)
|
|
|
|
{
|
|
|
|
pixbuf = gdk_win32_icon_to_pixbuf_libgtk_only (shfi.hIcon);
|
|
|
|
|
|
|
|
if (!DestroyIcon (shfi.hIcon))
|
|
|
|
g_warning (G_STRLOC ": DestroyIcon failed: %s\n",
|
|
|
|
g_win32_error_message (GetLastError ()));
|
|
|
|
|
|
|
|
gtk_icon_theme_add_builtin_icon (icon_name,
|
|
|
|
gdk_pixbuf_get_height (pixbuf),
|
|
|
|
pixbuf);
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (wfn);
|
|
|
|
return (NULL != pixbuf); /* at least one icon was created */
|
|
|
|
}
|
|
|
|
|
|
|
|
gchar *
|
|
|
|
get_icon_name (const gchar *filename,
|
|
|
|
IconType icon_type)
|
|
|
|
{
|
|
|
|
gchar *icon_name = NULL;
|
|
|
|
gchar *icon_path = NULL;
|
|
|
|
gint icon_index = -1;
|
|
|
|
|
|
|
|
icon_path = get_icon_path(filename, icon_type, &icon_index);
|
|
|
|
|
|
|
|
if (icon_path)
|
|
|
|
icon_name = g_strdup_printf ("gtk-win32-shell-icon;%s;%d",
|
|
|
|
icon_path, icon_index);
|
|
|
|
else
|
|
|
|
icon_name = g_strdup_printf ("gtk-win32-shell-icon;%s",
|
|
|
|
filename);
|
|
|
|
|
|
|
|
if (!gtk_icon_theme_has_icon (gtk_icon_theme_get_default (), icon_name) &&
|
|
|
|
!create_builtin_icon (filename, icon_name, icon_type))
|
|
|
|
{
|
|
|
|
g_free (icon_name);
|
|
|
|
icon_name = g_strdup (get_fallback_icon_name (icon_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (icon_path);
|
|
|
|
return icon_name;
|
2006-05-21 23:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gtk_file_system_win32_volume_get_icon_name (GtkFileSystem *file_system,
|
2007-03-07 23:17:38 +00:00
|
|
|
GtkFileSystemVolume *volume,
|
|
|
|
GError **error)
|
2006-05-21 23:48:49 +00:00
|
|
|
{
|
2007-03-07 23:17:38 +00:00
|
|
|
return get_icon_name (volume->drive, ICON_VOLUME);
|
2006-05-21 23:48:49 +00:00
|
|
|
}
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
#if 0 /* Unused, see below */
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static char *
|
|
|
|
get_parent_dir (const char *filename)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = strlen (filename);
|
|
|
|
|
|
|
|
/* Ignore trailing slashes */
|
|
|
|
if (len > 1 && G_IS_DIR_SEPARATOR (filename[len - 1]))
|
|
|
|
{
|
|
|
|
char *tmp, *parent;
|
|
|
|
|
|
|
|
tmp = g_strndup (filename, len - 1);
|
|
|
|
|
|
|
|
parent = g_path_get_dirname (tmp);
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return g_path_get_dirname (filename);
|
|
|
|
}
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
#endif
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_file_system_win32_get_parent (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GtkFilePath **parent,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
const char *filename;
|
|
|
|
|
|
|
|
filename = gtk_file_path_get_string (path);
|
|
|
|
g_return_val_if_fail (filename != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (g_path_is_absolute (filename), FALSE);
|
|
|
|
|
|
|
|
if (filename_is_some_root (filename))
|
|
|
|
{
|
|
|
|
*parent = NULL;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *parent_filename = g_path_get_dirname (filename);
|
|
|
|
*parent = filename_to_path (parent_filename);
|
|
|
|
g_free (parent_filename);
|
|
|
|
}
|
2005-08-26 13:44:50 +00:00
|
|
|
#if DEBUGGING_OUTPUT
|
|
|
|
printf ("%s: %s => %s\n", __FUNCTION__, (char*)path, (*parent)?(char*)*parent:"NULL"), fflush(stdout);
|
|
|
|
#endif
|
2003-11-15 20:35:55 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFilePath *
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_make_path (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *base_path,
|
|
|
|
const gchar *display_name,
|
|
|
|
GError **error)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-02-28 15:09:27 +00:00
|
|
|
const char *base_filename;
|
2003-11-15 20:35:55 +00:00
|
|
|
gchar *full_filename;
|
|
|
|
GtkFilePath *result;
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
char *p;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2004-02-28 15:09:27 +00:00
|
|
|
base_filename = gtk_file_path_get_string (base_path);
|
2003-11-15 20:35:55 +00:00
|
|
|
g_return_val_if_fail (base_filename != NULL, NULL);
|
2004-02-28 15:09:27 +00:00
|
|
|
g_return_val_if_fail (g_path_is_absolute (base_filename), NULL);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
if ((p = strpbrk (display_name, "<>\"/\\|")))
|
|
|
|
{
|
2006-08-23 08:48:42 +00:00
|
|
|
gchar badchar[2];
|
|
|
|
|
|
|
|
badchar[0] = *p; /* We know it is a single-byte char */
|
|
|
|
badchar[1] = '\0';
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
g_set_error (error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
|
2006-08-23 08:48:42 +00:00
|
|
|
_("The name \"%s\" is not valid because it contains the character \"%s\". "
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
"Please use a different name."),
|
|
|
|
display_name,
|
2006-08-23 08:48:42 +00:00
|
|
|
badchar);
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-12-12 21:09:13 +00:00
|
|
|
full_filename = g_build_filename (base_filename, display_name, NULL);
|
2003-11-15 20:35:55 +00:00
|
|
|
result = filename_to_path (full_filename);
|
|
|
|
g_free (full_filename);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If this was a publically exported function, it should return
|
|
|
|
* a dup'ed result, but we make it modify-in-place for efficiency
|
|
|
|
* here, and because it works for us.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
canonicalize_filename (gchar *filename)
|
|
|
|
{
|
|
|
|
gchar *p, *q;
|
2004-04-22 05:08:19 +00:00
|
|
|
gchar *past_root;
|
2003-11-15 20:35:55 +00:00
|
|
|
gboolean last_was_slash = FALSE;
|
|
|
|
|
2005-08-26 13:44:50 +00:00
|
|
|
#if DEBUGGING_OUTPUT
|
|
|
|
printf("%s: %s ", __FUNCTION__, filename), fflush (stdout);
|
2004-04-22 05:08:19 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-25 00:47:31 +00:00
|
|
|
past_root = (gchar *) g_path_skip_root (filename);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
q = p = past_root;
|
2004-04-22 05:08:19 +00:00
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
while (*p)
|
|
|
|
{
|
2004-04-22 05:08:19 +00:00
|
|
|
if (G_IS_DIR_SEPARATOR (*p))
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
if (!last_was_slash)
|
2005-08-26 13:44:50 +00:00
|
|
|
*q++ = '\\';
|
2003-11-15 20:35:55 +00:00
|
|
|
|
|
|
|
last_was_slash = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (last_was_slash && *p == '.')
|
|
|
|
{
|
2004-04-22 05:08:19 +00:00
|
|
|
if (G_IS_DIR_SEPARATOR (*(p + 1)) ||
|
2003-11-15 20:35:55 +00:00
|
|
|
*(p + 1) == '\0')
|
|
|
|
{
|
|
|
|
if (*(p + 1) == '\0')
|
|
|
|
break;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
p += 1;
|
|
|
|
}
|
|
|
|
else if (*(p + 1) == '.' &&
|
2004-04-22 05:08:19 +00:00
|
|
|
(G_IS_DIR_SEPARATOR (*(p + 2)) ||
|
2003-11-15 20:35:55 +00:00
|
|
|
*(p + 2) == '\0'))
|
|
|
|
{
|
2004-04-22 05:08:19 +00:00
|
|
|
if (q > past_root)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
q--;
|
2004-04-22 05:08:19 +00:00
|
|
|
while (q > past_root &&
|
|
|
|
!G_IS_DIR_SEPARATOR (*(q - 1)))
|
2003-11-15 20:35:55 +00:00
|
|
|
q--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*(p + 2) == '\0')
|
|
|
|
break;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*q++ = *p;
|
|
|
|
last_was_slash = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*q++ = *p;
|
|
|
|
last_was_slash = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2004-04-22 05:08:19 +00:00
|
|
|
if (q > past_root && G_IS_DIR_SEPARATOR (*(q - 1)))
|
2003-11-15 20:35:55 +00:00
|
|
|
q--;
|
|
|
|
|
|
|
|
*q = '\0';
|
2005-08-26 13:44:50 +00:00
|
|
|
|
|
|
|
#if DEBUGGING_OUTPUT
|
|
|
|
printf(" => %s\n", filename), fflush (stdout);
|
2004-04-22 05:08:19 +00:00
|
|
|
#endif
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_parse (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *base_path,
|
|
|
|
const gchar *str,
|
|
|
|
GtkFilePath **folder,
|
|
|
|
gchar **file_part,
|
|
|
|
GError **error)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-02-28 15:09:27 +00:00
|
|
|
const char *base_filename;
|
2004-04-22 05:08:19 +00:00
|
|
|
gchar *last_backslash, *last_slash;
|
2003-11-15 20:35:55 +00:00
|
|
|
gboolean result = FALSE;
|
|
|
|
|
2005-08-26 13:44:50 +00:00
|
|
|
#if DEBUGGING_OUTPUT
|
|
|
|
printf("%s: base_path=%s str=%s\n",__FUNCTION__,(char*)base_path,str),fflush(stdout);
|
2004-04-22 05:08:19 +00:00
|
|
|
#endif
|
|
|
|
|
2004-02-28 15:09:27 +00:00
|
|
|
base_filename = gtk_file_path_get_string (base_path);
|
2003-11-15 20:35:55 +00:00
|
|
|
g_return_val_if_fail (base_filename != NULL, FALSE);
|
2004-02-28 15:09:27 +00:00
|
|
|
g_return_val_if_fail (g_path_is_absolute (base_filename), FALSE);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2005-08-26 13:44:50 +00:00
|
|
|
last_backslash = strrchr (str, '\\');
|
2004-04-22 05:08:19 +00:00
|
|
|
last_slash = strrchr (str, '/');
|
|
|
|
if (last_slash == NULL ||
|
|
|
|
(last_backslash != NULL && last_backslash > last_slash))
|
|
|
|
last_slash = last_backslash;
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
if (!last_slash)
|
|
|
|
{
|
|
|
|
*folder = gtk_file_path_copy (base_path);
|
|
|
|
*file_part = g_strdup (str);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gchar *folder_part;
|
|
|
|
gchar *folder_path;
|
|
|
|
|
|
|
|
if (last_slash == str)
|
2004-04-22 05:08:19 +00:00
|
|
|
{
|
|
|
|
if (g_ascii_isalpha (base_filename[0]) &&
|
|
|
|
base_filename[1] == ':')
|
2005-08-26 13:44:50 +00:00
|
|
|
folder_part = g_strdup_printf ("%c:\\", base_filename[0]);
|
2004-04-22 05:08:19 +00:00
|
|
|
else
|
2005-08-26 13:44:50 +00:00
|
|
|
folder_part = g_strdup ("\\");
|
2004-04-22 05:08:19 +00:00
|
|
|
}
|
|
|
|
else if (g_ascii_isalpha (str[0]) &&
|
|
|
|
str[1] == ':' &&
|
2005-08-26 13:44:50 +00:00
|
|
|
last_slash == str + 2)
|
2004-12-12 22:22:36 +00:00
|
|
|
folder_part = g_strndup (str, last_slash - str + 1);
|
2005-08-26 13:44:50 +00:00
|
|
|
#if 0
|
|
|
|
/* Hmm, what the heck was this case supposed to do? It splits up
|
|
|
|
* \\server\share\foo\bar into folder_part
|
|
|
|
* \\server\share\foo\bar and file_path bar. Not good. As far as
|
|
|
|
* I can see, this isn't needed.
|
|
|
|
*/
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
else if (G_IS_DIR_SEPARATOR (str[0]) &&
|
|
|
|
G_IS_DIR_SEPARATOR (str[1]) &&
|
|
|
|
(!str[2] || !G_IS_DIR_SEPARATOR (str[2])))
|
|
|
|
folder_part = g_strdup (str);
|
2005-08-26 13:44:50 +00:00
|
|
|
#endif
|
2003-11-15 20:35:55 +00:00
|
|
|
else
|
2004-12-12 21:09:13 +00:00
|
|
|
folder_part = g_strndup (str, last_slash - str);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
g_assert (folder_part);
|
|
|
|
|
|
|
|
if (g_path_is_absolute (folder_part))
|
|
|
|
folder_path = folder_part;
|
2003-11-15 20:35:55 +00:00
|
|
|
else
|
|
|
|
{
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
folder_path = g_build_filename (base_filename, folder_part, NULL);
|
|
|
|
g_free (folder_part);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
2007-03-07 23:17:38 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
canonicalize_filename (folder_path);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
*folder = filename_to_path (folder_path);
|
|
|
|
*file_part = g_strdup (last_slash + 1);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
g_free (folder_path);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
result = TRUE;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2005-08-26 13:44:50 +00:00
|
|
|
#if DEBUGGING_OUTPUT
|
|
|
|
printf ("%s:returning folder=%s file_part=%s\n", __FUNCTION__, (*folder?(char*)*folder:"NULL"), *file_part), fflush(stdout);
|
2004-04-22 05:08:19 +00:00
|
|
|
#endif
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_path_to_uri (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
return g_filename_to_uri (gtk_file_path_get_string (path), NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_path_to_filename (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
|
|
|
return g_strdup (gtk_file_path_get_string (path));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFilePath *
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_uri_to_path (GtkFileSystem *file_system,
|
|
|
|
const gchar *uri)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
GtkFilePath *path;
|
2003-11-15 20:35:55 +00:00
|
|
|
gchar *filename = g_filename_from_uri (uri, NULL, NULL);
|
2005-08-26 13:44:50 +00:00
|
|
|
|
|
|
|
#if DEBUGGING_OUTPUT
|
|
|
|
printf ("%s: %s -> %s\n", __FUNCTION__, uri, filename?filename:"NULL"), fflush (stdout);
|
|
|
|
#endif
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
if (filename)
|
2004-08-06 19:20:42 +00:00
|
|
|
{
|
|
|
|
path = filename_to_path (filename);
|
|
|
|
g_free (filename);
|
|
|
|
}
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
else
|
|
|
|
path = NULL;
|
2004-08-06 19:20:42 +00:00
|
|
|
|
|
|
|
return path;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFilePath *
|
2003-12-08 23:13:14 +00:00
|
|
|
gtk_file_system_win32_filename_to_path (GtkFileSystem *file_system,
|
|
|
|
const gchar *filename)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-08-06 19:20:42 +00:00
|
|
|
return filename_to_path (filename);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-05-21 23:48:49 +00:00
|
|
|
bookmark_list_free (GSList *list)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
GSList *l;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
for (l = list; l; l = l->next)
|
|
|
|
g_free (l->data);
|
2004-03-24 17:22:36 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_slist_free (list);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/* Returns whether a URI is a local file:// */
|
|
|
|
static gboolean
|
|
|
|
is_local_uri (const char *uri)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
char *filename;
|
|
|
|
char *hostname;
|
|
|
|
gboolean result;
|
2004-03-20 23:45:35 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
/* This is rather crude, but hey */
|
|
|
|
filename = g_filename_from_uri (uri, &hostname, NULL);
|
2004-03-20 23:45:35 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
result = (filename && !hostname);
|
2004-03-20 23:45:35 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (filename);
|
|
|
|
g_free (hostname);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static char *
|
|
|
|
bookmark_get_filename (void)
|
|
|
|
{
|
|
|
|
char *filename;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
filename = g_build_filename (g_get_home_dir (),
|
2006-05-21 23:48:49 +00:00
|
|
|
BOOKMARKS_FILENAME, NULL);
|
|
|
|
g_assert (filename != NULL);
|
|
|
|
return filename;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2006-05-21 23:48:49 +00:00
|
|
|
bookmark_list_read (GSList **bookmarks, GError **error)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
gchar *filename;
|
|
|
|
gchar *contents;
|
|
|
|
gboolean result = FALSE;
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
filename = bookmark_get_filename ();
|
|
|
|
*bookmarks = NULL;
|
2005-08-26 13:44:50 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (g_file_get_contents (filename, &contents, NULL, error))
|
|
|
|
{
|
|
|
|
gchar **lines = g_strsplit (contents, "\n", -1);
|
|
|
|
int i;
|
|
|
|
GHashTable *table;
|
2005-08-26 13:44:50 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
table = g_hash_table_new (g_str_hash, g_str_equal);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
for (i = 0; lines[i]; i++)
|
|
|
|
{
|
|
|
|
if (lines[i][0] && !g_hash_table_lookup (table, lines[i]))
|
|
|
|
{
|
|
|
|
*bookmarks = g_slist_prepend (*bookmarks, g_strdup (lines[i]));
|
|
|
|
g_hash_table_insert (table, lines[i], lines[i]);
|
|
|
|
}
|
|
|
|
}
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (contents);
|
|
|
|
g_hash_table_destroy (table);
|
|
|
|
g_strfreev (lines);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
*bookmarks = g_slist_reverse (*bookmarks);
|
|
|
|
result = TRUE;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (filename);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
return result;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static gboolean
|
2007-03-07 23:17:38 +00:00
|
|
|
bookmark_list_write (GSList *bookmarks,
|
2006-05-21 23:48:49 +00:00
|
|
|
GError **error)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
GSList *l;
|
|
|
|
GString *string;
|
|
|
|
char *filename;
|
|
|
|
GError *tmp_error = NULL;
|
|
|
|
gboolean result;
|
2004-12-12 21:09:13 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
string = g_string_new ("");
|
2004-12-12 21:09:13 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
for (l = bookmarks; l; l = l->next)
|
2004-12-12 21:09:13 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
g_string_append (string, l->data);
|
|
|
|
g_string_append_c (string, '\n');
|
|
|
|
}
|
2004-12-12 21:09:13 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
filename = bookmark_get_filename ();
|
2004-12-12 21:09:13 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
result = g_file_set_contents (filename, string->str, -1, &tmp_error);
|
2004-12-12 21:09:13 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (filename);
|
|
|
|
g_string_free (string, TRUE);
|
|
|
|
|
|
|
|
if (!result)
|
2004-12-12 21:09:13 +00:00
|
|
|
{
|
2003-11-15 20:35:55 +00:00
|
|
|
g_set_error (error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
2006-05-21 23:48:49 +00:00
|
|
|
GTK_FILE_SYSTEM_ERROR_FAILED,
|
|
|
|
_("Bookmark saving failed: %s"),
|
|
|
|
tmp_error->message);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_error_free (tmp_error);
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static gboolean
|
|
|
|
gtk_file_system_win32_insert_bookmark (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
gint position,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GSList *bookmarks;
|
|
|
|
int num_bookmarks;
|
|
|
|
GSList *l;
|
|
|
|
char *uri;
|
|
|
|
gboolean result;
|
|
|
|
GError *err;
|
|
|
|
|
|
|
|
err = NULL;
|
|
|
|
if (!bookmark_list_read (&bookmarks, &err) && err->code != G_FILE_ERROR_NOENT)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
g_propagate_error (error, err);
|
|
|
|
return FALSE;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
num_bookmarks = g_slist_length (bookmarks);
|
|
|
|
g_return_val_if_fail (position >= -1 && position <= num_bookmarks, FALSE);
|
|
|
|
|
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
uri = gtk_file_system_win32_path_to_uri (file_system, path);
|
|
|
|
|
|
|
|
for (l = bookmarks; l; l = l->next)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
char *bookmark, *space;
|
|
|
|
|
|
|
|
bookmark = l->data;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
space = strchr (bookmark, ' ');
|
|
|
|
if (space)
|
|
|
|
*space = '\0';
|
|
|
|
if (strcmp (bookmark, uri) != 0)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
if (space)
|
|
|
|
*space = ' ';
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
2006-05-21 23:48:49 +00:00
|
|
|
else
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
g_set_error (error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_ALREADY_EXISTS,
|
|
|
|
_("'%s' already exists in the bookmarks list"),
|
|
|
|
uri);
|
|
|
|
goto out;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
bookmarks = g_slist_insert (bookmarks, g_strdup (uri), position);
|
|
|
|
if (bookmark_list_write (bookmarks, error))
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
result = TRUE;
|
|
|
|
g_signal_emit_by_name (file_system, "bookmarks-changed", 0);
|
|
|
|
}
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
out:
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (uri);
|
|
|
|
bookmark_list_free (bookmarks);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_file_system_win32_remove_bookmark (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GSList *bookmarks;
|
|
|
|
char *uri;
|
|
|
|
GSList *l;
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
if (!bookmark_list_read (&bookmarks, error))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
uri = gtk_file_system_path_to_uri (file_system, path);
|
|
|
|
|
|
|
|
for (l = bookmarks; l; l = l->next)
|
|
|
|
{
|
|
|
|
char *bookmark, *space;
|
|
|
|
|
|
|
|
bookmark = (char *)l->data;
|
|
|
|
space = strchr (bookmark, ' ');
|
|
|
|
if (space)
|
|
|
|
*space = '\0';
|
|
|
|
|
|
|
|
if (strcmp (bookmark, uri) != 0)
|
|
|
|
{
|
|
|
|
if (space)
|
|
|
|
*space = ' ';
|
|
|
|
}
|
2005-07-14 19:10:03 +00:00
|
|
|
else
|
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (l->data);
|
|
|
|
bookmarks = g_slist_remove_link (bookmarks, l);
|
|
|
|
g_slist_free_1 (l);
|
|
|
|
|
|
|
|
if (bookmark_list_write (bookmarks, error))
|
2005-07-14 19:10:03 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
result = TRUE;
|
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
g_signal_emit_by_name (file_system, "bookmarks-changed", 0);
|
2005-07-14 19:10:03 +00:00
|
|
|
}
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_set_error (error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
|
|
|
|
_("'%s' does not exist in the bookmarks list"),
|
|
|
|
uri);
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
|
|
|
g_free (uri);
|
|
|
|
bookmark_list_free (bookmarks);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *
|
|
|
|
gtk_file_system_win32_list_bookmarks (GtkFileSystem *file_system)
|
|
|
|
{
|
|
|
|
GSList *bookmarks;
|
|
|
|
GSList *result;
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
if (!bookmark_list_read (&bookmarks, NULL))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
result = NULL;
|
|
|
|
|
|
|
|
for (l = bookmarks; l; l = l->next)
|
|
|
|
{
|
|
|
|
char *bookmark, *space;
|
|
|
|
|
|
|
|
bookmark = (char *)l->data;
|
|
|
|
space = strchr (bookmark, ' ');
|
|
|
|
if (space)
|
|
|
|
*space = '\0';
|
|
|
|
|
|
|
|
if (is_local_uri (bookmark))
|
|
|
|
result = g_slist_prepend (result, gtk_file_system_win32_uri_to_path (file_system, bookmark));
|
|
|
|
}
|
|
|
|
|
|
|
|
bookmark_list_free (bookmarks);
|
|
|
|
|
|
|
|
result = g_slist_reverse (result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
gtk_file_system_win32_get_bookmark_label (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path)
|
|
|
|
{
|
|
|
|
GSList *labels;
|
|
|
|
gchar *label;
|
|
|
|
GSList *l;
|
|
|
|
char *bookmark, *space, *uri;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
labels = NULL;
|
|
|
|
label = NULL;
|
|
|
|
|
|
|
|
uri = gtk_file_system_path_to_uri (file_system, path);
|
|
|
|
bookmark_list_read (&labels, NULL);
|
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
for (l = labels; l && !label; l = l->next)
|
2006-05-21 23:48:49 +00:00
|
|
|
{
|
|
|
|
bookmark = (char *)l->data;
|
|
|
|
space = strchr (bookmark, ' ');
|
|
|
|
if (!space)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
*space = '\0';
|
|
|
|
|
|
|
|
if (strcmp (uri, bookmark) == 0)
|
|
|
|
label = g_strdup (space + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bookmark_list_free (labels);
|
|
|
|
g_free (uri);
|
|
|
|
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_file_system_win32_set_bookmark_label (GtkFileSystem *file_system,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
const gchar *label)
|
|
|
|
{
|
|
|
|
GSList *labels;
|
|
|
|
GSList *l;
|
|
|
|
gchar *bookmark, *space, *uri;
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
labels = NULL;
|
|
|
|
|
|
|
|
uri = gtk_file_system_path_to_uri (file_system, path);
|
|
|
|
bookmark_list_read (&labels, NULL);
|
|
|
|
|
|
|
|
found = FALSE;
|
2007-03-07 23:17:38 +00:00
|
|
|
for (l = labels; l && !found; l = l->next)
|
2006-05-21 23:48:49 +00:00
|
|
|
{
|
|
|
|
bookmark = (gchar *)l->data;
|
|
|
|
space = strchr (bookmark, ' ');
|
|
|
|
if (space)
|
|
|
|
*space = '\0';
|
|
|
|
|
|
|
|
if (strcmp (bookmark, uri) != 0)
|
|
|
|
{
|
|
|
|
if (space)
|
|
|
|
*space = ' ';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_free (bookmark);
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (label && *label)
|
|
|
|
l->data = g_strdup_printf ("%s %s", uri, label);
|
2005-07-14 19:10:03 +00:00
|
|
|
else
|
2006-05-21 23:48:49 +00:00
|
|
|
l->data = g_strdup (uri);
|
|
|
|
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
2005-07-14 19:10:03 +00:00
|
|
|
}
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
if (bookmark_list_write (labels, NULL))
|
|
|
|
g_signal_emit_by_name (file_system, "bookmarks-changed", 0);
|
|
|
|
}
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
bookmark_list_free (labels);
|
|
|
|
g_free (uri);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_file_folder_win32_class_init (GtkFileFolderWin32Class *class)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_file_folder_win32_finalize;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_file_folder_win32_iface_init (GtkFileFolderIface *iface)
|
|
|
|
{
|
|
|
|
iface->get_info = gtk_file_folder_win32_get_info;
|
|
|
|
iface->list_children = gtk_file_folder_win32_list_children;
|
|
|
|
iface->is_finished_loading = gtk_file_folder_win32_is_finished_loading;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_gtk_file_folder_win32_init (GtkFileFolderWin32 *impl)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_file_folder_win32_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkFileFolderWin32 *folder_win32 = GTK_FILE_FOLDER_WIN32 (object);
|
|
|
|
|
|
|
|
if (folder_win32->load_folder_id)
|
|
|
|
{
|
|
|
|
g_source_remove (folder_win32->load_folder_id);
|
|
|
|
folder_win32->load_folder_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_remove (folder_win32->system_win32->folder_hash, folder_win32->filename);
|
|
|
|
|
|
|
|
if (folder_win32->stat_info)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
g_print ("Releasing information for directory %s\n", folder_win32->filename);
|
|
|
|
#endif
|
|
|
|
g_hash_table_destroy (folder_win32->stat_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (folder_win32->filename);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (_gtk_file_folder_win32_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates a GtkFileInfo for a volume root by stat()ing it */
|
|
|
|
static GtkFileInfo *
|
|
|
|
file_info_for_root_with_error (const char *root_name,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
struct stat statbuf;
|
|
|
|
GtkFileInfo *info;
|
|
|
|
|
|
|
|
if (g_stat (root_name, &statbuf) != 0)
|
|
|
|
{
|
|
|
|
int saved_errno;
|
|
|
|
char *display_name;
|
|
|
|
|
2007-03-07 23:17:38 +00:00
|
|
|
saved_errno = errno;
|
2006-05-21 23:48:49 +00:00
|
|
|
display_name = g_filename_display_name (root_name);
|
|
|
|
g_set_error (error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
GTK_FILE_SYSTEM_ERROR_FAILED,
|
|
|
|
_("Error getting information for '%s': %s"),
|
|
|
|
display_name,
|
|
|
|
g_strerror (saved_errno));
|
|
|
|
|
|
|
|
g_free (display_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = gtk_file_info_new ();
|
|
|
|
gtk_file_info_set_display_name (info, root_name);
|
|
|
|
gtk_file_info_set_is_folder (info, TRUE);
|
|
|
|
gtk_file_info_set_is_hidden (info, FALSE);
|
|
|
|
gtk_file_info_set_mime_type (info, "x-directory/normal");
|
|
|
|
gtk_file_info_set_modification_time (info, statbuf.st_mtime);
|
|
|
|
gtk_file_info_set_size (info, statbuf.st_size);
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
stat_with_error (const char *filename,
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA *wfad,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, error);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (wfilename == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
rc = GetFileAttributesExW (wfilename, GetFileExInfoStandard, wfad);
|
|
|
|
|
|
|
|
if (rc == 0)
|
|
|
|
{
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
int error_number = GetLastError ();
|
|
|
|
char *emsg = g_win32_error_message (error_number);
|
|
|
|
gchar *display_name = g_filename_display_name (filename);
|
|
|
|
int code;
|
|
|
|
|
|
|
|
if (error_number == ERROR_FILE_NOT_FOUND ||
|
|
|
|
error_number == ERROR_PATH_NOT_FOUND)
|
|
|
|
code = GTK_FILE_SYSTEM_ERROR_NONEXISTENT;
|
|
|
|
else
|
|
|
|
code = GTK_FILE_SYSTEM_ERROR_FAILED;
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_set_error (error,
|
|
|
|
GTK_FILE_SYSTEM_ERROR,
|
|
|
|
code,
|
|
|
|
_("Error getting information for '%s': %s"),
|
|
|
|
display_name,
|
|
|
|
emsg);
|
|
|
|
g_free (display_name);
|
|
|
|
g_free (wfilename);
|
|
|
|
g_free (emsg);
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
g_free (wfilename);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Creates a new GtkFileInfo from the specified data */
|
|
|
|
static GtkFileInfo *
|
|
|
|
create_file_info (GtkFileFolderWin32 *folder_win32,
|
|
|
|
const char *filename,
|
|
|
|
GtkFileInfoType types,
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA *wfad,
|
|
|
|
const char *mime_type)
|
|
|
|
{
|
|
|
|
GtkFileInfo *info;
|
|
|
|
|
|
|
|
info = gtk_file_info_new ();
|
2007-03-07 23:17:38 +00:00
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
if (types & GTK_FILE_INFO_DISPLAY_NAME)
|
|
|
|
{
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
gchar *display_name;
|
|
|
|
|
|
|
|
if (filename_is_root (filename))
|
|
|
|
display_name = g_filename_display_name (filename);
|
|
|
|
else
|
|
|
|
display_name = g_filename_display_basename (filename);
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
gtk_file_info_set_display_name (info, display_name);
|
|
|
|
g_free (display_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (types & GTK_FILE_INFO_IS_HIDDEN)
|
|
|
|
{
|
|
|
|
gboolean is_hidden = !!(wfad->dwFileAttributes & FILE_ATTRIBUTE_HIDDEN);
|
|
|
|
gtk_file_info_set_is_hidden (info, is_hidden);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (types & GTK_FILE_INFO_IS_FOLDER)
|
|
|
|
gtk_file_info_set_is_folder (info, !!(wfad->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY));
|
|
|
|
|
|
|
|
if (types & GTK_FILE_INFO_MIME_TYPE)
|
|
|
|
gtk_file_info_set_mime_type (info, mime_type);
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
if (types & GTK_FILE_INFO_MODIFICATION_TIME)
|
|
|
|
{
|
2007-03-07 23:17:38 +00:00
|
|
|
GtkFileTime time = (wfad->ftLastWriteTime.dwLowDateTime
|
2006-05-21 23:48:49 +00:00
|
|
|
| ((guint64)wfad->ftLastWriteTime.dwHighDateTime) << 32);
|
2003-11-15 20:35:55 +00:00
|
|
|
/* 100-nanosecond intervals since January 1, 1601, urgh! */
|
2004-02-28 23:36:11 +00:00
|
|
|
time /= G_GINT64_CONSTANT (10000000); /* now seconds */
|
|
|
|
time -= G_GINT64_CONSTANT (134774) * 24 * 3600; /* good old Unix time */
|
2003-11-15 20:35:55 +00:00
|
|
|
gtk_file_info_set_modification_time (info, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (types & GTK_FILE_INFO_SIZE)
|
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
gint64 size = wfad->nFileSizeLow | ((guint64)wfad->nFileSizeHigh) << 32;
|
2003-11-15 20:35:55 +00:00
|
|
|
gtk_file_info_set_size (info, size);
|
|
|
|
}
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
if (types & GTK_FILE_INFO_ICON)
|
|
|
|
{
|
2007-03-07 23:17:38 +00:00
|
|
|
IconType icon_type = get_icon_type_from_path (folder_win32, wfad, filename);
|
|
|
|
gchar *icon_name = get_icon_name (filename, icon_type);
|
2006-05-21 23:48:49 +00:00
|
|
|
gtk_file_info_set_icon_name (info, icon_name);
|
2007-03-07 23:17:38 +00:00
|
|
|
g_free (icon_name);
|
2006-05-21 23:48:49 +00:00
|
|
|
}
|
|
|
|
|
2003-11-15 20:35:55 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
static struct stat_info_entry *
|
|
|
|
create_stat_info_entry_and_emit_add (GtkFileFolderWin32 *folder_win32,
|
|
|
|
const char *filename,
|
|
|
|
const char *basename,
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA *wfad)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
GSList *paths;
|
|
|
|
GtkFilePath *path;
|
|
|
|
struct stat_info_entry *entry;
|
|
|
|
|
|
|
|
entry = g_new0 (struct stat_info_entry, 1);
|
|
|
|
|
|
|
|
if ((folder_win32->types & STAT_NEEDED_MASK) != 0)
|
|
|
|
entry->wfad = *wfad;
|
|
|
|
|
|
|
|
if ((folder_win32->types & GTK_FILE_INFO_MIME_TYPE) != 0)
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
entry->mime_type = get_mime_type_for_file (filename, wfad);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
g_hash_table_insert (folder_win32->stat_info,
|
|
|
|
g_strdup (basename),
|
|
|
|
entry);
|
|
|
|
|
|
|
|
path = gtk_file_path_new_dup (filename);
|
|
|
|
paths = g_slist_append (NULL, path);
|
|
|
|
g_signal_emit_by_name (folder_win32, "files-added", paths);
|
|
|
|
gtk_file_path_free (path);
|
|
|
|
g_slist_free (paths);
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFileInfo *
|
|
|
|
gtk_file_folder_win32_get_info (GtkFileFolder *folder,
|
|
|
|
const GtkFilePath *path,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GtkFileFolderWin32 *folder_win32 = GTK_FILE_FOLDER_WIN32 (folder);
|
|
|
|
GtkFileInfo *info;
|
|
|
|
const char *filename;
|
|
|
|
GtkFileInfoType types;
|
|
|
|
WIN32_FILE_ATTRIBUTE_DATA wfad;
|
|
|
|
const char *mime_type;
|
|
|
|
|
|
|
|
/* Get_info for "/" */
|
|
|
|
if (!path)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (filename_is_root (folder_win32->filename), NULL);
|
|
|
|
return file_info_for_root_with_error (folder_win32->filename, error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get_info for normal files */
|
|
|
|
|
|
|
|
filename = gtk_file_path_get_string (path);
|
|
|
|
g_return_val_if_fail (filename != NULL, NULL);
|
|
|
|
g_return_val_if_fail (g_path_is_absolute (filename), NULL);
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
#if 0
|
|
|
|
/* Skip this sanity check, as it fails for server share roots, where
|
|
|
|
* dirname gets set to \\server\share\ and folder_win32->filename is
|
|
|
|
* \\server\share. Also, should we do a casefolded comparison here,
|
|
|
|
* too, anyway?
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
gchar *dirname = get_parent_dir (filename);
|
|
|
|
g_return_val_if_fail (strcmp (dirname, folder_win32->filename) == 0, NULL);
|
|
|
|
g_free (dirname);
|
|
|
|
}
|
|
|
|
#endif
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
types = folder_win32->types;
|
|
|
|
|
|
|
|
if (folder_win32->have_stat)
|
|
|
|
{
|
|
|
|
struct stat_info_entry *entry;
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
gchar *basename;
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
g_assert (folder_win32->stat_info != NULL);
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
|
|
|
|
basename = g_path_get_basename (filename);
|
2006-05-21 23:48:49 +00:00
|
|
|
entry = g_hash_table_lookup (folder_win32->stat_info, basename);
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
if (!stat_with_error (filename, &wfad, error))
|
|
|
|
{
|
|
|
|
g_free (basename);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry = create_stat_info_entry_and_emit_add (folder_win32, filename, basename, &wfad);
|
|
|
|
}
|
|
|
|
g_free (basename);
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
|
|
|
|
info = create_file_info (folder_win32, filename, types, &entry->wfad, entry->mime_type);
|
2006-05-21 23:48:49 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!stat_with_error (filename, &wfad, error))
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
return NULL;
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
if ((types & GTK_FILE_INFO_MIME_TYPE) != 0)
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
mime_type = get_mime_type_for_file (filename, &wfad);
|
2006-05-21 23:48:49 +00:00
|
|
|
else
|
|
|
|
mime_type = NULL;
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
info = create_file_info (folder_win32, filename, types, &wfad, mime_type);
|
|
|
|
|
2006-05-21 23:48:49 +00:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
cb_list_children (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
|
|
|
GSList **children = user_data;
|
|
|
|
*children = g_slist_prepend (*children, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_file_folder_win32_list_children (GtkFileFolder *folder,
|
|
|
|
GSList **children,
|
|
|
|
GError **error)
|
|
|
|
{
|
|
|
|
GtkFileFolderWin32 *folder_win32 = GTK_FILE_FOLDER_WIN32 (folder);
|
|
|
|
GSList *l;
|
|
|
|
|
|
|
|
*children = NULL;
|
|
|
|
|
|
|
|
/* Get the list of basenames. */
|
|
|
|
if (folder_win32->stat_info)
|
|
|
|
g_hash_table_foreach (folder_win32->stat_info, cb_list_children, children);
|
|
|
|
|
|
|
|
/* Turn basenames into GFilePaths. */
|
|
|
|
for (l = *children; l; l = l->next)
|
|
|
|
{
|
|
|
|
const char *basename = l->data;
|
|
|
|
char *fullname = g_build_filename (folder_win32->filename, basename, NULL);
|
|
|
|
l->data = filename_to_path (fullname);
|
|
|
|
g_free (fullname);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gtk_file_folder_win32_is_finished_loading (GtkFileFolder *folder)
|
|
|
|
{
|
|
|
|
return GTK_FILE_FOLDER_WIN32 (folder)->is_finished_loading;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
free_stat_info_entry (struct stat_info_entry *entry)
|
|
|
|
{
|
|
|
|
g_free (entry->mime_type);
|
|
|
|
g_free (entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
fill_in_names (GtkFileFolderWin32 *folder_win32, GError **error)
|
|
|
|
{
|
|
|
|
GDir *dir;
|
|
|
|
|
|
|
|
if (folder_win32->stat_info)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
dir = g_dir_open (folder_win32->filename, 0, error);
|
|
|
|
if (!dir)
|
|
|
|
return FALSE;
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
folder_win32->stat_info = g_hash_table_new_full (casefolded_hash, casefolded_equal,
|
2006-05-21 23:48:49 +00:00
|
|
|
(GDestroyNotify) g_free,
|
|
|
|
(GDestroyNotify) free_stat_info_entry);
|
|
|
|
|
|
|
|
while (TRUE)
|
|
|
|
{
|
|
|
|
struct stat_info_entry *entry;
|
|
|
|
const gchar *basename;
|
|
|
|
|
|
|
|
basename = g_dir_read_name (dir);
|
|
|
|
if (!basename)
|
|
|
|
break;
|
|
|
|
|
|
|
|
entry = g_new0 (struct stat_info_entry, 1);
|
|
|
|
if (folder_win32->is_network_dir)
|
|
|
|
{
|
|
|
|
g_assert_not_reached ();
|
|
|
|
entry->wfad.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY;
|
|
|
|
entry->mime_type = g_strdup ("x-directory/normal");
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_insert (folder_win32->stat_info,
|
|
|
|
g_strdup (basename),
|
|
|
|
entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_dir_close (dir);
|
|
|
|
|
|
|
|
folder_win32->asof = time (NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
cb_fill_in_stats (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
|
|
|
const char *basename = key;
|
|
|
|
struct stat_info_entry *entry = value;
|
|
|
|
GtkFileFolderWin32 *folder_win32 = user_data;
|
|
|
|
char *fullname = g_build_filename (folder_win32->filename, basename, NULL);
|
|
|
|
gboolean result;
|
|
|
|
|
|
|
|
if (!stat_with_error (fullname, &entry->wfad, NULL))
|
|
|
|
result = TRUE; /* Couldn't stat -- remove from hash. */
|
|
|
|
else
|
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
g_free (fullname);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
fill_in_stats (GtkFileFolderWin32 *folder_win32)
|
|
|
|
{
|
|
|
|
if (folder_win32->have_stat)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!fill_in_names (folder_win32, NULL))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!folder_win32->is_network_dir)
|
|
|
|
g_hash_table_foreach_remove (folder_win32->stat_info,
|
|
|
|
cb_fill_in_stats,
|
|
|
|
folder_win32);
|
|
|
|
|
|
|
|
folder_win32->have_stat = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
cb_fill_in_mime_type (gpointer key, gpointer value, gpointer user_data)
|
|
|
|
{
|
|
|
|
const char *basename = key;
|
|
|
|
struct stat_info_entry *entry = value;
|
|
|
|
GtkFileFolderWin32 *folder_win32 = user_data;
|
|
|
|
char *fullname = g_build_filename (folder_win32->filename, basename, NULL);
|
|
|
|
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
entry->mime_type = get_mime_type_for_file (fullname, &entry->wfad);
|
2006-05-21 23:48:49 +00:00
|
|
|
|
|
|
|
g_free (fullname);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fill_in_mime_type (GtkFileFolderWin32 *folder_win32)
|
|
|
|
{
|
|
|
|
if (folder_win32->have_mime_type)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!folder_win32->have_stat)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_assert (folder_win32->stat_info != NULL);
|
|
|
|
|
|
|
|
if (!folder_win32->is_network_dir)
|
|
|
|
g_hash_table_foreach_remove (folder_win32->stat_info,
|
|
|
|
cb_fill_in_mime_type,
|
|
|
|
folder_win32);
|
|
|
|
|
|
|
|
folder_win32->have_mime_type = TRUE;
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GtkFilePath *
|
|
|
|
filename_to_path (const char *filename)
|
|
|
|
{
|
2006-05-21 23:48:49 +00:00
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
tmp = remove_trailing_slash (filename);
|
|
|
|
return gtk_file_path_new_steal (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
filename_is_root (const char *filename)
|
|
|
|
{
|
|
|
|
const gchar *after_root;
|
|
|
|
|
|
|
|
after_root = g_path_skip_root (filename);
|
|
|
|
|
|
|
|
return (after_root != NULL && *after_root == '\0');
|
2003-11-15 20:35:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-04-22 05:08:19 +00:00
|
|
|
filename_is_drive_root (const char *filename)
|
2003-11-15 20:35:55 +00:00
|
|
|
{
|
2004-04-22 05:08:19 +00:00
|
|
|
guint len = strlen (filename);
|
2003-11-15 20:35:55 +00:00
|
|
|
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
return (len == 3 &&
|
|
|
|
g_ascii_isalpha (filename[0]) &&
|
|
|
|
filename[1] == ':' &&
|
|
|
|
G_IS_DIR_SEPARATOR (filename[2]));
|
|
|
|
}
|
|
|
|
|
2004-04-22 05:08:19 +00:00
|
|
|
static gboolean
|
|
|
|
filename_is_some_root (const char *filename)
|
|
|
|
{
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
return (g_path_is_absolute (filename) &&
|
|
|
|
*(g_path_skip_root (filename)) == '\0');
|
2007-03-07 23:17:38 +00:00
|
|
|
}
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
_gtk_file_system_win32_path_compare (const gchar *path1,
|
|
|
|
const gchar *path2)
|
|
|
|
{
|
Remove dead code. Reduce spurious differences between this file and
2006-08-23 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c: Remove dead code. Reduce spurious
differences between this file and gtkfilesystemunix.c so that it
is easier to compare them and check if differences are
intentional. I will later factor out the common functions and code
snippets from these two files.
2006-08-23 Tor Lillqvist <tml@novell.com>
Fix several problems with the file chooser on Windows, for
instance prevent duplicated directory entries from appearing.
* gtk/gtkfilesystem.c (gtk_file_paths_sort): Use
_gtk_file_system_win32_path_compare() on Windows for casefolded
sorting.
* gtk/gtkfilesystemwin32.c (casefolded_hash, casefolded_equal):
case-independent hash and equality functions. Scan the UTF-8
strings gunichar by gunichar, and ignore special casing rules, to
more closely match NTFS behaviour.
(gtk_file_system_win32_init): Use casefolded_hash() and
casefolded_equal() for the folder hash table.
(remove_trailing_slash): Don't remove the slash of a drive or
share root.
(get_mime_type_for_file): Take also a WIN32_FILE_ATTRIBUTE_DATA as
argument, and use that to recognize directories. Don't call
g_file_test() to check for executables, just look at the file name
extension directly.
(gtk_file_system_win32_make_path): Check illegal chars in file
name, like in gtkfilesystemunix.c.
(create_file_info): Drop unused basename parameter. Call
g_filename_display_name() directly for roots, as
g_filename_display_basename() mishandles those.
(gtk_file_folder_win32_get_info): Skip sanity check for now, as it
fails for server share roots. Construct basename only in the if
branch that uses it.
(fill_in_names): Use casefolded_hash() and casefolded_equal() for
the folder's stat_info hash table, too.
(_gtk_file_system_win32_path_compare): Scan the strings gunichar
by gunichar and ignore special casing here, too, instead of using
g_utf8_casefold(). Match slash and backslash.
2006-08-23 01:34:53 +00:00
|
|
|
while (*path1 && *path2)
|
|
|
|
{
|
|
|
|
gunichar c1 = g_utf8_get_char (path1);
|
|
|
|
gunichar c2 = g_utf8_get_char (path2);
|
|
|
|
if (c1 == c2 ||
|
|
|
|
(G_IS_DIR_SEPARATOR (c1) && G_IS_DIR_SEPARATOR (c1)) ||
|
|
|
|
g_unichar_toupper (c1) == g_unichar_toupper (c2))
|
|
|
|
{
|
|
|
|
path1 = g_utf8_next_char (path1);
|
|
|
|
path2 = g_utf8_next_char (path2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
2006-08-23 08:17:09 +00:00
|
|
|
if (!*path1 && !*path2)
|
|
|
|
return 0;
|
|
|
|
else if (!*path1)
|
|
|
|
return -1;
|
|
|
|
else if (!*path2)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return g_unichar_toupper (g_utf8_get_char (path1)) - g_unichar_toupper (g_utf8_get_char (path2));
|
Add -lole32, needed for CoTaskMemFree in get_special_folder() below.
2005-01-02 Tor Lillqvist <tml@iki.fi>
* gtk/Makefile.am (libgtk_target_ldflags): Add -lole32, needed for
CoTaskMemFree in get_special_folder() below.
* gtk/gtkfilesystem.h: Implement case-insensitive path compare on
Win32 using _gtk_file_system_win32_path_compare().
* gtk/gtk.symbols: Add _gtk_file_system_win32_path_compare.
* gtk/gtkfilechooserbutton.c (model_add_special)
* gtk/gtkfilechooserdefault.c (shortcuts_append_desktop): Use
_gtk_file_system_win32_get_desktop() to get correct Desktop folder
on Win32. (#144003)
* gtk/gtkfilesystemwin32.c: Remove unnecessary includes. Do
consider all drives "mounted", including floppies. Trying to
inspect the contents of a nonexistent floppy will cause errors
later that are handled normally, no need to avoid them
completely. Keep the drive type in the GtkFileSystemVolume.
Support UNC paths. (#161797) Fix error message capitalizations
as in gtkfilesystemunix.c.
(gtk_file_system_win32_init): Start one timeout per
GtkFileSystemWin32.
(gtk_file_system_win32_finalize): Remove the timeout.
(get_special_folder): Copied from GLib.
(_gtk_file_system_win32_get_desktop): New function, uses
get_special_folder().
(gtk_file_system_win32_list_volumes): Don't start a timeout at
each call to this function. Don't assume A: and B: are floppies.
(gtk_file_system_win32_get_volume_for_path): Don't assume all
volumes are drive roots, i.e. support share roots of UNC paths
(\\server\share).
(gtk_file_system_win32_get_folder): Don't assume errno is set
after g_file_test() returns FALSE. It isn't on Win32 (and even on
Unix I don't think one should assume anything about errno after
g_file_test()).
(gtk_file_system_win32_volume_get_is_mounted): Always return TRUE.
(gtk_file_system_win32_volume_get_display_name): Don't call
GetVolumeInformation() on drives A: or B: if they are removable,
as they might then be floppies, causing an unnecessary
delay. (#157820)
(gtk_file_system_win32_volume_render_icon): Use network icon for
unrecognized drive types.
(canonicalize_filename, gtk_file_system_win32_parse): Don't get
confused by UNC paths.
(bookmarks_serialize): Use _gtk_file_system_win32_path_compare()
for case-insensitive UTF-8 path comparison.
(extract_icon): Use SHGetFileInfo() which is faster than
ExtractAssociatedIcon(). Icon extraction is still slow, though,
needs work.
(win32_pseudo_mime_lookup): Don't use the same icon for all
shortcuts or executables. Cache only other file type icons.
(gtk_file_system_win32_render_icon): Use network stock icon for
remote drives and UNC server share roots. Compare home directory
case-insensitively. Do lookup icons also for executable files,
after all, it's these files that can have individual icons in the
first place. Yes, it can be slow. Needs work.
(filename_is_drive_root): Require also the slash after the colon.
(filename_is_server_share): New function.
(_gtk_file_system_win32_path_compare): New function, does
case-folded UTF-8 comparison.
* gtk/gtkfilesystemwin32.h: Declare
_gtk_file_system_win32_path_compare().
2005-01-02 23:15:21 +00:00
|
|
|
}
|
2005-03-20 07:01:23 +00:00
|
|
|
|
|
|
|
#define __GTK_FILE_SYSTEM_WIN32_C__
|
|
|
|
#include "gtkaliasdef.c"
|