[Xfce4-commits] <thunar:jannis/port-to-udev> React on "change" events of CD drives if they have media available.

Jannis Pohlmann noreply at xfce.org
Wed Jul 21 12:38:01 CEST 2010


Updating branch refs/heads/jannis/port-to-udev
         to a0170301b25157312f543518a071d4518420f25a (commit)
       from d35f28695a6965f8d518fdee9db779f4368ce480 (commit)

commit a0170301b25157312f543518a071d4518420f25a
Author: Jannis Pohlmann <jannis at xfce.org>
Date:   Wed Jul 21 12:36:09 2010 +0200

    React on "change" events of CD drives if they have media available.

 thunar/thunar-application.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index c885af6..0b2e8d6 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -2,7 +2,7 @@
 /*-
  * Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
  * Copyright (c) 2005      Jeff Franks <jcfranks at xfce.org>
- * Copyright (c) 2009      Jannis Pohlmann <jannis at xfce.org>
+ * Copyright (c) 2009-2010 Jannis Pohlmann <jannis at xfce.org>
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the Free
@@ -482,6 +482,8 @@ thunar_application_uevent (GUdevClient       *client,
                            ThunarApplication *application)
 {
   const gchar *sysfs_path;
+  gboolean     is_cdrom = FALSE;
+  gboolean     has_media = FALSE;
   GSList      *lp;
 
   _thunar_return_if_fail (G_UDEV_IS_CLIENT (client));
@@ -493,8 +495,13 @@ thunar_application_uevent (GUdevClient       *client,
   /* determine the sysfs path of the device */
   sysfs_path = g_udev_device_get_sysfs_path (device);
 
-  /* distinguish between "add", "change" and "remove" actions, ignore "change" and "move" */
-  if (g_strcmp0 (action, "add") == 0) /* || g_strcmp0 (action, "change") == 0) */
+  /* check if the device is a CD drive */
+  is_cdrom = g_udev_device_get_property_as_boolean (device, "ID_CDROM");
+  has_media = g_udev_device_get_property_as_boolean (device, "ID_CDROM_MEDIA");
+
+  /* distinguish between "add", "change" and "remove" actions, ignore "move" */
+  if (g_strcmp0 (action, "add") == 0  
+      || (is_cdrom && has_media && g_strcmp0 (action, "change") == 0))
     {
 #if 0
       g_debug ("path = %s, action = %s", sysfs_path, action);



More information about the Xfce4-commits mailing list