From cd5ce62734ad534dac85b735e1c190d7938aa37c Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 13 Aug 2015 12:25:50 +0200 Subject: Move Keymap Properties dialog to gtk_builder --- rcm-client-receive.c | 87 +++++--------------- rcm-client.ui | 222 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 239 insertions(+), 70 deletions(-) diff --git a/rcm-client-receive.c b/rcm-client-receive.c index a1a3536..bf23e88 100644 --- a/rcm-client-receive.c +++ b/rcm-client-receive.c @@ -576,94 +576,45 @@ static void properties_dialog(GtkButton *button, gpointer user_data) { struct remote *remote = user_data; - GtkWindow *parent = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))); GtkWidget *dialog; - GtkWidget *content_area; - GtkWidget *grid; - GtkWidget *icon; - GtkWidget *id_label; GtkWidget *id; - GtkWidget *name_label; GtkWidget *name_input; - GtkWidget *desc_label; GtkWidget *desc_input; - GtkWidget *width_label; - GtkAdjustment *width_adj; GtkWidget *width_input; - GtkWidget *height_label; - GtkAdjustment *height_adj; GtkWidget *height_input; - gint r; + GtkAdjustment *width_adj; + GtkAdjustment *height_adj; const gchar *name; gchar *name_cpy; const gchar *desc; gchar *desc_cpy; gint width; gint height; + gint r; - dialog = gtk_dialog_new_with_buttons("Keymap Properties", parent, - GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, - "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); + dialog = GTK_WIDGET(gtk_builder_get_object(global->builder, "keymap_properties")); - icon = gtk_image_new_from_icon_name("document-page-setup", GTK_ICON_SIZE_DIALOG); - gtk_widget_set_valign(icon, GTK_ALIGN_START); - gtk_grid_attach(GTK_GRID(grid), icon, 0, 1, 1, 2); + id = GTK_WIDGET(gtk_builder_get_object(global->builder, "keymap_properties_id_value")); + gtk_label_set_text(GTK_LABEL(id), remote->id); - id_label = gtk_label_new("ID:"); - gtk_widget_set_halign(id_label, GTK_ALIGN_START); - id = gtk_label_new(remote->id); - gtk_widget_set_halign(id, GTK_ALIGN_START); - gtk_grid_attach(GTK_GRID(grid), id_label, 1, 1, 1, 1); - gtk_grid_attach(GTK_GRID(grid), id, 2, 1, 1, 1); - - name_label = gtk_label_new("Name:"); - gtk_widget_set_halign(name_label, GTK_ALIGN_START); - name_input = gtk_entry_new(); - gtk_widget_set_hexpand(name_input, true); - gtk_entry_set_max_length(GTK_ENTRY(name_input), 100); + name_input = GTK_WIDGET(gtk_builder_get_object(global->builder, "keymap_properties_name_value")); gtk_entry_set_text(GTK_ENTRY(name_input), remote->name); - gtk_grid_attach(GTK_GRID(grid), name_label, 1, 2, 1, 1); - gtk_grid_attach(GTK_GRID(grid), name_input, 2, 2, 1, 1); - - desc_label = gtk_label_new("Description:"); - gtk_widget_set_halign(desc_label, GTK_ALIGN_START); - desc_input = gtk_entry_new(); - gtk_widget_set_hexpand(desc_input, true); - gtk_entry_set_max_length(GTK_ENTRY(desc_input), 100); + + desc_input = GTK_WIDGET(gtk_builder_get_object(global->builder, "keymap_properties_description_value")); gtk_entry_set_text(GTK_ENTRY(desc_input), remote->description); - gtk_grid_attach(GTK_GRID(grid), desc_label, 1, 3, 1, 1); - gtk_grid_attach(GTK_GRID(grid), desc_input, 2, 3, 1, 1); - - width_label = gtk_label_new("Width"); - gtk_widget_set_halign(width_label, GTK_ALIGN_START); - width_adj = gtk_adjustment_new(remote->width, 1.0, 100.0, 1.0, 5.0, 0.0); - width_input = gtk_spin_button_new(width_adj, 1.0, 0); - gtk_widget_set_hexpand(width_input, true); - gtk_grid_attach(GTK_GRID(grid), width_label, 1, 4, 1, 1); - gtk_grid_attach(GTK_GRID(grid), width_input, 2, 4, 1, 1); - - height_label = gtk_label_new("Height:"); - gtk_widget_set_halign(height_label, GTK_ALIGN_START); - height_adj = gtk_adjustment_new(remote->height, 1.0, 100.0, 1.0, 5.0, 0.0); - height_input = gtk_spin_button_new(height_adj, 1.0, 0); - gtk_widget_set_hexpand(height_input, true); - gtk_grid_attach(GTK_GRID(grid), height_label, 1, 5, 1, 1); - gtk_grid_attach(GTK_GRID(grid), height_input, 2, 5, 1, 1); - 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); + width_input = GTK_WIDGET(gtk_builder_get_object(global->builder, "keymap_properties_width_value")); + width_adj = GTK_ADJUSTMENT(gtk_builder_get_object(global->builder, "keymap_properties_width_adjustment")); + gtk_adjustment_set_value(width_adj, remote->width); + + height_input = GTK_WIDGET(gtk_builder_get_object(global->builder, "keymap_properties_height_value")); + height_adj = GTK_ADJUSTMENT(gtk_builder_get_object(global->builder, "keymap_properties_height_adjustment")); + gtk_adjustment_set_value(height_adj, remote->height); + gtk_widget_show_all(dialog); r = gtk_dialog_run(GTK_DIALOG(dialog)); - if (r != GTK_RESPONSE_ACCEPT) + if (r != 1) goto out; name = gtk_entry_get_text(GTK_ENTRY(name_input)); @@ -715,7 +666,7 @@ properties_dialog(GtkButton *button, gpointer user_data) "RemoteControlClientRemoteLabel"); out: - gtk_widget_destroy(dialog); + gtk_widget_hide(dialog); } static void diff --git a/rcm-client.ui b/rcm-client.ui index 927e84d..24828bd 100644 --- a/rcm-client.ui +++ b/rcm-client.ui @@ -2,6 +2,18 @@ + + 1 + 100 + 1 + 10 + + + 1 + 100 + 1 + 10 + RemoteControlClientWindow False @@ -16,7 +28,7 @@ 12 crossfade - + True False Connecting to server... @@ -27,7 +39,7 @@ - + True False none @@ -55,4 +67,210 @@ + + False + Keymap Properties + True + True + normal + main_window + + + False + baseline + 12 + 12 + 12 + 12 + vertical + 2 + + + False + end + + + OK + True + True + True + + + True + True + 0 + + + + + Cancel + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + 12 + 12 + 12 + + + True + False + 0 + document-page-setup + 6 + + + 0 + 0 + 5 + + + + + True + False + ID: + 1 + + + 1 + 0 + + + + + True + False + Name: + 1 + + + 1 + 1 + + + + + True + False + Description: + 1 + + + 1 + 2 + + + + + True + False + Width: + 1 + + + 1 + 3 + + + + + True + False + Height: + 1 + + + 1 + 4 + + + + + True + False + 0 + + + 2 + 0 + + + + + True + True + 100 + + + 2 + 1 + + + + + True + True + 100 + + + 2 + 2 + + + + + True + True + digits + keymap_properties_width_adjustment + + + 2 + 3 + + + + + True + True + digits + keymap_properties_height_adjustment + + + 2 + 4 + + + + + False + True + 1 + + + + + + keymap_properties_ok + keymap_properties_cancel + + -- cgit v1.2.3