summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2015-08-13 12:25:50 +0200
committerDavid Härdeman <david@hardeman.nu>2015-08-13 12:25:50 +0200
commitcd5ce62734ad534dac85b735e1c190d7938aa37c (patch)
tree77fb907e90aacdfdb24db51d3884a195b0b469ce
parent8b48c4b812ba80c00131c441d6655233c4010f42 (diff)
Move Keymap Properties dialog to gtk_builder
-rw-r--r--rcm-client-receive.c87
-rw-r--r--rcm-client.ui222
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 @@
<!-- Generated with glade 3.19.0 -->
<interface>
<requires lib="gtk+" version="3.16"/>
+ <object class="GtkAdjustment" id="keymap_properties_height_adjustment">
+ <property name="lower">1</property>
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="keymap_properties_width_adjustment">
+ <property name="lower">1</property>
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkWindow" id="main_window">
<property name="name">RemoteControlClientWindow</property>
<property name="can_focus">False</property>
@@ -16,7 +28,7 @@
<property name="margin_bottom">12</property>
<property name="transition_type">crossfade</property>
<child>
- <object class="GtkLabel" id="label1">
+ <object class="GtkLabel" id="status_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Connecting to server...</property>
@@ -27,7 +39,7 @@
</packing>
</child>
<child>
- <object class="GtkListBox" id="listbox1">
+ <object class="GtkListBox" id="hardware_listbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection_mode">none</property>
@@ -55,4 +67,210 @@
</object>
</child>
</object>
+ <object class="GtkDialog" id="keymap_properties">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Keymap Properties</property>
+ <property name="modal">True</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">normal</property>
+ <property name="transient_for">main_window</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="keymap_properties_vbox">
+ <property name="can_focus">False</property>
+ <property name="halign">baseline</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="keymap_properties_action_area">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="keymap_properties_ok">
+ <property name="label" translatable="yes">OK</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="keymap_properties_cancel">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="keymap_properties_grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_bottom">12</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
+ <child>
+ <object class="GtkImage" id="keymap_properties_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <property name="icon_name">document-page-setup</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="height">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="keymap_properties_id_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">ID:</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="keymap_properties_name_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Name:</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="keymap_properties_description_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Description:</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="keymap_properties_width_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Width:</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="keymap_properties_height_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Height:</property>
+ <property name="xalign">1</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="keymap_properties_id_value">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="keymap_properties_name_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">100</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="keymap_properties_description_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">100</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="keymap_properties_width_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="input_purpose">digits</property>
+ <property name="adjustment">keymap_properties_width_adjustment</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="keymap_properties_height_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="input_purpose">digits</property>
+ <property name="adjustment">keymap_properties_height_adjustment</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="1">keymap_properties_ok</action-widget>
+ <action-widget response="0">keymap_properties_cancel</action-widget>
+ </action-widgets>
+ </object>
</interface>