[Xfce4-commits] <thunar-volman:master> Add support for detecting USB printers.

Jannis Pohlmann noreply at xfce.org
Sun Jul 25 19:44:49 CEST 2010


Updating branch refs/heads/master
         to ab265b25f13f70b35f3a2ceb2538053507af1883 (commit)
       from 0a3fd067c0dd3e97382faa8d6429bc6d0300a665 (commit)

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

    Add support for detecting USB printers.

 thunar-volman/Makefile.am                          |    4 +-
 thunar-volman/tvm-device.c                         |    2 +
 .../{tvm-input-device.c => tvm-usb-device.c}       |   47 +++----------------
 .../{tvm-block-device.h => tvm-usb-device.h}       |    8 ++--
 4 files changed, 17 insertions(+), 44 deletions(-)

diff --git a/thunar-volman/Makefile.am b/thunar-volman/Makefile.am
index 9d9153d..7e73183 100644
--- a/thunar-volman/Makefile.am
+++ b/thunar-volman/Makefile.am
@@ -47,7 +47,9 @@ thunar_volman_SOURCES =							\
 	tvm-prompt.c							\
 	tvm-prompt.h							\
 	tvm-run.c							\
-	tvm-run.h
+	tvm-run.h							\
+	tvm-usb-device.c						\
+	tvm-usb-device.h
 
 thunar_volman_CFLAGS =							\
 	$(DBUS_CFLAGS)							\
diff --git a/thunar-volman/tvm-device.c b/thunar-volman/tvm-device.c
index 4da3aae..7249769 100644
--- a/thunar-volman/tvm-device.c
+++ b/thunar-volman/tvm-device.c
@@ -34,6 +34,7 @@
 #include <thunar-volman/tvm-context.h>
 #include <thunar-volman/tvm-device.h>
 #include <thunar-volman/tvm-input-device.h>
+#include <thunar-volman/tvm-usb-device.h>
 
 
 
@@ -57,6 +58,7 @@ static TvmDeviceHandler subsystem_handlers[] =
 {
   { "block",       tvm_block_device_added },
   { "input",       tvm_input_device_added },
+  { "usb",         tvm_usb_device_added   },
 #if 0
   { "sound",       tvm_sound_device_added },
   { "video4linux", tvm_video_device_added },
diff --git a/thunar-volman/tvm-input-device.c b/thunar-volman/tvm-usb-device.c
similarity index 57%
copy from thunar-volman/tvm-input-device.c
copy to thunar-volman/tvm-usb-device.c
index 3be0721..8db2c2c 100644
--- a/thunar-volman/tvm-input-device.c
+++ b/thunar-volman/tvm-usb-device.c
@@ -26,19 +26,16 @@
 
 #include <libxfce4util/libxfce4util.h>
 
-#include <thunar-volman/tvm-input-device.h>
 #include <thunar-volman/tvm-context.h>
 #include <thunar-volman/tvm-device.h>
 #include <thunar-volman/tvm-run.h>
+#include <thunar-volman/tvm-usb-device.h>
 
 
 
 void
-tvm_input_device_added (TvmContext *context)
+tvm_usb_device_added (TvmContext *context)
 {
-  const gchar *id_class;
-  const gchar *id_model;
-  const gchar *id_usb_driver;
   const gchar *driver;
   const gchar *enabled_property = NULL;
   const gchar *command_property = NULL;
@@ -48,46 +45,18 @@ tvm_input_device_added (TvmContext *context)
   g_return_if_fail (context != NULL);
 
   /* collect device information */
-  id_class = g_udev_device_get_property (context->device, "ID_CLASS");
-  id_model = g_udev_device_get_property (context->device, "ID_MODEL");
   driver = g_udev_device_get_property (context->device, "DRIVER");
-  id_usb_driver = g_udev_device_get_property (context->device, "ID_USB_DRIVER");
 
-  if (g_strcmp0 (id_class, "kbd") == 0)
+  if (g_strcmp0 (driver, "usblp") == 0)
     {
-      /* we have a keyboard */
-      enabled_property = "/autokeyboard/enabled";
-      command_property = "/autokeyboard/command";
-    }
-  else if (g_strcmp0 (driver, "wacom") == 0 
-           || g_strcmp0 (id_usb_driver, "wacom") == 0)
-    {
-      /* we have a wacom tablet */
-      enabled_property = "/autotablet/enabled";
-      command_property = "/autotabled/command";
-    }
-  else if (g_strcmp0 (id_class, "mouse") == 0)
-    {
-      if (g_strstr_len (id_model, -1, "Tablet") != NULL 
-          || g_strstr_len (id_model, -1, "TABLET") != NULL
-          || g_strstr_len (id_model, -1, "tablet") != NULL)
-        {
-          /* we have a tablet that can be used as a mouse */
-          enabled_property = "/autotablet/enabled";
-          command_property = "/autotablet/command";
-        }
-      else
-        {
-          /* we have a normal mouse */
-          enabled_property = "/automouse/enabled";
-          command_property = "/automouse/command";
-        }
+      enabled_property = "/autoprinter/enabled";
+      command_property = "/autoprinter/command";
     }
 
   /* check if we have a device that we support */
   if (enabled_property != NULL && command_property != NULL)
     {
-      /* check whether handling the keyboard/tablet/mouse is enabled */
+      /* check whether handling the printer or whatever is enabled */
       enabled = xfconf_channel_get_bool (context->channel, enabled_property, FALSE);
       if (enabled)
         {
@@ -102,9 +71,9 @@ tvm_input_device_added (TvmContext *context)
     }
   else
     {
-      /* return an error because we cannot handle the input device */
+      /* return an error because we cannot handle the usb device */
       g_set_error (context->error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
-                   _("Unsupported input device type"));
+                   _("Unsupported USB device type"));
     }
 
   /* finish processing the device */
diff --git a/thunar-volman/tvm-block-device.h b/thunar-volman/tvm-usb-device.h
similarity index 86%
copy from thunar-volman/tvm-block-device.h
copy to thunar-volman/tvm-usb-device.h
index 5f6f1d7..4b88002 100644
--- a/thunar-volman/tvm-block-device.h
+++ b/thunar-volman/tvm-usb-device.h
@@ -18,8 +18,8 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#ifndef __TVM_BLOCK_DEVICE_H__
-#define __TVM_BLOCK_DEVICE_H__
+#ifndef __TVM_USB_DEVICE_H__
+#define __TVM_USB_DEVICE_H__
 
 #include <glib.h>
 
@@ -28,8 +28,8 @@
 
 G_BEGIN_DECLS
 
-void tvm_block_device_added (TvmContext *context);
+void tvm_usb_device_added (TvmContext *context);
 
 G_END_DECLS
 
-#endif /* !__TVM_BLOCK_DEVICE_H__ */
+#endif /* !__TVM_USB_DEVICE_H__ */



More information about the Xfce4-commits mailing list