diff options
Diffstat (limited to 'rcm-client-receive.c')
-rw-r--r-- | rcm-client-receive.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c index b12b0c2..b54af85 100644 --- a/rcm-client-receive.c +++ b/rcm-client-receive.c @@ -21,6 +21,7 @@ struct remote { guint width; guint height; bool editing; + bool active; }; struct rcbutton { @@ -116,7 +117,7 @@ create_button_img(GtkWidget *button, const char *keycode) label = "<?>"; } - if (lik->cs) + if (lik->cairo_surface) goto out; img_size = calculate_img_size(button); @@ -152,10 +153,10 @@ create_button_img(GtkWidget *button, const char *keycode) pango_cairo_show_layout(ct, layout); g_object_unref(layout); cairo_destroy(ct); - lik->cs = surface; + lik->cairo_surface = surface; out: - img = gtk_image_new_from_surface(lik->cs); + img = gtk_image_new_from_surface(lik->cairo_surface); gtk_button_set_image(GTK_BUTTON(button), img); } @@ -314,14 +315,36 @@ on_notebook_page_change(GtkNotebook *notebook, GtkWidget *page, guint new_page_n if (new_page_num != own_page_num) { remove_header_buttons(); remote->editing = false; + remote->active = false; return; } + remote->active = true; remote->editing = false; set_edit_keymap(remote->editing); g_print("Page change: %i -> %u\n", own_page_num, new_page_num); } +void rcng_client_receive_keypress(GDBusObject *obj, const gchar *keycode, bool pressed) +{ + GList *l; + + /* FIXME: Use object path, this is just test code */ + if (!remote || !remote->active) + return; + + for (l = remote->buttons; l; l = l->next) { + struct rcbutton *rcb = l->data; + + if (strcmp(keycode, rcb->name)) + continue; + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rcb->button), pressed); + } + + g_print("Key %s %s\n", keycode, pressed ? "pressed" : "released"); +} + void rcng_client_receive_init_ui(GDBusObject *new_hw) { static bool first = true; |