diff options
Diffstat (limited to 'rcm-client-receive.c')
-rw-r--r-- | rcm-client-receive.c | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/rcm-client-receive.c b/rcm-client-receive.c index bf23e88..f4b40d1 100644 --- a/rcm-client-receive.c +++ b/rcm-client-receive.c @@ -217,67 +217,34 @@ new_blank_widget(struct rcbutton *rcb); static void edit_button_dialog(GtkButton *button, struct rcbutton *rcb) { - GtkWindow *parent = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))); GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *grid; - GtkWidget *icon; - GtkWidget *keycode_label; - GtkWidget *keycode_cbox; - GtkWidget *comment_label; - GtkWidget *comment_entry; + GtkComboBoxText *keycode_cbox; + GtkEntry *comment_entry; gint r; GList *ke; unsigned i; - dialog = gtk_dialog_new_with_buttons("Edit Button", parent, - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - "Delete", GTK_RESPONSE_NO, - "OK", GTK_RESPONSE_ACCEPT, - "Cancel", GTK_RESPONSE_REJECT, - NULL); - - grid = gtk_grid_new(); - gtk_grid_set_column_spacing(GTK_GRID(grid), 12); - gtk_grid_set_row_spacing(GTK_GRID(grid), 12); - gtk_container_set_border_width(GTK_CONTAINER(grid), 12); - - icon = gtk_image_new_from_icon_name("preferences-desktop-keyboard", GTK_ICON_SIZE_DIALOG); - gtk_widget_set_valign(icon, GTK_ALIGN_START); - gtk_grid_attach(GTK_GRID(grid), icon, 0, 1, 1, 2); - - keycode_label = gtk_label_new("Keycode:"); + dialog = GTK_WIDGET(gtk_builder_get_object(global->builder, "edit_button")); - gtk_widget_set_halign(keycode_label, GTK_ALIGN_START); - keycode_cbox = gtk_combo_box_text_new(); + keycode_cbox = GTK_COMBO_BOX_TEXT(gtk_builder_get_object(global->builder, "edit_button_keycode_value")); + gtk_combo_box_text_remove_all(keycode_cbox); for (ke = rcb->remote->keymap, i = 0; ke; ke = ke->next, i++) { struct keymap_entry *entry = ke->data; - gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(keycode_cbox), - NULL, entry->keycode); + gtk_combo_box_text_append(keycode_cbox, NULL, entry->keycode); if (rcb->name && !strcmp(rcb->name, entry->keycode)) gtk_combo_box_set_active(GTK_COMBO_BOX(keycode_cbox), i); } - gtk_grid_attach(GTK_GRID(grid), keycode_label, 1, 1, 1, 1); - gtk_grid_attach(GTK_GRID(grid), keycode_cbox, 2, 1, 1, 1); - comment_label = gtk_label_new("Comment:"); - gtk_widget_set_halign(comment_label, GTK_ALIGN_START); - comment_entry = gtk_entry_new(); - gtk_entry_set_max_length(GTK_ENTRY(comment_entry), 100); - gtk_entry_set_placeholder_text(GTK_ENTRY(comment_entry), "No comment"); - gtk_grid_attach(GTK_GRID(grid), comment_label, 1, 2, 1, 1); - gtk_grid_attach(GTK_GRID(grid), comment_entry, 2, 2, 1, 1); + comment_entry = GTK_ENTRY(gtk_builder_get_object(global->builder, "edit_button_comment_value")); + gtk_entry_set_text(comment_entry, ""); - content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); - gtk_container_set_border_width(GTK_CONTAINER(content_area), 12); - gtk_container_add(GTK_CONTAINER(content_area), grid); gtk_widget_show_all(dialog); - gchar *keycode; r = gtk_dialog_run(GTK_DIALOG(dialog)); switch (r) { - case GTK_RESPONSE_ACCEPT: + case 1: { + gchar *keycode; keycode = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(keycode_cbox)); if (!keycode) goto out; @@ -295,8 +262,9 @@ edit_button_dialog(GtkButton *button, struct rcbutton *rcb) rcb->button = new_button_widget(rcb, "dummy", 0xf001f001, keycode); gtk_widget_show_all(rcb->button); break; + } - case GTK_RESPONSE_NO: + case 2: if (rcb->type == RCBUTTON_TYPE_BLANK) goto out; @@ -314,7 +282,7 @@ edit_button_dialog(GtkButton *button, struct rcbutton *rcb) } out: - gtk_widget_destroy(dialog); + gtk_widget_hide(dialog); } static void |