gnome-scan r795 - in trunk: . modules/gsane
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r795 - in trunk: . modules/gsane
- Date: Thu, 15 Jan 2009 20:22:40 +0000 (UTC)
Author: bersace
Date: Thu Jan 15 20:22:40 2009
New Revision: 795
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=795&view=rev
Log:
Compute scanner icon name.
Modified:
trunk/ChangeLog
trunk/modules/gsane/gsane-scanner.c
Modified: trunk/modules/gsane/gsane-scanner.c
==============================================================================
--- trunk/modules/gsane/gsane-scanner.c (original)
+++ trunk/modules/gsane/gsane-scanner.c Thu Jan 15 20:22:40 2009
@@ -69,13 +69,88 @@
G_DEFINE_DYNAMIC_TYPE (GSaneScanner, gsane_scanner, GNOME_SCAN_TYPE_SCANNER);
+/* List of device type used for one icon name. */
+
+/* default */
+#define GSANE_SCANNER_ICON_NAME "scanner"
+static const gchar* scanner_types[] = {
+ "scanner",
+ "flatbed scanner",
+ "frame grabber",
+ "handheld scanner",
+ "sheetfed scanner",
+ "virtual device",
+ NULL
+};
+
+#define GSANE_PRINTER_ICON_NAME "printer"
+static const gchar* printer_types[] = {
+ "multi-function peripheral",
+ "all-in-one",
+ NULL
+};
+
+#define GSANE_WEBCAM_ICON_NAME "camera-web"
+static const gchar* webcam_types[] = {
+ "v4l", /* that's actually a backend name */
+ NULL
+};
+
+#define GSANE_CAMERA_ICON_NAME "camera-photo"
+static const gchar* camera_types[] = {
+ "still camera",
+ NULL
+};
+
+#define GSANE_VIDEO_ICON_NAME "camera-video"
+static const gchar* video_types[] = {
+ "video camera",
+ NULL
+};
+
+static const gchar*
+gsane_scanner_icon_name(const SANE_Device *device)
+{
+ gchar **parts = g_strsplit(device->name, ":", 2);
+ const gchar *backend_name = parts[0];
+ const gchar* icon_name;
+
+ icon_name = GSANE_SCANNER_ICON_NAME;
+
+ if (gsane_string_in_array(device->type, printer_types))
+ icon_name = GSANE_PRINTER_ICON_NAME;
+ else if (gsane_string_in_array(backend_name, webcam_types))
+ icon_name = GSANE_WEBCAM_ICON_NAME;
+ else if (gsane_string_in_array(device->type, camera_types))
+ icon_name = GSANE_CAMERA_ICON_NAME;
+ else if (gsane_string_in_array(device->type, video_types))
+ icon_name = GSANE_VIDEO_ICON_NAME;
+ else if (gsane_string_in_array(device->type, scanner_types))
+ icon_name = GSANE_SCANNER_ICON_NAME;
+ else
+ /* Just output unknown to maintain type list. */
+ g_debug("%s %s (%s) device type is %s",
+ device->vendor, device->model, device->name,
+ device->type);
+
+ g_strfreev(parts);
+
+ return icon_name;
+}
+
GnomeScanScanner*
gsane_scanner_new(const SANE_Device *device)
{
- gchar* name = g_strconcat(device->vendor, " ", device->model, NULL);
+ gchar* name;
+ if (g_str_equal(device->vendor, "Noname"))
+ name = g_strdup(device->model);
+ else
+ name = g_strconcat(device->vendor, " ", device->model, NULL);
+
+ const gchar* icon_name = gsane_scanner_icon_name(device);
GObject* object= g_object_new(GSANE_TYPE_SCANNER,
"name", name,
- "icon-name", "scanner",
+ "icon-name", icon_name,
"sane-id", device->name,
"sane-type", device->type,
NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]