gtk2/gtk/gtkfilesystemunix.c

965 lines
27 KiB
C
Raw Normal View History

2003-03-21 20:34:02 +00:00
/* GTK - The GIMP Toolkit
* gtkfilesystemunix.c: 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.
*/
#include "gtkfilesystem.h"
#include "gtkfilesystemunix.h"
#include "gtkintl.h"
2003-03-21 20:34:02 +00:00
#define XDG_PREFIX _gtk_xdg
#include "xdgmime/xdgmime.h"
2003-03-21 20:34:02 +00:00
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
typedef struct _GtkFileSystemUnixClass GtkFileSystemUnixClass;
#define GTK_FILE_SYSTEM_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_SYSTEM_UNIX, GtkFileSystemUnixClass))
#define GTK_IS_FILE_SYSTEM_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_SYSTEM_UNIX))
#define GTK_FILE_SYSTEM_UNIX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_SYSTEM_UNIX, GtkFileSystemUnixClass))
struct _GtkFileSystemUnixClass
{
GObjectClass parent_class;
};
struct _GtkFileSystemUnix
{
GObject parent_instance;
};
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
/* Simple stub for our returned volumes */
typedef struct {
int dummy;
} Volume;
2003-03-21 20:34:02 +00:00
#define GTK_TYPE_FILE_FOLDER_UNIX (gtk_file_folder_unix_get_type ())
#define GTK_FILE_FOLDER_UNIX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_FILE_FOLDER_UNIX, GtkFileFolderUnix))
#define GTK_IS_FILE_FOLDER_UNIX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_FILE_FOLDER_UNIX))
#define GTK_FILE_FOLDER_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_FILE_FOLDER_UNIX, GtkFileFolderUnixClass))
#define GTK_IS_FILE_FOLDER_UNIX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_FILE_FOLDER_UNIX))
#define GTK_FILE_FOLDER_UNIX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_FILE_FOLDER_UNIX, GtkFileFolderUnixClass))
typedef struct _GtkFileFolderUnix GtkFileFolderUnix;
typedef struct _GtkFileFolderUnixClass GtkFileFolderUnixClass;
struct _GtkFileFolderUnixClass
{
GObjectClass parent_class;
};
struct _GtkFileFolderUnix
{
GObject parent_instance;
GtkFileInfoType types;
gchar *filename;
};
static GObjectClass *system_parent_class;
static GObjectClass *folder_parent_class;
2003-03-21 20:34:02 +00:00
static void gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class);
static void gtk_file_system_unix_iface_init (GtkFileSystemIface *iface);
static void gtk_file_system_unix_init (GtkFileSystemUnix *impl);
static void gtk_file_system_unix_finalize (GObject *object);
static GSList * gtk_file_system_unix_list_volumes (GtkFileSystem *file_system);
static GtkFileSystemVolume *gtk_file_system_unix_get_volume_for_path (GtkFileSystem *file_system,
const GtkFilePath *path);
static GtkFileFolder *gtk_file_system_unix_get_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
GError **error);
static gboolean gtk_file_system_unix_create_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
static void gtk_file_system_unix_volume_free (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
static GtkFilePath *gtk_file_system_unix_volume_get_base_path (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
static gboolean gtk_file_system_unix_volume_get_is_mounted (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
static gboolean gtk_file_system_unix_volume_mount (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GError **error);
static gchar * gtk_file_system_unix_volume_get_display_name (GtkFileSystem *file_system,
GtkFileSystemVolume *volume);
static GdkPixbuf * gtk_file_system_unix_volume_render_icon (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GtkWidget *widget,
gint pixel_size,
GError **error);
static gboolean gtk_file_system_unix_get_parent (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFilePath **parent,
GError **error);
static GtkFilePath * gtk_file_system_unix_make_path (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *display_name,
GError **error);
static gboolean gtk_file_system_unix_parse (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *str,
GtkFilePath **folder,
gchar **file_part,
GError **error);
static gchar * gtk_file_system_unix_path_to_uri (GtkFileSystem *file_system,
const GtkFilePath *path);
static gchar * gtk_file_system_unix_path_to_filename (GtkFileSystem *file_system,
const GtkFilePath *path);
static GtkFilePath *gtk_file_system_unix_uri_to_path (GtkFileSystem *file_system,
const gchar *uri);
static GtkFilePath *gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system,
const gchar *filename);
2003-03-21 20:34:02 +00:00
static GdkPixbuf *gtk_file_system_unix_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error);
Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. 2003-10-17 Federico Mena Quintero <federico@ximian.com> * gtkfilesystemgnomevfs.c (gtk_file_system_gnome_vfs_get_supports_bookmarks): Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. (gtk_file_system_gnome_vfs_add_bookmark): Implement. (gtk_file_system_gnome_vfs_remove_bookmark): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Replaced the ::set_shortcut_folders() method with :;add_shortcut_folder() and ::remove_shortcut_folder(). * gtkfilechooserutils.c (delegate_add_shortcut_folder): New function. (delegate_remove_shortcut_folder): New function. (delegate_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Insert the Desktop directory as well. (shortcuts_insert_path): Renamed from shortcuts_append_path; now takes a position index instead of a parent node iter. Also takes a GError argument. (struct _GtkFileChooserImplDefault): Removed the shortcuts_folder list. It is all kept in the model now. (shortcuts_append_home): Save whether adding a shortcut for the home directory was successful. (shortcuts_append_desktop): Likewise for the desktop. (shortcuts_append_file_system_roots): Count and save the number of roots added. (shortcuts_append_shortcut_folders): Removed. (gtk_file_chooser_impl_default_add_shortcut_folder): Implement. (shortcuts_append_bookmarks): Now that we don't have a bookmarks parent node, don't expand the tree. (add_bookmark_button_clicked_cb): Use gtk_file_system_add_bookmark(). (remove_bookmark_button_clicked_cb): Use gtk_file_system_remove_bookmark(). (gtk_file_chooser_impl_default_list_shortcut_folders): Get the folders from the shortcuts model; we no longer keep a separate list. * gtkfilesystem.h (struct _GtkFileSystemIface): Oops, there shouldn't be shortcuts-related virtual methods here. * gtkfilechooser.c (file_paths_to_strings): New helper function. (gtk_file_chooser_get_filenames): Use file_paths_to_strings(). (gtk_file_chooser_get_uris): Likewise. (gtk_file_chooser_set_shortcut_folders): Removed. (gtk_file_chooser_list_shortcut_folders): Return a list of strings, not of GtkFilePath*. (gtk_file_chooser_list_shortcut_folder_uris): New function. (gtk_file_chooser_add_shortcut_folder): New function. (gtk_file_chooser_remove_shortcut_folder): New function. (gtk_file_chooser_add_shortcut_folder_uri): New function. (gtk_file_chooser_remove_shortcut_folder_uri): New function. (_gtk_file_chooser_add_shortcut_folder): New function. (_gtk_file_chooser_remove_shortcut_folder): New function. * gtkfilechooser.h: New enum. * gtkfilechooser.c (gtk_file_chooser_error_quark): New function. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): Removed. (gtk_file_system_set_bookmarks): Removed. (gtk_file_system_add_bookmark): New function. (gtk_file_system_remove_bookmark): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Removed. (gtk_file_system_unix_set_bookmarks): Removed. (gtk_file_system_unix_add_bookmark): Just a stub for now. (gtk_file_system_unix_remove_bookmark): Likewise. * testfilechooser.c (main): Add a shortcut for testing purposes.
2003-10-18 04:29:40 +00:00
static gboolean gtk_file_system_unix_add_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
static gboolean gtk_file_system_unix_remove_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error);
static GSList * gtk_file_system_unix_list_bookmarks (GtkFileSystem *file_system);
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
2003-03-21 20:34:02 +00:00
static GType gtk_file_folder_unix_get_type (void);
static void gtk_file_folder_unix_class_init (GtkFileFolderUnixClass *class);
static void gtk_file_folder_unix_iface_init (GtkFileFolderIface *iface);
static void gtk_file_folder_unix_init (GtkFileFolderUnix *impl);
static void gtk_file_folder_unix_finalize (GObject *object);
static GtkFileInfo *gtk_file_folder_unix_get_info (GtkFileFolder *folder,
const GtkFilePath *path,
2003-03-21 20:34:02 +00:00
GError **error);
static gboolean gtk_file_folder_unix_list_children (GtkFileFolder *folder,
GSList **children,
GError **error);
static gchar * filename_from_path (const GtkFilePath *path);
static GtkFilePath *filename_to_path (const gchar *filename);
2003-03-21 20:34:02 +00:00
static gboolean filename_is_root (const char *filename);
static GtkFileInfo *filename_get_info (const gchar *filename,
GtkFileInfoType types,
GError **error);
/*
* GtkFileSystemUnix
*/
GType
gtk_file_system_unix_get_type (void)
2003-03-21 20:34:02 +00:00
{
static GType file_system_unix_type = 0;
if (!file_system_unix_type)
{
static const GTypeInfo file_system_unix_info =
{
sizeof (GtkFileSystemUnixClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_file_system_unix_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkFileSystemUnix),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_file_system_unix_init,
};
2003-03-21 20:34:02 +00:00
static const GInterfaceInfo file_system_info =
{
(GInterfaceInitFunc) gtk_file_system_unix_iface_init, /* interface_init */
NULL, /* interface_finalize */
NULL /* interface_data */
};
file_system_unix_type = g_type_register_static (G_TYPE_OBJECT,
"GtkFileSystemUnix",
&file_system_unix_info, 0);
g_type_add_interface_static (file_system_unix_type,
GTK_TYPE_FILE_SYSTEM,
&file_system_info);
}
return file_system_unix_type;
}
/**
* gtk_file_system_unix_new:
*
* Creates a new #GtkFileSystemUnix object. #GtkFileSystemUnix
* implements the #GtkFileSystem interface with direct access to
* the filesystem using Unix/Linux API calls
*
* Return value: the new #GtkFileSystemUnix object
**/
GtkFileSystem *
gtk_file_system_unix_new (void)
{
return g_object_new (GTK_TYPE_FILE_SYSTEM_UNIX, NULL);
}
2003-03-21 20:34:02 +00:00
static void
gtk_file_system_unix_class_init (GtkFileSystemUnixClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
system_parent_class = g_type_class_peek_parent (class);
2003-03-21 20:34:02 +00:00
gobject_class->finalize = gtk_file_system_unix_finalize;
}
static void
gtk_file_system_unix_iface_init (GtkFileSystemIface *iface)
{
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
iface->list_volumes = gtk_file_system_unix_list_volumes;
iface->get_volume_for_path = gtk_file_system_unix_get_volume_for_path;
2003-03-21 20:34:02 +00:00
iface->get_folder = gtk_file_system_unix_get_folder;
iface->create_folder = gtk_file_system_unix_create_folder;
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
iface->volume_free = gtk_file_system_unix_volume_free;
iface->volume_get_base_path = gtk_file_system_unix_volume_get_base_path;
iface->volume_get_is_mounted = gtk_file_system_unix_volume_get_is_mounted;
iface->volume_mount = gtk_file_system_unix_volume_mount;
iface->volume_get_display_name = gtk_file_system_unix_volume_get_display_name;
iface->volume_render_icon = gtk_file_system_unix_volume_render_icon;
2003-03-21 20:34:02 +00:00
iface->get_parent = gtk_file_system_unix_get_parent;
iface->make_path = gtk_file_system_unix_make_path;
iface->parse = gtk_file_system_unix_parse;
iface->path_to_uri = gtk_file_system_unix_path_to_uri;
iface->path_to_filename = gtk_file_system_unix_path_to_filename;
iface->uri_to_path = gtk_file_system_unix_uri_to_path;
iface->filename_to_path = gtk_file_system_unix_filename_to_path;
iface->render_icon = gtk_file_system_unix_render_icon;
Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. 2003-10-17 Federico Mena Quintero <federico@ximian.com> * gtkfilesystemgnomevfs.c (gtk_file_system_gnome_vfs_get_supports_bookmarks): Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. (gtk_file_system_gnome_vfs_add_bookmark): Implement. (gtk_file_system_gnome_vfs_remove_bookmark): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Replaced the ::set_shortcut_folders() method with :;add_shortcut_folder() and ::remove_shortcut_folder(). * gtkfilechooserutils.c (delegate_add_shortcut_folder): New function. (delegate_remove_shortcut_folder): New function. (delegate_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Insert the Desktop directory as well. (shortcuts_insert_path): Renamed from shortcuts_append_path; now takes a position index instead of a parent node iter. Also takes a GError argument. (struct _GtkFileChooserImplDefault): Removed the shortcuts_folder list. It is all kept in the model now. (shortcuts_append_home): Save whether adding a shortcut for the home directory was successful. (shortcuts_append_desktop): Likewise for the desktop. (shortcuts_append_file_system_roots): Count and save the number of roots added. (shortcuts_append_shortcut_folders): Removed. (gtk_file_chooser_impl_default_add_shortcut_folder): Implement. (shortcuts_append_bookmarks): Now that we don't have a bookmarks parent node, don't expand the tree. (add_bookmark_button_clicked_cb): Use gtk_file_system_add_bookmark(). (remove_bookmark_button_clicked_cb): Use gtk_file_system_remove_bookmark(). (gtk_file_chooser_impl_default_list_shortcut_folders): Get the folders from the shortcuts model; we no longer keep a separate list. * gtkfilesystem.h (struct _GtkFileSystemIface): Oops, there shouldn't be shortcuts-related virtual methods here. * gtkfilechooser.c (file_paths_to_strings): New helper function. (gtk_file_chooser_get_filenames): Use file_paths_to_strings(). (gtk_file_chooser_get_uris): Likewise. (gtk_file_chooser_set_shortcut_folders): Removed. (gtk_file_chooser_list_shortcut_folders): Return a list of strings, not of GtkFilePath*. (gtk_file_chooser_list_shortcut_folder_uris): New function. (gtk_file_chooser_add_shortcut_folder): New function. (gtk_file_chooser_remove_shortcut_folder): New function. (gtk_file_chooser_add_shortcut_folder_uri): New function. (gtk_file_chooser_remove_shortcut_folder_uri): New function. (_gtk_file_chooser_add_shortcut_folder): New function. (_gtk_file_chooser_remove_shortcut_folder): New function. * gtkfilechooser.h: New enum. * gtkfilechooser.c (gtk_file_chooser_error_quark): New function. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): Removed. (gtk_file_system_set_bookmarks): Removed. (gtk_file_system_add_bookmark): New function. (gtk_file_system_remove_bookmark): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Removed. (gtk_file_system_unix_set_bookmarks): Removed. (gtk_file_system_unix_add_bookmark): Just a stub for now. (gtk_file_system_unix_remove_bookmark): Likewise. * testfilechooser.c (main): Add a shortcut for testing purposes.
2003-10-18 04:29:40 +00:00
iface->add_bookmark = gtk_file_system_unix_add_bookmark;
iface->remove_bookmark = gtk_file_system_unix_remove_bookmark;
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
iface->list_bookmarks = gtk_file_system_unix_list_bookmarks;
2003-03-21 20:34:02 +00:00
}
static void
gtk_file_system_unix_init (GtkFileSystemUnix *system_unix)
{
}
static void
gtk_file_system_unix_finalize (GObject *object)
{
system_parent_class->finalize (object);
2003-03-21 20:34:02 +00:00
}
/* Returns our single root volume */
static GtkFileSystemVolume *
get_root_volume (void)
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
{
return (GtkFileSystemVolume *) gtk_file_path_new_dup ("/");
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
}
2003-03-21 20:34:02 +00:00
static GSList *
gtk_file_system_unix_list_volumes (GtkFileSystem *file_system)
2003-03-21 20:34:02 +00:00
{
return g_slist_append (NULL, get_root_volume ());
2003-03-21 20:34:02 +00:00
}
static GtkFileSystemVolume *
gtk_file_system_unix_get_volume_for_path (GtkFileSystem *file_system,
const GtkFilePath *path)
2003-03-21 20:34:02 +00:00
{
return get_root_volume ();
2003-03-21 20:34:02 +00:00
}
static GtkFileFolder *
gtk_file_system_unix_get_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFileInfoType types,
GError **error)
2003-03-21 20:34:02 +00:00
{
GtkFileFolderUnix *folder_unix;
gchar *filename;
filename = filename_from_path (path);
g_return_val_if_fail (filename != NULL, NULL);
2003-03-21 20:34:02 +00:00
folder_unix = g_object_new (GTK_TYPE_FILE_FOLDER_UNIX, NULL);
folder_unix->filename = filename;
folder_unix->types = types;
return GTK_FILE_FOLDER (folder_unix);
}
static gboolean
gtk_file_system_unix_create_folder (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error)
2003-03-21 20:34:02 +00:00
{
gchar *filename;
gboolean result;
filename = filename_from_path (path);
g_return_val_if_fail (filename != NULL, FALSE);
Added a has_editable field. (_gtk_file_system_model_add_editable): New 2004-01-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystemmodel.c (struct _GtkFileSystemModel): Added a has_editable field. (_gtk_file_system_model_add_editable): New function. (_gtk_file_system_model_remove_editable): New function. (gtk_file_system_model_get_value): Return appropriate values for the temporary editable row. (_gtk_file_system_model_get_info): Handle the editable row. (_gtk_file_system_model_get_path): Likewise. * gtk/gtkfilechooserdefault.c (shortcuts_append_bookmarks): Removed an unused variable. (toolbar_button_new): Optionally show the button. (up_button_clicked_cb): Renamed from up_button_cb(), fixed prototype. (toolbar_create): Add a "New Folder" button for Save mode. (error_building_filename_dialog): New helper function. (gtk_file_chooser_default_get_paths): Use error_building_filename_dialog(). (create_file_list): Connect to the "edited" signal of the text cell renderer. Store the name column and text renderer in the impl structure. (renderer_edited_cb): New callback. (gtk_file_chooser_default_set_property): Show/hide the "New folder" button when the save action changes. (COMPARE_DIRECTORIES): Allow the info values to be NULL. (COMPARE_DIRECTORIES): Duh, use the list_model, not the tree_model. (get_list_file_info): Likewise! (list_icon_data_func): Handle the path being NULL. (new_folder_button_clicked): New callback. (list_name_data_func): If we are on the editable row, set the text to "Type name of new folder". (list_selection_changed): Handle the editable row. (list_mtime_data_func): Likewise. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_make_path): Return NULL, not FALSE. (gtk_file_system_unix_create_folder): Test the result of mkdir() correctly.
2004-01-17 04:34:49 +00:00
result = mkdir (filename, 0777) == 0;
2003-03-21 20:34:02 +00:00
if (!result)
{
gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
_("error creating directory '%s': %s"),
2003-03-21 20:34:02 +00:00
filename_utf8 ? filename_utf8 : "???",
g_strerror (errno));
g_free (filename_utf8);
}
2003-03-21 20:34:02 +00:00
g_free (filename);
2003-03-21 20:34:02 +00:00
return result;
}
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
static void
gtk_file_system_unix_volume_free (GtkFileSystem *file_system,
GtkFileSystemVolume *volume)
{
GtkFilePath *path;
path = (GtkFilePath *) volume;
gtk_file_path_free (path);
}
static GtkFilePath *
gtk_file_system_unix_volume_get_base_path (GtkFileSystem *file_system,
GtkFileSystemVolume *volume)
{
return gtk_file_path_new_dup ("/");
}
static gboolean
gtk_file_system_unix_volume_get_is_mounted (GtkFileSystem *file_system,
GtkFileSystemVolume *volume)
{
return TRUE;
}
static gboolean
gtk_file_system_unix_volume_mount (GtkFileSystem *file_system,
Added a "volumes-changed" signal. Added the following methods: 2003-12-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystem.h (struct _GtkFileSystemIface): Added a "volumes-changed" signal. Added the following methods: list_volumes volume_free volume_get_base_path volume_get_is_mounted volume_mount volume_get_display_name volume_render_icon * gtk/gtkfilesystem.c (gtk_file_system_base_init): Create the "volumes-changed" signal. (gtk_file_system_list_volumes): New function. (gtk_file_system_volume_free): New function. (gtk_file_system_volume_get_base_path): New function. (gtk_file_system_volume_get_is_mounted): New function. (gtk_file_system_volume_mount): New function. (gtk_file_system_volume_get_display_name): New function. (gtk_file_system_volume_render_icon): New function. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_volume_free): Implement. (gtk_file_system_unix_volume_get_base_path): Implement. (gtk_file_system_unix_volume_get_is_mounted): Implement. (gtk_file_system_unix_volume_mount): Implement. (gtk_file_system_unix_volume_get_display_name): Implement. (gtk_file_system_unix_volume_render_icon): Implement. * gtk/gtkfilechooserdefault.c (struct _GtkFileChooserDefault): Added a field for the "volumes-changed" signal connection. (gtk_file_chooser_default_set_property): Connect to "volumes-changed" on the file system. (gtk_file_chooser_default_finalize): Disconnect from "volumes-changed". * gtk/gtkfilechooserdefault.c (shortcuts_remove_rows): New helper function. (shortcuts_get_index): New helper function. (shortcuts_insert_path): Can now insert volumes as well as paths. (shortcuts_append_paths): Don't take is_file_system_root. (shortcuts_add_volumes): New function. (shortcuts_append_file_system_roots): Removed. (create_shortcuts_model): Use shortcuts_add_volumes(). (remove_bookmark_button_clicked_cb): Check that the index is within range. (bookmarks_check_add_sensitivity): Take volumes into account. (shortcuts_get_selected_index): New helper function. (remove_bookmark_button_clicked_cb): Use shortcuts_get_selected_index(). (bookmarks_check_remove_sensitivity): Likewise. (shortcuts_select_func): Likewise. (shortcuts_row_activated_cb): Handle volumes as well as normal paths. (shortcuts_activate_volume): New function. (struct _GtkFileChooserDefault): Removed the bookmarks_set and bookmarks_iter fields. (shortcuts_append_bookmarks): Use shortcuts_remove_rows(). (bookmarks_changed_cb): Use shortcuts_add_bookmarks(). (remove_bookmark_rows): Removed. (shortcuts_add_bookmarks): New function; moved most of the code over from shortcuts_append_bookmarks(). (shortcuts_append_bookmarks): Add the separator node here, and then call shortcuts_add_bookmarks().
2003-12-17 05:55:16 +00:00
GtkFileSystemVolume *volume,
GError **error)
{
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_FAILED,
_("This file system does not support mounting"));
return FALSE;
}
static gchar *
gtk_file_system_unix_volume_get_display_name (GtkFileSystem *file_system,
GtkFileSystemVolume *volume)
{
return g_strdup (_("Filesystem")); /* Same as Nautilus */
}
static GdkPixbuf *
gtk_file_system_unix_volume_render_icon (GtkFileSystem *file_system,
GtkFileSystemVolume *volume,
GtkWidget *widget,
gint pixel_size,
GError **error)
{
return NULL; /* FIXME: We need a hard disk icon or something */
}
2003-03-21 20:34:02 +00:00
static gboolean
gtk_file_system_unix_get_parent (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkFilePath **parent,
GError **error)
2003-03-21 20:34:02 +00:00
{
gchar *filename = filename_from_path (path);
g_return_val_if_fail (filename != NULL, FALSE);
2003-03-21 20:34:02 +00:00
if (filename_is_root (filename))
{
*parent = NULL;
}
else
{
gchar *parent_filename = g_path_get_dirname (filename);
*parent = filename_to_path (parent_filename);
2003-03-21 20:34:02 +00:00
g_free (parent_filename);
}
g_free (filename);
return TRUE;
}
static GtkFilePath *
gtk_file_system_unix_make_path (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *display_name,
GError **error)
2003-03-21 20:34:02 +00:00
{
gchar *base_filename;
gchar *filename;
gchar *full_filename;
GError *tmp_error = NULL;
GtkFilePath *result;
base_filename = filename_from_path (base_path);
g_return_val_if_fail (base_filename != NULL, NULL);
2003-03-21 20:34:02 +00:00
filename = g_filename_from_utf8 (display_name, -1, NULL, NULL, &tmp_error);
if (!filename)
{
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
"%s",
tmp_error->message);
2003-03-21 20:34:02 +00:00
g_error_free (tmp_error);
g_free (base_filename);
Added a has_editable field. (_gtk_file_system_model_add_editable): New 2004-01-16 Federico Mena Quintero <federico@ximian.com> * gtk/gtkfilesystemmodel.c (struct _GtkFileSystemModel): Added a has_editable field. (_gtk_file_system_model_add_editable): New function. (_gtk_file_system_model_remove_editable): New function. (gtk_file_system_model_get_value): Return appropriate values for the temporary editable row. (_gtk_file_system_model_get_info): Handle the editable row. (_gtk_file_system_model_get_path): Likewise. * gtk/gtkfilechooserdefault.c (shortcuts_append_bookmarks): Removed an unused variable. (toolbar_button_new): Optionally show the button. (up_button_clicked_cb): Renamed from up_button_cb(), fixed prototype. (toolbar_create): Add a "New Folder" button for Save mode. (error_building_filename_dialog): New helper function. (gtk_file_chooser_default_get_paths): Use error_building_filename_dialog(). (create_file_list): Connect to the "edited" signal of the text cell renderer. Store the name column and text renderer in the impl structure. (renderer_edited_cb): New callback. (gtk_file_chooser_default_set_property): Show/hide the "New folder" button when the save action changes. (COMPARE_DIRECTORIES): Allow the info values to be NULL. (COMPARE_DIRECTORIES): Duh, use the list_model, not the tree_model. (get_list_file_info): Likewise! (list_icon_data_func): Handle the path being NULL. (new_folder_button_clicked): New callback. (list_name_data_func): If we are on the editable row, set the text to "Type name of new folder". (list_selection_changed): Handle the editable row. (list_mtime_data_func): Likewise. * gtk/gtkfilesystemunix.c (gtk_file_system_unix_make_path): Return NULL, not FALSE. (gtk_file_system_unix_create_folder): Test the result of mkdir() correctly.
2004-01-17 04:34:49 +00:00
return NULL;
2003-03-21 20:34:02 +00:00
}
2003-03-21 20:34:02 +00:00
full_filename = g_build_filename (base_filename, filename, NULL);
result = filename_to_path (full_filename);
2003-03-21 20:34:02 +00:00
g_free (base_filename);
g_free (filename);
g_free (full_filename);
return result;
}
/* If this was a publically exported function, it should return
* a dup'ed result, but we make it modify-in-place for efficiency
* here, and because it works for us.
*/
static void
canonicalize_filename (gchar *filename)
{
gchar *p, *q;
gboolean last_was_slash = FALSE;
p = filename;
q = filename;
while (*p)
{
if (*p == G_DIR_SEPARATOR)
{
if (!last_was_slash)
*q++ = G_DIR_SEPARATOR;
last_was_slash = TRUE;
}
else
{
if (last_was_slash && *p == '.')
{
if (*(p + 1) == G_DIR_SEPARATOR ||
*(p + 1) == '\0')
{
if (*(p + 1) == '\0')
break;
p += 1;
}
else if (*(p + 1) == '.' &&
(*(p + 2) == G_DIR_SEPARATOR ||
*(p + 2) == '\0'))
{
if (q > filename + 1)
{
q--;
while (q > filename + 1 &&
*(q - 1) != G_DIR_SEPARATOR)
q--;
}
if (*(p + 2) == '\0')
break;
p += 2;
}
else
{
*q++ = *p;
last_was_slash = FALSE;
}
}
else
{
*q++ = *p;
last_was_slash = FALSE;
}
}
p++;
}
if (q > filename + 1 && *(q - 1) == G_DIR_SEPARATOR)
q--;
*q = '\0';
}
static gboolean
gtk_file_system_unix_parse (GtkFileSystem *file_system,
const GtkFilePath *base_path,
const gchar *str,
GtkFilePath **folder,
gchar **file_part,
GError **error)
{
char *base_filename;
gchar *last_slash;
gboolean result = FALSE;
base_filename = filename_from_path (base_path);
g_return_val_if_fail (base_filename != NULL, FALSE);
last_slash = strrchr (str, G_DIR_SEPARATOR);
if (!last_slash)
{
*folder = gtk_file_path_copy (base_path);
*file_part = g_strdup (str);
result = TRUE;
}
else
{
gchar *folder_part;
gchar *folder_path;
GError *tmp_error = NULL;
if (last_slash == str)
folder_part = g_strdup ("/");
else
folder_part = g_filename_from_utf8 (str, last_slash - str,
NULL, NULL, &tmp_error);
if (!folder_part)
{
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_BAD_FILENAME,
"%s",
tmp_error->message);
g_error_free (tmp_error);
}
else
{
if (folder_part[0] == G_DIR_SEPARATOR)
folder_path = folder_part;
else
{
folder_path = g_build_filename (base_filename, folder_part, NULL);
g_free (folder_part);
}
canonicalize_filename (folder_path);
*folder = filename_to_path (folder_path);
*file_part = g_strdup (last_slash + 1);
g_free (folder_path);
result = TRUE;
}
}
g_free (base_filename);
2003-03-21 20:34:02 +00:00
return result;
}
static gchar *
gtk_file_system_unix_path_to_uri (GtkFileSystem *file_system,
const GtkFilePath *path)
{
return g_filename_to_uri (gtk_file_path_get_string (path), NULL, NULL);
}
static gchar *
gtk_file_system_unix_path_to_filename (GtkFileSystem *file_system,
const GtkFilePath *path)
{
return g_strdup (gtk_file_path_get_string (path));
}
static GtkFilePath *
gtk_file_system_unix_uri_to_path (GtkFileSystem *file_system,
const gchar *uri)
{
gchar *filename = g_filename_from_uri (uri, NULL, NULL);
if (filename)
return gtk_file_path_new_steal (filename);
else
return NULL;
}
static GtkFilePath *
gtk_file_system_unix_filename_to_path (GtkFileSystem *file_system,
const gchar *filename)
{
return gtk_file_path_new_dup (filename);
}
static GdkPixbuf *
gtk_file_system_unix_render_icon (GtkFileSystem *file_system,
const GtkFilePath *path,
GtkWidget *widget,
gint pixel_size,
GError **error)
{
/* FIXME: Implement this */
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_FAILED,
_("This file system does not support icons"));
return NULL;
}
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
static gboolean
Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. 2003-10-17 Federico Mena Quintero <federico@ximian.com> * gtkfilesystemgnomevfs.c (gtk_file_system_gnome_vfs_get_supports_bookmarks): Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. (gtk_file_system_gnome_vfs_add_bookmark): Implement. (gtk_file_system_gnome_vfs_remove_bookmark): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Replaced the ::set_shortcut_folders() method with :;add_shortcut_folder() and ::remove_shortcut_folder(). * gtkfilechooserutils.c (delegate_add_shortcut_folder): New function. (delegate_remove_shortcut_folder): New function. (delegate_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Insert the Desktop directory as well. (shortcuts_insert_path): Renamed from shortcuts_append_path; now takes a position index instead of a parent node iter. Also takes a GError argument. (struct _GtkFileChooserImplDefault): Removed the shortcuts_folder list. It is all kept in the model now. (shortcuts_append_home): Save whether adding a shortcut for the home directory was successful. (shortcuts_append_desktop): Likewise for the desktop. (shortcuts_append_file_system_roots): Count and save the number of roots added. (shortcuts_append_shortcut_folders): Removed. (gtk_file_chooser_impl_default_add_shortcut_folder): Implement. (shortcuts_append_bookmarks): Now that we don't have a bookmarks parent node, don't expand the tree. (add_bookmark_button_clicked_cb): Use gtk_file_system_add_bookmark(). (remove_bookmark_button_clicked_cb): Use gtk_file_system_remove_bookmark(). (gtk_file_chooser_impl_default_list_shortcut_folders): Get the folders from the shortcuts model; we no longer keep a separate list. * gtkfilesystem.h (struct _GtkFileSystemIface): Oops, there shouldn't be shortcuts-related virtual methods here. * gtkfilechooser.c (file_paths_to_strings): New helper function. (gtk_file_chooser_get_filenames): Use file_paths_to_strings(). (gtk_file_chooser_get_uris): Likewise. (gtk_file_chooser_set_shortcut_folders): Removed. (gtk_file_chooser_list_shortcut_folders): Return a list of strings, not of GtkFilePath*. (gtk_file_chooser_list_shortcut_folder_uris): New function. (gtk_file_chooser_add_shortcut_folder): New function. (gtk_file_chooser_remove_shortcut_folder): New function. (gtk_file_chooser_add_shortcut_folder_uri): New function. (gtk_file_chooser_remove_shortcut_folder_uri): New function. (_gtk_file_chooser_add_shortcut_folder): New function. (_gtk_file_chooser_remove_shortcut_folder): New function. * gtkfilechooser.h: New enum. * gtkfilechooser.c (gtk_file_chooser_error_quark): New function. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): Removed. (gtk_file_system_set_bookmarks): Removed. (gtk_file_system_add_bookmark): New function. (gtk_file_system_remove_bookmark): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Removed. (gtk_file_system_unix_set_bookmarks): Removed. (gtk_file_system_unix_add_bookmark): Just a stub for now. (gtk_file_system_unix_remove_bookmark): Likewise. * testfilechooser.c (main): Add a shortcut for testing purposes.
2003-10-18 04:29:40 +00:00
gtk_file_system_unix_add_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error)
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
{
/* FIXME: Implement as a really simple ~/.gtk-bookmarks */
Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. 2003-10-17 Federico Mena Quintero <federico@ximian.com> * gtkfilesystemgnomevfs.c (gtk_file_system_gnome_vfs_get_supports_bookmarks): Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. (gtk_file_system_gnome_vfs_add_bookmark): Implement. (gtk_file_system_gnome_vfs_remove_bookmark): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Replaced the ::set_shortcut_folders() method with :;add_shortcut_folder() and ::remove_shortcut_folder(). * gtkfilechooserutils.c (delegate_add_shortcut_folder): New function. (delegate_remove_shortcut_folder): New function. (delegate_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Insert the Desktop directory as well. (shortcuts_insert_path): Renamed from shortcuts_append_path; now takes a position index instead of a parent node iter. Also takes a GError argument. (struct _GtkFileChooserImplDefault): Removed the shortcuts_folder list. It is all kept in the model now. (shortcuts_append_home): Save whether adding a shortcut for the home directory was successful. (shortcuts_append_desktop): Likewise for the desktop. (shortcuts_append_file_system_roots): Count and save the number of roots added. (shortcuts_append_shortcut_folders): Removed. (gtk_file_chooser_impl_default_add_shortcut_folder): Implement. (shortcuts_append_bookmarks): Now that we don't have a bookmarks parent node, don't expand the tree. (add_bookmark_button_clicked_cb): Use gtk_file_system_add_bookmark(). (remove_bookmark_button_clicked_cb): Use gtk_file_system_remove_bookmark(). (gtk_file_chooser_impl_default_list_shortcut_folders): Get the folders from the shortcuts model; we no longer keep a separate list. * gtkfilesystem.h (struct _GtkFileSystemIface): Oops, there shouldn't be shortcuts-related virtual methods here. * gtkfilechooser.c (file_paths_to_strings): New helper function. (gtk_file_chooser_get_filenames): Use file_paths_to_strings(). (gtk_file_chooser_get_uris): Likewise. (gtk_file_chooser_set_shortcut_folders): Removed. (gtk_file_chooser_list_shortcut_folders): Return a list of strings, not of GtkFilePath*. (gtk_file_chooser_list_shortcut_folder_uris): New function. (gtk_file_chooser_add_shortcut_folder): New function. (gtk_file_chooser_remove_shortcut_folder): New function. (gtk_file_chooser_add_shortcut_folder_uri): New function. (gtk_file_chooser_remove_shortcut_folder_uri): New function. (_gtk_file_chooser_add_shortcut_folder): New function. (_gtk_file_chooser_remove_shortcut_folder): New function. * gtkfilechooser.h: New enum. * gtkfilechooser.c (gtk_file_chooser_error_quark): New function. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): Removed. (gtk_file_system_set_bookmarks): Removed. (gtk_file_system_add_bookmark): New function. (gtk_file_system_remove_bookmark): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Removed. (gtk_file_system_unix_set_bookmarks): Removed. (gtk_file_system_unix_add_bookmark): Just a stub for now. (gtk_file_system_unix_remove_bookmark): Likewise. * testfilechooser.c (main): Add a shortcut for testing purposes.
2003-10-18 04:29:40 +00:00
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_FAILED,
_("This file system does not support bookmarks"));
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
return FALSE;
}
Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. 2003-10-17 Federico Mena Quintero <federico@ximian.com> * gtkfilesystemgnomevfs.c (gtk_file_system_gnome_vfs_get_supports_bookmarks): Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. (gtk_file_system_gnome_vfs_add_bookmark): Implement. (gtk_file_system_gnome_vfs_remove_bookmark): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Replaced the ::set_shortcut_folders() method with :;add_shortcut_folder() and ::remove_shortcut_folder(). * gtkfilechooserutils.c (delegate_add_shortcut_folder): New function. (delegate_remove_shortcut_folder): New function. (delegate_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Insert the Desktop directory as well. (shortcuts_insert_path): Renamed from shortcuts_append_path; now takes a position index instead of a parent node iter. Also takes a GError argument. (struct _GtkFileChooserImplDefault): Removed the shortcuts_folder list. It is all kept in the model now. (shortcuts_append_home): Save whether adding a shortcut for the home directory was successful. (shortcuts_append_desktop): Likewise for the desktop. (shortcuts_append_file_system_roots): Count and save the number of roots added. (shortcuts_append_shortcut_folders): Removed. (gtk_file_chooser_impl_default_add_shortcut_folder): Implement. (shortcuts_append_bookmarks): Now that we don't have a bookmarks parent node, don't expand the tree. (add_bookmark_button_clicked_cb): Use gtk_file_system_add_bookmark(). (remove_bookmark_button_clicked_cb): Use gtk_file_system_remove_bookmark(). (gtk_file_chooser_impl_default_list_shortcut_folders): Get the folders from the shortcuts model; we no longer keep a separate list. * gtkfilesystem.h (struct _GtkFileSystemIface): Oops, there shouldn't be shortcuts-related virtual methods here. * gtkfilechooser.c (file_paths_to_strings): New helper function. (gtk_file_chooser_get_filenames): Use file_paths_to_strings(). (gtk_file_chooser_get_uris): Likewise. (gtk_file_chooser_set_shortcut_folders): Removed. (gtk_file_chooser_list_shortcut_folders): Return a list of strings, not of GtkFilePath*. (gtk_file_chooser_list_shortcut_folder_uris): New function. (gtk_file_chooser_add_shortcut_folder): New function. (gtk_file_chooser_remove_shortcut_folder): New function. (gtk_file_chooser_add_shortcut_folder_uri): New function. (gtk_file_chooser_remove_shortcut_folder_uri): New function. (_gtk_file_chooser_add_shortcut_folder): New function. (_gtk_file_chooser_remove_shortcut_folder): New function. * gtkfilechooser.h: New enum. * gtkfilechooser.c (gtk_file_chooser_error_quark): New function. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): Removed. (gtk_file_system_set_bookmarks): Removed. (gtk_file_system_add_bookmark): New function. (gtk_file_system_remove_bookmark): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Removed. (gtk_file_system_unix_set_bookmarks): Removed. (gtk_file_system_unix_add_bookmark): Just a stub for now. (gtk_file_system_unix_remove_bookmark): Likewise. * testfilechooser.c (main): Add a shortcut for testing purposes.
2003-10-18 04:29:40 +00:00
static gboolean
gtk_file_system_unix_remove_bookmark (GtkFileSystem *file_system,
const GtkFilePath *path,
GError **error)
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
{
/* FIXME: Implement as a really simple ~/.gtk-bookmarks */
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_FAILED,
_("This file system does not support bookmarks"));
Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. 2003-10-17 Federico Mena Quintero <federico@ximian.com> * gtkfilesystemgnomevfs.c (gtk_file_system_gnome_vfs_get_supports_bookmarks): Removed. (gtk_file_system_gnome_vfs_set_bookmarks): Removed. (gtk_file_system_gnome_vfs_add_bookmark): Implement. (gtk_file_system_gnome_vfs_remove_bookmark): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Replaced the ::set_shortcut_folders() method with :;add_shortcut_folder() and ::remove_shortcut_folder(). * gtkfilechooserutils.c (delegate_add_shortcut_folder): New function. (delegate_remove_shortcut_folder): New function. (delegate_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Insert the Desktop directory as well. (shortcuts_insert_path): Renamed from shortcuts_append_path; now takes a position index instead of a parent node iter. Also takes a GError argument. (struct _GtkFileChooserImplDefault): Removed the shortcuts_folder list. It is all kept in the model now. (shortcuts_append_home): Save whether adding a shortcut for the home directory was successful. (shortcuts_append_desktop): Likewise for the desktop. (shortcuts_append_file_system_roots): Count and save the number of roots added. (shortcuts_append_shortcut_folders): Removed. (gtk_file_chooser_impl_default_add_shortcut_folder): Implement. (shortcuts_append_bookmarks): Now that we don't have a bookmarks parent node, don't expand the tree. (add_bookmark_button_clicked_cb): Use gtk_file_system_add_bookmark(). (remove_bookmark_button_clicked_cb): Use gtk_file_system_remove_bookmark(). (gtk_file_chooser_impl_default_list_shortcut_folders): Get the folders from the shortcuts model; we no longer keep a separate list. * gtkfilesystem.h (struct _GtkFileSystemIface): Oops, there shouldn't be shortcuts-related virtual methods here. * gtkfilechooser.c (file_paths_to_strings): New helper function. (gtk_file_chooser_get_filenames): Use file_paths_to_strings(). (gtk_file_chooser_get_uris): Likewise. (gtk_file_chooser_set_shortcut_folders): Removed. (gtk_file_chooser_list_shortcut_folders): Return a list of strings, not of GtkFilePath*. (gtk_file_chooser_list_shortcut_folder_uris): New function. (gtk_file_chooser_add_shortcut_folder): New function. (gtk_file_chooser_remove_shortcut_folder): New function. (gtk_file_chooser_add_shortcut_folder_uri): New function. (gtk_file_chooser_remove_shortcut_folder_uri): New function. (_gtk_file_chooser_add_shortcut_folder): New function. (_gtk_file_chooser_remove_shortcut_folder): New function. * gtkfilechooser.h: New enum. * gtkfilechooser.c (gtk_file_chooser_error_quark): New function. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): Removed. (gtk_file_system_set_bookmarks): Removed. (gtk_file_system_add_bookmark): New function. (gtk_file_system_remove_bookmark): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Removed. (gtk_file_system_unix_set_bookmarks): Removed. (gtk_file_system_unix_add_bookmark): Just a stub for now. (gtk_file_system_unix_remove_bookmark): Likewise. * testfilechooser.c (main): Add a shortcut for testing purposes.
2003-10-18 04:29:40 +00:00
return FALSE;
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
}
static GSList *
gtk_file_system_unix_list_bookmarks (GtkFileSystem *file_system)
{
/* FIXME: Implement as a really simple ~/.gtk-bookmarks */
Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), 2003-10-07 Federico Mena Quintero <federico@ximian.com> * gtkfilesystem.h (struct _GtkFileSystemIface): Added methods for ::get_supports_bookmarks(), ::set_bookmarks(), ::list_bookmarks(). Added a ::bookmarks_changed() signal. * gtkfilesystem.c (gtk_file_system_get_supports_bookmarks): New function. (gtk_file_system_set_bookmarks): New function. (gtk_file_system_list_bookmarks): New function. (gtk_file_system_base_init): Create the "bookmarks-changed" signal. (gtk_file_paths_copy): New function. * gtkfilesystemunix.c (gtk_file_system_unix_get_supports_bookmarks): Implement. (gtk_file_system_unix_set_bookmarks): Implement. (gtk_file_system_unix_get_bookmarks): Implement. * gtkfilesystemgnomevfs.c (struct _GtkFileSystemGnomeVFS): Added fields for the bookmarks and the GConfClient. (gtk_file_system_gnome_vfs_set_bookmarks): Implement. (gtk_file_system_gnome_vfs_list_bookmarks): Implement. * gtkfilechooserprivate.h (struct _GtkFileChooserIface): Added methods for ::set_shortcut_folders(), ::list_shortcut_folders(). * gtkfilechooser.c (gtk_file_chooser_set_shortcut_folders): New function. (gtk_file_chooser_list_shortcut_folders): New function. * gtkfilechooserimpldefault.c (create_shortcuts_model): Unref the old shortcuts model if it exists. Create the nodes for the app-specific shortcut folders. (struct _GtkFileChooserImplDefault): Added a field for the shortcut_folders. (gtk_file_chooser_impl_default_set_shortcut_folders): Implement. (select_shortcuts_folder): New helper function. (gtk_file_chooser_impl_default_set_current_folder): Use select_shortcuts_folder(). (shortcuts_append_path): Get the file info here, instead of the caller. (shortcuts_append_home): Use shortcuts_append_path(). (shortcuts_append_file_system_roots): Likewise. (create_shortcuts_model): Add the app-specific shortcut folders and the bookmarks. (gtk_file_chooser_impl_default_list_shortcut_folders): Implement. (create_shortcuts_tree): Added a button to let the user add the current folder to the bookmarks. (gtk_file_chooser_impl_default_set_property): Connect to "bookmarks-changed" on the file system. (shortcuts_append_bookmarks): New function. * configure.ac: Depend on GConf.
2003-10-08 04:14:55 +00:00
return NULL;
}
2003-03-21 20:34:02 +00:00
/*
* GtkFileFolderUnix
*/
static GType
gtk_file_folder_unix_get_type (void)
{
static GType file_folder_unix_type = 0;
if (!file_folder_unix_type)
{
static const GTypeInfo file_folder_unix_info =
{
sizeof (GtkFileFolderUnixClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_file_folder_unix_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkFileFolderUnix),
0, /* n_preallocs */
(GInstanceInitFunc) gtk_file_folder_unix_init,
};
2003-03-21 20:34:02 +00:00
static const GInterfaceInfo file_folder_info =
{
(GInterfaceInitFunc) gtk_file_folder_unix_iface_init, /* interface_init */
NULL, /* interface_finalize */
NULL /* interface_data */
};
file_folder_unix_type = g_type_register_static (G_TYPE_OBJECT,
"GtkFileFolderUnix",
&file_folder_unix_info, 0);
g_type_add_interface_static (file_folder_unix_type,
GTK_TYPE_FILE_FOLDER,
&file_folder_info);
}
return file_folder_unix_type;
}
static void
gtk_file_folder_unix_class_init (GtkFileFolderUnixClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
folder_parent_class = g_type_class_peek_parent (class);
2003-03-21 20:34:02 +00:00
gobject_class->finalize = gtk_file_folder_unix_finalize;
}
static void
gtk_file_folder_unix_iface_init (GtkFileFolderIface *iface)
{
iface->get_info = gtk_file_folder_unix_get_info;
iface->list_children = gtk_file_folder_unix_list_children;
}
static void
gtk_file_folder_unix_init (GtkFileFolderUnix *impl)
{
}
static void
gtk_file_folder_unix_finalize (GObject *object)
{
GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (object);
g_free (folder_unix->filename);
folder_parent_class->finalize (object);
2003-03-21 20:34:02 +00:00
}
static GtkFileInfo *
gtk_file_folder_unix_get_info (GtkFileFolder *folder,
const GtkFilePath *path,
2003-03-21 20:34:02 +00:00
GError **error)
{
GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (folder);
GtkFileInfo *info;
gchar *dirname;
gchar *filename;
filename = filename_from_path (path);
g_return_val_if_fail (filename != NULL, NULL);
2003-03-21 20:34:02 +00:00
dirname = g_path_get_dirname (filename);
g_return_val_if_fail (strcmp (dirname, folder_unix->filename) == 0, NULL);
g_free (dirname);
info = filename_get_info (filename, folder_unix->types, error);
g_free (filename);
return info;
}
static gboolean
gtk_file_folder_unix_list_children (GtkFileFolder *folder,
GSList **children,
GError **error)
{
GtkFileFolderUnix *folder_unix = GTK_FILE_FOLDER_UNIX (folder);
GError *tmp_error = NULL;
GDir *dir;
*children = NULL;
dir = g_dir_open (folder_unix->filename, 0, &tmp_error);
if (!dir)
{
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
2003-03-21 20:34:02 +00:00
"%s",
tmp_error->message);
2003-03-21 20:34:02 +00:00
g_error_free (tmp_error);
return FALSE;
}
while (TRUE)
{
const gchar *filename = g_dir_read_name (dir);
gchar *fullname;
if (!filename)
break;
fullname = g_build_filename (folder_unix->filename, filename, NULL);
*children = g_slist_prepend (*children, filename_to_path (fullname));
2003-03-21 20:34:02 +00:00
g_free (fullname);
}
g_dir_close (dir);
*children = g_slist_reverse (*children);
2003-03-21 20:34:02 +00:00
return TRUE;
}
static GtkFileInfo *
filename_get_info (const gchar *filename,
GtkFileInfoType types,
GError **error)
{
GtkFileInfo *info;
#if 0
GtkFileIconType icon_type = GTK_FILE_ICON_REGULAR;
#endif
2003-03-21 20:34:02 +00:00
struct stat statbuf;
2003-03-21 20:34:02 +00:00
/* If stat fails, try to fall back to lstat to catch broken links
*/
if (stat (filename, &statbuf) != 0 &&
lstat (filename, &statbuf) != 0)
{
gchar *filename_utf8 = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
g_set_error (error,
GTK_FILE_SYSTEM_ERROR,
GTK_FILE_SYSTEM_ERROR_NONEXISTENT,
_("error getting information for '%s': %s"),
2003-03-21 20:34:02 +00:00
filename_utf8 ? filename_utf8 : "???",
g_strerror (errno));
g_free (filename_utf8);
2003-03-21 20:34:02 +00:00
return NULL;
}
info = gtk_file_info_new ();
if (filename_is_root (filename))
{
if (types & GTK_FILE_INFO_DISPLAY_NAME)
gtk_file_info_set_display_name (info, "/");
2003-03-21 20:34:02 +00:00
if (types & GTK_FILE_INFO_IS_HIDDEN)
gtk_file_info_set_is_hidden (info, FALSE);
}
else
{
gchar *basename = g_path_get_basename (filename);
2003-03-21 20:34:02 +00:00
if (types & GTK_FILE_INFO_DISPLAY_NAME)
{
gchar *display_name = g_filename_to_utf8 (basename, -1, NULL, NULL, NULL);
if (!display_name)
display_name = g_strescape (basename, NULL);
2003-03-21 20:34:02 +00:00
gtk_file_info_set_display_name (info, display_name);
2003-03-21 20:34:02 +00:00
g_free (display_name);
}
2003-03-21 20:34:02 +00:00
if (types & GTK_FILE_INFO_IS_HIDDEN)
{
gtk_file_info_set_is_hidden (info, basename[0] == '.');
}
g_free (basename);
}
if (types & GTK_FILE_INFO_IS_FOLDER)
{
gtk_file_info_set_is_folder (info, S_ISDIR (statbuf.st_mode));
}
#if 0
if (types & GTK_FILE_INFO_ICON)
{
if (S_ISBLK (statbuf.st_mode))
icon_type = GTK_FILE_ICON_BLOCK_DEVICE;
else if (S_ISLNK (statbuf.st_mode))
icon_type = GTK_FILE_ICON_BROKEN_SYMBOLIC_LINK;
else if (S_ISCHR (statbuf.st_mode))
icon_type = GTK_FILE_ICON_CHARACTER_DEVICE;
else if (S_ISDIR (statbuf.st_mode))
icon_type = GTK_FILE_ICON_DIRECTORY;
else if (S_ISFIFO (statbuf.st_mode))
icon_type = GTK_FILE_ICON_FIFO;
else if (S_ISSOCK (statbuf.st_mode))
icon_type = GTK_FILE_ICON_SOCKET;
gtk_file_info_set_icon_type (info, icon_type);
}
if ((types & GTK_FILE_INFO_MIME_TYPE) ||
((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR))
#else
if (types & GTK_FILE_INFO_MIME_TYPE)
#endif
2003-03-21 20:34:02 +00:00
{
const char *mime_type = xdg_mime_get_mime_type_for_file (filename);
gtk_file_info_set_mime_type (info, mime_type);
#if 0
if ((types & GTK_FILE_INFO_ICON) && icon_type == GTK_FILE_ICON_REGULAR &&
(statbuf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) &&
(strcmp (mime_type, XDG_MIME_TYPE_UNKNOWN) == 0 ||
strcmp (mime_type, "application/x-executable") == 0 ||
strcmp (mime_type, "application/x-shellscript") == 0))
gtk_file_info_set_icon_type (info, GTK_FILE_ICON_EXECUTABLE);
#endif
2003-03-21 20:34:02 +00:00
}
if (types & GTK_FILE_INFO_MODIFICATION_TIME)
{
gtk_file_info_set_modification_time (info, statbuf.st_mtime);
}
if (types & GTK_FILE_INFO_SIZE)
{
gtk_file_info_set_size (info, (gint64)statbuf.st_size);
2003-03-21 20:34:02 +00:00
}
2003-03-21 20:34:02 +00:00
return info;
}
static gchar *
filename_from_path (const GtkFilePath *path)
2003-03-21 20:34:02 +00:00
{
return g_strdup (gtk_file_path_get_string (path));
2003-03-21 20:34:02 +00:00
}
static GtkFilePath *
filename_to_path (const char *filename)
2003-03-21 20:34:02 +00:00
{
return gtk_file_path_new_dup (filename);
2003-03-21 20:34:02 +00:00
}
static gboolean
filename_is_root (const char *filename)
{
const gchar *after_root;
2003-03-21 20:34:02 +00:00
after_root = g_path_skip_root (filename);
return (after_root != NULL && *after_root == '\0');
2003-03-21 20:34:02 +00:00
}