summaryrefslogtreecommitdiff
path: root/rcm-client-receive.c
diff options
context:
space:
mode:
Diffstat (limited to 'rcm-client-receive.c')
-rw-r--r--rcm-client-receive.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c
index 4f21f78..9931a08 100644
--- a/rcm-client-receive.c
+++ b/rcm-client-receive.c
@@ -50,6 +50,7 @@ struct rcbutton {
};
struct state {
+ RCDevice *object;
GList *remotes;
GList *header_buttons;
bool editing;
@@ -518,6 +519,65 @@ resize_layout(struct remote *remote, guint16 new_width, guint16 new_height)
}
static void
+update_remote(struct remote *remote)
+{
+ GVariantBuilder kbuilder;
+ GVariantBuilder lbuilder;
+ GList *l;
+
+ g_variant_builder_init(&kbuilder, G_VARIANT_TYPE("aa{sv}"));
+ for (l = remote->keymap; l; l = l->next) {
+ struct keymap_entry *ke = l->data;
+
+ g_variant_builder_open(&kbuilder, G_VARIANT_TYPE ("a{sv}"));
+
+ g_variant_builder_add(&kbuilder, "{sv}", "protocol",
+ g_variant_new_string(ke->protocol));
+
+ g_variant_builder_add(&kbuilder, "{sv}", "scancode",
+ g_variant_new_uint64(ke->scancode));
+
+ g_variant_builder_add(&kbuilder, "{sv}", "keycode",
+ g_variant_new_string(ke->keycode));
+
+ g_variant_builder_close(&kbuilder);
+ }
+
+ g_variant_builder_init(&lbuilder, G_VARIANT_TYPE("aa{sv}"));
+ for (l = remote->buttons; l; l = l->next) {
+ struct rcbutton *rcb = l->data;
+
+ g_variant_builder_open(&lbuilder, G_VARIANT_TYPE ("a{sv}"));
+
+ switch (rcb->type) {
+ case RCBUTTON_TYPE_NORMAL:
+ g_variant_builder_add(&lbuilder, "{sv}", "type",
+ g_variant_new_string("button"));
+ g_variant_builder_add(&lbuilder, "{sv}", "keycode",
+ g_variant_new_string(rcb->name));
+ break;
+
+ case RCBUTTON_TYPE_BLANK:
+ g_variant_builder_add(&lbuilder, "{sv}", "type",
+ g_variant_new_string("blank"));
+ break;
+
+ default:
+ g_assert_not_reached();
+ }
+
+ g_variant_builder_close(&lbuilder);
+ }
+
+ rcdevice_call_set_keymap_sync(state.object, remote->id,
+ remote->name, remote->description,
+ remote->width, remote->height,
+ g_variant_builder_end(&kbuilder),
+ g_variant_builder_end(&lbuilder),
+ NULL, NULL);
+}
+
+static void
resize_layout_dialog(GtkButton *button, gpointer user_data)
{
struct remote *remote = user_data;
@@ -589,6 +649,8 @@ resize_layout_dialog(GtkButton *button, gpointer user_data)
resize_layout(remote, width, height);
+ update_remote(remote);
+
out:
gtk_widget_destroy(dialog);
}
@@ -856,13 +918,14 @@ void rcng_client_receive_init_ui(GDBusObject *new_hw)
return;
gchar **keymap_ids = NULL;
- RCDevice *object = RCDEVICE(interface);
- rcdevice_call_list_keymaps_sync(object, &keymap_ids, NULL, NULL);
+ /* FIXME: unref object */
+ state.object = RCDEVICE(interface);
+ rcdevice_call_list_keymaps_sync(state.object, &keymap_ids, NULL, NULL);
for (i = 0; keymap_ids[i]; i++) {
struct remote *remote;
g_print("Fetching keymap: %s\n", keymap_ids[i]);
- remote = get_keymap(object, keymap_ids[i]);
+ remote = get_keymap(state.object, keymap_ids[i]);
state.remotes = g_list_prepend(state.remotes, remote);
gtk_grid_attach(GTK_GRID(rgrid), remote->widget, i, 1, 1, 1);