[Xfce4-commits] <xfce4-settings:jeromeg/keyboard-shortcuts> Improve the contents of the command dialog.

Jérôme Guelfucci noreply at xfce.org
Sat Dec 22 10:18:01 CET 2012


Updating branch refs/heads/jeromeg/keyboard-shortcuts
         to 1161ff583b2c946715826a514a5489a7309dacea (commit)
       from b1b9fa1598e54093c4a9682b875f083dfb0a2a74 (commit)

commit 1161ff583b2c946715826a514a5489a7309dacea
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sat Dec 22 10:00:57 2012 +0100

    Improve the contents of the command dialog.
    
    When creating a shortcut show an explanation instead of an empty
    shortcut label. Show the shortcut label when we have one instead of the
    raw Gtk+ accelerator string.

 dialogs/keyboard-settings/command-dialog.c         |   36 +++++++++++++++-----
 dialogs/keyboard-settings/xfce-keyboard-settings.c |    6 +++-
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/dialogs/keyboard-settings/command-dialog.c b/dialogs/keyboard-settings/command-dialog.c
index 7216c7b..5256b3a 100644
--- a/dialogs/keyboard-settings/command-dialog.c
+++ b/dialogs/keyboard-settings/command-dialog.c
@@ -120,6 +120,21 @@ command_dialog_create_contents (CommandDialog *dialog,
   gtk_widget_grab_default (button);
   gtk_widget_show (button);
 
+  if (!shortcut)
+    {
+      const gchar *explanation;
+      gchar       *explanation_markup;
+
+      label = gtk_label_new (NULL);
+
+      explanation = _("Enter the command you want to trigger with a shortcut.");
+      explanation_markup = g_strdup_printf ("<i>%s</i>", explanation);
+      gtk_label_set_markup (GTK_LABEL (label), explanation_markup);
+      gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+                          label, FALSE, FALSE, 0);
+      gtk_widget_show (label);
+    }
+
   table = gtk_table_new (3, 2, FALSE);
   gtk_table_set_row_spacings (GTK_TABLE (table), 6);
   gtk_table_set_col_spacings (GTK_TABLE (table), 12);
@@ -127,15 +142,18 @@ command_dialog_create_contents (CommandDialog *dialog,
   gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), table);
   gtk_widget_show (table);
 
-  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, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
-  gtk_widget_show (label);
-
-  label = gtk_label_new (shortcut);
-  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-  gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
-  gtk_widget_show (label);
+  if (shortcut)
+    {
+      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, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+      gtk_widget_show (label);
+
+      label = gtk_label_new (shortcut);
+      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+      gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
+      gtk_widget_show (label);
+    }
 
   label = gtk_label_new (_("Command:"));
   gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
diff --git a/dialogs/keyboard-settings/xfce-keyboard-settings.c b/dialogs/keyboard-settings/xfce-keyboard-settings.c
index 0a01e1a..6880d95 100644
--- a/dialogs/keyboard-settings/xfce-keyboard-settings.c
+++ b/dialogs/keyboard-settings/xfce-keyboard-settings.c
@@ -728,14 +728,17 @@ xfce_keyboard_settings_edit_command (XfceKeyboardSettings *settings,
   /* Convert tree path to tree iter */
   if (G_LIKELY (gtk_tree_model_get_iter (model, &iter, path)))
     {
+      gchar *shortcut_label;
+
       /* Read shortcut and current command from the activated row */
       gtk_tree_model_get (model, &iter,
                           COMMAND_COLUMN, &command,
                           SHORTCUT_COLUMN, &shortcut,
+                          SHORTCUT_LABEL_COLUMN, &shortcut_label,
                           SNOTIFY_COLUMN, &snotify, -1);
 
       /* Request a new command from the user */
-      dialog = command_dialog_new (shortcut, command, snotify);
+      dialog = command_dialog_new (shortcut_label, command, snotify);
       response = command_dialog_run (COMMAND_DIALOG (dialog), GTK_WIDGET (tree_view));
 
       if (G_LIKELY (response == GTK_RESPONSE_OK))
@@ -760,6 +763,7 @@ xfce_keyboard_settings_edit_command (XfceKeyboardSettings *settings,
       gtk_widget_destroy (dialog);
 
       /* Free strings */
+      g_free (shortcut_label);
       g_free (shortcut);
       g_free (command);
     }


More information about the Xfce4-commits mailing list