summaryrefslogtreecommitdiff
path: root/gtk/gtkfilesystem.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2003-12-17 05:55:16 +0000
committerFederico Mena Quintero <federico@src.gnome.org>2003-12-17 05:55:16 +0000
commit8baf8571b52f21c0012420669483f4769cfa13ca (patch)
tree56b9ae2e89c29cd6647295ec52ef4cfc327f0487 /gtk/gtkfilesystem.c
parent6b80f394a59244ab7a2e04fa6649728743469702 (diff)
downloadgtk+-8baf8571b52f21c0012420669483f4769cfa13ca.tar.gz
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().
Diffstat (limited to 'gtk/gtkfilesystem.c')
-rw-r--r--gtk/gtkfilesystem.c153
1 files changed, 152 insertions, 1 deletions
diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c
index c927029d06..691941b42a 100644
--- a/gtk/gtkfilesystem.c
+++ b/gtk/gtkfilesystem.c
@@ -447,6 +447,13 @@ gtk_file_system_base_init (gpointer g_class)
{
GType iface_type = G_TYPE_FROM_INTERFACE (g_class);
+ g_signal_new ("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 ("roots-changed",
iface_type,
G_SIGNAL_RUN_LAST,
@@ -467,6 +474,14 @@ gtk_file_system_base_init (gpointer g_class)
}
GSList *
+gtk_file_system_list_volumes (GtkFileSystem *file_system)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->list_volumes (file_system);
+}
+
+GSList *
gtk_file_system_list_roots (GtkFileSystem *file_system)
{
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
@@ -513,6 +528,142 @@ gtk_file_system_create_folder(GtkFileSystem *file_system,
}
/**
+ * gtk_file_system_volume_free:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ *
+ * Frees a #GtkFileSystemVolume structure as returned by
+ * gtk_file_system_list_volumes().
+ **/
+void
+gtk_file_system_volume_free (GtkFileSystem *file_system,
+ GtkFileSystemVolume *volume)
+{
+ g_return_if_fail (GTK_IS_FILE_SYSTEM (file_system));
+ g_return_if_fail (volume != NULL);
+
+ GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_free (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_get_base_path:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ *
+ * Queries the base path for a volume. For example, a CD-ROM device may yield a
+ * path of "/mnt/cdrom".
+ *
+ * Return value: a #GtkFilePath with the base mount path of the specified
+ * @volume.
+ **/
+GtkFilePath *
+gtk_file_system_volume_get_base_path (GtkFileSystem *file_system,
+ GtkFileSystemVolume *volume)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+ g_return_val_if_fail (volume != NULL, NULL);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_base_path (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_get_is_mounted:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ *
+ * Queries whether a #GtkFileSystemVolume is mounted or not. If it is not, it
+ * can be mounted with gtk_file_system_volume_mount().
+ *
+ * Return value: TRUE if the @volume is mounted, FALSE otherwise.
+ **/
+gboolean
+gtk_file_system_volume_get_is_mounted (GtkFileSystem *file_system,
+ GtkFileSystemVolume *volume)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+ g_return_val_if_fail (volume != NULL, FALSE);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_is_mounted (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_mount:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * @error: location to store error, or %NULL
+ *
+ * Tries to mount an unmounted volume. This may cause the "volumes-changed"
+ * signal in the @file_system to be emitted.
+ *
+ * Return value: TRUE if the @volume was mounted successfully, FALSE otherwise.
+ **/
+gboolean
+gtk_file_system_volume_mount (GtkFileSystem *file_system,
+ GtkFileSystemVolume *volume,
+ GError **error)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), FALSE);
+ g_return_val_if_fail (volume != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_mount (file_system, volume, error);
+}
+
+/**
+ * gtk_file_system_volume_get_display_name:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ *
+ * Queries the human-readable name for a @volume. This string can be displayed
+ * in a list of volumes that can be accessed, for example.
+ *
+ * Return value: A string with the human-readable name for a #GtkFileSystemVolume.
+ **/
+char *
+gtk_file_system_volume_get_display_name (GtkFileSystem *file_system,
+ GtkFileSystemVolume *volume)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+ g_return_val_if_fail (volume != NULL, NULL);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_get_display_name (file_system, volume);
+}
+
+/**
+ * gtk_file_system_volume_render_icon:
+ * @file_system: a #GtkFileSystem
+ * @volume: a #GtkFileSystemVolume
+ * @widget: Reference widget to render icons.
+ * @pixel_size: Size of the icon.
+ * @error: location to store error, or %NULL
+ *
+ * Renders an icon suitable for a file #GtkFileSystemVolume.
+ *
+ * Return value: A #GdkPixbuf containing an icon, or NULL if the icon could not
+ * be rendered. In the latter case, the @error value will be set as
+ * appropriate.
+ **/
+GdkPixbuf *
+gtk_file_system_volume_render_icon (GtkFileSystem *file_system,
+ GtkFileSystemVolume *volume,
+ GtkWidget *widget,
+ gint pixel_size,
+ GError **error)
+{
+ g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
+ g_return_val_if_fail (volume != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
+ g_return_val_if_fail (pixel_size > 0, NULL);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ return GTK_FILE_SYSTEM_GET_IFACE (file_system)->volume_render_icon (file_system,
+ volume,
+ widget,
+ pixel_size,
+ error);
+}
+
+/**
* gtk_file_system_get_parent:
* @file_system: a #GtkFileSystem
* @path: base path name
@@ -680,7 +831,7 @@ gtk_file_system_render_icon (GtkFileSystem *file_system,
{
g_return_val_if_fail (GTK_IS_FILE_SYSTEM (file_system), NULL);
g_return_val_if_fail (path != NULL, NULL);
- g_return_val_if_fail (widget != NULL, NULL);
+ g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
g_return_val_if_fail (pixel_size > 0, NULL);
return GTK_FILE_SYSTEM_GET_IFACE (file_system)->render_icon (file_system, path, widget, pixel_size, error);