From 6b7f41a334a46c6149edbde31158bdd549f959a5 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 15 Jul 2015 16:28:05 +0200 Subject: Add tooltip to buttons --- rcm-client-receive.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/rcm-client-receive.c b/rcm-client-receive.c index 6663f66..f88b453 100644 --- a/rcm-client-receive.c +++ b/rcm-client-receive.c @@ -160,22 +160,27 @@ out: } static struct rcbutton * -new_button_add(GtkGrid *grid, const char *name, GdkRGBA *color, +new_button_add(GtkGrid *grid, const gchar *protocol, guint64 scancode, + const char *keycode, GdkRGBA *color, guint x, guint y, guint w, guint h) { struct rcbutton *rcb; + gchar *tooltip; rcb = g_malloc0(sizeof(*rcb)); - rcb->name = strdup(name); + rcb->name = strdup(keycode); rcb->col = x; rcb->row = y; rcb->cols = w; rcb->rows = h; rcb->button = gtk_toggle_button_new(); gtk_widget_set_sensitive(rcb->button, false); + tooltip = g_strdup_printf("Protocol: %s\nScancode: 0x%08" PRIx64 "\nKeycode : %s", protocol, scancode, keycode); + gtk_widget_set_tooltip_text(rcb->button, tooltip); + g_free(tooltip); remote->buttons = g_list_append(remote->buttons, rcb); gtk_grid_attach(grid, rcb->button, x, y, w, h); - create_button_img(rcb->button, name); + create_button_img(rcb->button, keycode); return rcb; } @@ -402,7 +407,7 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw) g_variant_lookup(item, "scancode", "t", &scancode); g_variant_lookup(item, "keycode", "s", &keycode); - new_button_add(GTK_GRID(grid), keycode, NULL, col, row, 1, 1); + new_button_add(GTK_GRID(grid), protocol, scancode, keycode, NULL, col, row, 1, 1); col++; if (col >= km_width) { -- cgit v1.2.3