* Boston, MA 02111-1307, USA.
*/
+#include <config.h>
#include <gmodule.h>
#include "gtkfilesystem.h"
#include "gtkicontheme.h"
-#include "gtkmain.h"
+#include "gtkmodules.h"
+#include "gtkintl.h"
+#include "gtkalias.h"
#include <string.h>
static GType our_type = 0;
if (our_type == 0)
- our_type = g_boxed_type_register_static ("GtkFileInfo",
+ our_type = g_boxed_type_register_static (I_("GtkFileInfo"),
(GBoxedCopyFunc) gtk_file_info_copy,
(GBoxedFreeFunc) gtk_file_info_free);
* gtk_file_info_get_display_key:
* @info: a #GtkFileInfo
*
- * Returns results of g_utf8_collate_key() on the display name
- * for @info. This is useful when sorting a bunch of #GtkFileInfo
- * structures since the collate key will be only computed once.
+ * Returns for the collation key for the display name for @info.
+ * This is useful when sorting a bunch of #GtkFileInfo structures
+ * since the collate key will be only computed once.
*
* Return value: The collate key for the display name, or %NULL
* if the display name hasn't been set.
{
/* Since info->display_key is only a cache, we cast off the const
*/
- ((GtkFileInfo *)info)->display_key = g_utf8_collate_key (info->display_name, -1);
+ ((GtkFileInfo *)info)->display_key = g_utf8_collate_key_for_filename (info->display_name, -1);
}
return info->display_key;
{
g_return_if_fail (info != NULL);
+ if (display_name == info->display_name)
+ return;
+
if (info->display_name)
g_free (info->display_name);
if (info->display_key)
};
file_system_type = g_type_register_static (G_TYPE_INTERFACE,
- "GtkFileSystem",
+ I_("GtkFileSystem"),
&file_system_info, 0);
g_type_interface_add_prerequisite (file_system_type, G_TYPE_OBJECT);
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
- g_signal_new ("volumes-changed",
+ g_signal_new (I_("volumes-changed"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileSystemIface, volumes_changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- g_signal_new ("bookmarks-changed",
+ g_signal_new (I_("bookmarks-changed"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileSystemIface, bookmarks_changed),
* @path: a #GtkFilePath
*
* Queries the file system volume that corresponds to a specific path.
+ * There might not be a volume for all paths (consinder for instance remote
+ * shared), so this can return NULL.
*
* Return value: the #GtkFileSystemVolume that corresponds to the specified
- * @path. You should free this value with gtk_file_system_volume_free().
+ * @path, or NULL if there is no such volume. You should free this value with
+ * gtk_file_system_volume_free().
**/
GtkFileSystemVolume *
gtk_file_system_get_volume_for_path (GtkFileSystem *file_system,
* @parent: location to store parent path name
* @error: location to store error, or %NULL
*
- * Gets the name of the parent folder of a file.
+ * Gets the name of the parent folder of a path. If the path has no parent, as when
+ * you request the parent of a file system root, then @parent will be set to %NULL.
*
- * Return value: TRUE if the operation was successful; note that in this case @parent
- * can be returned as %NULL if the base @path has no parent folder (i.e. if it is
- * already a file system root). If the operation fails, this function returns FALSE
- * and sets the @error value if it is specified.
+ * Return value: %TRUE if the operation was successful: @parent will be set to
+ * the name of the @path's parent, or to %NULL if @path is already a file system
+ * root. If the operation fails, this function returns %FALSE, sets @parent to
+ * NULL, and sets the @error value if it is specified.
**/
gboolean
gtk_file_system_get_parent (GtkFileSystem *file_system,
GtkFilePath **parent,
GError **error)
{
- GtkFilePath *tmp_parent = NULL;
gboolean result;
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (parent != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
- result = GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_parent (file_system, path, &tmp_parent, error);
- g_assert (result || tmp_parent == NULL);
+ *parent = NULL;
+
+ result = GTK_FILE_SYSTEM_GET_IFACE (file_system)->get_parent (file_system, path, parent, error);
+ g_assert (result || *parent == NULL);
- if (parent)
- *parent = tmp_parent;
- else
- gtk_file_path_free (tmp_parent);
-
return result;
}
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
g_return_val_if_fail (base_path != NULL, FALSE);
+ g_return_val_if_fail (str != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
result = GTK_FILE_SYSTEM_GET_IFACE (file_system)->parse (file_system, base_path, str,
&tmp_folder, &tmp_file_part,
error);
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->filename_to_path (file_system, filename);
}
+/**
+ * gtk_file_system_path_is_local:
+ * @filesystem: a #GtkFileSystem
+ * @path: A #GtkFilePath from that filesystem
+ *
+ * Checks whether a #GtkFilePath is local; that is whether
+ * gtk_file_system_path_to_filename would return non-%NULL.
+ *
+ * Return value: %TRUE if the path is loca
+ **/
+gboolean
+gtk_file_system_path_is_local (GtkFileSystem *file_system,
+ const GtkFilePath *path)
+{
+ gchar *filename;
+ gboolean result;
+
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ filename = gtk_file_system_path_to_filename (file_system, path);
+ result = filename != NULL;
+ g_free (filename);
+
+ return result;
+}
+
GdkPixbuf *
gtk_file_system_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_bookmarks (file_system);
}
+/**
+ * gtk_file_system_get_bookmark_label:
+ * @file_system: a #GtkFileSystem
+ * @path: path of the bookmark
+ *
+ * Gets the label to display for a bookmark, or %NULL.
+ *
+ * Returns: the label for the bookmark @path
+ *
+ * Since: 2.8
+ */
+gchar *
+gtk_file_system_get_bookmark_label (GtkFileSystem *file_system,
+ const GtkFilePath *path)
+{
+ GtkFileSystemIface *iface;
+
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ iface = GTK_FILE_SYSTEM_GET_IFACE (file_system);
+ if (iface->get_bookmark_label)
+ return iface->get_bookmark_label (file_system, path);
+
+ return NULL;
+}
+
+/**
+ * gtk_file_system_set_bookmark_label:
+ * @file_system: a #GtkFileSystem
+ * @path: path of the bookmark
+ * @label: the label for the bookmark, or %NULL to display
+ * the path itself
+ *
+ * Sets the label to display for a bookmark.
+ *
+ * Since: 2.8
+ */
+void
+gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
+ const GtkFilePath *path,
+ const gchar *label)
+{
+ GtkFileSystemIface *iface;
+
+ g_return_if_fail (GTK_IS_FILE_SYSTEM (file_system));
+ g_return_if_fail (path != NULL);
+
+ iface = GTK_FILE_SYSTEM_GET_IFACE (file_system);
+ if (iface->set_bookmark_label)
+ iface->set_bookmark_label (file_system, path, label);
+}
+
/*****************************************
* GtkFileFolder *
*****************************************/
};
file_folder_type = g_type_register_static (G_TYPE_INTERFACE,
- "GtkFileFolder",
+ I_("GtkFileFolder"),
&file_folder_info, 0);
g_type_interface_add_prerequisite (file_folder_type, G_TYPE_OBJECT);
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
- g_signal_new ("deleted",
+ g_signal_new (I_("deleted"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileFolderIface, deleted),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- g_signal_new ("files-added",
+ g_signal_new (I_("files-added"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileFolderIface, files_added),
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- g_signal_new ("files-changed",
+ g_signal_new (I_("files-changed"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileFolderIface, files_changed),
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
- g_signal_new ("files-removed",
+ g_signal_new (I_("files-removed"),
iface_type,
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkFileFolderIface, files_removed),
g_cclosure_marshal_VOID__POINTER,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
+ g_signal_new (I_("finished-loading"),
+ iface_type,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GtkFileFolderIface, finished_loading),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
initialized = TRUE;
}
GError **error)
{
g_return_val_if_fail (GTK_IS_FILE_FOLDER (folder), NULL);
- g_return_val_if_fail (path != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
return GTK_FILE_FOLDER_GET_IFACE (folder)->get_info (folder, path, error);
}
+gboolean
+gtk_file_folder_is_finished_loading (GtkFileFolder *folder)
+{
+ GtkFileFolderIface *iface;
+
+ g_return_val_if_fail (GTK_IS_FILE_FOLDER (folder), TRUE);
+
+ iface = GTK_FILE_FOLDER_GET_IFACE (folder);
+ if (!iface->is_finished_loading)
+ return TRUE;
+ else
+ return iface->is_finished_loading (folder);
+}
+
+
+/*****************************************
+ * GtkFilePath modules *
+ *****************************************/
+
+/* We make these real functions in case either copy or free are implemented as macros
+ */
+static gpointer
+gtk_file_path_real_copy (gpointer boxed)
+{
+ return gtk_file_path_copy ((GtkFilePath *) boxed);
+}
+
+static void
+gtk_file_path_real_free (gpointer boxed)
+{
+ gtk_file_path_free (boxed);
+}
+
+GType
+gtk_file_path_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static (I_("GtkFilePath"),
+ (GBoxedCopyFunc) gtk_file_path_real_copy,
+ (GBoxedFreeFunc) gtk_file_path_real_free);
+
+ return our_type;
+}
+
+
GSList *
gtk_file_paths_sort (GSList *paths)
{
GTypeModuleClass parent_class;
};
-G_DEFINE_TYPE (GtkFileSystemModule, gtk_file_system_module, G_TYPE_TYPE_MODULE);
-#define GTK_TYPE_FILE_SYSTEM_MODULE (gtk_file_system_module_get_type ())
+G_DEFINE_TYPE (GtkFileSystemModule, _gtk_file_system_module, G_TYPE_TYPE_MODULE);
+#define GTK_TYPE_FILE_SYSTEM_MODULE (_gtk_file_system_module_get_type ())
#define GTK_FILE_SYSTEM_MODULE(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), GTK_TYPE_FILE_SYSTEM_MODULE, GtkFileSystemModule))
g_free (module->path);
- G_OBJECT_CLASS (gtk_file_system_module_parent_class)->finalize (object);
+ G_OBJECT_CLASS (_gtk_file_system_module_parent_class)->finalize (object);
}
static void
-gtk_file_system_module_class_init (GtkFileSystemModuleClass *class)
+_gtk_file_system_module_class_init (GtkFileSystemModuleClass *class)
{
GTypeModuleClass *module_class = G_TYPE_MODULE_CLASS (class);
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
}
static void
-gtk_file_system_module_init (GtkFileSystemModule *fs_module)
+_gtk_file_system_module_init (GtkFileSystemModule *fs_module)
{
}
return fs;
}
-
+#define __GTK_FILE_SYSTEM_C__
+#include "gtkaliasdef.c"