[gnome-color-manager] Add initial support for HP printers too
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] Add initial support for HP printers too
- Date: Thu, 5 Nov 2009 12:36:14 +0000 (UTC)
commit 7737ffb996a4aef7486c7f7afef3b748c3d4dd33
Author: Richard Hughes <richard hughsie com>
Date: Thu Nov 5 12:35:28 2009 +0000
Add initial support for HP printers too
src/gcm-client.c | 19 +++++++++++++++----
src/gcm-prefs.c | 39 +++++++++++++++++++++++++++++++--------
2 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/src/gcm-client.c b/src/gcm-client.c
index fbac88f..42f9da4 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -169,10 +169,10 @@ gcm_client_gudev_remove (GcmClient *client, GUdevDevice *udev_device)
}
/**
- * gcm_client_gudev_add_scanner:
+ * gcm_client_gudev_add_type:
**/
static void
-gcm_client_gudev_add_scanner (GcmClient *client, GUdevDevice *udev_device)
+gcm_client_gudev_add_type (GcmClient *client, GUdevDevice *udev_device, GcmDeviceType type)
{
gchar *title;
GcmDevice *device = NULL;
@@ -187,10 +187,13 @@ gcm_client_gudev_add_scanner (GcmClient *client, GUdevDevice *udev_device)
g_udev_device_get_property (udev_device, "ID_VENDOR"),
g_udev_device_get_property (udev_device, "ID_MODEL"));
+ /* turn space delimiters into spaces */
+ g_strdelimit (title, "_", ' ');
+
/* create device */
device = gcm_device_new ();
g_object_set (device,
- "type", GCM_DEVICE_TYPE_SCANNER,
+ "type", type,
"id", id,
"title", title,
NULL);
@@ -223,11 +226,19 @@ static void
gcm_client_gudev_add (GcmClient *client, GUdevDevice *udev_device)
{
const gchar *value;
+
+ /* only matches HP printers, need to expand to all of CUPS printers */
+ value = g_udev_device_get_property (udev_device, "ID_HPLIP");
+ if (value != NULL) {
+ egg_debug ("found printer device: %s", g_udev_device_get_sysfs_path (udev_device));
+ gcm_client_gudev_add_type (client, udev_device, GCM_DEVICE_TYPE_PRINTER);
+ }
+
/* sane is slightly odd in a lowercase property, and "yes" as a value rather than "1" */
value = g_udev_device_get_property (udev_device, "libsane_matched");
if (value != NULL) {
egg_debug ("found scanner device: %s", g_udev_device_get_sysfs_path (udev_device));
- gcm_client_gudev_add_scanner (client, udev_device);
+ gcm_client_gudev_add_type (client, udev_device, GCM_DEVICE_TYPE_SCANNER);
}
}
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index d16e33e..f2927e9 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -312,13 +312,13 @@ gcm_prefs_add_devices_columns (GtkTreeView *treeview)
/* image */
renderer = gtk_cell_renderer_pixbuf_new ();
g_object_set (renderer, "stock-size", GTK_ICON_SIZE_DIALOG, NULL);
- column = gtk_tree_view_column_new_with_attributes (_("Screen"), renderer,
+ column = gtk_tree_view_column_new_with_attributes ("", renderer,
"icon-name", GPM_DEVICES_COLUMN_ICON, NULL);
gtk_tree_view_append_column (treeview, column);
/* column for text */
renderer = gtk_cell_renderer_text_new ();
- column = gtk_tree_view_column_new_with_attributes (_("Label"), renderer,
+ column = gtk_tree_view_column_new_with_attributes ("", renderer,
"markup", GPM_DEVICES_COLUMN_TITLE, NULL);
gtk_tree_view_column_set_sort_column_id (column, GPM_DEVICES_COLUMN_TITLE);
gtk_tree_view_append_column (treeview, column);
@@ -364,7 +364,7 @@ gcm_prefs_devices_treeview_clicked_cb (GtkTreeSelection *selection, gboolean dat
NULL);
/* not a xrandr device */
- if (type == GCM_DEVICE_TYPE_SCANNER) {
+ if (type != GCM_DEVICE_TYPE_DISPLAY) {
widget = GTK_WIDGET (gtk_builder_get_object (builder, "expander1"));
gtk_widget_hide (widget);
widget = GTK_WIDGET (gtk_builder_get_object (builder, "button_reset"));
@@ -740,27 +740,50 @@ gcm_prefs_uevent_cb (GUdevClient *client_, const gchar *action, GUdevDevice *dev
}
/**
- * gcm_prefs_add_device_scanner:
+ * gcm_prefs_device_type_to_icon_name:
+ **/
+static const gchar *
+gcm_prefs_device_type_to_icon_name (GcmDeviceType type)
+{
+ if (type == GCM_DEVICE_TYPE_DISPLAY)
+ return "video-display";
+ if (type == GCM_DEVICE_TYPE_SCANNER)
+ return "scanner";
+ if (type == GCM_DEVICE_TYPE_PRINTER)
+ return "printer";
+ if (type == GCM_DEVICE_TYPE_CAMERA)
+ return "camera-photo";
+ return "image-missing";
+}
+
+/**
+ * gcm_prefs_add_device_type:
**/
static void
-gcm_prefs_add_device_scanner (GcmDevice *device)
+gcm_prefs_add_device_type (GcmDevice *device)
{
GtkTreeIter iter;
gchar *title;
gchar *id;
+ GcmDeviceType type;
+ const gchar *icon_name;
/* get details */
g_object_get (device,
"id", &id,
"title", &title,
+ "type", &type,
NULL);
+ /* get icon */
+ icon_name = gcm_prefs_device_type_to_icon_name (type);
+
/* add to list */
gtk_list_store_append (list_store_devices, &iter);
gtk_list_store_set (list_store_devices, &iter,
GPM_DEVICES_COLUMN_ID, id,
GPM_DEVICES_COLUMN_TITLE, title,
- GPM_DEVICES_COLUMN_ICON, "scanner", -1);
+ GPM_DEVICES_COLUMN_ICON, icon_name, -1);
g_free (id);
g_free (title);
}
@@ -782,8 +805,8 @@ gcm_prefs_added_cb (GcmClient *gcm_client_, GcmDevice *gcm_device, gpointer user
/* add the device */
if (type == GCM_DEVICE_TYPE_DISPLAY)
gcm_prefs_add_device_xrandr (gcm_device);
- else if (type == GCM_DEVICE_TYPE_SCANNER)
- gcm_prefs_add_device_scanner (gcm_device);
+ else
+ gcm_prefs_add_device_type (gcm_device);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]