diff options
-rw-r--r-- | RemoteControlManager.xml | 1 | ||||
-rw-r--r-- | rcm-client-hardware-list.c | 39 | ||||
-rw-r--r-- | rcm-server-main.c | 6 | ||||
-rw-r--r-- | rcm-server-main.h | 1 |
4 files changed, 40 insertions, 7 deletions
diff --git a/RemoteControlManager.xml b/RemoteControlManager.xml index cc7438c..c4cb500 100644 --- a/RemoteControlManager.xml +++ b/RemoteControlManager.xml @@ -36,6 +36,7 @@ <property name='DriverName' type='s' access='read'/> <property name='KernelKeymapName' type='s' access='read'/> <property name='HardwareType' type='s' access='read'/> + <property name='Error' type='s' access='read'/> </interface> <interface name='org.gnome.RemoteControlManager.IRDevice'> <annotation name="org.gtk.GDBus.C.Name" value="RCIRDevice"/> diff --git a/rcm-client-hardware-list.c b/rcm-client-hardware-list.c index 64a0236..662dbf3 100644 --- a/rcm-client-hardware-list.c +++ b/rcm-client-hardware-list.c @@ -109,10 +109,12 @@ hw_selected_cb(GtkListBox *box, GtkListBoxRow *row, gpointer user_data) { RCDevice *object = user_data; GtkWidget *advanced_button; + gchar *error; advanced_button = GTK_WIDGET(gtk_builder_get_object(global->builder, "hardware_page_action_advanced")); + error = row ? g_object_get_data(G_OBJECT(row), "error") : NULL; g_signal_connect(advanced_button, "clicked", G_CALLBACK(advanced_cb), object); - gtk_widget_set_sensitive(advanced_button, row ? true : false); + gtk_widget_set_sensitive(advanced_button, row && !error ? true : false); } static gint @@ -137,6 +139,7 @@ void rcng_client_hardware_list_add(GDBusObject *hw) GtkWidget *hw_list_box; GDBusInterface *interface; RCDevice *object; + const gchar *error; g_print(" - Object at %s\n", g_dbus_object_get_object_path(hw)); @@ -152,15 +155,22 @@ void rcng_client_hardware_list_add(GDBusObject *hw) return; object = RCDEVICE(interface); - printf("Name: %s, Desc: %s, Driver: %s, Kernel keymap: %s, HW: %s\n", + error = rcdevice_get_error(object); + if (error && strlen(error) == 0) + error = NULL; + + printf("Name: %s, Desc: %s, Driver: %s, Kernel keymap: %s, HW: %s, error %s\n", rcdevice_get_sys_name(object), rcdevice_get_description(object), rcdevice_get_driver_name(object), rcdevice_get_kernel_keymap_name(object), - rcdevice_get_hardware_type(object)); + rcdevice_get_hardware_type(object), + rcdevice_get_error(object)); row = gtk_list_box_row_new(); g_object_set_data_full(G_OBJECT(row), "rcdev", rcdevice_dup_sys_name(object), g_free); + if (error) + g_object_set_data_full(G_OBJECT(row), "error", rcdevice_dup_error(object), g_free); box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12); gtk_widget_set_margin_top(box, 6); @@ -173,10 +183,23 @@ void rcng_client_hardware_list_add(GDBusObject *hw) gtk_widget_set_halign(icon, GTK_ALIGN_START); gtk_box_pack_start(GTK_BOX(box), icon, FALSE, FALSE, 0); - labeltxt = g_strdup_printf("%s: %s", - rcdevice_get_sys_name(object), - rcdevice_get_description(object)); - label = gtk_label_new(labeltxt); + const char *dev_name = rcdevice_get_sys_name(object); + const char *dev_desc = rcdevice_get_description(object); + + if (dev_desc && strlen(dev_desc) < 1) + dev_desc = NULL; + + if (error) { + labeltxt = g_markup_printf_escaped("<span foreground=\"red\">%s%s%s</span>", + dev_name, + dev_desc ? ": " : "", + dev_desc ? dev_desc : ""); + gtk_widget_set_tooltip_text(row, error); + } else + labeltxt = g_markup_printf_escaped("%s: %s", dev_name, dev_desc); + + label = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(label), labeltxt); g_free(labeltxt); gtk_widget_set_valign(label, GTK_ALIGN_CENTER); gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0); @@ -185,12 +208,14 @@ void rcng_client_hardware_list_add(GDBusObject *hw) gtk_widget_set_valign(button, GTK_ALIGN_CENTER); gtk_widget_set_halign(button, GTK_ALIGN_END); g_signal_connect(button, "clicked", G_CALLBACK(hardware_properties_cb), object); + gtk_widget_set_sensitive(button, error ? false : true); gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); button = gtk_button_new_from_icon_name("accessories-calculator-symbolic", GTK_ICON_SIZE_MENU); gtk_widget_set_valign(button, GTK_ALIGN_CENTER); gtk_widget_set_halign(button, GTK_ALIGN_END); g_signal_connect(button, "clicked", G_CALLBACK(edit_keymaps_cb), hw); + gtk_widget_set_sensitive(button, error ? false : true); gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0); gtk_container_add(GTK_CONTAINER(row), box); diff --git a/rcm-server-main.c b/rcm-server-main.c index 65c82f7..4a0adbc 100644 --- a/rcm-server-main.c +++ b/rcm-server-main.c @@ -54,6 +54,8 @@ property_get(sd_bus *bus, const char *path, const char *interface, return sd_bus_message_append(reply, "s", dev->keymap_name); else if (!strcmp(property, "HardwareType")) return sd_bus_message_append(reply, "s", "ir"); + else if (!strcmp(property, "Error")) + return sd_bus_message_append(reply, "s", dev->error); sd_bus_error_set_const(error, "org.gnome.RemoteControlManager.InvalidProperty", "Sorry, invalid property"); return -EINVAL; @@ -654,6 +656,7 @@ static const sd_bus_vtable device_vtable[] = { SD_BUS_PROPERTY("DriverName", "s", property_get, 0, 0), SD_BUS_PROPERTY("KernelKeymapName", "s", property_get, 0, 0), SD_BUS_PROPERTY("HardwareType", "s", property_get, 0, 0), + SD_BUS_PROPERTY("Error", "s", property_get, 0, 0), SD_BUS_METHOD("ListKeymaps", NULL, "as", method_listkeymaps, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("GetKeymap", "s", "ssqqaa{sv}aa{sv}", method_getkeymap, SD_BUS_VTABLE_UNPRIVILEGED), SD_BUS_METHOD("SetKeymap", "sssqqaa{sv}aa{sv}", NULL, method_setkeymap, SD_BUS_VTABLE_UNPRIVILEGED), @@ -711,6 +714,7 @@ add_device(struct manager *mgr, struct udev_device *udev) device->path = path; device->name = device->path + strlen("/org/gnome/RemoteControlManager/"); device->evdev_fd = -1; + device->error = NULL; if (keymaps_load(device) < 0) { fprintf(stderr, "failed to load keymaps: %m\n"); @@ -751,6 +755,8 @@ add_device(struct manager *mgr, struct udev_device *udev) r = evdev_setup(device, devnode); if (r < 0) { printf("Failed to setup evdev: %s\n", devnode); + device->error = "Error: Failed to setup evdev"; + device->input_name = NULL; udev_device_unref(evdev); continue; } diff --git a/rcm-server-main.h b/rcm-server-main.h index 0be3bf4..689c4fd 100644 --- a/rcm-server-main.h +++ b/rcm-server-main.h @@ -7,6 +7,7 @@ struct device { char *input_name; char *driver_name; char *keymap_name; + char *error; int evdev_fd; sd_event_source *evdev_ev; struct libevdev *evdev_dev; |