summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rcm-client-receive.c58
-rw-r--r--rcm-client.ui148
2 files changed, 161 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
diff --git a/rcm-client.ui b/rcm-client.ui
index 338f439..1a47d26 100644
--- a/rcm-client.ui
+++ b/rcm-client.ui
@@ -64,6 +64,154 @@
</object>
</child>
</object>
+ <object class="GtkDialog" id="edit_button">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Edit Button</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="edit_button_vbox">
+ <property name="can_focus">False</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="edit_button_action_area">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="edit_button_delete">
+ <property name="label" translatable="yes">Delete</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="edit_button_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">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="edit_button_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">2</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="edit_button_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="edit_button_icon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="yalign">0</property>
+ <property name="icon_name">preferences-desktop-keyboard</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="height">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="edit_button_keycode_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Keycode:</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="edit_button_comment_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Comment:</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="GtkComboBoxText" id="edit_button_keycode_value">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="edit_button_comment_value">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="max_length">100</property>
+ <property name="placeholder_text" translatable="yes">No comment</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</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="2">edit_button_delete</action-widget>
+ <action-widget response="1">edit_button_ok</action-widget>
+ <action-widget response="0">edit_button_cancel</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkDialog" id="keymap_properties">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Keymap Properties</property>