[gvfs] mtpvolume: implement symbolic icons



commit ed451a1c8307f3b02f2d4aa9f3bd691e3c0a2f0e
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Jan 29 19:11:30 2014 +0100

    mtpvolume: implement symbolic icons
    
    The places sidebar in nautilus and the places menu in the shell
    use symbolic icons exclusively, so make sure one is provided, to
    avoid falling back to a generic "network mount" icon.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723251

 monitor/mtp/gmtpvolume.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/monitor/mtp/gmtpvolume.c b/monitor/mtp/gmtpvolume.c
index 362a58c..c392b5c 100644
--- a/monitor/mtp/gmtpvolume.c
+++ b/monitor/mtp/gmtpvolume.c
@@ -46,6 +46,7 @@ struct _GMtpVolume {
 
   char *name;
   char *icon;
+  char *symbolic_icon;
 };
 
 static void g_mtp_volume_volume_iface_init (GVolumeIface *iface);
@@ -188,6 +189,17 @@ set_volume_icon (GMtpVolume *volume)
     volume->icon = g_strdup ("camera-photo");
 }
 
+static void
+set_volume_symbolic_icon (GMtpVolume *volume)
+{
+  if (g_udev_device_has_property (volume->device, "ID_MEDIA_PLAYER_ICON_NAME"))
+    volume->symbolic_icon = g_strconcat (g_udev_device_get_property (volume->device, 
"ID_MEDIA_PLAYER_ICON_NAME"), "-symbolic", NULL);
+  else if (g_udev_device_has_property (volume->device, "ID_MEDIA_PLAYER"))
+    volume->symbolic_icon = g_strdup ("multimedia-player-symbolic");
+  else
+    volume->symbolic_icon = g_strdup ("camera-photo-symbolic");
+}
+
 GMtpVolume *
 g_mtp_volume_new (GVolumeMonitor   *volume_monitor,
                   GUdevDevice      *device,
@@ -215,6 +227,7 @@ g_mtp_volume_new (GVolumeMonitor   *volume_monitor,
 
   set_volume_name (volume);
   set_volume_icon (volume);
+  set_volume_symbolic_icon (volume);
   /* we do not really need to listen for changes */
 
   return volume;
@@ -237,6 +250,18 @@ g_mtp_volume_get_icon (GVolume *volume)
   return icon;
 }
 
+static GIcon *
+g_mtp_volume_get_symbolic_icon (GVolume *volume)
+{
+  GMtpVolume *mtp_volume = G_MTP_VOLUME (volume);
+  GIcon *icon;
+
+  G_LOCK (mtp_volume);
+  icon = g_themed_icon_new_with_default_fallbacks (mtp_volume->symbolic_icon);
+  G_UNLOCK (mtp_volume);
+  return icon;
+}
+
 static char *
 g_mtp_volume_get_name (GVolume *volume)
 {
@@ -417,6 +442,7 @@ g_mtp_volume_volume_iface_init (GVolumeIface *iface)
 {
   iface->get_name = g_mtp_volume_get_name;
   iface->get_icon = g_mtp_volume_get_icon;
+  iface->get_symbolic_icon = g_mtp_volume_get_symbolic_icon;
   iface->get_uuid = g_mtp_volume_get_uuid;
   iface->get_drive = g_mtp_volume_get_drive;
   iface->get_mount = g_mtp_volume_get_mount;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]