We need symbolic icon support for display in Nautilus.
https://bugzilla.gnome.org/show_bug.cgi?id=682101
g_mount_get_name
g_mount_get_uuid
g_mount_get_icon
+g_mount_get_symbolic_icon
g_mount_get_drive
g_mount_get_root
g_mount_get_volume
g_volume_get_name
g_volume_get_uuid
g_volume_get_icon
+g_volume_get_symbolic_icon
g_volume_get_drive
g_volume_get_mount
g_volume_can_mount
GDriveStartStopType
g_drive_get_name
g_drive_get_icon
+g_drive_get_symbolic_icon
g_drive_has_volumes
g_drive_get_volumes
g_drive_can_eject
g_unix_mount_is_readonly
g_unix_mount_is_system_internal
g_unix_mount_guess_icon
+g_unix_mount_guess_symbolic_icon
g_unix_mount_guess_name
g_unix_mount_guess_can_eject
g_unix_mount_guess_should_display
g_unix_mount_point_is_user_mountable
g_unix_mount_point_is_loopback
g_unix_mount_point_guess_icon
+g_unix_mount_point_guess_symbolic_icon
g_unix_mount_point_guess_name
g_unix_mount_point_guess_can_eject
g_unix_mount_points_get
#include "config.h"
#include "gdrive.h"
#include "gsimpleasyncresult.h"
+#include "gthemedicon.h"
#include "gasyncresult.h"
#include "gioerror.h"
#include "glibintl.h"
}
/**
+ * g_drive_get_symbolic_icon:
+ * @drive: a #GDrive.
+ *
+ * Gets the icon for @drive.
+ *
+ * Returns: (transfer full): symbolic #GIcon for the @drive.
+ * Free the returned object with g_object_unref().
+ *
+ * Since: 2.34
+ **/
+GIcon *
+g_drive_get_symbolic_icon (GDrive *drive)
+{
+ GDriveIface *iface;
+ GIcon *ret;
+
+ g_return_val_if_fail (G_IS_DRIVE (drive), NULL);
+
+ iface = G_DRIVE_GET_IFACE (drive);
+
+ if (iface->get_symbolic_icon != NULL)
+ ret = iface->get_symbolic_icon (drive);
+ else
+ ret = g_themed_icon_new_with_default_fallbacks ("drive-removable-media-symbolic");
+
+ return ret;
+}
+
+/**
* g_drive_has_volumes:
* @drive: a #GDrive.
*
* @eject_with_operation: Starts ejecting a #GDrive using a #GMountOperation. Since 2.22.
* @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
* @get_sort_key: Gets a key used for sorting #GDrive instances or %NULL if no such key exists. Since 2.32.
+ * @get_symbolic_icon: Returns a symbolic #GIcon for the given #GDrive. Since 2.34.
*
* Interface for creating #GDrive implementations.
*/
GError **error);
const gchar * (* get_sort_key) (GDrive *drive);
+ GIcon * (* get_symbolic_icon) (GDrive *drive);
+
};
GType g_drive_get_type (void) G_GNUC_CONST;
char * g_drive_get_name (GDrive *drive);
GIcon * g_drive_get_icon (GDrive *drive);
+GIcon * g_drive_get_symbolic_icon (GDrive *drive);
gboolean g_drive_has_volumes (GDrive *drive);
GList * g_drive_get_volumes (GDrive *drive);
gboolean g_drive_is_media_removable (GDrive *drive);
g_drive_get_type
g_drive_get_name
g_drive_get_icon
+g_drive_get_symbolic_icon
g_drive_has_volumes
g_drive_get_volumes
g_drive_is_media_removable
g_unix_mount_guess_should_display
g_unix_mount_guess_name
g_unix_mount_guess_icon
+g_unix_mount_guess_symbolic_icon
g_unix_mount_point_compare
g_unix_mount_point_get_mount_path
g_unix_mount_point_get_device_path
g_unix_mount_point_guess_can_eject
g_unix_mount_point_guess_name
g_unix_mount_point_guess_icon
+g_unix_mount_point_guess_symbolic_icon
g_unix_mount_points_get
g_unix_mounts_get
g_unix_mount_at
g_mount_get_root
g_mount_get_name
g_mount_get_icon
+g_mount_get_symbolic_icon
g_mount_get_uuid
g_mount_get_volume
g_mount_get_drive
g_volume_get_type
g_volume_get_name
g_volume_get_icon
+g_volume_get_symbolic_icon
g_volume_get_uuid
g_volume_get_drive
g_volume_get_mount
#include "gmount.h"
#include "gmountprivate.h"
+#include "gthemedicon.h"
#include "gasyncresult.h"
#include "gsimpleasyncresult.h"
#include "gioerror.h"
return (* iface->get_icon) (mount);
}
+
+/**
+ * g_mount_get_symbolic_icon:
+ * @mount: a #GMount.
+ *
+ * Gets the symbolic icon for @mount.
+ *
+ * Returns: (transfer full): a #GIcon.
+ * The returned object should be unreffed with
+ * g_object_unref() when no longer needed.
+ *
+ * Since: 2.34
+ **/
+GIcon *
+g_mount_get_symbolic_icon (GMount *mount)
+{
+ GMountIface *iface;
+ GIcon *ret;
+
+ g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
+
+ iface = G_MOUNT_GET_IFACE (mount);
+
+ if (iface->get_symbolic_icon != NULL)
+ ret = iface->get_symbolic_icon (mount);
+ else
+ ret = g_themed_icon_new_with_default_fallbacks ("folder-remote-symbolic");
+
+ return ret;
+}
+
/**
* g_mount_get_uuid:
* @mount: a #GMount.
* @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
* @get_default_location: Gets a #GFile indication a start location that can be use as the entry point for this mount. Since 2.24.
* @get_sort_key: Gets a key used for sorting #GMount instance or %NULL if no such key exists. Since 2.32.
+ * @get_symbolic_icon: Gets a symbolic #GIcon for the #GMount. Since 2.34.
*
* Interface for implementing operations for mounts.
**/
GFile * (* get_default_location) (GMount *mount);
const gchar * (* get_sort_key) (GMount *mount);
+ GIcon * (* get_symbolic_icon) (GMount *mount);
};
GType g_mount_get_type (void) G_GNUC_CONST;
GFile * g_mount_get_default_location (GMount *mount);
char * g_mount_get_name (GMount *mount);
GIcon * g_mount_get_icon (GMount *mount);
+GIcon * g_mount_get_symbolic_icon (GMount *mount);
char * g_mount_get_uuid (GMount *mount);
GVolume * g_mount_get_volume (GMount *mount);
GDrive * g_mount_get_drive (GMount *mount);
char *name;
GIcon *icon;
+ GIcon *symbolic_icon;
char *device_path;
char *mount_path;
/* TODO: g_warn_if_fail (volume->volume == NULL); */
g_object_unref (mount->icon);
+ g_object_unref (mount->symbolic_icon);
g_free (mount->name);
g_free (mount->device_path);
g_free (mount->mount_path);
mount->name = g_unix_mount_guess_name (mount_entry);
mount->icon = g_unix_mount_guess_icon (mount_entry);
+ mount->symbolic_icon = g_unix_mount_guess_symbolic_icon (mount_entry);
/* need to do this last */
mount->volume = volume;
return g_object_ref (unix_mount->icon);
}
+static GIcon *
+g_unix_mount_get_symbolic_icon (GMount *mount)
+{
+ GUnixMount *unix_mount = G_UNIX_MOUNT (mount);
+
+ return g_object_ref (unix_mount->symbolic_icon);
+}
+
static char *
g_unix_mount_get_uuid (GMount *mount)
{
iface->get_root = g_unix_mount_get_root;
iface->get_name = g_unix_mount_get_name;
iface->get_icon = g_unix_mount_get_icon;
+ iface->get_symbolic_icon = g_unix_mount_get_symbolic_icon;
iface->get_uuid = g_unix_mount_get_uuid;
iface->get_drive = g_unix_mount_get_drive;
iface->get_volume = g_unix_mount_get_volume;
}
static const char *
-type_to_icon (GUnixMountType type, gboolean is_mount_point)
+type_to_icon (GUnixMountType type, gboolean is_mount_point, gboolean use_symbolic)
{
const char *icon_name;
{
case G_UNIX_MOUNT_TYPE_HD:
if (is_mount_point)
- icon_name = "drive-removable-media";
+ icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
else
- icon_name = "drive-harddisk";
+ icon_name = use_symbolic ? "drive-harddisk-symbolic" : "drive-harddisk";
break;
case G_UNIX_MOUNT_TYPE_FLOPPY:
case G_UNIX_MOUNT_TYPE_ZIP:
case G_UNIX_MOUNT_TYPE_JAZ:
if (is_mount_point)
- icon_name = "drive-removable-media";
+ icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
else
- icon_name = "media-floppy";
+ icon_name = use_symbolic ? "media-removable-symbolic" : "media-floppy";
break;
case G_UNIX_MOUNT_TYPE_CDROM:
if (is_mount_point)
- icon_name = "drive-optical";
+ icon_name = use_symbolic ? "drive-optical-symbolic" : "drive-optical";
else
- icon_name = "media-optical";
+ icon_name = use_symbolic ? "media-optical-symbolic" : "media-optical";
break;
case G_UNIX_MOUNT_TYPE_NFS:
- /* TODO: Would like a better icon here... */
- if (is_mount_point)
- icon_name = "drive-removable-media";
- else
- icon_name = "drive-harddisk";
+ icon_name = use_symbolic ? "folder-remote-symbolic" : "folder-remote";
break;
case G_UNIX_MOUNT_TYPE_MEMSTICK:
if (is_mount_point)
- icon_name = "drive-removable-media";
+ icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
else
- icon_name = "media-flash";
+ icon_name = use_symbolic ? "media-removable-symbolic" : "media-flash";
break;
case G_UNIX_MOUNT_TYPE_CAMERA:
if (is_mount_point)
- icon_name = "drive-removable-media";
+ icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
else
- icon_name = "camera-photo";
+ icon_name = use_symbolic ? "camera-photo-symbolic" : "camera-photo";
break;
case G_UNIX_MOUNT_TYPE_IPOD:
if (is_mount_point)
- icon_name = "drive-removable-media";
+ icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
else
- icon_name = "multimedia-player";
+ icon_name = use_symbolic ? "multimedia-player-symbolic" : "multimedia-player";
break;
case G_UNIX_MOUNT_TYPE_UNKNOWN:
default:
if (is_mount_point)
- icon_name = "drive-removable-media";
+ icon_name = use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
else
- icon_name = "drive-harddisk";
+ icon_name = use_symbolic ? "drive-harddisk-symbolic" : "drive-harddisk";
break;
}
GIcon *
g_unix_mount_guess_icon (GUnixMountEntry *mount_entry)
{
- return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE));
+ return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE, FALSE));
+}
+
+/**
+ * g_unix_mount_guess_symbolic_icon:
+ * @mount_entry: a #GUnixMountEntry
+ *
+ * Guesses the symbolic icon of a Unix mount.
+ *
+ * Returns: (transfer full): a #GIcon
+ *
+ * Since: 2.34
+ */
+GIcon *
+g_unix_mount_guess_symbolic_icon (GUnixMountEntry *mount_entry)
+{
+ return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_guess_type (mount_entry), FALSE, TRUE));
}
/**
GIcon *
g_unix_mount_point_guess_icon (GUnixMountPoint *mount_point)
{
- return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE));
+ return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE, FALSE));
+}
+
+/**
+ * g_unix_mount_point_guess_symbolic_icon:
+ *
+ * Guesses the symbolic icon of a Unix mount point.
+ *
+ * Returns: (transfer full): a #GIcon
+ *
+ * Since: 2.34
+ */
+GIcon *
+g_unix_mount_point_guess_symbolic_icon (GUnixMountPoint *mount_point)
+{
+ return g_themed_icon_new_with_default_fallbacks (type_to_icon (g_unix_mount_point_guess_type (mount_point), TRUE, TRUE));
}
/**
gboolean g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry);
char * g_unix_mount_guess_name (GUnixMountEntry *mount_entry);
GIcon * g_unix_mount_guess_icon (GUnixMountEntry *mount_entry);
+GIcon * g_unix_mount_guess_symbolic_icon (GUnixMountEntry *mount_entry);
+
gint g_unix_mount_point_compare (GUnixMountPoint *mount1,
GUnixMountPoint *mount2);
gboolean g_unix_mount_point_guess_can_eject (GUnixMountPoint *mount_point);
char * g_unix_mount_point_guess_name (GUnixMountPoint *mount_point);
GIcon * g_unix_mount_point_guess_icon (GUnixMountPoint *mount_point);
+GIcon * g_unix_mount_point_guess_symbolic_icon (GUnixMountPoint *mount_point);
+
GList * g_unix_mount_points_get (guint64 *time_read);
GList * g_unix_mounts_get (guint64 *time_read);
char *name;
GIcon *icon;
+ GIcon *symbolic_icon;
};
static void g_unix_volume_volume_iface_init (GVolumeIface *iface);
_g_unix_mount_unset_volume (volume->mount, volume);
g_object_unref (volume->icon);
+ g_object_unref (volume->symbolic_icon);
g_free (volume->name);
g_free (volume->mount_path);
g_free (volume->device_path);
volume->name = g_unix_mount_point_guess_name (mountpoint);
volume->icon = g_unix_mount_point_guess_icon (mountpoint);
+ volume->symbolic_icon = g_unix_mount_point_guess_symbolic_icon (mountpoint);
if (strcmp (g_unix_mount_point_get_fs_type (mountpoint), "nfs") == 0)
return g_object_ref (unix_volume->icon);
}
+static GIcon *
+g_unix_volume_get_symbolic_icon (GVolume *volume)
+{
+ GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
+ return g_object_ref (unix_volume->symbolic_icon);
+}
+
static char *
g_unix_volume_get_name (GVolume *volume)
{
{
iface->get_name = g_unix_volume_get_name;
iface->get_icon = g_unix_volume_get_icon;
+ iface->get_symbolic_icon = g_unix_volume_get_symbolic_icon;
iface->get_uuid = g_unix_volume_get_uuid;
iface->get_drive = g_unix_volume_get_drive;
iface->get_mount = g_unix_volume_get_mount;
#include "config.h"
#include "gmount.h"
#include "gvolume.h"
+#include "gthemedicon.h"
#include "gasyncresult.h"
#include "gsimpleasyncresult.h"
#include "gioerror.h"
}
/**
+ * g_volume_get_symbolic_icon:
+ * @volume: a #GVolume.
+ *
+ * Gets the symbolic icon for @volume.
+ *
+ * Returns: (transfer full): a #GIcon.
+ * The returned object should be unreffed with g_object_unref()
+ * when no longer needed.
+ *
+ * Since: 2.34
+ **/
+GIcon *
+g_volume_get_symbolic_icon (GVolume *volume)
+{
+ GVolumeIface *iface;
+ GIcon *ret;
+
+ g_return_val_if_fail (G_IS_VOLUME (volume), NULL);
+
+ iface = G_VOLUME_GET_IFACE (volume);
+
+ if (iface->get_symbolic_icon != NULL)
+ ret = iface->get_symbolic_icon (volume);
+ else
+ ret = g_themed_icon_new_with_default_fallbacks ("folder-remote-symbolic");
+
+ return ret;
+
+}
+
+/**
* g_volume_get_uuid:
* @volume: a #GVolume.
*
* @eject_with_operation: Starts ejecting a #GVolume using a #GMountOperation. Since 2.22.
* @eject_with_operation_finish: Finishes an eject operation using a #GMountOperation. Since 2.22.
* @get_sort_key: Gets a key used for sorting #GVolume instance or %NULL if no such key exists. Since 2.32.
+ * @get_symbolic_icon: Gets a symbolic #GIcon for the #GVolume. Since 2.34.
*
* Interface for implementing operations for mountable volumes.
**/
GError **error);
const gchar * (* get_sort_key) (GVolume *volume);
+ GIcon * (* get_symbolic_icon) (GVolume *volume);
};
GType g_volume_get_type (void) G_GNUC_CONST;
char * g_volume_get_name (GVolume *volume);
GIcon * g_volume_get_icon (GVolume *volume);
+GIcon * g_volume_get_symbolic_icon (GVolume *volume);
char * g_volume_get_uuid (GVolume *volume);
GDrive * g_volume_get_drive (GVolume *volume);
GMount * g_volume_get_mount (GVolume *volume);
/* why does all this stuff need to be duplicated? It is in volume already! */
char *name;
GIcon *icon;
+ GIcon *symbolic_icon;
char *mount_path;
gboolean can_eject;
if (mount->icon != NULL)
g_object_unref (mount->icon);
+ if (mount->symbolic_icon != NULL)
+ g_object_unref (mount->symbolic_icon);
g_free (mount->name);
g_free (mount->mount_path);
}
const char *
-_win32_drive_type_to_icon (int type)
+_win32_drive_type_to_icon (int type, gboolean use_symbolic)
{
switch (type)
{
- case DRIVE_REMOVABLE : return "gtk-floppy";
- case DRIVE_FIXED : return "gtk-harddisk";
- case DRIVE_REMOTE : return "gtk-network";
- case DRIVE_CDROM : return "gtk-cdrom";
- default : return "gtk-directory";
+ case DRIVE_REMOVABLE : return use_symbolic ? "drive-removable-media-symbolic" : "drive-removable-media";
+ case DRIVE_FIXED : return use_symbolic ? "drive-harddisk-symbolic" : "drive-harddisk";
+ case DRIVE_REMOTE : return use_symbolic ? "folder-remote-symbolic" : "folder-remote";
+ case DRIVE_CDROM : return use_symbolic ? "drive-optical-symbolic" : "drive-optical";
+ default : return use_symbolic ? "folder-symbolic" : "folder";
}
}
}
else
{
- win32_mount->icon = g_themed_icon_new_with_default_fallbacks (
- _win32_drive_type_to_icon (win32_mount->drive_type));
+ win32_mount->icon = g_themed_icon_new_with_default_fallbacks (_win32_drive_type_to_icon (win32_mount->drive_type, FALSE);
}
}
return g_object_ref (win32_mount->icon);
}
+static GIcon *
+g_win32_mount_get_symbolic_icon (GMount *mount)
+{
+ GWin32Mount *win32_mount = G_WIN32_MOUNT (mount);
+
+ g_return_val_if_fail (win32_mount->mount_path != NULL, NULL);
+
+ /* lazy creation */
+ if (!win32_mount->symbolic_icon)
+ {
+ win32_mount->symbolic_icon = g_themed_icon_new_with_default_fallbacks (_win32_drive_type_to_icon (win32_mount->drive_type, TRUE);
+ }
+
+ return g_object_ref (win32_mount->symbolic_icon);
+}
+
static char *
g_win32_mount_get_uuid (GMount *mount)
{
iface->get_root = g_win32_mount_get_root;
iface->get_name = g_win32_mount_get_name;
iface->get_icon = g_win32_mount_get_icon;
+ iface->get_symbolic_icon = g_win32_mount_get_symbolic_icon;
iface->get_uuid = g_win32_mount_get_uuid;
iface->get_drive = g_win32_mount_get_drive;
iface->get_volume = g_win32_mount_get_volume;