Bug 520874 - Should use gio directly.

2008-06-10  Carlos Garnacho  <carlos@imendio.com>

        Bug 520874 - Should use gio directly.

        * gtk/gtkfilesystem.[ch]: Turn into a private object, which mostly
        provides helper functions for asynchronous calls, folder abstraction
        and uniform handling of volumes/drives/mounts.

        * gtk/gtkfilesystemwin32.[ch]:
        * gtk/gtkfilesystemunix.[ch]: Removed, these are no longer required.

        * gtk/gtkfilechooser.c:
        * gtk/gtkfilechooserbutton.c:
        * gtk/gtkfilechooserdefault.c:
        * gtk/gtkfilechooserentry.[ch]:
        * gtk/gtkfilechooserprivate.h:
        * gtk/gtkfilechooserutils.c:
        * gtk/gtkfilesystemmodel.[ch]:
        * gtk/gtkpathbar.[ch]: Use GIO internally. Adapt to GtkFileSystem API.
        Do not load filesystem implementation modules.

        * gtk/Makefile.am:
        * gtk/gtk.symbols: the gtkfilesystem.h private header isn't installed
        anymore, nor the unix/win32 implementations.

        * README.in: Add blurb about these changes.

svn path=/trunk/; revision=20342
This commit is contained in:
Carlos Garnacho 2008-06-10 00:39:35 +00:00 committed by Carlos Garnacho
parent d717e77c1d
commit 640d68778a
21 changed files with 3836 additions and 9708 deletions

View File

@ -1,3 +1,30 @@
2008-06-10 Carlos Garnacho <carlos@imendio.com>
Bug 520874 - Should use gio directly.
* gtk/gtkfilesystem.[ch]: Turn into a private object, which mostly
provides helper functions for asynchronous calls, folder abstraction
and uniform handling of volumes/drives/mounts.
* gtk/gtkfilesystemwin32.[ch]:
* gtk/gtkfilesystemunix.[ch]: Removed, these are no longer required.
* gtk/gtkfilechooser.c:
* gtk/gtkfilechooserbutton.c:
* gtk/gtkfilechooserdefault.c:
* gtk/gtkfilechooserentry.[ch]:
* gtk/gtkfilechooserprivate.h:
* gtk/gtkfilechooserutils.c:
* gtk/gtkfilesystemmodel.[ch]:
* gtk/gtkpathbar.[ch]: Use GIO internally. Adapt to GtkFileSystem API.
Do not load filesystem implementation modules.
* gtk/Makefile.am:
* gtk/gtk.symbols: the gtkfilesystem.h private header isn't installed
anymore, nor the unix/win32 implementations.
* README.in: Add blurb about these changes.
2008-06-09 Kristian Rietveld <kris@gtk.org> 2008-06-09 Kristian Rietveld <kris@gtk.org>
Bug 526987 - GtkCellRendererCombo should allow model to be NULL Bug 526987 - GtkCellRendererCombo should allow model to be NULL

View File

@ -36,6 +36,12 @@ Release notes for 2.14
without including gtkitemfactory.h - even though this behaviour has never without including gtkitemfactory.h - even though this behaviour has never
been supported in the first place. been supported in the first place.
* The GtkFileSystem semi-private interface has been removed.
The GTK+ filechooser implementation now uses GIO directly, which has
rendered external filesystem implementations unnecessary. Consequently,
the GtkFileSystem interface is no longer available, nor the filechooser
will load any GtkFileSystem implementation.
Release notes for 2.12 Release notes for 2.12
====================== ======================

View File

@ -344,8 +344,7 @@ endif
# Installed header files without compatibility guarantees # Installed header files without compatibility guarantees
# that are not included in gtk/gtk.h # that are not included in gtk/gtk.h
gtk_semi_private_h_sources = \ gtk_semi_private_h_sources = \
gtktextlayout.h \ gtktextlayout.h
gtkfilesystem.h
# GTK+ header files that don't get installed # GTK+ header files that don't get installed
gtk_private_h_sources = \ gtk_private_h_sources = \
@ -361,8 +360,8 @@ gtk_private_h_sources = \
gtkfilechooserprivate.h \ gtkfilechooserprivate.h \
gtkfilechoosersettings.h \ gtkfilechoosersettings.h \
gtkfilechooserutils.h \ gtkfilechooserutils.h \
gtkfilesystem.h \
gtkfilesystemmodel.h \ gtkfilesystemmodel.h \
gtkfilesystemunix.h \
gtkhsv.h \ gtkhsv.h \
gtkiconcache.h \ gtkiconcache.h \
gtkintl.h \ gtkintl.h \
@ -654,7 +653,6 @@ gtk_c_sources = $(gtk_base_c_sources)
gtk_all_c_sources = $(gtk_base_c_sources) gtk_all_c_sources = $(gtk_base_c_sources)
gtk_os_unix_c_sources = \ gtk_os_unix_c_sources = \
gtkfilesystemunix.c \
gtkpagesetupunixdialog.c \ gtkpagesetupunixdialog.c \
gtkprinter.c \ gtkprinter.c \
gtkprinteroption.c \ gtkprinteroption.c \
@ -669,7 +667,6 @@ gtk_os_unix_c_sources = \
gtk_all_c_sources += $(gtk_os_unix_c_sources) gtk_all_c_sources += $(gtk_os_unix_c_sources)
if OS_UNIX if OS_UNIX
gtk_private_h_sources += \ gtk_private_h_sources += \
gtkfilesystemunix.h \
gtkiconcachevalidator.h \ gtkiconcachevalidator.h \
gtkprintbackend.h \ gtkprintbackend.h \
gtkprinter-private.h \ gtkprinter-private.h \
@ -682,12 +679,11 @@ gtk_c_sources += $(gtk_os_unix_c_sources)
endif endif
gtk_os_win32_c_sources = \ gtk_os_win32_c_sources = \
gtkfilesystemwin32.c \
gtkprint-win32.c \ gtkprint-win32.c \
gtkprintoperation-win32.c gtkprintoperation-win32.c
gtk_all_c_sources += $(gtk_os_win32_c_sources) gtk_all_c_sources += $(gtk_os_win32_c_sources)
if OS_WIN32 if OS_WIN32
gtk_private_h_sources += gtkfilesystemwin32.h gtkprint-win32.h gtk_private_h_sources += gtkprint-win32.h
gtk_c_sources += $(gtk_os_win32_c_sources) gtk_c_sources += $(gtk_os_win32_c_sources)
endif endif
@ -1242,8 +1238,6 @@ EXTRA_DIST += \
gtkwin32embed.h \ gtkwin32embed.h \
gtkwin32embedwidget.h \ gtkwin32embedwidget.h \
gtkwin32embedwidget.c \ gtkwin32embedwidget.c \
gtkfilesystemwin32.h \
gtkfilesystemwin32.c \
gtkprint-win32.h \ gtkprint-win32.h \
gtkprint-win32.c \ gtkprint-win32.c \
gtksearchenginequartz.h \ gtksearchenginequartz.h \

View File

@ -1461,87 +1461,6 @@ gtk_file_filter_set_name
#endif #endif
#endif #endif
#if IN_HEADER(__GTK_FILE_SYSTEM_H__)
#if IN_FILE(__GTK_FILE_SYSTEM_C__)
gtk_file_folder_get_info
gtk_file_folder_get_type G_GNUC_CONST
gtk_file_folder_is_finished_loading
gtk_file_folder_list_children
gtk_file_info_copy
gtk_file_info_free
gtk_file_info_get_display_key
gtk_file_info_get_display_name
gtk_file_info_get_icon_name
gtk_file_info_get_is_folder
gtk_file_info_get_is_hidden
gtk_file_info_get_mime_type
gtk_file_info_get_modification_time
gtk_file_info_get_size
gtk_file_info_get_type G_GNUC_CONST
gtk_file_info_new
gtk_file_info_render_icon
gtk_file_info_set_display_name
gtk_file_info_set_icon_name
gtk_file_info_set_is_folder
gtk_file_info_set_is_hidden
gtk_file_info_set_mime_type
gtk_file_info_set_modification_time
gtk_file_info_set_size
gtk_file_path_get_type G_GNUC_CONST
gtk_file_paths_copy
gtk_file_paths_free
gtk_file_paths_sort
gtk_file_system_cancel_operation
gtk_file_system_create
gtk_file_system_create_folder
gtk_file_system_error_quark
gtk_file_system_filename_to_path
gtk_file_system_get_info
gtk_file_system_get_folder
gtk_file_system_get_parent
gtk_file_system_get_type G_GNUC_CONST
gtk_file_system_get_volume_for_path
gtk_file_system_handle_get_type G_GNUC_CONST
gtk_file_system_insert_bookmark
gtk_file_system_list_bookmarks
gtk_file_system_list_volumes
gtk_file_system_make_path
gtk_file_system_parse
gtk_file_system_path_is_local
gtk_file_system_path_to_filename
gtk_file_system_path_to_uri
gtk_file_system_remove_bookmark
gtk_file_system_uri_to_path
gtk_file_system_volume_free
gtk_file_system_volume_get_base_path
gtk_file_system_volume_get_display_name
gtk_file_system_volume_get_icon_name
gtk_file_system_volume_get_is_mounted
gtk_file_system_volume_mount
gtk_file_system_volume_render_icon
gtk_file_system_get_bookmark_label
gtk_file_system_set_bookmark_label
#endif
#endif
#if IN_HEADER(__GTK_FILE_SYSTEM_UNIX_H__)
#if IN_FILE(__GTK_FILE_SYSTEM_UNIX_C__)
#ifdef G_OS_UNIX
gtk_file_system_unix_get_type G_GNUC_CONST
gtk_file_system_unix_new
#endif
#endif
#endif
#if IN_HEADER(__GTK_FILE_SYSTEM_WIN32_H__)
#if IN_FILE(__GTK_FILE_SYSTEM_WIN32_C__)
#ifdef G_OS_WIN32
gtk_file_system_win32_get_type G_GNUC_CONST
gtk_file_system_win32_new
#endif
#endif
#endif
#if IN_HEADER(__GTK_FILESEL_H__) #if IN_HEADER(__GTK_FILESEL_H__)
#if IN_FILE(__GTK_FILESEL_C__) #if IN_FILE(__GTK_FILESEL_C__)
#ifndef GTK_DISABLE_DEPRECATED #ifndef GTK_DISABLE_DEPRECATED

View File

@ -21,7 +21,6 @@
#include <config.h> #include <config.h>
#include "gtkfilechooser.h" #include "gtkfilechooser.h"
#include "gtkfilechooserprivate.h" #include "gtkfilechooserprivate.h"
#include "gtkfilesystem.h"
#include "gtkintl.h" #include "gtkintl.h"
#include "gtktypebuiltins.h" #include "gtktypebuiltins.h"
#include "gtkprivate.h" #include "gtkprivate.h"
@ -30,7 +29,7 @@
static void gtk_file_chooser_class_init (gpointer g_iface); static void gtk_file_chooser_class_init (gpointer g_iface);
static GtkFilePath *gtk_file_chooser_get_path (GtkFileChooser *chooser); static GFile *gtk_file_chooser_get_file (GtkFileChooser *chooser);
GType GType
gtk_file_chooser_get_type (void) gtk_file_chooser_get_type (void)
@ -446,18 +445,17 @@ gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
gchar * gchar *
gtk_file_chooser_get_filename (GtkFileChooser *chooser) gtk_file_chooser_get_filename (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gchar *result = NULL; gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = gtk_file_chooser_get_file (chooser);
path = gtk_file_chooser_get_path (chooser);
if (path) if (file)
{ {
result = gtk_file_system_path_to_filename (file_system, path); result = g_file_get_basename (file);
gtk_file_path_free (path); g_object_unref (file);
} }
return result; return result;
@ -535,23 +533,15 @@ gboolean
gtk_file_chooser_select_filename (GtkFileChooser *chooser, gtk_file_chooser_select_filename (GtkFileChooser *chooser,
const gchar *filename) const gchar *filename)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser); file = g_file_new_for_path (filename);
result = _gtk_file_chooser_select_file (chooser, file, NULL);
path = gtk_file_system_filename_to_path (file_system, filename); g_object_unref (file);
if (path)
{
result = _gtk_file_chooser_select_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
return result; return result;
} }
@ -571,39 +561,32 @@ void
gtk_file_chooser_unselect_filename (GtkFileChooser *chooser, gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
const char *filename) const char *filename)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser)); g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
g_return_if_fail (filename != NULL); g_return_if_fail (filename != NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = g_file_new_for_path (filename);
_gtk_file_chooser_unselect_file (chooser, file);
path = gtk_file_system_filename_to_path (file_system, filename); g_object_unref (file);
if (path)
{
_gtk_file_chooser_unselect_path (chooser, path);
gtk_file_path_free (path);
}
} }
/* Converts a list of GtkFilePath* to a list of strings using the specified function */ /* Converts a list of GFile* to a list of strings using the specified function */
static GSList * static GSList *
file_paths_to_strings (GtkFileSystem *fs, files_to_strings (GSList *files,
GSList *paths, gchar * (*convert_func) (GFile *file))
gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
{ {
GSList *strings; GSList *strings;
strings = NULL; strings = NULL;
for (; paths; paths = paths->next) for (; files; files = files->next)
{ {
GtkFilePath *path; GFile *file;
gchar *string; gchar *string;
path = paths->data; file = files->data;
string = (* convert_func) (fs, path); string = (* convert_func) (file);
if (string) if (string)
strings = g_slist_prepend (strings, string); strings = g_slist_prepend (strings, string);
@ -630,17 +613,16 @@ file_paths_to_strings (GtkFileSystem *fs,
GSList * GSList *
gtk_file_chooser_get_filenames (GtkFileChooser *chooser) gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GSList *files, *result;
GSList *paths;
GSList *result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); files = _gtk_file_chooser_get_files (chooser);
paths = _gtk_file_chooser_get_paths (chooser);
result = files_to_strings (files, g_file_get_path);
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_filename);
gtk_file_paths_free (paths);
return result; return result;
} }
@ -662,23 +644,15 @@ gboolean
gtk_file_chooser_set_current_folder (GtkFileChooser *chooser, gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
const gchar *filename) const gchar *filename)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (filename != NULL, FALSE); g_return_val_if_fail (filename != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser); file = g_file_new_for_path (filename);
result = _gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
path = gtk_file_system_filename_to_path (file_system, filename); g_object_unref (file);
if (path)
{
result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
return result; return result;
} }
@ -709,20 +683,17 @@ gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
gchar * gchar *
gtk_file_chooser_get_current_folder (GtkFileChooser *chooser) gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gchar *filename; gchar *filename;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = _gtk_file_chooser_get_current_folder_file (chooser);
if (!file)
path = _gtk_file_chooser_get_current_folder_path (chooser);
if (!path)
return NULL; return NULL;
filename = gtk_file_system_path_to_filename (file_system, path); filename = g_file_get_path (file);
gtk_file_path_free (path); g_object_unref (file);
return filename; return filename;
} }
@ -773,18 +744,16 @@ gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
gchar * gchar *
gtk_file_chooser_get_uri (GtkFileChooser *chooser) gtk_file_chooser_get_uri (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gchar *result = NULL; gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = gtk_file_chooser_get_file (chooser);
path = gtk_file_chooser_get_path (chooser); if (file)
if (path)
{ {
result = gtk_file_system_path_to_uri (file_system, path); result = g_file_get_uri (file);
gtk_file_path_free (path); g_object_unref (file);
} }
return result; return result;
@ -861,23 +830,15 @@ gboolean
gtk_file_chooser_select_uri (GtkFileChooser *chooser, gtk_file_chooser_select_uri (GtkFileChooser *chooser,
const char *uri) const char *uri)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (uri != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser); file = g_file_new_for_uri (uri);
result = _gtk_file_chooser_select_file (chooser, file, NULL);
path = gtk_file_system_uri_to_path (file_system, uri); g_object_unref (file);
if (path)
{
result = _gtk_file_chooser_select_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
return result; return result;
} }
@ -897,20 +858,14 @@ void
gtk_file_chooser_unselect_uri (GtkFileChooser *chooser, gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
const char *uri) const char *uri)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser)); g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
g_return_if_fail (uri != NULL); g_return_if_fail (uri != NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = g_file_new_for_uri (uri);
_gtk_file_chooser_unselect_file (chooser, file);
path = gtk_file_system_uri_to_path (file_system, uri); g_object_unref (file);
if (path)
{
_gtk_file_chooser_unselect_path (chooser, path);
gtk_file_path_free (path);
}
} }
/** /**
@ -962,17 +917,16 @@ gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
GSList * GSList *
gtk_file_chooser_get_uris (GtkFileChooser *chooser) gtk_file_chooser_get_uris (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GSList *files, *result;
GSList *paths;
GSList *result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); files = _gtk_file_chooser_get_files (chooser);
paths = _gtk_file_chooser_get_paths (chooser);
result = files_to_strings (files, g_file_get_uri);
g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
result = file_paths_to_strings (file_system, paths, gtk_file_system_path_to_uri);
gtk_file_paths_free (paths);
return result; return result;
} }
@ -994,23 +948,15 @@ gboolean
gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser, gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
const gchar *uri) const gchar *uri)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (uri != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser); file = g_file_new_for_path (uri);
result = _gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
path = gtk_file_system_uri_to_path (file_system, uri); g_object_unref (file);
if (path)
{
result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
return result; return result;
} }
@ -1040,31 +986,28 @@ gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
gchar * gchar *
gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser) gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gchar *uri; gchar *uri;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = _gtk_file_chooser_get_current_folder_file (chooser);
if (!file)
path = _gtk_file_chooser_get_current_folder_path (chooser);
if (!path)
return NULL; return NULL;
uri = gtk_file_system_path_to_uri (file_system, path); uri = g_file_get_uri (file);
gtk_file_path_free (path); g_object_unref (file);
return uri; return uri;
} }
/** /**
* _gtk_file_chooser_set_current_folder_path: * _gtk_file_chooser_set_current_folder_file:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* @path: the #GtkFilePath for the new folder * @file: the #GFile for the new folder
* @error: location to store error, or %NULL. * @error: location to store error, or %NULL.
* *
* Sets the current folder for @chooser from a #GtkFilePath. * Sets the current folder for @chooser from a #GFile.
* Internal function, see gtk_file_chooser_set_current_folder_uri(). * Internal function, see gtk_file_chooser_set_current_folder_uri().
* *
* Return value: %TRUE if the folder could be changed successfully, %FALSE * Return value: %TRUE if the folder could be changed successfully, %FALSE
@ -1073,31 +1016,30 @@ gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
* Since: 2.4 * Since: 2.4
**/ **/
gboolean gboolean
_gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser, _gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, path, error); return GTK_FILE_CHOOSER_GET_IFACE (chooser)->set_current_folder (chooser, file, error);
} }
/** /**
* _gtk_file_chooser_get_current_folder_path: * _gtk_file_chooser_get_current_folder_file:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* *
* Gets the current folder of @chooser as #GtkFilePath. * Gets the current folder of @chooser as #GFile.
* See gtk_file_chooser_get_current_folder_uri(). * See gtk_file_chooser_get_current_folder_uri().
* *
* Return value: the #GtkFilePath for the current folder. * Return value: the #GFile for the current folder.
* Free with gtk_file_path_free().
* *
* Since: 2.4 * Since: 2.4
*/ */
GtkFilePath * GFile *
_gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser) _gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
@ -1105,9 +1047,9 @@ _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
} }
/** /**
* _gtk_file_chooser_select_path: * _gtk_file_chooser_select_file:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* @path: the path to select * @file: the file to select
* @error: location to store error, or %NULL * @error: location to store error, or %NULL
* *
* Selects the file referred to by @path. An internal function. See * Selects the file referred to by @path. An internal function. See
@ -1119,15 +1061,15 @@ _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
* Since: 2.4 * Since: 2.4
**/ **/
gboolean gboolean
_gtk_file_chooser_select_path (GtkFileChooser *chooser, _gtk_file_chooser_select_file (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_path (chooser, path, error); return GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, error);
} }
/** /**
@ -1141,49 +1083,52 @@ _gtk_file_chooser_select_path (GtkFileChooser *chooser,
* Since: 2.4 * Since: 2.4
**/ **/
void void
_gtk_file_chooser_unselect_path (GtkFileChooser *chooser, _gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
const GtkFilePath *path) GFile *file)
{ {
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser)); g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
g_return_if_fail (G_IS_FILE (file));
GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_path (chooser, path); GTK_FILE_CHOOSER_GET_IFACE (chooser)->unselect_file (chooser, file);
} }
/** /**
* _gtk_file_chooser_get_paths: * _gtk_file_chooser_get_files:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* *
* Lists all the selected files and subfolders in the current folder of @chooser * Lists all the selected files and subfolders in the current folder of @chooser
* as #GtkFilePath. An internal function, see gtk_file_chooser_get_uris(). * as #GFile. An internal function, see gtk_file_chooser_get_uris().
* *
* Return value: a #GSList containing a #GtkFilePath for each selected * Return value: a #GSList containing a #GFile for each selected
* file and subfolder in the current folder. Free the returned list * file and subfolder in the current folder. Free the returned list
* with g_slist_free(), and the paths with gtk_file_path_free(). * with g_slist_free(), and the files with g_object_unref().
* *
* Since: 2.4 * Since: 2.4
**/ **/
GSList * GSList *
_gtk_file_chooser_get_paths (GtkFileChooser *chooser) _gtk_file_chooser_get_files (GtkFileChooser *chooser)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser); return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
} }
static GtkFilePath * static GFile *
gtk_file_chooser_get_path (GtkFileChooser *chooser) gtk_file_chooser_get_file (GtkFileChooser *chooser)
{ {
GSList *list; GSList *list;
GtkFilePath *result = NULL; GFile *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
list = _gtk_file_chooser_get_paths (chooser); list = _gtk_file_chooser_get_files (chooser);
if (list) if (list)
{ {
result = list->data; result = list->data;
list = g_slist_delete_link (list, list); list = g_slist_delete_link (list, list);
gtk_file_paths_free (list);
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
g_slist_free (list);
} }
return result; return result;
@ -1364,29 +1309,29 @@ gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser)
} }
/** /**
* gtk_file_chooser_get_preview_filename: * gtk_file_chooser_get_preview_file:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* *
* Gets the filename that should be previewed in a custom preview * Gets the filename that should be previewed in a custom preview
* Internal function, see gtk_file_chooser_get_preview_uri(). * Internal function, see gtk_file_chooser_get_preview_uri().
* *
* Return value: the #GtkFilePath for the file to preview, or %NULL if no file * Return value: the #GFile for the file to preview, or %NULL if no file
* is selected. Free with gtk_file_path_free(). * is selected. Free with gtk_file_path_free().
* *
* Since: 2.4 * Since: 2.4
**/ **/
GtkFilePath * GFile *
_gtk_file_chooser_get_preview_path (GtkFileChooser *chooser) _gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_path (chooser); return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_preview_file (chooser);
} }
/** /**
* _gtk_file_chooser_add_shortcut_folder: * _gtk_file_chooser_add_shortcut_folder:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* @path: path of the folder to add * @file: file for the folder to add
* @error: location to store error, or %NULL * @error: location to store error, or %NULL
* *
* Adds a folder to be displayed with the shortcut folders in a file chooser. * Adds a folder to be displayed with the shortcut folders in a file chooser.
@ -1398,20 +1343,20 @@ _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
* Since: 2.4 * Since: 2.4
**/ **/
gboolean gboolean
_gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error); return GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
} }
/** /**
* _gtk_file_chooser_remove_shortcut_folder: * _gtk_file_chooser_remove_shortcut_folder:
* @chooser: a #GtkFileChooser * @chooser: a #GtkFileChooser
* @path: path of the folder to remove * @file: file for the folder to remove
* @error: location to store error, or %NULL * @error: location to store error, or %NULL
* *
* Removes a folder from the shortcut folders in a file chooser. Internal * Removes a folder from the shortcut folders in a file chooser. Internal
@ -1423,14 +1368,14 @@ _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
* Since: 2.4 * Since: 2.4
**/ **/
gboolean gboolean
_gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (path != NULL, FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error); return GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
} }
/** /**
@ -1449,18 +1394,16 @@ _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
char * char *
gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser) gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gchar *result = NULL; gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file =_gtk_file_chooser_get_preview_file (chooser);
path = _gtk_file_chooser_get_preview_path (chooser); if (file)
if (path)
{ {
result = gtk_file_system_path_to_filename (file_system, path); result = g_file_get_path (file);
gtk_file_path_free (path); g_object_unref (file);
} }
return result; return result;
@ -1481,18 +1424,16 @@ gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
char * char *
gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser) gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
{ {
GtkFileSystem *file_system; GFile *file;
GtkFilePath *path;
gchar *result = NULL; gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser); file = _gtk_file_chooser_get_preview_file (chooser);
path = _gtk_file_chooser_get_preview_path (chooser); if (file)
if (path)
{ {
result = gtk_file_system_path_to_uri (file_system, path); result = g_file_get_uri (file);
gtk_file_path_free (path); g_object_unref (file);
} }
return result; return result;
@ -1682,26 +1623,15 @@ gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
const char *folder, const char *folder,
GError **error) GError **error)
{ {
GtkFilePath *path; GFile *file;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (folder != NULL, FALSE); g_return_val_if_fail (folder != NULL, FALSE);
path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder); file = g_file_new_for_path (folder);
if (!path) result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
{ g_object_unref (file);
g_set_error (error,
GTK_FILE_CHOOSER_ERROR,
GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
_("Invalid filename: %s"),
folder);
return FALSE;
}
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
gtk_file_path_free (path);
return result; return result;
} }
@ -1726,26 +1656,15 @@ gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
const char *folder, const char *folder,
GError **error) GError **error)
{ {
GtkFilePath *path; GFile *file;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (folder != NULL, FALSE); g_return_val_if_fail (folder != NULL, FALSE);
path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder); file = g_file_new_for_path (folder);
if (!path) result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
{ g_object_unref (file);
g_set_error (error,
GTK_FILE_CHOOSER_ERROR,
GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
_("Invalid filename: %s"),
folder);
return FALSE;
}
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
gtk_file_path_free (path);
return result; return result;
} }
@ -1773,10 +1692,10 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser)
folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser); folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser), result = files_to_strings (folders, g_file_get_path);
folders, g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
gtk_file_system_path_to_filename); g_slist_free (folders);
gtk_file_paths_free (folders);
return result; return result;
} }
@ -1801,26 +1720,15 @@ gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
const char *uri, const char *uri,
GError **error) GError **error)
{ {
GtkFilePath *path; GFile *file;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (uri != NULL, FALSE);
path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri); file = g_file_new_for_uri (uri);
if (!path) result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
{ g_object_unref (file);
g_set_error (error,
GTK_FILE_CHOOSER_ERROR,
GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
_("Invalid filename: %s"),
uri);
return FALSE;
}
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, path, error);
gtk_file_path_free (path);
return result; return result;
} }
@ -1845,26 +1753,15 @@ gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
const char *uri, const char *uri,
GError **error) GError **error)
{ {
GtkFilePath *path; GFile *file;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE); g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE); g_return_val_if_fail (uri != NULL, FALSE);
path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri); file = g_file_new_for_uri (uri);
if (!path) result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
{ g_object_unref (file);
g_set_error (error,
GTK_FILE_CHOOSER_ERROR,
GTK_FILE_CHOOSER_ERROR_BAD_FILENAME,
_("Invalid filename: %s"),
uri);
return FALSE;
}
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, path, error);
gtk_file_path_free (path);
return result; return result;
} }
@ -1892,10 +1789,10 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser)
folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser); folders = GTK_FILE_CHOOSER_GET_IFACE (chooser)->list_shortcut_folders (chooser);
result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser), result = files_to_strings (folders, g_file_get_uri);
folders, g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
gtk_file_system_path_to_uri); g_slist_free (folders);
gtk_file_paths_free (folders);
return result; return result;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -57,14 +57,14 @@ struct _GtkFileChooserEntry
GtkFileChooserAction action; GtkFileChooserAction action;
GtkFileSystem *file_system; GtkFileSystem *file_system;
GtkFilePath *base_folder; GFile *base_folder;
GFile *current_folder_file;
gchar *file_part; gchar *file_part;
gint file_part_pos; gint file_part_pos;
/* Folder being loaded or already loaded */ /* Folder being loaded or already loaded */
GtkFilePath *current_folder_path; GtkFolder *current_folder;
GtkFileFolder *current_folder; GCancellable *load_folder_cancellable;
GtkFileSystemHandle *load_folder_handle;
LoadCompleteAction load_complete_action; LoadCompleteAction load_complete_action;
@ -84,7 +84,7 @@ struct _GtkFileChooserEntry
enum enum
{ {
DISPLAY_NAME_COLUMN, DISPLAY_NAME_COLUMN,
PATH_COLUMN, FILE_COLUMN,
N_COLUMNS N_COLUMNS
}; };
@ -134,8 +134,8 @@ static gboolean completion_match_func (GtkEntryCompletion *comp,
const char *key, const char *key,
GtkTreeIter *iter, GtkTreeIter *iter,
gpointer data); gpointer data);
static char *maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry, static char *maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
GtkFilePath *path, GFile *file,
gchar *display_name); gchar *display_name);
typedef enum { typedef enum {
@ -145,7 +145,7 @@ typedef enum {
static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry, static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
RefreshMode refresh_mode); RefreshMode refresh_mode);
static void finished_loading_cb (GtkFileFolder *folder, static void finished_loading_cb (GFile *file,
gpointer data); gpointer data);
static void autocomplete (GtkFileChooserEntry *chooser_entry); static void autocomplete (GtkFileChooserEntry *chooser_entry);
static void install_start_autocompletion_idle (GtkFileChooserEntry *chooser_entry); static void install_start_autocompletion_idle (GtkFileChooserEntry *chooser_entry);
@ -230,8 +230,15 @@ gtk_file_chooser_entry_finalize (GObject *object)
{ {
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object); GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (object);
gtk_file_path_free (chooser_entry->base_folder); if (chooser_entry->base_folder)
gtk_file_path_free (chooser_entry->current_folder_path); g_object_unref (chooser_entry->base_folder);
if (chooser_entry->current_folder)
g_object_unref (chooser_entry->current_folder);
if (chooser_entry->current_folder_file)
g_object_unref (chooser_entry->current_folder_file);
g_free (chooser_entry->file_part); g_free (chooser_entry->file_part);
G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->finalize (object); G_OBJECT_CLASS (_gtk_file_chooser_entry_parent_class)->finalize (object);
@ -256,10 +263,10 @@ gtk_file_chooser_entry_dispose (GObject *object)
chooser_entry->completion_store = NULL; chooser_entry->completion_store = NULL;
} }
if (chooser_entry->load_folder_handle) if (chooser_entry->load_folder_cancellable)
{ {
gtk_file_system_cancel_operation (chooser_entry->load_folder_handle); g_cancellable_cancel (chooser_entry->load_folder_cancellable);
chooser_entry->load_folder_handle = NULL; chooser_entry->load_folder_cancellable = NULL;
} }
if (chooser_entry->current_folder) if (chooser_entry->current_folder)
@ -287,23 +294,23 @@ match_selected_callback (GtkEntryCompletion *completion,
GtkFileChooserEntry *chooser_entry) GtkFileChooserEntry *chooser_entry)
{ {
char *display_name; char *display_name;
GtkFilePath *path; GFile *file;
gint pos; gint pos;
gtk_tree_model_get (model, iter, gtk_tree_model_get (model, iter,
DISPLAY_NAME_COLUMN, &display_name, DISPLAY_NAME_COLUMN, &display_name,
PATH_COLUMN, &path, FILE_COLUMN, &file,
-1); -1);
if (!display_name || !path) if (!display_name || !file)
{ {
/* these shouldn't complain if passed NULL */ /* these shouldn't complain if passed NULL */
gtk_file_path_free (path); g_object_unref (file);
g_free (display_name); g_free (display_name);
return FALSE; return FALSE;
} }
display_name = maybe_append_separator_to_path (chooser_entry, path, display_name); display_name = maybe_append_separator_to_file (chooser_entry, file, display_name);
pos = chooser_entry->file_part_pos; pos = chooser_entry->file_part_pos;
@ -316,7 +323,7 @@ match_selected_callback (GtkEntryCompletion *completion,
&pos); &pos);
gtk_editable_set_position (GTK_EDITABLE (chooser_entry), -1); gtk_editable_set_position (GTK_EDITABLE (chooser_entry), -1);
gtk_file_path_free (path); g_object_unref (file);
g_free (display_name); g_free (display_name);
return TRUE; return TRUE;
@ -411,36 +418,35 @@ beep (GtkFileChooserEntry *chooser_entry)
/* This function will append a directory separator to paths to /* This function will append a directory separator to paths to
* display_name iff the path associated with it is a directory. * display_name iff the path associated with it is a directory.
* maybe_append_separator_to_path will g_free the display_name and * maybe_append_separator_to_file will g_free the display_name and
* return a new one if needed. Otherwise, it will return the old one. * return a new one if needed. Otherwise, it will return the old one.
* You should be safe calling * You should be safe calling
* *
* display_name = maybe_append_separator_to_path (entry, path, display_name); * display_name = maybe_append_separator_to_file (entry, file, display_name);
* ... * ...
* g_free (display_name); * g_free (display_name);
*/ */
static char * static char *
maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry, maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
GtkFilePath *path, GFile *file,
gchar *display_name) gchar *display_name)
{ {
if (!g_str_has_suffix (display_name, G_DIR_SEPARATOR_S) && path) if (!g_str_has_suffix (display_name, G_DIR_SEPARATOR_S) && file)
{ {
GtkFileInfo *info; GFileInfo *info;
info = gtk_file_folder_get_info (chooser_entry->current_folder, info = gtk_folder_get_info (chooser_entry->current_folder, file);
path, NULL); /* NULL-GError */
if (info) if (info)
{ {
if (gtk_file_info_get_is_folder (info)) if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY)
{ {
gchar *tmp = display_name; gchar *tmp = display_name;
display_name = g_strconcat (tmp, G_DIR_SEPARATOR_S, NULL); display_name = g_strconcat (tmp, G_DIR_SEPARATOR_S, NULL);
g_free (tmp); g_free (tmp);
} }
gtk_file_info_free (info); g_object_unref (info);
} }
} }
@ -466,7 +472,7 @@ trim_dir_separator_suffix (const char *str)
static gboolean static gboolean
find_common_prefix (GtkFileChooserEntry *chooser_entry, find_common_prefix (GtkFileChooserEntry *chooser_entry,
gchar **common_prefix_ret, gchar **common_prefix_ret,
GtkFilePath **unique_path_ret, GFile **unique_file_ret,
gboolean *is_complete_not_unique_ret, gboolean *is_complete_not_unique_ret,
gboolean *prefix_expands_the_file_part_ret, gboolean *prefix_expands_the_file_part_ret,
GError **error) GError **error)
@ -476,11 +482,11 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
gboolean parsed; gboolean parsed;
gboolean valid; gboolean valid;
char *text_up_to_cursor; char *text_up_to_cursor;
GtkFilePath *parsed_folder_path; GFile *parsed_folder_file;
char *parsed_file_part; char *parsed_file_part;
*common_prefix_ret = NULL; *common_prefix_ret = NULL;
*unique_path_ret = NULL; *unique_file_ret = NULL;
*is_complete_not_unique_ret = FALSE; *is_complete_not_unique_ret = FALSE;
*prefix_expands_the_file_part_ret = FALSE; *prefix_expands_the_file_part_ret = FALSE;
@ -491,7 +497,7 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
parsed = gtk_file_system_parse (chooser_entry->file_system, parsed = gtk_file_system_parse (chooser_entry->file_system,
chooser_entry->base_folder, chooser_entry->base_folder,
text_up_to_cursor, text_up_to_cursor,
&parsed_folder_path, &parsed_folder_file,
&parsed_file_part, &parsed_file_part,
error); error);
@ -500,11 +506,11 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
if (!parsed) if (!parsed)
return FALSE; return FALSE;
g_assert (parsed_folder_path != NULL g_assert (parsed_folder_file != NULL
&& chooser_entry->current_folder_path != NULL && chooser_entry->current_folder != NULL
&& gtk_file_path_compare (parsed_folder_path, chooser_entry->current_folder_path) == 0); && g_file_equal (parsed_folder_file, chooser_entry->current_folder_file));
gtk_file_path_free (parsed_folder_path); g_object_unref (parsed_folder_file);
/* First pass: find the common prefix */ /* First pass: find the common prefix */
@ -513,12 +519,12 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
while (valid) while (valid)
{ {
gchar *display_name; gchar *display_name;
GtkFilePath *path; GFile *file;
gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store), gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
&iter, &iter,
DISPLAY_NAME_COLUMN, &display_name, DISPLAY_NAME_COLUMN, &display_name,
PATH_COLUMN, &path, FILE_COLUMN, &file,
-1); -1);
if (g_str_has_prefix (display_name, parsed_file_part)) if (g_str_has_prefix (display_name, parsed_file_part))
@ -526,7 +532,7 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
if (!*common_prefix_ret) if (!*common_prefix_ret)
{ {
*common_prefix_ret = trim_dir_separator_suffix (display_name); *common_prefix_ret = trim_dir_separator_suffix (display_name);
*unique_path_ret = gtk_file_path_copy (path); *unique_file_ret = g_object_ref (file);
} }
else else
{ {
@ -541,13 +547,16 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
*p = '\0'; *p = '\0';
gtk_file_path_free (*unique_path_ret); if (*unique_file_ret)
*unique_path_ret = NULL; {
g_object_unref (*unique_file_ret);
*unique_file_ret = NULL;
}
} }
} }
g_free (display_name); g_free (display_name);
gtk_file_path_free (path); g_object_unref (file);
valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser_entry->completion_store), &iter); valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (chooser_entry->completion_store), &iter);
} }
@ -629,7 +638,7 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
gboolean show_errors) gboolean show_errors)
{ {
gchar *common_prefix; gchar *common_prefix;
GtkFilePath *unique_path; GFile *unique_file;
gboolean is_complete_not_unique; gboolean is_complete_not_unique;
gboolean prefix_expands_the_file_part; gboolean prefix_expands_the_file_part;
GError *error; GError *error;
@ -642,7 +651,7 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
return NO_MATCH; return NO_MATCH;
error = NULL; error = NULL;
if (!find_common_prefix (chooser_entry, &common_prefix, &unique_path, &is_complete_not_unique, &prefix_expands_the_file_part, &error)) if (!find_common_prefix (chooser_entry, &common_prefix, &unique_file, &is_complete_not_unique, &prefix_expands_the_file_part, &error))
{ {
if (show_errors) if (show_errors)
{ {
@ -657,14 +666,14 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
have_result = FALSE; have_result = FALSE;
if (unique_path) if (unique_file)
{ {
if (!char_after_cursor_is_directory_separator (chooser_entry)) if (!char_after_cursor_is_directory_separator (chooser_entry))
common_prefix = maybe_append_separator_to_path (chooser_entry, common_prefix = maybe_append_separator_to_file (chooser_entry,
unique_path, unique_file,
common_prefix); common_prefix);
gtk_file_path_free (unique_path); g_object_unref (unique_file);
if (common_prefix) if (common_prefix)
{ {
@ -1036,7 +1045,7 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
CommonPrefixResult result; CommonPrefixResult result;
g_assert (chooser_entry->current_folder != NULL); g_assert (chooser_entry->current_folder != NULL);
g_assert (gtk_file_folder_is_finished_loading (chooser_entry->current_folder)); g_assert (gtk_folder_is_finished_loading (chooser_entry->current_folder));
/* FIXME: see what Emacs does in case there is no common prefix, or there is more than one match: /* FIXME: see what Emacs does in case there is no common prefix, or there is more than one match:
* *
@ -1088,7 +1097,7 @@ start_explicit_completion (GtkFileChooserEntry *chooser_entry)
{ {
refresh_current_folder_and_file_part (chooser_entry, REFRESH_UP_TO_CURSOR_POSITION); refresh_current_folder_and_file_part (chooser_entry, REFRESH_UP_TO_CURSOR_POSITION);
if (!chooser_entry->current_folder_path) if (!chooser_entry->current_folder_file)
{ {
/* Here, no folder path means we couldn't parse what the user typed. */ /* Here, no folder path means we couldn't parse what the user typed. */
@ -1100,7 +1109,7 @@ start_explicit_completion (GtkFileChooserEntry *chooser_entry)
} }
if (chooser_entry->current_folder if (chooser_entry->current_folder
&& gtk_file_folder_is_finished_loading (chooser_entry->current_folder)) && gtk_folder_is_finished_loading (chooser_entry->current_folder))
{ {
explicitly_complete (chooser_entry); explicitly_complete (chooser_entry);
} }
@ -1201,47 +1210,46 @@ discard_completion_store (GtkFileChooserEntry *chooser_entry)
static void static void
populate_completion_store (GtkFileChooserEntry *chooser_entry) populate_completion_store (GtkFileChooserEntry *chooser_entry)
{ {
GSList *paths; GSList *files;
GSList *tmp_list; GSList *tmp_list;
discard_completion_store (chooser_entry); discard_completion_store (chooser_entry);
if (!gtk_file_folder_list_children (chooser_entry->current_folder, &paths, NULL)) /* NULL-GError */ files = gtk_folder_list_children (chooser_entry->current_folder);
return;
chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS, chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS,
G_TYPE_STRING, G_TYPE_STRING,
GTK_TYPE_FILE_PATH); G_TYPE_FILE);
for (tmp_list = paths; tmp_list; tmp_list = tmp_list->next) for (tmp_list = files; tmp_list; tmp_list = tmp_list->next)
{ {
GtkFileInfo *info; GFileInfo *info;
GtkFilePath *path; GFile *file;
path = tmp_list->data; file = tmp_list->data;
info = gtk_folder_get_info (chooser_entry->current_folder, file);
info = gtk_file_folder_get_info (chooser_entry->current_folder,
path,
NULL); /* NULL-GError */
if (info) if (info)
{ {
gchar *display_name = g_strdup (gtk_file_info_get_display_name (info)); gchar *display_name = g_strdup (g_file_info_get_display_name (info));
GtkTreeIter iter; GtkTreeIter iter;
display_name = maybe_append_separator_to_path (chooser_entry, path, display_name); display_name = maybe_append_separator_to_file (chooser_entry, file, display_name);
gtk_list_store_append (chooser_entry->completion_store, &iter); gtk_list_store_append (chooser_entry->completion_store, &iter);
gtk_list_store_set (chooser_entry->completion_store, &iter, gtk_list_store_set (chooser_entry->completion_store, &iter,
DISPLAY_NAME_COLUMN, display_name, DISPLAY_NAME_COLUMN, display_name,
PATH_COLUMN, path, FILE_COLUMN, file,
-1); -1);
gtk_file_info_free (info); g_object_unref (info);
g_free (display_name); g_free (display_name);
} }
} }
gtk_file_paths_free (paths); g_slist_foreach (files, (GFunc) g_object_unref, NULL);
g_slist_free (files);
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store), gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (chooser_entry->completion_store),
DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING); DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
@ -1287,8 +1295,8 @@ finish_folder_load (GtkFileChooserEntry *chooser_entry)
/* Callback when the current folder finishes loading */ /* Callback when the current folder finishes loading */
static void static void
finished_loading_cb (GtkFileFolder *folder, finished_loading_cb (GFile *file,
gpointer data) gpointer data)
{ {
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data); GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data);
@ -1297,18 +1305,18 @@ finished_loading_cb (GtkFileFolder *folder,
/* Callback when the current folder's handle gets obtained (not necessarily loaded completely) */ /* Callback when the current folder's handle gets obtained (not necessarily loaded completely) */
static void static void
load_directory_get_folder_callback (GtkFileSystemHandle *handle, load_directory_get_folder_callback (GCancellable *cancellable,
GtkFileFolder *folder, GtkFolder *folder,
const GError *error, const GError *error,
gpointer data) gpointer data)
{ {
gboolean cancelled = handle->cancelled; gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GtkFileChooserEntry *chooser_entry = data; GtkFileChooserEntry *chooser_entry = data;
if (handle != chooser_entry->load_folder_handle) if (cancellable != chooser_entry->load_folder_cancellable)
goto out; goto out;
chooser_entry->load_folder_handle = NULL; chooser_entry->load_folder_cancellable = NULL;
if (error) if (error)
{ {
@ -1326,19 +1334,22 @@ load_directory_get_folder_callback (GtkFileSystemHandle *handle,
pop_up_completion_feedback (chooser_entry, error->message); pop_up_completion_feedback (chooser_entry, error->message);
} }
gtk_file_path_free (chooser_entry->current_folder_path); if (chooser_entry->current_folder)
chooser_entry->current_folder_path = NULL; {
g_object_unref (chooser_entry->current_folder);
chooser_entry->current_folder = NULL;
}
} }
if (cancelled || error) if (cancelled || error)
goto out; goto out;
g_assert (folder != NULL); g_assert (folder != NULL);
chooser_entry->current_folder = folder; chooser_entry->current_folder = g_object_ref (folder);
discard_completion_store (chooser_entry); discard_completion_store (chooser_entry);
if (gtk_file_folder_is_finished_loading (chooser_entry->current_folder)) if (gtk_folder_is_finished_loading (chooser_entry->current_folder))
finish_folder_load (chooser_entry); finish_folder_load (chooser_entry);
else else
g_signal_connect (chooser_entry->current_folder, "finished-loading", g_signal_connect (chooser_entry->current_folder, "finished-loading",
@ -1346,37 +1357,37 @@ load_directory_get_folder_callback (GtkFileSystemHandle *handle,
out: out:
g_object_unref (chooser_entry); g_object_unref (chooser_entry);
g_object_unref (handle); g_object_unref (cancellable);
} }
static void static void
start_loading_current_folder (GtkFileChooserEntry *chooser_entry) start_loading_current_folder (GtkFileChooserEntry *chooser_entry)
{ {
if (chooser_entry->current_folder_path == NULL || if (chooser_entry->current_folder_file == NULL ||
chooser_entry->file_system == NULL) chooser_entry->file_system == NULL)
return; return;
g_assert (chooser_entry->current_folder == NULL); g_assert (chooser_entry->current_folder == NULL);
g_assert (chooser_entry->load_folder_handle == NULL); g_assert (chooser_entry->load_folder_cancellable == NULL);
chooser_entry->load_folder_handle = chooser_entry->load_folder_cancellable =
gtk_file_system_get_folder (chooser_entry->file_system, gtk_file_system_get_folder (chooser_entry->file_system,
chooser_entry->current_folder_path, chooser_entry->current_folder_file,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER, "standard::name,standard::display-name,standard::type",
load_directory_get_folder_callback, load_directory_get_folder_callback,
g_object_ref (chooser_entry)); g_object_ref (chooser_entry));
} }
static void static void
reload_current_folder (GtkFileChooserEntry *chooser_entry, reload_current_folder (GtkFileChooserEntry *chooser_entry,
GtkFilePath *folder_path, GFile *folder_file,
gboolean force_reload) gboolean force_reload)
{ {
gboolean reload = FALSE; gboolean reload = FALSE;
if (chooser_entry->current_folder_path) if (chooser_entry->current_folder_file)
{ {
if ((folder_path && gtk_file_path_compare (folder_path, chooser_entry->current_folder_path) != 0) if ((folder_file && !g_file_equal (folder_file, chooser_entry->current_folder_file))
|| force_reload) || force_reload)
{ {
reload = TRUE; reload = TRUE;
@ -1386,23 +1397,23 @@ reload_current_folder (GtkFileChooserEntry *chooser_entry,
*/ */
if (chooser_entry->current_folder) if (chooser_entry->current_folder)
{ {
if (chooser_entry->load_folder_handle) if (chooser_entry->load_folder_cancellable)
{ {
gtk_file_system_cancel_operation (chooser_entry->load_folder_handle); g_cancellable_cancel (chooser_entry->load_folder_cancellable);
chooser_entry->load_folder_handle = NULL; chooser_entry->load_folder_cancellable = NULL;
} }
g_object_unref (chooser_entry->current_folder); g_object_unref (chooser_entry->current_folder);
chooser_entry->current_folder = NULL; chooser_entry->current_folder = NULL;
} }
gtk_file_path_free (chooser_entry->current_folder_path); g_object_unref (chooser_entry->current_folder_file);
chooser_entry->current_folder_path = gtk_file_path_copy (folder_path); chooser_entry->current_folder_file = g_object_ref (folder_file);
} }
} }
else else
{ {
chooser_entry->current_folder_path = gtk_file_path_copy (folder_path); chooser_entry->current_folder_file = (folder_file) ? g_object_ref (folder_file) : NULL;
reload = TRUE; reload = TRUE;
} }
@ -1417,7 +1428,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
GtkEditable *editable; GtkEditable *editable;
gint end_pos; gint end_pos;
gchar *text; gchar *text;
GtkFilePath *folder_path; GFile *folder_file;
gchar *file_part; gchar *file_part;
gsize total_len, file_part_len; gsize total_len, file_part_len;
gint file_part_pos; gint file_part_pos;
@ -1445,9 +1456,9 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
!chooser_entry->base_folder || !chooser_entry->base_folder ||
!gtk_file_system_parse (chooser_entry->file_system, !gtk_file_system_parse (chooser_entry->file_system,
chooser_entry->base_folder, text, chooser_entry->base_folder, text,
&folder_path, &file_part, NULL)) /* NULL-GError */ &folder_file, &file_part, NULL)) /* NULL-GError */
{ {
folder_path = gtk_file_path_copy (chooser_entry->base_folder); folder_file = (chooser_entry->base_folder) ? g_object_ref (chooser_entry->base_folder) : NULL;
file_part = g_strdup (""); file_part = g_strdup ("");
file_part_pos = -1; file_part_pos = -1;
} }
@ -1468,15 +1479,17 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
chooser_entry->file_part = file_part; chooser_entry->file_part = file_part;
chooser_entry->file_part_pos = file_part_pos; chooser_entry->file_part_pos = file_part_pos;
reload_current_folder (chooser_entry, folder_path, file_part_pos == -1); reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
gtk_file_path_free (folder_path);
if (folder_file)
g_object_unref (folder_file);
} }
static void static void
autocomplete (GtkFileChooserEntry *chooser_entry) autocomplete (GtkFileChooserEntry *chooser_entry)
{ {
g_assert (chooser_entry->current_folder != NULL); g_assert (chooser_entry->current_folder != NULL);
g_assert (gtk_file_folder_is_finished_loading (chooser_entry->current_folder)); g_assert (gtk_folder_is_finished_loading (chooser_entry->current_folder));
g_assert (gtk_editable_get_position (GTK_EDITABLE (chooser_entry)) == GTK_ENTRY (chooser_entry)->text_length); g_assert (gtk_editable_get_position (GTK_EDITABLE (chooser_entry)) == GTK_ENTRY (chooser_entry)->text_length);
append_common_prefix (chooser_entry, TRUE, FALSE); append_common_prefix (chooser_entry, TRUE, FALSE);
@ -1495,7 +1508,7 @@ start_autocompletion (GtkFileChooserEntry *chooser_entry)
return; return;
} }
if (gtk_file_folder_is_finished_loading (chooser_entry->current_folder)) if (gtk_folder_is_finished_loading (chooser_entry->current_folder))
autocomplete (chooser_entry); autocomplete (chooser_entry);
else else
chooser_entry->load_complete_action = LOAD_COMPLETE_AUTOCOMPLETE; chooser_entry->load_complete_action = LOAD_COMPLETE_AUTOCOMPLETE;
@ -1634,18 +1647,21 @@ _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry,
/** /**
* _gtk_file_chooser_entry_set_base_folder: * _gtk_file_chooser_entry_set_base_folder:
* @chooser_entry: a #GtkFileChooserEntry * @chooser_entry: a #GtkFileChooserEntry
* @path: path of a folder in the chooser entries current file system. * @file: file for a folder in the chooser entries current file system.
* *
* Sets the folder with respect to which completions occur. * Sets the folder with respect to which completions occur.
**/ **/
void void
_gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry, _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *path) GFile *file)
{ {
if (chooser_entry->base_folder) if (chooser_entry->base_folder)
gtk_file_path_free (chooser_entry->base_folder); g_object_unref (chooser_entry->base_folder);
chooser_entry->base_folder = gtk_file_path_copy (path); chooser_entry->base_folder = file;
if (chooser_entry->base_folder)
g_object_ref (chooser_entry->base_folder);
clear_completions (chooser_entry); clear_completions (chooser_entry);
_gtk_file_chooser_entry_select_filename (chooser_entry); _gtk_file_chooser_entry_select_filename (chooser_entry);
@ -1663,14 +1679,14 @@ _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
* path that doesn't point to a folder in the file system, it will * path that doesn't point to a folder in the file system, it will
* be %NULL. * be %NULL.
* *
* Return value: the path of current folder - this value is owned by the * Return value: the file for the current folder - this value is owned by the
* chooser entry and must not be modified or freed. * chooser entry and must not be modified or freed.
**/ **/
const GtkFilePath * GFile *
_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry) _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
{ {
commit_completion_and_refresh (chooser_entry); commit_completion_and_refresh (chooser_entry);
return chooser_entry->current_folder_path; return chooser_entry->current_folder_file;
} }
/** /**
@ -1679,7 +1695,7 @@ _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry)
* *
* Gets the non-folder portion of whatever the user has entered * Gets the non-folder portion of whatever the user has entered
* into the file selector. What is returned is a UTF-8 string, * into the file selector. What is returned is a UTF-8 string,
* and if a filename path is needed, gtk_file_system_make_path() * and if a filename path is needed, g_file_get_child_for_display_name()
* must be used * must be used
* *
* Return value: the entered filename - this value is owned by the * Return value: the entered filename - this value is owned by the
@ -1771,20 +1787,20 @@ _gtk_file_chooser_entry_get_action (GtkFileChooserEntry *chooser_entry)
gboolean gboolean
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry, _gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *path) GFile *file)
{ {
gboolean retval = FALSE; gboolean retval = FALSE;
if (chooser_entry->current_folder) if (chooser_entry->current_folder)
{ {
GtkFileInfo *file_info; GFileInfo *file_info;
file_info = gtk_folder_get_info (chooser_entry->current_folder, file);
file_info = gtk_file_folder_get_info (chooser_entry->current_folder,
path, NULL);
if (file_info) if (file_info)
{ {
retval = gtk_file_info_get_is_folder (file_info); retval = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY);
gtk_file_info_free (file_info); g_object_unref (file_info);
} }
} }

View File

@ -41,13 +41,13 @@ GtkFileChooserAction _gtk_file_chooser_entry_get_action (GtkFileChooserEnt
void _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry, void _gtk_file_chooser_entry_set_file_system (GtkFileChooserEntry *chooser_entry,
GtkFileSystem *file_system); GtkFileSystem *file_system);
void _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry, void _gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *path); GFile *folder);
void _gtk_file_chooser_entry_set_file_part (GtkFileChooserEntry *chooser_entry, void _gtk_file_chooser_entry_set_file_part (GtkFileChooserEntry *chooser_entry,
const gchar *file_part); const gchar *file_part);
const GtkFilePath *_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry); GFile * _gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *chooser_entry);
const gchar * _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry); const gchar * _gtk_file_chooser_entry_get_file_part (GtkFileChooserEntry *chooser_entry);
gboolean _gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry, gboolean _gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *path); GFile *file);
void _gtk_file_chooser_entry_select_filename (GtkFileChooserEntry *chooser_entry); void _gtk_file_chooser_entry_select_filename (GtkFileChooserEntry *chooser_entry);
G_END_DECLS G_END_DECLS

View File

@ -47,20 +47,20 @@ struct _GtkFileChooserIface
/* Methods /* Methods
*/ */
gboolean (*set_current_folder) (GtkFileChooser *chooser, gboolean (*set_current_folder) (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
GtkFilePath * (*get_current_folder) (GtkFileChooser *chooser); GFile * (*get_current_folder) (GtkFileChooser *chooser);
void (*set_current_name) (GtkFileChooser *chooser, void (*set_current_name) (GtkFileChooser *chooser,
const gchar *name); const gchar *name);
gboolean (*select_path) (GtkFileChooser *chooser, gboolean (*select_file) (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
void (*unselect_path) (GtkFileChooser *chooser, void (*unselect_file) (GtkFileChooser *chooser,
const GtkFilePath *path); GFile *file);
void (*select_all) (GtkFileChooser *chooser); void (*select_all) (GtkFileChooser *chooser);
void (*unselect_all) (GtkFileChooser *chooser); void (*unselect_all) (GtkFileChooser *chooser);
GSList * (*get_paths) (GtkFileChooser *chooser); GSList * (*get_files) (GtkFileChooser *chooser);
GtkFilePath * (*get_preview_path) (GtkFileChooser *chooser); GFile * (*get_preview_file) (GtkFileChooser *chooser);
GtkFileSystem *(*get_file_system) (GtkFileChooser *chooser); GtkFileSystem *(*get_file_system) (GtkFileChooser *chooser);
void (*add_filter) (GtkFileChooser *chooser, void (*add_filter) (GtkFileChooser *chooser,
GtkFileFilter *filter); GtkFileFilter *filter);
@ -68,10 +68,10 @@ struct _GtkFileChooserIface
GtkFileFilter *filter); GtkFileFilter *filter);
GSList * (*list_filters) (GtkFileChooser *chooser); GSList * (*list_filters) (GtkFileChooser *chooser);
gboolean (*add_shortcut_folder) (GtkFileChooser *chooser, gboolean (*add_shortcut_folder) (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
gboolean (*remove_shortcut_folder) (GtkFileChooser *chooser, gboolean (*remove_shortcut_folder) (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
GSList * (*list_shortcut_folders) (GtkFileChooser *chooser); GSList * (*list_shortcut_folders) (GtkFileChooser *chooser);
@ -85,22 +85,22 @@ struct _GtkFileChooserIface
}; };
GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser); GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser);
gboolean _gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser, gboolean _gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
GtkFilePath * _gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser); GFile * _gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser);
gboolean _gtk_file_chooser_select_path (GtkFileChooser *chooser, gboolean _gtk_file_chooser_select_file (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
void _gtk_file_chooser_unselect_path (GtkFileChooser *chooser, void _gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
const GtkFilePath *path); GFile *file);
GSList * _gtk_file_chooser_get_paths (GtkFileChooser *chooser); GSList * _gtk_file_chooser_get_files (GtkFileChooser *chooser);
GtkFilePath * _gtk_file_chooser_get_preview_path (GtkFileChooser *chooser); GFile * _gtk_file_chooser_get_preview_file (GtkFileChooser *chooser);
gboolean _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser, gboolean _gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *folder,
GError **error); GError **error);
gboolean _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser, gboolean _gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *folder,
GError **error); GError **error);
/* GtkFileChooserDialog private */ /* GtkFileChooserDialog private */
@ -232,15 +232,15 @@ struct _GtkFileChooserDefault
/* Handles */ /* Handles */
GSList *loading_shortcuts; GSList *loading_shortcuts;
GSList *reload_icon_handles; GSList *reload_icon_cancellables;
GtkFileSystemHandle *file_list_drag_data_received_handle; GCancellable *file_list_drag_data_received_cancellable;
GtkFileSystemHandle *update_current_folder_handle; GCancellable *update_current_folder_cancellable;
GtkFileSystemHandle *show_and_select_paths_handle; GCancellable *show_and_select_files_cancellable;
GtkFileSystemHandle *should_respond_get_info_handle; GCancellable *should_respond_get_info_cancellable;
GtkFileSystemHandle *file_exists_get_info_handle; GCancellable *file_exists_get_info_cancellable;
GtkFileSystemHandle *update_from_entry_handle; GCancellable *update_from_entry_cancellable;
GtkFileSystemHandle *shortcuts_activate_iter_handle; GCancellable *shortcuts_activate_iter_cancellable;
GSList *pending_handles; GSList *pending_cancellables;
LoadState load_state; LoadState load_state;
ReloadState reload_state; ReloadState reload_state;
@ -248,7 +248,7 @@ struct _GtkFileChooserDefault
OperationMode operation_mode; OperationMode operation_mode;
GSList *pending_select_paths; GSList *pending_select_files;
GtkFileFilter *current_filter; GtkFileFilter *current_filter;
GSList *filters; GSList *filters;
@ -262,9 +262,9 @@ struct _GtkFileChooserDefault
gulong volumes_changed_id; gulong volumes_changed_id;
gulong bookmarks_changed_id; gulong bookmarks_changed_id;
GtkFilePath *current_volume_path; GFile *current_volume_file;
GtkFilePath *current_folder; GFile *current_folder;
GtkFilePath *preview_path; GFile *preview_file;
char *preview_display_name; char *preview_display_name;
GtkTreeViewColumn *list_name_column; GtkTreeViewColumn *list_name_column;
@ -320,10 +320,10 @@ struct _GtkFileSystemModel
GObject parent_instance; GObject parent_instance;
GtkFileSystem *file_system; GtkFileSystem *file_system;
GtkFileInfoType types; gchar *attributes;
FileModelNode *roots; FileModelNode *roots;
GtkFileFolder *root_folder; GtkFolder *root_folder;
GtkFilePath *root_path; GFile *root_file;
GtkFileSystemModelFilter filter_func; GtkFileSystemModelFilter filter_func;
gpointer filter_data; gpointer filter_data;
@ -333,8 +333,8 @@ struct _GtkFileSystemModel
gushort max_depth; gushort max_depth;
GSList *pending_handles; GSList *pending_cancellables;
guint show_hidden : 1; guint show_hidden : 1;
guint show_folders : 1; guint show_folders : 1;
guint show_files : 1; guint show_files : 1;
@ -344,12 +344,12 @@ struct _GtkFileSystemModel
struct _FileModelNode struct _FileModelNode
{ {
GtkFilePath *path; GFile *file;
FileModelNode *next; FileModelNode *next;
GtkFileInfo *info; GFileInfo *info;
GtkFileFolder *folder; GtkFolder *folder;
FileModelNode *children; FileModelNode *children;
FileModelNode *parent; FileModelNode *parent;
GtkFileSystemModel *model; GtkFileSystemModel *model;

View File

@ -28,20 +28,20 @@
#include "gtkalias.h" #include "gtkalias.h"
static gboolean delegate_set_current_folder (GtkFileChooser *chooser, static gboolean delegate_set_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
static GtkFilePath * delegate_get_current_folder (GtkFileChooser *chooser); static GFile * delegate_get_current_folder (GtkFileChooser *chooser);
static void delegate_set_current_name (GtkFileChooser *chooser, static void delegate_set_current_name (GtkFileChooser *chooser,
const gchar *name); const gchar *name);
static gboolean delegate_select_path (GtkFileChooser *chooser, static gboolean delegate_select_file (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
static void delegate_unselect_path (GtkFileChooser *chooser, static void delegate_unselect_file (GtkFileChooser *chooser,
const GtkFilePath *path); GFile *file);
static void delegate_select_all (GtkFileChooser *chooser); static void delegate_select_all (GtkFileChooser *chooser);
static void delegate_unselect_all (GtkFileChooser *chooser); static void delegate_unselect_all (GtkFileChooser *chooser);
static GSList * delegate_get_paths (GtkFileChooser *chooser); static GSList * delegate_get_files (GtkFileChooser *chooser);
static GtkFilePath * delegate_get_preview_path (GtkFileChooser *chooser); static GFile * delegate_get_preview_file (GtkFileChooser *chooser);
static GtkFileSystem *delegate_get_file_system (GtkFileChooser *chooser); static GtkFileSystem *delegate_get_file_system (GtkFileChooser *chooser);
static void delegate_add_filter (GtkFileChooser *chooser, static void delegate_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter); GtkFileFilter *filter);
@ -49,10 +49,10 @@ static void delegate_remove_filter (GtkFileChooser *choose
GtkFileFilter *filter); GtkFileFilter *filter);
static GSList * delegate_list_filters (GtkFileChooser *chooser); static GSList * delegate_list_filters (GtkFileChooser *chooser);
static gboolean delegate_add_shortcut_folder (GtkFileChooser *chooser, static gboolean delegate_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
static gboolean delegate_remove_shortcut_folder (GtkFileChooser *chooser, static gboolean delegate_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error); GError **error);
static GSList * delegate_list_shortcut_folders (GtkFileChooser *chooser); static GSList * delegate_list_shortcut_folders (GtkFileChooser *chooser);
static void delegate_notify (GObject *object, static void delegate_notify (GObject *object,
@ -136,12 +136,12 @@ _gtk_file_chooser_delegate_iface_init (GtkFileChooserIface *iface)
iface->set_current_folder = delegate_set_current_folder; iface->set_current_folder = delegate_set_current_folder;
iface->get_current_folder = delegate_get_current_folder; iface->get_current_folder = delegate_get_current_folder;
iface->set_current_name = delegate_set_current_name; iface->set_current_name = delegate_set_current_name;
iface->select_path = delegate_select_path; iface->select_file = delegate_select_file;
iface->unselect_path = delegate_unselect_path; iface->unselect_file = delegate_unselect_file;
iface->select_all = delegate_select_all; iface->select_all = delegate_select_all;
iface->unselect_all = delegate_unselect_all; iface->unselect_all = delegate_unselect_all;
iface->get_paths = delegate_get_paths; iface->get_files = delegate_get_files;
iface->get_preview_path = delegate_get_preview_path; iface->get_preview_file = delegate_get_preview_file;
iface->get_file_system = delegate_get_file_system; iface->get_file_system = delegate_get_file_system;
iface->add_filter = delegate_add_filter; iface->add_filter = delegate_add_filter;
iface->remove_filter = delegate_remove_filter; iface->remove_filter = delegate_remove_filter;
@ -203,18 +203,18 @@ get_delegate (GtkFileChooser *receiver)
} }
static gboolean static gboolean
delegate_select_path (GtkFileChooser *chooser, delegate_select_file (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
return _gtk_file_chooser_select_path (get_delegate (chooser), path, error); return _gtk_file_chooser_select_file (get_delegate (chooser), file, error);
} }
static void static void
delegate_unselect_path (GtkFileChooser *chooser, delegate_unselect_file (GtkFileChooser *chooser,
const GtkFilePath *path) GFile *file)
{ {
_gtk_file_chooser_unselect_path (get_delegate (chooser), path); _gtk_file_chooser_unselect_file (get_delegate (chooser), file);
} }
static void static void
@ -230,15 +230,15 @@ delegate_unselect_all (GtkFileChooser *chooser)
} }
static GSList * static GSList *
delegate_get_paths (GtkFileChooser *chooser) delegate_get_files (GtkFileChooser *chooser)
{ {
return _gtk_file_chooser_get_paths (get_delegate (chooser)); return _gtk_file_chooser_get_files (get_delegate (chooser));
} }
static GtkFilePath * static GFile *
delegate_get_preview_path (GtkFileChooser *chooser) delegate_get_preview_file (GtkFileChooser *chooser)
{ {
return _gtk_file_chooser_get_preview_path (get_delegate (chooser)); return _gtk_file_chooser_get_preview_file (get_delegate (chooser));
} }
static GtkFileSystem * static GtkFileSystem *
@ -268,19 +268,19 @@ delegate_list_filters (GtkFileChooser *chooser)
} }
static gboolean static gboolean
delegate_add_shortcut_folder (GtkFileChooser *chooser, delegate_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
return _gtk_file_chooser_add_shortcut_folder (get_delegate (chooser), path, error); return _gtk_file_chooser_add_shortcut_folder (get_delegate (chooser), file, error);
} }
static gboolean static gboolean
delegate_remove_shortcut_folder (GtkFileChooser *chooser, delegate_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
return _gtk_file_chooser_remove_shortcut_folder (get_delegate (chooser), path, error); return _gtk_file_chooser_remove_shortcut_folder (get_delegate (chooser), file, error);
} }
static GSList * static GSList *
@ -290,17 +290,17 @@ delegate_list_shortcut_folders (GtkFileChooser *chooser)
} }
static gboolean static gboolean
delegate_set_current_folder (GtkFileChooser *chooser, delegate_set_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path, GFile *file,
GError **error) GError **error)
{ {
return _gtk_file_chooser_set_current_folder_path (get_delegate (chooser), path, error); return _gtk_file_chooser_set_current_folder_file (get_delegate (chooser), file, error);
} }
static GtkFilePath * static GFile *
delegate_get_current_folder (GtkFileChooser *chooser) delegate_get_current_folder (GtkFileChooser *chooser)
{ {
return _gtk_file_chooser_get_current_folder_path (get_delegate (chooser)); return _gtk_file_chooser_get_current_folder_file (get_delegate (chooser));
} }
static void static void

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* GTK - The GIMP Toolkit /* GTK - The GIMP Toolkit
* gtkfilesystem.h: Abstract file system interfaces * gtkfilesystem.h: Filesystem abstraction functions.
* Copyright (C) 2003, Red Hat, Inc. * Copyright (C) 2003, Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -21,43 +21,25 @@
#ifndef __GTK_FILE_SYSTEM_H__ #ifndef __GTK_FILE_SYSTEM_H__
#define __GTK_FILE_SYSTEM_H__ #define __GTK_FILE_SYSTEM_H__
/* This is a "semi-private" header; it is meant only for #include <gio/gio.h>
* alternate GtkFileChooser backend modules; no stability guarantees
* are made at this point
*/
#ifndef GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
#error "GtkFileSystem is not supported API for general use"
#endif
#include <glib-object.h> #include <glib-object.h>
#include <gtk/gtkwidget.h> /* For icon handling */ #include <gtk/gtkwidget.h> /* For icon handling */
G_BEGIN_DECLS G_BEGIN_DECLS
typedef gint64 GtkFileTime; #define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
#define GTK_FILE_SYSTEM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
#define GTK_FILE_SYSTEM_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass))
#define GTK_IS_FILE_SYSTEM(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FILE_SYSTEM))
#define GTK_IS_FILE_SYSTEM_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_FILE_SYSTEM))
#define GTK_FILE_SYSTEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FILE_SYSTEM, GtkFileSystemClass))
typedef struct _GtkFileFolder GtkFileFolder; #define GTK_TYPE_FOLDER (gtk_folder_get_type ())
typedef struct _GtkFileFolderIface GtkFileFolderIface; #define GTK_FOLDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FOLDER, GtkFolder))
typedef struct _GtkFileInfo GtkFileInfo; #define GTK_FOLDER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_FOLDER, GtkFolderClass))
typedef struct _GtkFileSystem GtkFileSystem; #define GTK_IS_FOLDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FOLDER))
typedef struct _GtkFileSystemIface GtkFileSystemIface; #define GTK_IS_FOLDER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_FOLDER))
typedef struct _GtkFileSystemVolume GtkFileSystemVolume; #define GTK_FOLDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FOLDER, GtkFolderClass))
typedef struct _GtkFilePath GtkFilePath;
/* Mask of information about a file, for monitoring and
* gtk_file_system_get_info()
*/
typedef enum {
GTK_FILE_INFO_DISPLAY_NAME = 1 << 0,
GTK_FILE_INFO_IS_FOLDER = 1 << 1,
GTK_FILE_INFO_IS_HIDDEN = 1 << 2,
GTK_FILE_INFO_MIME_TYPE = 1 << 3,
GTK_FILE_INFO_MODIFICATION_TIME = 1 << 4,
GTK_FILE_INFO_SIZE = 1 << 5,
GTK_FILE_INFO_ICON = 1 << 6,
GTK_FILE_INFO_ALL = (1 << 7) - 1
} GtkFileInfoType;
/* GError enumeration for GtkFileSystem /* GError enumeration for GtkFileSystem
*/ */
@ -76,372 +58,137 @@ typedef enum
GQuark gtk_file_system_error_quark (void); GQuark gtk_file_system_error_quark (void);
/* Boxed-type for gtk_file_folder_get_info() results typedef struct GtkFileSystemClass GtkFileSystemClass;
*/ typedef struct GtkFileSystem GtkFileSystem;
#define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ()) typedef struct GtkFolderClass GtkFolderClass;
typedef struct GtkFolder GtkFolder;
typedef struct GtkFileSystemVolume GtkFileSystemVolume; /* opaque struct */
typedef struct GtkFileSystemBookmark GtkFileSystemBookmark; /* opaque struct */
GType gtk_file_info_get_type (void) G_GNUC_CONST; struct GtkFileSystemClass
GtkFileInfo *gtk_file_info_new (void);
GtkFileInfo *gtk_file_info_copy (GtkFileInfo *info);
void gtk_file_info_free (GtkFileInfo *info);
G_CONST_RETURN gchar *gtk_file_info_get_display_name (const GtkFileInfo *info);
G_CONST_RETURN gchar *gtk_file_info_get_display_key (const GtkFileInfo *info);
void gtk_file_info_set_display_name (GtkFileInfo *info,
const gchar *display_name);
gboolean gtk_file_info_get_is_folder (const GtkFileInfo *info);
void gtk_file_info_set_is_folder (GtkFileInfo *info,
gboolean is_folder);
gboolean gtk_file_info_get_is_hidden (const GtkFileInfo *info);
void gtk_file_info_set_is_hidden (GtkFileInfo *info,
gboolean is_hidden);
G_CONST_RETURN gchar *gtk_file_info_get_mime_type (const GtkFileInfo *info);
void gtk_file_info_set_mime_type (GtkFileInfo *info,
const gchar *mime_type);
GtkFileTime gtk_file_info_get_modification_time (const GtkFileInfo *info);
void gtk_file_info_set_modification_time (GtkFileInfo *info,
GtkFileTime modification_time);
gint64 gtk_file_info_get_size (const GtkFileInfo *info);
void gtk_file_info_set_size (GtkFileInfo *info,
gint64 size);
void gtk_file_info_set_icon_name (GtkFileInfo *info,
const gchar *con_name);
G_CONST_RETURN gchar *gtk_file_info_get_icon_name (const GtkFileInfo *info);
GdkPixbuf *gtk_file_info_render_icon (const GtkFileInfo *info,
GtkWidget *widget,
gint pixel_size,
GError **error);
/* GtkFileSystemHandle
*/
#define GTK_TYPE_FILE_SYSTEM_HANDLE (gtk_file_system_handle_get_type ())
#define GTK_FILE_SYSTEM_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandle))
#define GTK_IS_FILE_SYSTEM_HANDLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE))
#define GTK_FILE_SYSTEM_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandleUnixClass))
#define GTK_IS_FILE_SYSTEM_HANDLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_HANDLE))
#define GTK_FILE_SYSTEM_HANDLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_HANDLE, GtkFileSystemHandleClass))
typedef struct _GtkFileSystemHandle GtkFileSystemHandle;
typedef struct _GtkFileSystemHandleClass GtkFileSystemHandleClass;
struct _GtkFileSystemHandle
{
GObject parent_instance;
GtkFileSystem *file_system;
guint cancelled : 1;
};
struct _GtkFileSystemHandleClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
void (*bookmarks_changed) (GtkFileSystem *file_system);
void (*volumes_changed) (GtkFileSystem *file_system);
}; };
GType gtk_file_system_handle_get_type (void); struct GtkFileSystem
{
GObject parent_object;
};
/* The base GtkFileSystem interface struct GtkFolderClass
*/ {
#define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ()) GObjectClass parent_class;
#define GTK_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM, GtkFileSystem))
#define GTK_IS_FILE_SYSTEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM))
#define GTK_FILE_SYSTEM_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_SYSTEM, GtkFileSystemIface))
/* Callbacks for the asynchronous GtkFileSystem operations void (*files_added) (GtkFolder *folder,
*/ GList *paths);
void (*files_removed) (GtkFolder *folder,
GList *paths);
void (*files_changed) (GtkFolder *folder,
GList *paths);
void (*finished_loading) (GtkFolder *folder);
void (*deleted) (GtkFolder *folder);
};
typedef void (* GtkFileSystemGetInfoCallback) (GtkFileSystemHandle *handle, struct GtkFolder
const GtkFileInfo *file_info, {
const GError *error, GObject parent_object;
gpointer data); };
typedef void (* GtkFileSystemGetFolderCallback) (GtkFileSystemHandle *handle,
GtkFileFolder *folder, typedef void (* GtkFileSystemGetFolderCallback) (GCancellable *cancellable,
const GError *error, GtkFolder *folder,
gpointer data); const GError *error,
typedef void (* GtkFileSystemCreateFolderCallback) (GtkFileSystemHandle *handle, gpointer data);
const GtkFilePath *path, typedef void (* GtkFileSystemGetInfoCallback) (GCancellable *cancellable,
GFileInfo *file_info,
const GError *error,
gpointer data);
typedef void (* GtkFileSystemVolumeMountCallback) (GCancellable *cancellable,
GtkFileSystemVolume *volume,
const GError *error, const GError *error,
gpointer data); gpointer data);
typedef void (* GtkFileSystemVolumeMountCallback) (GtkFileSystemHandle *handle,
GtkFileSystemVolume *volume,
const GError *error,
gpointer data);
/* /* GtkFileSystem methods */
*/ GType gtk_file_system_get_type (void) G_GNUC_CONST;
struct _GtkFileSystemIface GtkFileSystem * gtk_file_system_new (void);
{
GTypeInterface base_iface;
/* Methods GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
*/ GSList * gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
GSList * (*list_volumes) (GtkFileSystem *file_system);
GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem *file_system,
const GtkFilePath *path);
GtkFileSystemHandle * (*get_folder) (GtkFileSystem *file_system, gboolean gtk_file_system_parse (GtkFileSystem *file_system,
const GtkFilePath *path, GFile *base_file,
GtkFileInfoType types, const gchar *str,
GtkFileSystemGetFolderCallback callback, GFile **folder,
gpointer data); gchar **file_part,
GtkFileSystemHandle * (*get_info) (GtkFileSystem *file_system, GError **error);
const GtkFilePath *path,
GtkFileInfoType types,
GtkFileSystemGetInfoCallback callback,
gpointer data);
GtkFileSystemHandle * (*create_folder) (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileSystemCreateFolderCallback callback,
gpointer data);
void (*cancel_operation) (GtkFileSystemHandle *handle); GCancellable * gtk_file_system_get_folder (GtkFileSystem *file_system,
GFile *file,
const gchar *attributes,
GtkFileSystemGetFolderCallback callback,
gpointer data);
GCancellable * gtk_file_system_get_info (GtkFileSystem *file_system,
GFile *file,
const gchar *attributes,
GtkFileSystemGetInfoCallback callback,
gpointer data);
GCancellable * gtk_file_system_mount_volume (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GMountOperation *mount_operation,
GtkFileSystemVolumeMountCallback callback,
gpointer data);
GCancellable * gtk_file_system_mount_enclosing_volume (GtkFileSystem *file_system,
GFile *file,
GMountOperation *mount_operation,
GtkFileSystemVolumeMountCallback callback,
gpointer data);
/* Volumes gboolean gtk_file_system_insert_bookmark (GtkFileSystem *file_system,
*/ GFile *file,
void (*volume_free) (GtkFileSystem *file_system, gint position,
GtkFileSystemVolume *volume); GError **error);
GtkFilePath * (*volume_get_base_path) (GtkFileSystem *file_system, gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
GtkFileSystemVolume *volume); GFile *file,
gboolean (*volume_get_is_mounted) (GtkFileSystem *file_system, GError **error);
GtkFileSystemVolume *volume);
GtkFileSystemHandle * (*volume_mount) (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GtkFileSystemVolumeMountCallback callback,
gpointer data);
char * (*volume_get_display_name) (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
gchar * (*volume_get_icon_name) (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GError **error);
/* Path Manipulation gchar * gtk_file_system_get_bookmark_label (GtkFileSystem *file_system,
*/ GFile *file);
gboolean (*get_parent) (GtkFileSystem *file_system, void gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
const GtkFilePath *path, GFile *file,
GtkFilePath **parent, const gchar *label);
GError **error);
GtkFilePath * (*make_path) (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *display_name,
GError **error);
gboolean (*parse) (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *str,
GtkFilePath **folder,
gchar **file_part,
GError **error);
gchar * (*path_to_uri) (GtkFileSystem *file_system,
const GtkFilePath *path);
gchar * (*path_to_filename) (GtkFileSystem *file_system,
const GtkFilePath *path);
GtkFilePath *(*uri_to_path) (GtkFileSystem *file_system,
const gchar *uri);
GtkFilePath *(*filename_to_path) (GtkFileSystem *file_system,
const gchar *path);
/* Bookmarks GtkFileSystemVolume * gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
*/ GFile *file);
gboolean (*insert_bookmark) (GtkFileSystem *file_system,
const GtkFilePath *path,
gint position,
GError **error);
gboolean (*remove_bookmark) (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
GSList * (*list_bookmarks) (GtkFileSystem *file_system);
/* Signals /* GtkFolder functions */
*/ GSList * gtk_folder_list_children (GtkFolder *folder);
void (*volumes_changed) (GtkFileSystem *file_system); GFileInfo * gtk_folder_get_info (GtkFolder *folder,
void (*bookmarks_changed) (GtkFileSystem *file_system); GFile *file);
/* Bookmark labels gboolean gtk_folder_is_finished_loading (GtkFolder *folder);
*/
gchar * (*get_bookmark_label) (GtkFileSystem *file_system,
const GtkFilePath *path);
void (*set_bookmark_label) (GtkFileSystem *file_system,
const GtkFilePath *path,
const gchar *label);
};
GType gtk_file_system_get_type (void) G_GNUC_CONST;
GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
GtkFileSystemVolume *gtk_file_system_get_volume_for_path (GtkFileSystem *file_system,
const GtkFilePath *path);
void gtk_file_system_volume_free (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
GtkFilePath * gtk_file_system_volume_get_base_path (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
gboolean gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
GtkFileSystemHandle *gtk_file_system_volume_mount (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GtkFileSystemVolumeMountCallback callback,
gpointer data);
char * gtk_file_system_volume_get_display_name (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GtkWidget *widget,
gint pixel_size,
GError **error);
gchar * gtk_file_system_volume_get_icon_name (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GError **error);
gboolean gtk_file_system_get_parent (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFilePath **parent,
GError **error);
GtkFileSystemHandle *gtk_file_system_get_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
GtkFileSystemGetFolderCallback callback,
gpointer data);
GtkFileSystemHandle *gtk_file_system_get_info (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
GtkFileSystemGetInfoCallback callback,
gpointer data);
GtkFileSystemHandle *gtk_file_system_create_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileSystemCreateFolderCallback callback,
gpointer data);
void gtk_file_system_cancel_operation (GtkFileSystemHandle *handle);
GtkFilePath * gtk_file_system_make_path (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *display_name,
GError **error);
gboolean gtk_file_system_parse (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *str,
GtkFilePath **folder,
gchar **file_part,
GError **error);
gchar * gtk_file_system_path_to_uri (GtkFileSystem *file_system,
const GtkFilePath *path);
gchar * gtk_file_system_path_to_filename (GtkFileSystem *file_system,
const GtkFilePath *path);
GtkFilePath *gtk_file_system_uri_to_path (GtkFileSystem *file_system,
const gchar *uri);
GtkFilePath *gtk_file_system_filename_to_path (GtkFileSystem *file_system,
const gchar *filename);
gboolean gtk_file_system_path_is_local (GtkFileSystem *filesystem,
const GtkFilePath *path);
gboolean gtk_file_system_insert_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
gint position,
GError **error);
gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
GSList *gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
gchar *gtk_file_system_get_bookmark_label (GtkFileSystem *file_system,
const GtkFilePath *path);
void gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
const GtkFilePath *path,
const gchar *label);
/*
* Detailed information about a particular folder
*/
#define GTK_TYPE_FILE_FOLDER (gtk_file_folder_get_type ())
#define GTK_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER, GtkFileFolder))
#define GTK_IS_FILE_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER))
#define GTK_FILE_FOLDER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_FOLDER, GtkFileFolderIface))
struct _GtkFileFolderIface
{
GTypeInterface base_iface;
/* Methods
*/
GtkFileInfo * (*get_info) (GtkFileFolder *folder,
const GtkFilePath *path,
GError **error);
gboolean (*list_children) (GtkFileFolder *folder,
GSList **children,
GError **error);
/* ??? refresh() ??? */
/* Signals
*/
void (*deleted) (GtkFileFolder *monitor);
void (*files_added) (GtkFileFolder *monitor,
GSList *paths);
void (*files_changed) (GtkFileFolder *monitor,
GSList *paths);
void (*files_removed) (GtkFileFolder *monitor,
GSList *paths);
/* Method / signal */
gboolean (*is_finished_loading) (GtkFileFolder *folder);
void (*finished_loading) (GtkFileFolder *folder);
};
GType gtk_file_folder_get_type (void) G_GNUC_CONST;
gboolean gtk_file_folder_list_children (GtkFileFolder *folder,
GSList **children,
GError **error);
GtkFileInfo *gtk_file_folder_get_info (GtkFileFolder *folder,
const GtkFilePath *path,
GError **error);
gboolean gtk_file_folder_is_finished_loading (GtkFileFolder *folder);
/* GtkFilePath */ /* GtkFileSystemVolume methods */
#define GTK_TYPE_FILE_PATH (gtk_file_path_get_type ()) gchar * gtk_file_system_volume_get_display_name (GtkFileSystemVolume *volume);
gboolean gtk_file_system_volume_is_mounted (GtkFileSystemVolume *volume);
GFile * gtk_file_system_volume_get_root (GtkFileSystemVolume *volume);
GdkPixbuf * gtk_file_system_volume_render_icon (GtkFileSystemVolume *volume,
GtkWidget *widget,
gint icon_size,
GError **error);
GType gtk_file_path_get_type (void) G_GNUC_CONST; void gtk_file_system_volume_free (GtkFileSystemVolume *volume);
#ifdef __GNUC__
#define gtk_file_path_new_dup(str) \
({ const gchar *__s = (str); (GtkFilePath *)g_strdup(__s); })
#define gtk_file_path_new_steal(str) \
({ gchar *__s = (str); (GtkFilePath *)__s; })
#define gtk_file_path_get_string(path) \
({ const GtkFilePath *__p = (path); (const gchar *)__p; })
#define gtk_file_path_free(path) \
({ GtkFilePath *__p = (path); g_free (__p); })
#else /* __GNUC__ */
#define gtk_file_path_new_dup(str) ((GtkFilePath *)g_strdup(str))
#define gtk_file_path_new_steal(str) ((GtkFilePath *)(str))
#define gtk_file_path_get_string(str) ((const gchar *)(str))
#define gtk_file_path_free(path) g_free (path)
#endif/* __GNUC__ */
#define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path)) /* GtkFileSystemBookmark methods */
#ifdef G_OS_WIN32 void gtk_file_system_bookmark_free (GtkFileSystemBookmark *bookmark);
int _gtk_file_system_win32_path_compare (const gchar *path1,
const gchar *path2);
#define gtk_file_path_compare(path1,path2) \
_gtk_file_system_win32_path_compare (gtk_file_path_get_string (path1), \
gtk_file_path_get_string (path2))
#else
#define gtk_file_path_compare(path1,path2) strcmp (gtk_file_path_get_string (path1), \
gtk_file_path_get_string (path2))
#endif
GSList *gtk_file_paths_sort (GSList *paths); /* GFileInfo helper functions */
GSList *gtk_file_paths_copy (GSList *paths); GdkPixbuf * gtk_file_info_render_icon (GFileInfo *info,
void gtk_file_paths_free (GSList *paths); GtkWidget *widget,
gint icon_size);
/* GtkFileSystem modules support */
GtkFileSystem *gtk_file_system_create (const char *file_system_name);
G_END_DECLS G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@ -42,13 +42,13 @@ typedef enum {
} GtkFileSystemModelColumns; } GtkFileSystemModelColumns;
GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystem *file_system, GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystem *file_system,
const GtkFilePath *root_path, GFile *root_file,
gint max_depth, gint max_depth,
GtkFileInfoType types, const gchar *attributes,
GError **error); GError **error);
const GtkFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model, GFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
GtkTreeIter *iter); GtkTreeIter *iter);
const GtkFilePath * _gtk_file_system_model_get_path (GtkFileSystemModel *model, GFile * _gtk_file_system_model_get_file (GtkFileSystemModel *model,
GtkTreeIter *iter); GtkTreeIter *iter);
void _gtk_file_system_model_set_show_hidden (GtkFileSystemModel *model, void _gtk_file_system_model_set_show_hidden (GtkFileSystemModel *model,
gboolean show_hidden); gboolean show_hidden);
@ -58,8 +58,8 @@ void _gtk_file_system_model_set_show_files (GtkFileSystemModel
gboolean show_files); gboolean show_files);
typedef gboolean (*GtkFileSystemModelFilter) (GtkFileSystemModel *model, typedef gboolean (*GtkFileSystemModelFilter) (GtkFileSystemModel *model,
GtkFilePath *path, GFile *file,
const GtkFileInfo *info, GFileInfo *info,
gpointer user_data); gpointer user_data);
void _gtk_file_system_model_set_filter (GtkFileSystemModel *model, void _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
@ -72,7 +72,7 @@ typedef void (*GtkFileSystemModelPathFunc) (GtkFileSystemModel *model,
gpointer user_data); gpointer user_data);
void _gtk_file_system_model_path_do (GtkFileSystemModel *model, void _gtk_file_system_model_path_do (GtkFileSystemModel *model,
const GtkFilePath *path, GFile *file,
GtkFileSystemModelPathFunc func, GtkFileSystemModelPathFunc func,
gpointer user_data); gpointer user_data);

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkfilesystemunix.h: Default implementation of GtkFileSystem for UNIX-like systems
* Copyright (C) 2003, Red Hat, Inc.
*
* 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.
*/
#ifndef __GTK_FILE_SYSTEM_UNIX_H__
#define __GTK_FILE_SYSTEM_UNIX_H__
#include <glib-object.h>
#include "gtkfilesystem.h"
G_BEGIN_DECLS
#define GTK_TYPE_FILE_SYSTEM_UNIX (gtk_file_system_unix_get_type ())
#define GTK_FILE_SYSTEM_UNIX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_UNIX, GtkFileSystemUnix))
#define GTK_IS_FILE_SYSTEM_UNIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_UNIX))
typedef struct _GtkFileSystemUnix GtkFileSystemUnix;
GtkFileSystem *gtk_file_system_unix_new (void);
GType gtk_file_system_unix_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_UNIX_H__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +0,0 @@
/* GTK - The GIMP Toolkit
* gtkfilesystemunix.h: Default implementation of GtkFileSystem for UNIX-like systems
* Copyright (C) 2003, Red Hat, Inc.
*
* 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.
*/
#ifndef __GTK_FILE_SYSTEM_WIN32_H__
#define __GTK_FILE_SYSTEM_WIN32_H__
#include <glib-object.h>
#include "gtkfilesystem.h"
G_BEGIN_DECLS
#define GTK_TYPE_FILE_SYSTEM_WIN32 (gtk_file_system_win32_get_type ())
#define GTK_FILE_SYSTEM_WIN32(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_SYSTEM_WIN32, GtkFileSystemWin32))
#define GTK_IS_FILE_SYSTEM_WIN32(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_SYSTEM_WIN32))
typedef struct _GtkFileSystemWin32 GtkFileSystemWin32;
GtkFileSystem *gtk_file_system_win32_new (void);
GType gtk_file_system_win32_get_type (void) G_GNUC_CONST;
gchar *_gtk_file_system_win32_get_desktop (void);
G_END_DECLS
#endif /* __GTK_FILE_SYSTEM_WIN32_H__ */

View File

@ -63,10 +63,10 @@ struct _ButtonData
GtkWidget *button; GtkWidget *button;
ButtonType type; ButtonType type;
char *dir_name; char *dir_name;
GtkFilePath *path; GFile *file;
GtkWidget *image; GtkWidget *image;
GtkWidget *label; GtkWidget *label;
GtkFileSystemHandle *handle; GCancellable *cancellable;
guint ignore_changes : 1; guint ignore_changes : 1;
guint file_is_hidden : 1; guint file_is_hidden : 1;
}; };
@ -171,7 +171,7 @@ gtk_path_bar_init (GtkPathBar *path_bar)
GTK_WIDGET_SET_FLAGS (path_bar, GTK_NO_WINDOW); GTK_WIDGET_SET_FLAGS (path_bar, GTK_NO_WINDOW);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE); gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
path_bar->set_path_handle = NULL; path_bar->get_info_cancellable = NULL;
path_bar->spacing = 0; path_bar->spacing = 0;
path_bar->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT); path_bar->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
@ -248,12 +248,12 @@ gtk_path_bar_finalize (GObject *object)
gtk_path_bar_stop_scrolling (path_bar); gtk_path_bar_stop_scrolling (path_bar);
g_list_free (path_bar->button_list); g_list_free (path_bar->button_list);
if (path_bar->root_path) if (path_bar->root_file)
gtk_file_path_free (path_bar->root_path); g_object_unref (path_bar->root_file);
if (path_bar->home_path) if (path_bar->home_file)
gtk_file_path_free (path_bar->home_path); g_object_unref (path_bar->home_file);
if (path_bar->desktop_path) if (path_bar->desktop_file)
gtk_file_path_free (path_bar->desktop_path); g_object_unref (path_bar->desktop_file);
if (path_bar->root_icon) if (path_bar->root_icon)
g_object_unref (path_bar->root_icon); g_object_unref (path_bar->root_icon);
@ -291,9 +291,9 @@ gtk_path_bar_dispose (GObject *object)
remove_settings_signal (path_bar, gtk_widget_get_screen (GTK_WIDGET (object))); remove_settings_signal (path_bar, gtk_widget_get_screen (GTK_WIDGET (object)));
if (path_bar->set_path_handle) if (path_bar->get_info_cancellable)
gtk_file_system_cancel_operation (path_bar->set_path_handle); g_cancellable_cancel (path_bar->get_info_cancellable);
path_bar->set_path_handle = NULL; path_bar->get_info_cancellable = NULL;
G_OBJECT_CLASS (gtk_path_bar_parent_class)->dispose (object); G_OBJECT_CLASS (gtk_path_bar_parent_class)->dispose (object);
} }
@ -1137,7 +1137,7 @@ button_clicked_cb (GtkWidget *button,
GtkPathBar *path_bar; GtkPathBar *path_bar;
GList *button_list; GList *button_list;
gboolean child_is_hidden; gboolean child_is_hidden;
GtkFilePath *child_path; GFile *child_file;
button_data = BUTTON_DATA (data); button_data = BUTTON_DATA (data);
if (button_data->ignore_changes) if (button_data->ignore_changes)
@ -1159,17 +1159,17 @@ button_clicked_cb (GtkWidget *button,
ButtonData *child_data; ButtonData *child_data;
child_data = BUTTON_DATA (button_list->prev->data); child_data = BUTTON_DATA (button_list->prev->data);
child_path = child_data->path; child_file = child_data->file;
child_is_hidden = child_data->file_is_hidden; child_is_hidden = child_data->file_is_hidden;
} }
else else
{ {
child_path = NULL; child_file = NULL;
child_is_hidden = FALSE; child_is_hidden = FALSE;
} }
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0,
button_data->path, child_path, child_is_hidden); button_data->file, child_file, child_is_hidden);
} }
struct SetButtonImageData struct SetButtonImageData
@ -1179,19 +1179,19 @@ struct SetButtonImageData
}; };
static void static void
set_button_image_get_info_cb (GtkFileSystemHandle *handle, set_button_image_get_info_cb (GCancellable *cancellable,
const GtkFileInfo *info, GFileInfo *info,
const GError *error, const GError *error,
gpointer user_data) gpointer user_data)
{ {
gboolean cancelled = handle->cancelled; gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GdkPixbuf *pixbuf; GdkPixbuf *pixbuf;
struct SetButtonImageData *data = user_data; struct SetButtonImageData *data = user_data;
if (handle != data->button_data->handle) if (cancellable != data->button_data->cancellable)
goto out; goto out;
data->button_data->handle = NULL; data->button_data->cancellable = NULL;
if (!data->button_data->button) if (!data->button_data->button)
{ {
@ -1203,7 +1203,7 @@ set_button_image_get_info_cb (GtkFileSystemHandle *handle,
goto out; goto out;
pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->path_bar), pixbuf = gtk_file_info_render_icon (info, GTK_WIDGET (data->path_bar),
data->path_bar->icon_size, NULL); data->path_bar->icon_size);
gtk_image_set_from_pixbuf (GTK_IMAGE (data->button_data->image), pixbuf); gtk_image_set_from_pixbuf (GTK_IMAGE (data->button_data->image), pixbuf);
switch (data->button_data->type) switch (data->button_data->type)
@ -1228,7 +1228,7 @@ set_button_image_get_info_cb (GtkFileSystemHandle *handle,
out: out:
g_free (data); g_free (data);
g_object_unref (handle); g_object_unref (cancellable);
} }
static void static void
@ -1247,17 +1247,16 @@ set_button_image (GtkPathBar *path_bar,
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->root_icon); gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->root_icon);
break; break;
} }
volume = gtk_file_system_get_volume_for_path (path_bar->file_system, path_bar->root_path); volume = gtk_file_system_get_volume_for_file (path_bar->file_system, path_bar->root_file);
if (volume == NULL) if (volume == NULL)
return; return;
path_bar->root_icon = gtk_file_system_volume_render_icon (path_bar->file_system, path_bar->root_icon = gtk_file_system_volume_render_icon (volume,
volume,
GTK_WIDGET (path_bar), GTK_WIDGET (path_bar),
path_bar->icon_size, path_bar->icon_size,
NULL); NULL);
gtk_file_system_volume_free (path_bar->file_system, volume); gtk_file_system_volume_free (volume);
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->root_icon); gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), path_bar->root_icon);
break; break;
@ -1273,13 +1272,13 @@ set_button_image (GtkPathBar *path_bar,
data->path_bar = path_bar; data->path_bar = path_bar;
data->button_data = button_data; data->button_data = button_data;
if (button_data->handle) if (button_data->cancellable)
gtk_file_system_cancel_operation (button_data->handle); g_cancellable_cancel (button_data->cancellable);
button_data->handle = button_data->cancellable =
gtk_file_system_get_info (path_bar->file_system, gtk_file_system_get_info (path_bar->file_system,
path_bar->home_path, path_bar->home_file,
GTK_FILE_INFO_ICON, "standard::icon",
set_button_image_get_info_cb, set_button_image_get_info_cb,
data); data);
break; break;
@ -1295,13 +1294,13 @@ set_button_image (GtkPathBar *path_bar,
data->path_bar = path_bar; data->path_bar = path_bar;
data->button_data = button_data; data->button_data = button_data;
if (button_data->handle) if (button_data->cancellable)
gtk_file_system_cancel_operation (button_data->handle); g_cancellable_cancel (button_data->cancellable);
button_data->handle = button_data->cancellable =
gtk_file_system_get_info (path_bar->file_system, gtk_file_system_get_info (path_bar->file_system,
path_bar->desktop_path, path_bar->desktop_file,
GTK_FILE_INFO_ICON, "standard::icon",
set_button_image_get_info_cb, set_button_image_get_info_cb,
data); data);
break; break;
@ -1313,17 +1312,17 @@ set_button_image (GtkPathBar *path_bar,
static void static void
button_data_free (ButtonData *button_data) button_data_free (ButtonData *button_data)
{ {
if (button_data->path) if (button_data->file)
gtk_file_path_free (button_data->path); g_object_unref (button_data->file);
button_data->path = NULL; button_data->file = NULL;
g_free (button_data->dir_name); g_free (button_data->dir_name);
button_data->dir_name = NULL; button_data->dir_name = NULL;
button_data->button = NULL; button_data->button = NULL;
if (button_data->handle) if (button_data->cancellable)
gtk_file_system_cancel_operation (button_data->handle); g_cancellable_cancel (button_data->cancellable);
else else
g_free (button_data); g_free (button_data);
} }
@ -1398,16 +1397,16 @@ gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
static ButtonType static ButtonType
find_button_type (GtkPathBar *path_bar, find_button_type (GtkPathBar *path_bar,
GtkFilePath *path) GFile *file)
{ {
if (path_bar->root_path != NULL && if (path_bar->root_file != NULL &&
! gtk_file_path_compare (path, path_bar->root_path)) g_file_equal (file, path_bar->root_file))
return ROOT_BUTTON; return ROOT_BUTTON;
if (path_bar->home_path != NULL && if (path_bar->home_file != NULL &&
! gtk_file_path_compare (path, path_bar->home_path)) g_file_equal (file, path_bar->home_file))
return HOME_BUTTON; return HOME_BUTTON;
if (path_bar->desktop_path != NULL && if (path_bar->desktop_file != NULL &&
! gtk_file_path_compare (path, path_bar->desktop_path)) g_file_equal (file, path_bar->desktop_file))
return DESKTOP_BUTTON; return DESKTOP_BUTTON;
return NORMAL_BUTTON; return NORMAL_BUTTON;
@ -1428,7 +1427,7 @@ button_drag_data_get_cb (GtkWidget *widget,
button_data = data; button_data = data;
path_bar = GTK_PATH_BAR (widget->parent); /* the button's parent *is* the path bar */ path_bar = GTK_PATH_BAR (widget->parent); /* the button's parent *is* the path bar */
uris[0] = gtk_file_system_path_to_uri (path_bar->file_system, button_data->path); uris[0] = g_file_get_uri (button_data->file);
uris[1] = NULL; uris[1] = NULL;
gtk_selection_data_set_uris (selection_data, uris); gtk_selection_data_set_uris (selection_data, uris);
@ -1438,7 +1437,7 @@ button_drag_data_get_cb (GtkWidget *widget,
static ButtonData * static ButtonData *
make_directory_button (GtkPathBar *path_bar, make_directory_button (GtkPathBar *path_bar,
const char *dir_name, const char *dir_name,
GtkFilePath *path, GFile *file,
gboolean current_dir, gboolean current_dir,
gboolean file_is_hidden) gboolean file_is_hidden)
{ {
@ -1451,7 +1450,7 @@ make_directory_button (GtkPathBar *path_bar,
/* Is it a special button? */ /* Is it a special button? */
button_data = g_new0 (ButtonData, 1); button_data = g_new0 (ButtonData, 1);
button_data->type = find_button_type (path_bar, path); button_data->type = find_button_type (path_bar, file);
button_data->button = gtk_toggle_button_new (); button_data->button = gtk_toggle_button_new ();
atk_obj = gtk_widget_get_accessible (button_data->button); atk_obj = gtk_widget_get_accessible (button_data->button);
gtk_button_set_focus_on_click (GTK_BUTTON (button_data->button), FALSE); gtk_button_set_focus_on_click (GTK_BUTTON (button_data->button), FALSE);
@ -1492,9 +1491,9 @@ make_directory_button (GtkPathBar *path_bar,
G_CALLBACK (label_size_request_cb), button_data); G_CALLBACK (label_size_request_cb), button_data);
button_data->dir_name = g_strdup (dir_name); button_data->dir_name = g_strdup (dir_name);
button_data->path = gtk_file_path_new_dup (gtk_file_path_get_string (path)); button_data->file = g_object_ref (file);
button_data->file_is_hidden = file_is_hidden; button_data->file_is_hidden = file_is_hidden;
gtk_container_add (GTK_CONTAINER (button_data->button), child); gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_widget_show_all (button_data->button); gtk_widget_show_all (button_data->button);
@ -1519,7 +1518,7 @@ make_directory_button (GtkPathBar *path_bar,
static gboolean static gboolean
gtk_path_bar_check_parent_path (GtkPathBar *path_bar, gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
const GtkFilePath *file_path, GFile *file,
GtkFileSystem *file_system) GtkFileSystem *file_system)
{ {
GList *list; GList *list;
@ -1531,7 +1530,7 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
ButtonData *button_data; ButtonData *button_data;
button_data = list->data; button_data = list->data;
if (! gtk_file_path_compare (file_path, button_data->path)) if (g_file_equal (file, button_data->file))
{ {
current_path = list; current_path = list;
break; break;
@ -1577,10 +1576,10 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
} }
struct SetPathInfo struct SetFileInfo
{ {
GtkFilePath *path; GFile *file;
GtkFilePath *parent_path; GFile *parent_file;
GtkPathBar *path_bar; GtkPathBar *path_bar;
GList *new_buttons; GList *new_buttons;
GList *fake_root; GList *fake_root;
@ -1588,8 +1587,8 @@ struct SetPathInfo
}; };
static void static void
gtk_path_bar_set_path_finish (struct SetPathInfo *info, gtk_path_bar_set_file_finish (struct SetFileInfo *info,
gboolean result) gboolean result)
{ {
if (result) if (result)
{ {
@ -1620,95 +1619,86 @@ gtk_path_bar_set_path_finish (struct SetPathInfo *info,
g_list_free (info->new_buttons); g_list_free (info->new_buttons);
} }
if (info->path) if (info->file)
gtk_file_path_free (info->path); g_object_unref (info->file);
if (info->parent_path) if (info->parent_file)
gtk_file_path_free (info->parent_path); g_object_unref (info->parent_file);
g_free (info); g_free (info);
} }
static void static void
gtk_path_bar_get_info_callback (GtkFileSystemHandle *handle, gtk_path_bar_get_info_callback (GCancellable *cancellable,
const GtkFileInfo *file_info, GFileInfo *info,
const GError *error, const GError *error,
gpointer data) gpointer data)
{ {
gboolean cancelled = handle->cancelled; gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct SetPathInfo *path_info = data; struct SetFileInfo *file_info = data;
ButtonData *button_data; ButtonData *button_data;
const gchar *display_name; const gchar *display_name;
gboolean is_hidden; gboolean is_hidden;
gboolean valid;
if (handle != path_info->path_bar->set_path_handle) if (cancellable != file_info->path_bar->get_info_cancellable)
{ {
gtk_path_bar_set_path_finish (path_info, FALSE); gtk_path_bar_set_file_finish (file_info, FALSE);
g_object_unref (handle); g_object_unref (cancellable);
return; return;
} }
g_object_unref (handle); g_object_unref (cancellable);
path_info->path_bar->set_path_handle = NULL; file_info->path_bar->get_info_cancellable = NULL;
if (cancelled || !file_info) if (cancelled || !info)
{ {
gtk_path_bar_set_path_finish (path_info, FALSE); gtk_path_bar_set_file_finish (file_info, FALSE);
return; return;
} }
display_name = gtk_file_info_get_display_name (file_info); display_name = g_file_info_get_display_name (info);
is_hidden = gtk_file_info_get_is_hidden (file_info); is_hidden = g_file_info_get_is_hidden (info);
gtk_widget_push_composite_child (); gtk_widget_push_composite_child ();
button_data = make_directory_button (path_info->path_bar, display_name, button_data = make_directory_button (file_info->path_bar, display_name,
path_info->path, file_info->file,
path_info->first_directory, is_hidden); file_info->first_directory, is_hidden);
gtk_widget_pop_composite_child (); gtk_widget_pop_composite_child ();
gtk_file_path_free (path_info->path); g_object_unref (file_info->file);
path_info->new_buttons = g_list_prepend (path_info->new_buttons, button_data); file_info->new_buttons = g_list_prepend (file_info->new_buttons, button_data);
if (BUTTON_IS_FAKE_ROOT (button_data)) if (BUTTON_IS_FAKE_ROOT (button_data))
path_info->fake_root = path_info->new_buttons; file_info->fake_root = file_info->new_buttons;
path_info->path = path_info->parent_path; file_info->file = file_info->parent_file;
path_info->first_directory = FALSE; file_info->first_directory = FALSE;
if (!path_info->path) if (!file_info->file)
{ {
gtk_path_bar_set_path_finish (path_info, TRUE); gtk_path_bar_set_file_finish (file_info, TRUE);
return; return;
} }
valid = gtk_file_system_get_parent (path_info->path_bar->file_system, file_info->parent_file = g_file_get_parent (file_info->file);
path_info->path,
&path_info->parent_path,
NULL);
if (!valid)
{
gtk_path_bar_set_path_finish (path_info, FALSE);
return;
}
path_info->path_bar->set_path_handle = file_info->path_bar->get_info_cancellable =
gtk_file_system_get_info (handle->file_system, gtk_file_system_get_info (file_info->path_bar->file_system,
path_info->path, file_info->file,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN, "standard::display-name,standard::is-hidden",
gtk_path_bar_get_info_callback, gtk_path_bar_get_info_callback,
path_info); file_info);
} }
gboolean gboolean
_gtk_path_bar_set_path (GtkPathBar *path_bar, _gtk_path_bar_set_file (GtkPathBar *path_bar,
const GtkFilePath *file_path, GFile *file,
const gboolean keep_trail, const gboolean keep_trail,
GError **error) GError **error)
{ {
struct SetPathInfo *info; struct SetFileInfo *info;
gboolean result; gboolean result;
g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE); g_return_val_if_fail (GTK_IS_PATH_BAR (path_bar), FALSE);
g_return_val_if_fail (file_path != NULL, FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE);
result = TRUE; result = TRUE;
@ -1716,30 +1706,22 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
* This could be a parent directory or a previous selected subdirectory. * This could be a parent directory or a previous selected subdirectory.
*/ */
if (keep_trail && if (keep_trail &&
gtk_path_bar_check_parent_path (path_bar, file_path, path_bar->file_system)) gtk_path_bar_check_parent_path (path_bar, file, path_bar->file_system))
return TRUE; return TRUE;
info = g_new0 (struct SetPathInfo, 1); info = g_new0 (struct SetFileInfo, 1);
info->path = gtk_file_path_copy (file_path); info->file = g_object_ref (file);
info->path_bar = path_bar; info->path_bar = path_bar;
info->first_directory = TRUE; info->first_directory = TRUE;
info->parent_file = g_file_get_parent (info->file);
result = gtk_file_system_get_parent (path_bar->file_system, if (path_bar->get_info_cancellable)
info->path, &info->parent_path, error); g_cancellable_cancel (path_bar->get_info_cancellable);
if (!result)
{
gtk_file_path_free (info->path);
g_free (info);
return result;
}
if (path_bar->set_path_handle) path_bar->get_info_cancellable =
gtk_file_system_cancel_operation (path_bar->set_path_handle);
path_bar->set_path_handle =
gtk_file_system_get_info (path_bar->file_system, gtk_file_system_get_info (path_bar->file_system,
info->path, info->file,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN, "standard::display-name,standard::is-hidden",
gtk_path_bar_get_info_callback, gtk_path_bar_get_info_callback,
info); info);
@ -1764,22 +1746,22 @@ _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
{ {
const gchar *desktop; const gchar *desktop;
path_bar->home_path = gtk_file_system_filename_to_path (path_bar->file_system, home); path_bar->home_file = g_file_new_for_path (home);
/* FIXME: Need file system backend specific way of getting the /* FIXME: Need file system backend specific way of getting the
* Desktop path. * Desktop path.
*/ */
desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP); desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
if (desktop != NULL) if (desktop != NULL)
path_bar->desktop_path = gtk_file_system_filename_to_path (path_bar->file_system, desktop); path_bar->desktop_file = g_file_new_for_path (desktop);
else else
path_bar->desktop_path = NULL; path_bar->desktop_file = NULL;
} }
else else
{ {
path_bar->home_path = NULL; path_bar->home_file = NULL;
path_bar->desktop_path = NULL; path_bar->desktop_file = NULL;
} }
path_bar->root_path = gtk_file_system_filename_to_path (path_bar->file_system, "/"); path_bar->root_file = g_file_new_for_path ("/");
} }
/** /**

View File

@ -41,11 +41,11 @@ struct _GtkPathBar
GtkContainer parent; GtkContainer parent;
GtkFileSystem *file_system; GtkFileSystem *file_system;
GtkFilePath *root_path; GFile *root_file;
GtkFilePath *home_path; GFile *home_file;
GtkFilePath *desktop_path; GFile *desktop_file;
GtkFileSystemHandle *set_path_handle; GCancellable *get_info_cancellable;
GdkPixbuf *root_icon; GdkPixbuf *root_icon;
GdkPixbuf *home_icon; GdkPixbuf *home_icon;
@ -76,16 +76,16 @@ struct _GtkPathBarClass
GtkContainerClass parent_class; GtkContainerClass parent_class;
void (* path_clicked) (GtkPathBar *path_bar, void (* path_clicked) (GtkPathBar *path_bar,
GtkFilePath *file_path, GFile *file,
GtkFilePath *child_path, GFile *child_file,
gboolean child_is_hidden); gboolean child_is_hidden);
}; };
GType gtk_path_bar_get_type (void) G_GNUC_CONST; GType gtk_path_bar_get_type (void) G_GNUC_CONST;
void _gtk_path_bar_set_file_system (GtkPathBar *path_bar, void _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
GtkFileSystem *file_system); GtkFileSystem *file_system);
gboolean _gtk_path_bar_set_path (GtkPathBar *path_bar, gboolean _gtk_path_bar_set_file (GtkPathBar *path_bar,
const GtkFilePath *file_path, GFile *file,
gboolean keep_trail, gboolean keep_trail,
GError **error); GError **error);
void _gtk_path_bar_up (GtkPathBar *path_bar); void _gtk_path_bar_up (GtkPathBar *path_bar);