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>
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
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
======================

View File

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

View File

@ -1461,87 +1461,6 @@ gtk_file_filter_set_name
#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_FILE(__GTK_FILESEL_C__)
#ifndef GTK_DISABLE_DEPRECATED

View File

@ -21,7 +21,6 @@
#include <config.h>
#include "gtkfilechooser.h"
#include "gtkfilechooserprivate.h"
#include "gtkfilesystem.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
@ -30,7 +29,7 @@
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
gtk_file_chooser_get_type (void)
@ -446,18 +445,17 @@ gtk_file_chooser_get_select_multiple (GtkFileChooser *chooser)
gchar *
gtk_file_chooser_get_filename (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_chooser_get_path (chooser);
if (path)
file = gtk_file_chooser_get_file (chooser);
if (file)
{
result = gtk_file_system_path_to_filename (file_system, path);
gtk_file_path_free (path);
result = g_file_get_basename (file);
g_object_unref (file);
}
return result;
@ -535,23 +533,15 @@ gboolean
gtk_file_chooser_select_filename (GtkFileChooser *chooser,
const gchar *filename)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_filename_to_path (file_system, filename);
if (path)
{
result = _gtk_file_chooser_select_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
file = g_file_new_for_path (filename);
result = _gtk_file_chooser_select_file (chooser, file, NULL);
g_object_unref (file);
return result;
}
@ -571,39 +561,32 @@ void
gtk_file_chooser_unselect_filename (GtkFileChooser *chooser,
const char *filename)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
g_return_if_fail (filename != NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_filename_to_path (file_system, filename);
if (path)
{
_gtk_file_chooser_unselect_path (chooser, path);
gtk_file_path_free (path);
}
file = g_file_new_for_path (filename);
_gtk_file_chooser_unselect_file (chooser, file);
g_object_unref (file);
}
/* 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 *
file_paths_to_strings (GtkFileSystem *fs,
GSList *paths,
gchar * (*convert_func) (GtkFileSystem *fs, const GtkFilePath *path))
files_to_strings (GSList *files,
gchar * (*convert_func) (GFile *file))
{
GSList *strings;
strings = NULL;
for (; paths; paths = paths->next)
for (; files; files = files->next)
{
GtkFilePath *path;
GFile *file;
gchar *string;
path = paths->data;
string = (* convert_func) (fs, path);
file = files->data;
string = (* convert_func) (file);
if (string)
strings = g_slist_prepend (strings, string);
@ -630,17 +613,16 @@ file_paths_to_strings (GtkFileSystem *fs,
GSList *
gtk_file_chooser_get_filenames (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GSList *paths;
GSList *result;
GSList *files, *result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
paths = _gtk_file_chooser_get_paths (chooser);
files = _gtk_file_chooser_get_files (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;
}
@ -662,23 +644,15 @@ gboolean
gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
const gchar *filename)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_filename_to_path (file_system, filename);
if (path)
{
result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
file = g_file_new_for_path (filename);
result = _gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
g_object_unref (file);
return result;
}
@ -709,20 +683,17 @@ gtk_file_chooser_set_current_folder (GtkFileChooser *chooser,
gchar *
gtk_file_chooser_get_current_folder (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gchar *filename;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = _gtk_file_chooser_get_current_folder_path (chooser);
if (!path)
file = _gtk_file_chooser_get_current_folder_file (chooser);
if (!file)
return NULL;
filename = gtk_file_system_path_to_filename (file_system, path);
gtk_file_path_free (path);
filename = g_file_get_path (file);
g_object_unref (file);
return filename;
}
@ -773,18 +744,16 @@ gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
gchar *
gtk_file_chooser_get_uri (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_chooser_get_path (chooser);
if (path)
file = gtk_file_chooser_get_file (chooser);
if (file)
{
result = gtk_file_system_path_to_uri (file_system, path);
gtk_file_path_free (path);
result = g_file_get_uri (file);
g_object_unref (file);
}
return result;
@ -861,23 +830,15 @@ gboolean
gtk_file_chooser_select_uri (GtkFileChooser *chooser,
const char *uri)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_uri_to_path (file_system, uri);
if (path)
{
result = _gtk_file_chooser_select_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
file = g_file_new_for_uri (uri);
result = _gtk_file_chooser_select_file (chooser, file, NULL);
g_object_unref (file);
return result;
}
@ -897,20 +858,14 @@ void
gtk_file_chooser_unselect_uri (GtkFileChooser *chooser,
const char *uri)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
g_return_if_fail (uri != NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_uri_to_path (file_system, uri);
if (path)
{
_gtk_file_chooser_unselect_path (chooser, path);
gtk_file_path_free (path);
}
file = g_file_new_for_uri (uri);
_gtk_file_chooser_unselect_file (chooser, file);
g_object_unref (file);
}
/**
@ -962,17 +917,16 @@ gtk_file_chooser_unselect_all (GtkFileChooser *chooser)
GSList *
gtk_file_chooser_get_uris (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GSList *paths;
GSList *result;
GSList *files, *result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
paths = _gtk_file_chooser_get_paths (chooser);
files = _gtk_file_chooser_get_files (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;
}
@ -994,23 +948,15 @@ gboolean
gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
const gchar *uri)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = gtk_file_system_uri_to_path (file_system, uri);
if (path)
{
result = _gtk_file_chooser_set_current_folder_path (chooser, path, NULL);
gtk_file_path_free (path);
}
else
result = FALSE;
file = g_file_new_for_path (uri);
result = _gtk_file_chooser_set_current_folder_file (chooser, file, NULL);
g_object_unref (file);
return result;
}
@ -1040,31 +986,28 @@ gtk_file_chooser_set_current_folder_uri (GtkFileChooser *chooser,
gchar *
gtk_file_chooser_get_current_folder_uri (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gchar *uri;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = _gtk_file_chooser_get_current_folder_path (chooser);
if (!path)
file = _gtk_file_chooser_get_current_folder_file (chooser);
if (!file)
return NULL;
uri = gtk_file_system_path_to_uri (file_system, path);
gtk_file_path_free (path);
uri = g_file_get_uri (file);
g_object_unref (file);
return uri;
}
/**
* _gtk_file_chooser_set_current_folder_path:
* _gtk_file_chooser_set_current_folder_file:
* @chooser: a #GtkFileChooser
* @path: the #GtkFilePath for the new folder
* @file: the #GFile for the new folder
* @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().
*
* 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
**/
gboolean
_gtk_file_chooser_set_current_folder_path (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
_gtk_file_chooser_set_current_folder_file (GtkFileChooser *chooser,
GFile *file,
GError **error)
{
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);
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
*
* Gets the current folder of @chooser as #GtkFilePath.
* Gets the current folder of @chooser as #GFile.
* See gtk_file_chooser_get_current_folder_uri().
*
* Return value: the #GtkFilePath for the current folder.
* Free with gtk_file_path_free().
* Return value: the #GFile for the current folder.
*
* Since: 2.4
*/
GtkFilePath *
_gtk_file_chooser_get_current_folder_path (GtkFileChooser *chooser)
GFile *
_gtk_file_chooser_get_current_folder_file (GtkFileChooser *chooser)
{
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
* @path: the path to select
* @file: the file to select
* @error: location to store error, or %NULL
*
* 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
**/
gboolean
_gtk_file_chooser_select_path (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
_gtk_file_chooser_select_file (GtkFileChooser *chooser,
GFile *file,
GError **error)
{
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);
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
**/
void
_gtk_file_chooser_unselect_path (GtkFileChooser *chooser,
const GtkFilePath *path)
_gtk_file_chooser_unselect_file (GtkFileChooser *chooser,
GFile *file)
{
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
*
* 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
* 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
**/
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);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_paths (chooser);
return GTK_FILE_CHOOSER_GET_IFACE (chooser)->get_files (chooser);
}
static GtkFilePath *
gtk_file_chooser_get_path (GtkFileChooser *chooser)
static GFile *
gtk_file_chooser_get_file (GtkFileChooser *chooser)
{
GSList *list;
GtkFilePath *result = NULL;
GFile *result = 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)
{
result = list->data;
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;
@ -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
*
* Gets the filename that should be previewed in a custom preview
* 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().
*
* Since: 2.4
**/
GtkFilePath *
_gtk_file_chooser_get_preview_path (GtkFileChooser *chooser)
GFile *
_gtk_file_chooser_get_preview_file (GtkFileChooser *chooser)
{
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:
* @chooser: a #GtkFileChooser
* @path: path of the folder to add
* @file: file for the folder to add
* @error: location to store error, or %NULL
*
* 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
**/
gboolean
_gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
_gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
GFile *file,
GError **error)
{
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:
* @chooser: a #GtkFileChooser
* @path: path of the folder to remove
* @file: file for the folder to remove
* @error: location to store error, or %NULL
*
* 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
**/
gboolean
_gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
_gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
GFile *file,
GError **error)
{
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 *
gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = _gtk_file_chooser_get_preview_path (chooser);
if (path)
file =_gtk_file_chooser_get_preview_file (chooser);
if (file)
{
result = gtk_file_system_path_to_filename (file_system, path);
gtk_file_path_free (path);
result = g_file_get_path (file);
g_object_unref (file);
}
return result;
@ -1481,18 +1424,16 @@ gtk_file_chooser_get_preview_filename (GtkFileChooser *chooser)
char *
gtk_file_chooser_get_preview_uri (GtkFileChooser *chooser)
{
GtkFileSystem *file_system;
GtkFilePath *path;
GFile *file;
gchar *result = NULL;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
file_system = _gtk_file_chooser_get_file_system (chooser);
path = _gtk_file_chooser_get_preview_path (chooser);
if (path)
file = _gtk_file_chooser_get_preview_file (chooser);
if (file)
{
result = gtk_file_system_path_to_uri (file_system, path);
gtk_file_path_free (path);
result = g_file_get_uri (file);
g_object_unref (file);
}
return result;
@ -1682,26 +1623,15 @@ gtk_file_chooser_add_shortcut_folder (GtkFileChooser *chooser,
const char *folder,
GError **error)
{
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (folder != NULL, FALSE);
path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
if (!path)
{
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);
file = g_file_new_for_path (folder);
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
g_object_unref (file);
return result;
}
@ -1726,26 +1656,15 @@ gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
const char *folder,
GError **error)
{
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (folder != NULL, FALSE);
path = gtk_file_system_filename_to_path (_gtk_file_chooser_get_file_system (chooser), folder);
if (!path)
{
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);
file = g_file_new_for_path (folder);
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
g_object_unref (file);
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);
result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
folders,
gtk_file_system_path_to_filename);
gtk_file_paths_free (folders);
result = files_to_strings (folders, g_file_get_path);
g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
g_slist_free (folders);
return result;
}
@ -1801,26 +1720,15 @@ gtk_file_chooser_add_shortcut_folder_uri (GtkFileChooser *chooser,
const char *uri,
GError **error)
{
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
if (!path)
{
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);
file = g_file_new_for_uri (uri);
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->add_shortcut_folder (chooser, file, error);
g_object_unref (file);
return result;
}
@ -1845,26 +1753,15 @@ gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
const char *uri,
GError **error)
{
GtkFilePath *path;
GFile *file;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
path = gtk_file_system_uri_to_path (_gtk_file_chooser_get_file_system (chooser), uri);
if (!path)
{
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);
file = g_file_new_for_uri (uri);
result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->remove_shortcut_folder (chooser, file, error);
g_object_unref (file);
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);
result = file_paths_to_strings (_gtk_file_chooser_get_file_system (chooser),
folders,
gtk_file_system_path_to_uri);
gtk_file_paths_free (folders);
result = files_to_strings (folders, g_file_get_uri);
g_slist_foreach (folders, (GFunc) g_object_unref, NULL);
g_slist_free (folders);
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;
GtkFileSystem *file_system;
GtkFilePath *base_folder;
GFile *base_folder;
GFile *current_folder_file;
gchar *file_part;
gint file_part_pos;
/* Folder being loaded or already loaded */
GtkFilePath *current_folder_path;
GtkFileFolder *current_folder;
GtkFileSystemHandle *load_folder_handle;
GtkFolder *current_folder;
GCancellable *load_folder_cancellable;
LoadCompleteAction load_complete_action;
@ -84,7 +84,7 @@ struct _GtkFileChooserEntry
enum
{
DISPLAY_NAME_COLUMN,
PATH_COLUMN,
FILE_COLUMN,
N_COLUMNS
};
@ -134,8 +134,8 @@ static gboolean completion_match_func (GtkEntryCompletion *comp,
const char *key,
GtkTreeIter *iter,
gpointer data);
static char *maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry,
GtkFilePath *path,
static char *maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
GFile *file,
gchar *display_name);
typedef enum {
@ -145,7 +145,7 @@ typedef enum {
static void refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
RefreshMode refresh_mode);
static void finished_loading_cb (GtkFileFolder *folder,
static void finished_loading_cb (GFile *file,
gpointer data);
static void autocomplete (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);
gtk_file_path_free (chooser_entry->base_folder);
gtk_file_path_free (chooser_entry->current_folder_path);
if (chooser_entry->base_folder)
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_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;
}
if (chooser_entry->load_folder_handle)
if (chooser_entry->load_folder_cancellable)
{
gtk_file_system_cancel_operation (chooser_entry->load_folder_handle);
chooser_entry->load_folder_handle = NULL;
g_cancellable_cancel (chooser_entry->load_folder_cancellable);
chooser_entry->load_folder_cancellable = NULL;
}
if (chooser_entry->current_folder)
@ -287,23 +294,23 @@ match_selected_callback (GtkEntryCompletion *completion,
GtkFileChooserEntry *chooser_entry)
{
char *display_name;
GtkFilePath *path;
GFile *file;
gint pos;
gtk_tree_model_get (model, iter,
DISPLAY_NAME_COLUMN, &display_name,
PATH_COLUMN, &path,
FILE_COLUMN, &file,
-1);
if (!display_name || !path)
if (!display_name || !file)
{
/* these shouldn't complain if passed NULL */
gtk_file_path_free (path);
g_object_unref (file);
g_free (display_name);
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;
@ -316,7 +323,7 @@ match_selected_callback (GtkEntryCompletion *completion,
&pos);
gtk_editable_set_position (GTK_EDITABLE (chooser_entry), -1);
gtk_file_path_free (path);
g_object_unref (file);
g_free (display_name);
return TRUE;
@ -411,36 +418,35 @@ beep (GtkFileChooserEntry *chooser_entry)
/* This function will append a directory separator to paths to
* 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.
* 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);
*/
static char *
maybe_append_separator_to_path (GtkFileChooserEntry *chooser_entry,
GtkFilePath *path,
maybe_append_separator_to_file (GtkFileChooserEntry *chooser_entry,
GFile *file,
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;
info = gtk_file_folder_get_info (chooser_entry->current_folder,
path, NULL); /* NULL-GError */
GFileInfo *info;
info = gtk_folder_get_info (chooser_entry->current_folder, file);
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;
display_name = g_strconcat (tmp, G_DIR_SEPARATOR_S, NULL);
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
find_common_prefix (GtkFileChooserEntry *chooser_entry,
gchar **common_prefix_ret,
GtkFilePath **unique_path_ret,
GFile **unique_file_ret,
gboolean *is_complete_not_unique_ret,
gboolean *prefix_expands_the_file_part_ret,
GError **error)
@ -476,11 +482,11 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
gboolean parsed;
gboolean valid;
char *text_up_to_cursor;
GtkFilePath *parsed_folder_path;
GFile *parsed_folder_file;
char *parsed_file_part;
*common_prefix_ret = NULL;
*unique_path_ret = NULL;
*unique_file_ret = NULL;
*is_complete_not_unique_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,
chooser_entry->base_folder,
text_up_to_cursor,
&parsed_folder_path,
&parsed_folder_file,
&parsed_file_part,
error);
@ -500,11 +506,11 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
if (!parsed)
return FALSE;
g_assert (parsed_folder_path != NULL
&& chooser_entry->current_folder_path != NULL
&& gtk_file_path_compare (parsed_folder_path, chooser_entry->current_folder_path) == 0);
g_assert (parsed_folder_file != NULL
&& chooser_entry->current_folder != NULL
&& 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 */
@ -513,12 +519,12 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
while (valid)
{
gchar *display_name;
GtkFilePath *path;
GFile *file;
gtk_tree_model_get (GTK_TREE_MODEL (chooser_entry->completion_store),
&iter,
DISPLAY_NAME_COLUMN, &display_name,
PATH_COLUMN, &path,
FILE_COLUMN, &file,
-1);
if (g_str_has_prefix (display_name, parsed_file_part))
@ -526,7 +532,7 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
if (!*common_prefix_ret)
{
*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
{
@ -541,13 +547,16 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
*p = '\0';
gtk_file_path_free (*unique_path_ret);
*unique_path_ret = NULL;
if (*unique_file_ret)
{
g_object_unref (*unique_file_ret);
*unique_file_ret = NULL;
}
}
}
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);
}
@ -629,7 +638,7 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
gboolean show_errors)
{
gchar *common_prefix;
GtkFilePath *unique_path;
GFile *unique_file;
gboolean is_complete_not_unique;
gboolean prefix_expands_the_file_part;
GError *error;
@ -642,7 +651,7 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
return NO_MATCH;
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)
{
@ -657,14 +666,14 @@ append_common_prefix (GtkFileChooserEntry *chooser_entry,
have_result = FALSE;
if (unique_path)
if (unique_file)
{
if (!char_after_cursor_is_directory_separator (chooser_entry))
common_prefix = maybe_append_separator_to_path (chooser_entry,
unique_path,
common_prefix = maybe_append_separator_to_file (chooser_entry,
unique_file,
common_prefix);
gtk_file_path_free (unique_path);
g_object_unref (unique_file);
if (common_prefix)
{
@ -1036,7 +1045,7 @@ explicitly_complete (GtkFileChooserEntry *chooser_entry)
CommonPrefixResult result;
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:
*
@ -1088,7 +1097,7 @@ start_explicit_completion (GtkFileChooserEntry *chooser_entry)
{
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. */
@ -1100,7 +1109,7 @@ start_explicit_completion (GtkFileChooserEntry *chooser_entry)
}
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);
}
@ -1201,47 +1210,46 @@ discard_completion_store (GtkFileChooserEntry *chooser_entry)
static void
populate_completion_store (GtkFileChooserEntry *chooser_entry)
{
GSList *paths;
GSList *files;
GSList *tmp_list;
discard_completion_store (chooser_entry);
if (!gtk_file_folder_list_children (chooser_entry->current_folder, &paths, NULL)) /* NULL-GError */
return;
files = gtk_folder_list_children (chooser_entry->current_folder);
chooser_entry->completion_store = gtk_list_store_new (N_COLUMNS,
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;
GtkFilePath *path;
GFileInfo *info;
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)
{
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;
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_set (chooser_entry->completion_store, &iter,
DISPLAY_NAME_COLUMN, display_name,
PATH_COLUMN, path,
FILE_COLUMN, file,
-1);
gtk_file_info_free (info);
g_object_unref (info);
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),
DISPLAY_NAME_COLUMN, GTK_SORT_ASCENDING);
@ -1287,8 +1295,8 @@ finish_folder_load (GtkFileChooserEntry *chooser_entry)
/* Callback when the current folder finishes loading */
static void
finished_loading_cb (GtkFileFolder *folder,
gpointer data)
finished_loading_cb (GFile *file,
gpointer 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) */
static void
load_directory_get_folder_callback (GtkFileSystemHandle *handle,
GtkFileFolder *folder,
const GError *error,
gpointer data)
load_directory_get_folder_callback (GCancellable *cancellable,
GtkFolder *folder,
const GError *error,
gpointer data)
{
gboolean cancelled = handle->cancelled;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GtkFileChooserEntry *chooser_entry = data;
if (handle != chooser_entry->load_folder_handle)
if (cancellable != chooser_entry->load_folder_cancellable)
goto out;
chooser_entry->load_folder_handle = NULL;
chooser_entry->load_folder_cancellable = NULL;
if (error)
{
@ -1326,19 +1334,22 @@ load_directory_get_folder_callback (GtkFileSystemHandle *handle,
pop_up_completion_feedback (chooser_entry, error->message);
}
gtk_file_path_free (chooser_entry->current_folder_path);
chooser_entry->current_folder_path = NULL;
if (chooser_entry->current_folder)
{
g_object_unref (chooser_entry->current_folder);
chooser_entry->current_folder = NULL;
}
}
if (cancelled || error)
goto out;
g_assert (folder != NULL);
chooser_entry->current_folder = folder;
chooser_entry->current_folder = g_object_ref (folder);
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);
else
g_signal_connect (chooser_entry->current_folder, "finished-loading",
@ -1346,37 +1357,37 @@ load_directory_get_folder_callback (GtkFileSystemHandle *handle,
out:
g_object_unref (chooser_entry);
g_object_unref (handle);
g_object_unref (cancellable);
}
static void
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)
return;
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,
chooser_entry->current_folder_path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_FOLDER,
chooser_entry->current_folder_file,
"standard::name,standard::display-name,standard::type",
load_directory_get_folder_callback,
g_object_ref (chooser_entry));
}
static void
reload_current_folder (GtkFileChooserEntry *chooser_entry,
GtkFilePath *folder_path,
GFile *folder_file,
gboolean force_reload)
{
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)
{
reload = TRUE;
@ -1386,23 +1397,23 @@ reload_current_folder (GtkFileChooserEntry *chooser_entry,
*/
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);
chooser_entry->load_folder_handle = NULL;
g_cancellable_cancel (chooser_entry->load_folder_cancellable);
chooser_entry->load_folder_cancellable = NULL;
}
g_object_unref (chooser_entry->current_folder);
chooser_entry->current_folder = NULL;
}
gtk_file_path_free (chooser_entry->current_folder_path);
chooser_entry->current_folder_path = gtk_file_path_copy (folder_path);
g_object_unref (chooser_entry->current_folder_file);
chooser_entry->current_folder_file = g_object_ref (folder_file);
}
}
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;
}
@ -1417,7 +1428,7 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
GtkEditable *editable;
gint end_pos;
gchar *text;
GtkFilePath *folder_path;
GFile *folder_file;
gchar *file_part;
gsize total_len, file_part_len;
gint file_part_pos;
@ -1445,9 +1456,9 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
!chooser_entry->base_folder ||
!gtk_file_system_parse (chooser_entry->file_system,
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_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_pos = file_part_pos;
reload_current_folder (chooser_entry, folder_path, file_part_pos == -1);
gtk_file_path_free (folder_path);
reload_current_folder (chooser_entry, folder_file, file_part_pos == -1);
if (folder_file)
g_object_unref (folder_file);
}
static void
autocomplete (GtkFileChooserEntry *chooser_entry)
{
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);
append_common_prefix (chooser_entry, TRUE, FALSE);
@ -1495,7 +1508,7 @@ start_autocompletion (GtkFileChooserEntry *chooser_entry)
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);
else
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:
* @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.
**/
void
_gtk_file_chooser_entry_set_base_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *path)
GFile *file)
{
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);
_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
* 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.
**/
const GtkFilePath *
GFile *
_gtk_file_chooser_entry_get_current_folder (GtkFileChooserEntry *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
* 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
*
* 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
_gtk_file_chooser_entry_get_is_folder (GtkFileChooserEntry *chooser_entry,
const GtkFilePath *path)
GFile *file)
{
gboolean retval = FALSE;
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)
{
retval = gtk_file_info_get_is_folder (file_info);
gtk_file_info_free (file_info);
retval = (g_file_info_get_file_type (file_info) == G_FILE_TYPE_DIRECTORY);
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,
GtkFileSystem *file_system);
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,
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);
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);
G_END_DECLS

View File

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

View File

@ -28,20 +28,20 @@
#include "gtkalias.h"
static gboolean delegate_set_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GFile *file,
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,
const gchar *name);
static gboolean delegate_select_path (GtkFileChooser *chooser,
const GtkFilePath *path,
static gboolean delegate_select_file (GtkFileChooser *chooser,
GFile *file,
GError **error);
static void delegate_unselect_path (GtkFileChooser *chooser,
const GtkFilePath *path);
static void delegate_unselect_file (GtkFileChooser *chooser,
GFile *file);
static void delegate_select_all (GtkFileChooser *chooser);
static void delegate_unselect_all (GtkFileChooser *chooser);
static GSList * delegate_get_paths (GtkFileChooser *chooser);
static GtkFilePath * delegate_get_preview_path (GtkFileChooser *chooser);
static GSList * delegate_get_files (GtkFileChooser *chooser);
static GFile * delegate_get_preview_file (GtkFileChooser *chooser);
static GtkFileSystem *delegate_get_file_system (GtkFileChooser *chooser);
static void delegate_add_filter (GtkFileChooser *chooser,
GtkFileFilter *filter);
@ -49,10 +49,10 @@ static void delegate_remove_filter (GtkFileChooser *choose
GtkFileFilter *filter);
static GSList * delegate_list_filters (GtkFileChooser *chooser);
static gboolean delegate_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GFile *file,
GError **error);
static gboolean delegate_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GFile *file,
GError **error);
static GSList * delegate_list_shortcut_folders (GtkFileChooser *chooser);
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->get_current_folder = delegate_get_current_folder;
iface->set_current_name = delegate_set_current_name;
iface->select_path = delegate_select_path;
iface->unselect_path = delegate_unselect_path;
iface->select_file = delegate_select_file;
iface->unselect_file = delegate_unselect_file;
iface->select_all = delegate_select_all;
iface->unselect_all = delegate_unselect_all;
iface->get_paths = delegate_get_paths;
iface->get_preview_path = delegate_get_preview_path;
iface->get_files = delegate_get_files;
iface->get_preview_file = delegate_get_preview_file;
iface->get_file_system = delegate_get_file_system;
iface->add_filter = delegate_add_filter;
iface->remove_filter = delegate_remove_filter;
@ -203,18 +203,18 @@ get_delegate (GtkFileChooser *receiver)
}
static gboolean
delegate_select_path (GtkFileChooser *chooser,
const GtkFilePath *path,
delegate_select_file (GtkFileChooser *chooser,
GFile *file,
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
delegate_unselect_path (GtkFileChooser *chooser,
const GtkFilePath *path)
delegate_unselect_file (GtkFileChooser *chooser,
GFile *file)
{
_gtk_file_chooser_unselect_path (get_delegate (chooser), path);
_gtk_file_chooser_unselect_file (get_delegate (chooser), file);
}
static void
@ -230,15 +230,15 @@ delegate_unselect_all (GtkFileChooser *chooser)
}
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 *
delegate_get_preview_path (GtkFileChooser *chooser)
static GFile *
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 *
@ -268,19 +268,19 @@ delegate_list_filters (GtkFileChooser *chooser)
}
static gboolean
delegate_add_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
delegate_add_shortcut_folder (GtkFileChooser *chooser,
GFile *file,
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
delegate_remove_shortcut_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
delegate_remove_shortcut_folder (GtkFileChooser *chooser,
GFile *file,
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 *
@ -290,17 +290,17 @@ delegate_list_shortcut_folders (GtkFileChooser *chooser)
}
static gboolean
delegate_set_current_folder (GtkFileChooser *chooser,
const GtkFilePath *path,
GError **error)
delegate_set_current_folder (GtkFileChooser *chooser,
GFile *file,
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)
{
return _gtk_file_chooser_get_current_folder_path (get_delegate (chooser));
return _gtk_file_chooser_get_current_folder_file (get_delegate (chooser));
}
static void

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* GTK - The GIMP Toolkit
* gtkfilesystem.h: Abstract file system interfaces
* gtkfilesystem.h: Filesystem abstraction functions.
* Copyright (C) 2003, Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
@ -21,43 +21,25 @@
#ifndef __GTK_FILE_SYSTEM_H__
#define __GTK_FILE_SYSTEM_H__
/* This is a "semi-private" header; it is meant only for
* 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 <gio/gio.h>
#include <glib-object.h>
#include <gtk/gtkwidget.h> /* For icon handling */
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;
typedef struct _GtkFileFolderIface GtkFileFolderIface;
typedef struct _GtkFileInfo GtkFileInfo;
typedef struct _GtkFileSystem GtkFileSystem;
typedef struct _GtkFileSystemIface GtkFileSystemIface;
typedef struct _GtkFileSystemVolume GtkFileSystemVolume;
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;
#define GTK_TYPE_FOLDER (gtk_folder_get_type ())
#define GTK_FOLDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_FOLDER, GtkFolder))
#define GTK_FOLDER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_FOLDER, GtkFolderClass))
#define GTK_IS_FOLDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_FOLDER))
#define GTK_IS_FOLDER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), GTK_TYPE_FOLDER))
#define GTK_FOLDER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_FOLDER, GtkFolderClass))
/* GError enumeration for GtkFileSystem
*/
@ -76,372 +58,137 @@ typedef enum
GQuark gtk_file_system_error_quark (void);
/* Boxed-type for gtk_file_folder_get_info() results
*/
#define GTK_TYPE_FILE_INFO (gtk_file_info_get_type ())
typedef struct GtkFileSystemClass GtkFileSystemClass;
typedef struct GtkFileSystem GtkFileSystem;
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;
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
struct GtkFileSystemClass
{
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
*/
#define GTK_TYPE_FILE_SYSTEM (gtk_file_system_get_type ())
#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))
struct GtkFolderClass
{
GObjectClass parent_class;
/* 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,
const GtkFileInfo *file_info,
const GError *error,
gpointer data);
typedef void (* GtkFileSystemGetFolderCallback) (GtkFileSystemHandle *handle,
GtkFileFolder *folder,
const GError *error,
gpointer data);
typedef void (* GtkFileSystemCreateFolderCallback) (GtkFileSystemHandle *handle,
const GtkFilePath *path,
struct GtkFolder
{
GObject parent_object;
};
typedef void (* GtkFileSystemGetFolderCallback) (GCancellable *cancellable,
GtkFolder *folder,
const GError *error,
gpointer data);
typedef void (* GtkFileSystemGetInfoCallback) (GCancellable *cancellable,
GFileInfo *file_info,
const GError *error,
gpointer data);
typedef void (* GtkFileSystemVolumeMountCallback) (GCancellable *cancellable,
GtkFileSystemVolume *volume,
const GError *error,
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
{
GTypeInterface base_iface;
GtkFileSystem * gtk_file_system_new (void);
/* Methods
*/
GSList * (*list_volumes) (GtkFileSystem *file_system);
GtkFileSystemVolume * (*get_volume_for_path) (GtkFileSystem *file_system,
const GtkFilePath *path);
GSList * gtk_file_system_list_volumes (GtkFileSystem *file_system);
GSList * gtk_file_system_list_bookmarks (GtkFileSystem *file_system);
GtkFileSystemHandle * (*get_folder) (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
GtkFileSystemGetFolderCallback callback,
gpointer data);
GtkFileSystemHandle * (*get_info) (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
GtkFileSystemGetInfoCallback callback,
gpointer data);
GtkFileSystemHandle * (*create_folder) (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileSystemCreateFolderCallback callback,
gpointer data);
gboolean gtk_file_system_parse (GtkFileSystem *file_system,
GFile *base_file,
const gchar *str,
GFile **folder,
gchar **file_part,
GError **error);
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
*/
void (*volume_free) (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
GtkFilePath * (*volume_get_base_path) (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
gboolean (*volume_get_is_mounted) (GtkFileSystem *file_system,
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);
gboolean gtk_file_system_insert_bookmark (GtkFileSystem *file_system,
GFile *file,
gint position,
GError **error);
gboolean gtk_file_system_remove_bookmark (GtkFileSystem *file_system,
GFile *file,
GError **error);
/* Path Manipulation
*/
gboolean (*get_parent) (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFilePath **parent,
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);
gchar * gtk_file_system_get_bookmark_label (GtkFileSystem *file_system,
GFile *file);
void gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
GFile *file,
const gchar *label);
/* Bookmarks
*/
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);
GtkFileSystemVolume * gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
GFile *file);
/* Signals
*/
void (*volumes_changed) (GtkFileSystem *file_system);
void (*bookmarks_changed) (GtkFileSystem *file_system);
/* GtkFolder functions */
GSList * gtk_folder_list_children (GtkFolder *folder);
GFileInfo * gtk_folder_get_info (GtkFolder *folder,
GFile *file);
/* Bookmark labels
*/
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);
gboolean gtk_folder_is_finished_loading (GtkFolder *folder);
/* GtkFilePath */
#define GTK_TYPE_FILE_PATH (gtk_file_path_get_type ())
/* GtkFileSystemVolume methods */
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;
#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__ */
void gtk_file_system_volume_free (GtkFileSystemVolume *volume);
#define gtk_file_path_copy(path) gtk_file_path_new_dup (gtk_file_path_get_string(path))
#ifdef G_OS_WIN32
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
/* GtkFileSystemBookmark methods */
void gtk_file_system_bookmark_free (GtkFileSystemBookmark *bookmark);
GSList *gtk_file_paths_sort (GSList *paths);
GSList *gtk_file_paths_copy (GSList *paths);
void gtk_file_paths_free (GSList *paths);
/* GtkFileSystem modules support */
GtkFileSystem *gtk_file_system_create (const char *file_system_name);
/* GFileInfo helper functions */
GdkPixbuf * gtk_file_info_render_icon (GFileInfo *info,
GtkWidget *widget,
gint icon_size);
G_END_DECLS

File diff suppressed because it is too large Load Diff

View File

@ -42,13 +42,13 @@ typedef enum {
} GtkFileSystemModelColumns;
GtkFileSystemModel *_gtk_file_system_model_new (GtkFileSystem *file_system,
const GtkFilePath *root_path,
GFile *root_file,
gint max_depth,
GtkFileInfoType types,
const gchar *attributes,
GError **error);
const GtkFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
GFileInfo * _gtk_file_system_model_get_info (GtkFileSystemModel *model,
GtkTreeIter *iter);
const GtkFilePath * _gtk_file_system_model_get_path (GtkFileSystemModel *model,
GFile * _gtk_file_system_model_get_file (GtkFileSystemModel *model,
GtkTreeIter *iter);
void _gtk_file_system_model_set_show_hidden (GtkFileSystemModel *model,
gboolean show_hidden);
@ -58,8 +58,8 @@ void _gtk_file_system_model_set_show_files (GtkFileSystemModel
gboolean show_files);
typedef gboolean (*GtkFileSystemModelFilter) (GtkFileSystemModel *model,
GtkFilePath *path,
const GtkFileInfo *info,
GFile *file,
GFileInfo *info,
gpointer user_data);
void _gtk_file_system_model_set_filter (GtkFileSystemModel *model,
@ -72,7 +72,7 @@ typedef void (*GtkFileSystemModelPathFunc) (GtkFileSystemModel *model,
gpointer user_data);
void _gtk_file_system_model_path_do (GtkFileSystemModel *model,
const GtkFilePath *path,
GFile *file,
GtkFileSystemModelPathFunc func,
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;
ButtonType type;
char *dir_name;
GtkFilePath *path;
GFile *file;
GtkWidget *image;
GtkWidget *label;
GtkFileSystemHandle *handle;
GCancellable *cancellable;
guint ignore_changes : 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_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->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);
g_list_free (path_bar->button_list);
if (path_bar->root_path)
gtk_file_path_free (path_bar->root_path);
if (path_bar->home_path)
gtk_file_path_free (path_bar->home_path);
if (path_bar->desktop_path)
gtk_file_path_free (path_bar->desktop_path);
if (path_bar->root_file)
g_object_unref (path_bar->root_file);
if (path_bar->home_file)
g_object_unref (path_bar->home_file);
if (path_bar->desktop_file)
g_object_unref (path_bar->desktop_file);
if (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)));
if (path_bar->set_path_handle)
gtk_file_system_cancel_operation (path_bar->set_path_handle);
path_bar->set_path_handle = NULL;
if (path_bar->get_info_cancellable)
g_cancellable_cancel (path_bar->get_info_cancellable);
path_bar->get_info_cancellable = NULL;
G_OBJECT_CLASS (gtk_path_bar_parent_class)->dispose (object);
}
@ -1137,7 +1137,7 @@ button_clicked_cb (GtkWidget *button,
GtkPathBar *path_bar;
GList *button_list;
gboolean child_is_hidden;
GtkFilePath *child_path;
GFile *child_file;
button_data = BUTTON_DATA (data);
if (button_data->ignore_changes)
@ -1159,17 +1159,17 @@ button_clicked_cb (GtkWidget *button,
ButtonData *child_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;
}
else
{
child_path = NULL;
child_file = NULL;
child_is_hidden = FALSE;
}
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
@ -1179,19 +1179,19 @@ struct SetButtonImageData
};
static void
set_button_image_get_info_cb (GtkFileSystemHandle *handle,
const GtkFileInfo *info,
const GError *error,
gpointer user_data)
set_button_image_get_info_cb (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer user_data)
{
gboolean cancelled = handle->cancelled;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
GdkPixbuf *pixbuf;
struct SetButtonImageData *data = user_data;
if (handle != data->button_data->handle)
if (cancellable != data->button_data->cancellable)
goto out;
data->button_data->handle = NULL;
data->button_data->cancellable = NULL;
if (!data->button_data->button)
{
@ -1203,7 +1203,7 @@ set_button_image_get_info_cb (GtkFileSystemHandle *handle,
goto out;
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);
switch (data->button_data->type)
@ -1228,7 +1228,7 @@ set_button_image_get_info_cb (GtkFileSystemHandle *handle,
out:
g_free (data);
g_object_unref (handle);
g_object_unref (cancellable);
}
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);
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)
return;
path_bar->root_icon = gtk_file_system_volume_render_icon (path_bar->file_system,
volume,
path_bar->root_icon = gtk_file_system_volume_render_icon (volume,
GTK_WIDGET (path_bar),
path_bar->icon_size,
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);
break;
@ -1273,13 +1272,13 @@ set_button_image (GtkPathBar *path_bar,
data->path_bar = path_bar;
data->button_data = button_data;
if (button_data->handle)
gtk_file_system_cancel_operation (button_data->handle);
if (button_data->cancellable)
g_cancellable_cancel (button_data->cancellable);
button_data->handle =
button_data->cancellable =
gtk_file_system_get_info (path_bar->file_system,
path_bar->home_path,
GTK_FILE_INFO_ICON,
path_bar->home_file,
"standard::icon",
set_button_image_get_info_cb,
data);
break;
@ -1295,13 +1294,13 @@ set_button_image (GtkPathBar *path_bar,
data->path_bar = path_bar;
data->button_data = button_data;
if (button_data->handle)
gtk_file_system_cancel_operation (button_data->handle);
if (button_data->cancellable)
g_cancellable_cancel (button_data->cancellable);
button_data->handle =
button_data->cancellable =
gtk_file_system_get_info (path_bar->file_system,
path_bar->desktop_path,
GTK_FILE_INFO_ICON,
path_bar->desktop_file,
"standard::icon",
set_button_image_get_info_cb,
data);
break;
@ -1313,17 +1312,17 @@ set_button_image (GtkPathBar *path_bar,
static void
button_data_free (ButtonData *button_data)
{
if (button_data->path)
gtk_file_path_free (button_data->path);
button_data->path = NULL;
if (button_data->file)
g_object_unref (button_data->file);
button_data->file = NULL;
g_free (button_data->dir_name);
button_data->dir_name = NULL;
button_data->button = NULL;
if (button_data->handle)
gtk_file_system_cancel_operation (button_data->handle);
if (button_data->cancellable)
g_cancellable_cancel (button_data->cancellable);
else
g_free (button_data);
}
@ -1398,16 +1397,16 @@ gtk_path_bar_update_button_appearance (GtkPathBar *path_bar,
static ButtonType
find_button_type (GtkPathBar *path_bar,
GtkFilePath *path)
GFile *file)
{
if (path_bar->root_path != NULL &&
! gtk_file_path_compare (path, path_bar->root_path))
if (path_bar->root_file != NULL &&
g_file_equal (file, path_bar->root_file))
return ROOT_BUTTON;
if (path_bar->home_path != NULL &&
! gtk_file_path_compare (path, path_bar->home_path))
if (path_bar->home_file != NULL &&
g_file_equal (file, path_bar->home_file))
return HOME_BUTTON;
if (path_bar->desktop_path != NULL &&
! gtk_file_path_compare (path, path_bar->desktop_path))
if (path_bar->desktop_file != NULL &&
g_file_equal (file, path_bar->desktop_file))
return DESKTOP_BUTTON;
return NORMAL_BUTTON;
@ -1428,7 +1427,7 @@ button_drag_data_get_cb (GtkWidget *widget,
button_data = data;
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;
gtk_selection_data_set_uris (selection_data, uris);
@ -1438,7 +1437,7 @@ button_drag_data_get_cb (GtkWidget *widget,
static ButtonData *
make_directory_button (GtkPathBar *path_bar,
const char *dir_name,
GtkFilePath *path,
GFile *file,
gboolean current_dir,
gboolean file_is_hidden)
{
@ -1451,7 +1450,7 @@ make_directory_button (GtkPathBar *path_bar,
/* Is it a special button? */
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 ();
atk_obj = gtk_widget_get_accessible (button_data->button);
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);
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;
gtk_container_add (GTK_CONTAINER (button_data->button), child);
gtk_widget_show_all (button_data->button);
@ -1519,7 +1518,7 @@ make_directory_button (GtkPathBar *path_bar,
static gboolean
gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
const GtkFilePath *file_path,
GFile *file,
GtkFileSystem *file_system)
{
GList *list;
@ -1531,7 +1530,7 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
ButtonData *button_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;
break;
@ -1577,10 +1576,10 @@ gtk_path_bar_check_parent_path (GtkPathBar *path_bar,
}
struct SetPathInfo
struct SetFileInfo
{
GtkFilePath *path;
GtkFilePath *parent_path;
GFile *file;
GFile *parent_file;
GtkPathBar *path_bar;
GList *new_buttons;
GList *fake_root;
@ -1588,8 +1587,8 @@ struct SetPathInfo
};
static void
gtk_path_bar_set_path_finish (struct SetPathInfo *info,
gboolean result)
gtk_path_bar_set_file_finish (struct SetFileInfo *info,
gboolean result)
{
if (result)
{
@ -1620,95 +1619,86 @@ gtk_path_bar_set_path_finish (struct SetPathInfo *info,
g_list_free (info->new_buttons);
}
if (info->path)
gtk_file_path_free (info->path);
if (info->parent_path)
gtk_file_path_free (info->parent_path);
if (info->file)
g_object_unref (info->file);
if (info->parent_file)
g_object_unref (info->parent_file);
g_free (info);
}
static void
gtk_path_bar_get_info_callback (GtkFileSystemHandle *handle,
const GtkFileInfo *file_info,
const GError *error,
gpointer data)
gtk_path_bar_get_info_callback (GCancellable *cancellable,
GFileInfo *info,
const GError *error,
gpointer data)
{
gboolean cancelled = handle->cancelled;
struct SetPathInfo *path_info = data;
gboolean cancelled = g_cancellable_is_cancelled (cancellable);
struct SetFileInfo *file_info = data;
ButtonData *button_data;
const gchar *display_name;
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);
g_object_unref (handle);
gtk_path_bar_set_file_finish (file_info, FALSE);
g_object_unref (cancellable);
return;
}
g_object_unref (handle);
path_info->path_bar->set_path_handle = NULL;
g_object_unref (cancellable);
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;
}
display_name = gtk_file_info_get_display_name (file_info);
is_hidden = gtk_file_info_get_is_hidden (file_info);
display_name = g_file_info_get_display_name (info);
is_hidden = g_file_info_get_is_hidden (info);
gtk_widget_push_composite_child ();
button_data = make_directory_button (path_info->path_bar, display_name,
path_info->path,
path_info->first_directory, is_hidden);
button_data = make_directory_button (file_info->path_bar, display_name,
file_info->file,
file_info->first_directory, is_hidden);
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))
path_info->fake_root = path_info->new_buttons;
file_info->fake_root = file_info->new_buttons;
path_info->path = path_info->parent_path;
path_info->first_directory = FALSE;
file_info->file = file_info->parent_file;
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;
}
valid = gtk_file_system_get_parent (path_info->path_bar->file_system,
path_info->path,
&path_info->parent_path,
NULL);
if (!valid)
{
gtk_path_bar_set_path_finish (path_info, FALSE);
return;
}
file_info->parent_file = g_file_get_parent (file_info->file);
path_info->path_bar->set_path_handle =
gtk_file_system_get_info (handle->file_system,
path_info->path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
file_info->path_bar->get_info_cancellable =
gtk_file_system_get_info (file_info->path_bar->file_system,
file_info->file,
"standard::display-name,standard::is-hidden",
gtk_path_bar_get_info_callback,
path_info);
file_info);
}
gboolean
_gtk_path_bar_set_path (GtkPathBar *path_bar,
const GtkFilePath *file_path,
const gboolean keep_trail,
_gtk_path_bar_set_file (GtkPathBar *path_bar,
GFile *file,
const gboolean keep_trail,
GError **error)
{
struct SetPathInfo *info;
struct SetFileInfo *info;
gboolean result;
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;
@ -1716,30 +1706,22 @@ _gtk_path_bar_set_path (GtkPathBar *path_bar,
* This could be a parent directory or a previous selected subdirectory.
*/
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;
info = g_new0 (struct SetPathInfo, 1);
info->path = gtk_file_path_copy (file_path);
info = g_new0 (struct SetFileInfo, 1);
info->file = g_object_ref (file);
info->path_bar = path_bar;
info->first_directory = TRUE;
info->parent_file = g_file_get_parent (info->file);
result = gtk_file_system_get_parent (path_bar->file_system,
info->path, &info->parent_path, error);
if (!result)
{
gtk_file_path_free (info->path);
g_free (info);
return result;
}
if (path_bar->get_info_cancellable)
g_cancellable_cancel (path_bar->get_info_cancellable);
if (path_bar->set_path_handle)
gtk_file_system_cancel_operation (path_bar->set_path_handle);
path_bar->set_path_handle =
path_bar->get_info_cancellable =
gtk_file_system_get_info (path_bar->file_system,
info->path,
GTK_FILE_INFO_DISPLAY_NAME | GTK_FILE_INFO_IS_HIDDEN,
info->file,
"standard::display-name,standard::is-hidden",
gtk_path_bar_get_info_callback,
info);
@ -1764,22 +1746,22 @@ _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
{
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
* Desktop path.
*/
desktop = g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP);
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
path_bar->desktop_path = NULL;
path_bar->desktop_file = NULL;
}
else
{
path_bar->home_path = NULL;
path_bar->desktop_path = NULL;
path_bar->home_file = 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;
GtkFileSystem *file_system;
GtkFilePath *root_path;
GtkFilePath *home_path;
GtkFilePath *desktop_path;
GFile *root_file;
GFile *home_file;
GFile *desktop_file;
GtkFileSystemHandle *set_path_handle;
GCancellable *get_info_cancellable;
GdkPixbuf *root_icon;
GdkPixbuf *home_icon;
@ -76,16 +76,16 @@ struct _GtkPathBarClass
GtkContainerClass parent_class;
void (* path_clicked) (GtkPathBar *path_bar,
GtkFilePath *file_path,
GtkFilePath *child_path,
GFile *file,
GFile *child_file,
gboolean child_is_hidden);
};
GType gtk_path_bar_get_type (void) G_GNUC_CONST;
void _gtk_path_bar_set_file_system (GtkPathBar *path_bar,
GtkFileSystem *file_system);
gboolean _gtk_path_bar_set_path (GtkPathBar *path_bar,
const GtkFilePath *file_path,
gboolean _gtk_path_bar_set_file (GtkPathBar *path_bar,
GFile *file,
gboolean keep_trail,
GError **error);
void _gtk_path_bar_up (GtkPathBar *path_bar);