Updating branch refs/heads/jeromeg/keyboard-shortcuts to 3e158dc0c8b3cbca57d2af07f13780d3337d1ce5 (commit) from f29fa617c47ac595d4c13095eb210fdf0b54aad2 (commit)
commit 3e158dc0c8b3cbca57d2af07f13780d3337d1ce5 Author: Jérôme Guelfucci <jero...@xfce.org> Date: Fri Dec 21 15:05:55 2012 +0100 Improve the UI of the dialog to grab shortcuts. Add an explanation string to make it clear that the user is expected to press the keys. libxfce4kbd-private/xfce-shortcut-dialog.c | 77 ++++++++++++++++++++-------- 1 files changed, 55 insertions(+), 22 deletions(-) diff --git a/libxfce4kbd-private/xfce-shortcut-dialog.c b/libxfce4kbd-private/xfce-shortcut-dialog.c index fc5b6fa..f85bff9 100644 --- a/libxfce4kbd-private/xfce-shortcut-dialog.c +++ b/libxfce4kbd-private/xfce-shortcut-dialog.c @@ -193,26 +193,35 @@ xfce_shortcut_dialog_create_contents (XfceShortcutDialog *dialog, const gchar *action_name, const gchar *action) { + GtkWidget *content_box; + GtkWidget *alignment; + GtkWidget *box; GtkWidget *button; - GtkWidget *table; GtkWidget *label; + const gchar *action_type; const gchar *title; - const gchar *action_label; + gchar *explanation_label; if (g_utf8_collate (provider, "xfwm4") == 0) { title = _("Window Manager Action Shortcut"); - action_label = _("Action:"); + /* TRANSLATORS: this string will be used to create an explanation for + * the user in a following string */ + action_type = _("action"); } else if (g_utf8_collate (provider, "commands") == 0) { title = _("Command Shortcut"); - action_label = _("Command:"); + /* TRANSLATORS: this string will be used to create an explanation for + * the user in a following string */ + action_type = _("command"); } else { title = _("Shortcut"); - action_label = _("Action:"); + /* TRANSLATORS: this string will be used to create an explanation for + * the user in a following string */ + action_type = _("action"); } /* Set dialog title */ @@ -232,31 +241,55 @@ xfce_shortcut_dialog_create_contents (XfceShortcutDialog *dialog, gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CANCEL); gtk_widget_show (button); - table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); - gtk_container_set_border_width (GTK_CONTAINER (table), 12); - gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), table); - gtk_widget_show (table); - - label = gtk_label_new (action_label); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - gtk_widget_show (label); - - label = gtk_label_new (action_name); + /* Main content container */ + alignment = gtk_alignment_new (0, 0, 1, 1); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 6, 12, 0); + gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), + alignment); + gtk_widget_show (alignment); + + #if GTK_CHECK_VERSION (3, 0, 0) + content_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); + #else + content_box = gtk_vbox_new (FALSE, 6); + #endif + gtk_container_set_border_width (GTK_CONTAINER (content_box), 6); + gtk_container_add (GTK_CONTAINER (alignment), content_box); + gtk_widget_show (content_box); + + /* TRANSLATORS: this creates the explanation for the user. The first %s is replaced + * by the action type which you translated earlier, the second %s is replaced by the + * action name which comes from somewhere else. + * THE ORDER MUSTN'T BE REVERSED! */ + explanation_label = + g_strdup_printf (_("Press now the keyboard keys you want to use to trigger the %s '%s'."), + action_type, action_name); + + label = gtk_label_new (explanation_label); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 0, 1); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_container_add (GTK_CONTAINER (content_box), label); gtk_widget_show (label); + g_free (explanation_label); + + /* Box and labels to display the shortcut currently being grabbed. + * It will be updated to key-press events. */ + #if GTK_CHECK_VERSION (3, 0, 0) + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12); + #else + box = gtk_hbox_new (FALSE, 12); + #endif + gtk_container_add (GTK_CONTAINER (content_box), box); + gtk_widget_show (box); label = gtk_label_new (_("Shortcut:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0); + gtk_container_add (GTK_CONTAINER (box), label); gtk_widget_show (label); - dialog->shortcut_label = gtk_label_new (NULL); + dialog->shortcut_label = gtk_label_new (_("No keys pressed yet, proceed.")); gtk_misc_set_alignment (GTK_MISC (dialog->shortcut_label), 0.0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (table), dialog->shortcut_label, 1, 2, 1, 2); + gtk_container_add (GTK_CONTAINER (box), dialog->shortcut_label); gtk_widget_show (dialog->shortcut_label); /* Connect to key release signal for determining the new shortcut */ _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits