diff options
Diffstat (limited to 'rcm-client-hardware-list.c')
-rw-r--r-- | rcm-client-hardware-list.c | 39 |
1 files changed, 32 insertions, 7 deletions
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); |