diff --git a/dialogs/keyboard-settings/command-dialog.c b/dialogs/keyboard-settings/command-dialog.c index 539a68a3..b294f206 100644 --- a/dialogs/keyboard-settings/command-dialog.c +++ b/dialogs/keyboard-settings/command-dialog.c @@ -235,7 +235,7 @@ command_dialog_run (CommandDialog *dialog, { response = gtk_dialog_run (GTK_DIALOG (dialog)); - if (G_UNLIKELY (response != GTK_RESPONSE_CANCEL && g_utf8_strlen (command_dialog_get_command (dialog), -1) == 0)) + if (G_UNLIKELY (response == GTK_RESPONSE_OK && g_utf8_strlen (command_dialog_get_command (dialog), -1) == 0)) xfce_dialog_show_error (GTK_WINDOW (dialog), NULL, _("The command may not be empty.")); else finished = TRUE; diff --git a/dialogs/keyboard-settings/xfce-keyboard-settings.c b/dialogs/keyboard-settings/xfce-keyboard-settings.c index 3b2f4307..a2793326 100644 --- a/dialogs/keyboard-settings/xfce-keyboard-settings.c +++ b/dialogs/keyboard-settings/xfce-keyboard-settings.c @@ -983,27 +983,14 @@ xfce_keyboard_settings_add_button_clicked (XfceKeyboardSettings *settings, GObject *parent; const gchar *shortcut; const gchar *command; - gboolean finished = FALSE; gint response; gboolean snotify; g_return_if_fail (XFCE_IS_KEYBOARD_SETTINGS (settings)); - /* Create command dialog */ + /* Request a command from the user */ command_dialog = command_dialog_new (NULL, NULL, FALSE); - - /* Run command dialog until a valid (non-empty) command is entered or the dialog is cancelled */ - do - { - response = command_dialog_run (COMMAND_DIALOG (command_dialog), GTK_WIDGET (button)); - - if (G_UNLIKELY (response == GTK_RESPONSE_OK && - g_utf8_strlen (command_dialog_get_command (COMMAND_DIALOG (command_dialog)), -1) == 0)) - xfce_dialog_show_error (GTK_WINDOW (command_dialog), NULL, _("Shortcut command may not be empty.")); - else - finished = TRUE; - } - while (!finished); + response = command_dialog_run (COMMAND_DIALOG (command_dialog), GTK_WIDGET (button)); /* Abort if the dialog was cancelled */ if (G_UNLIKELY (response == GTK_RESPONSE_OK)) @@ -1076,7 +1063,6 @@ xfce_keyboard_settings_edit_button_clicked (XfceKeyboardSettings *settings) if (G_LIKELY (gtk_tree_model_get_iter (model, &iter, path))) { GtkWidget *command_dialog; - gboolean finished = FALSE; gboolean snotify; gchar *shortcut_label; gchar *shortcut; @@ -1093,21 +1079,9 @@ xfce_keyboard_settings_edit_button_clicked (XfceKeyboardSettings *settings) DBG ("Edit shortcut %s / command %s", shortcut, command); - /* Create command dialog */ + /* Request a new command from the user */ command_dialog = command_dialog_new (shortcut_label, command, snotify); - - /* Run command dialog until a valid (non-empty) command is entered or the dialog is cancelled */ - do - { - response = command_dialog_run (COMMAND_DIALOG (command_dialog), GTK_WIDGET (view)); - - if (G_UNLIKELY (response == GTK_RESPONSE_OK && - g_utf8_strlen (command_dialog_get_command (COMMAND_DIALOG (command_dialog)), -1) == 0)) - xfce_dialog_show_error (GTK_WINDOW (command_dialog), NULL, _("Shortcut command may not be empty.")); - else - finished = TRUE; - } - while (!finished); + response = command_dialog_run (COMMAND_DIALOG (command_dialog), GTK_WIDGET (view)); /* Abort if the dialog was cancelled */ if (G_UNLIKELY (response == GTK_RESPONSE_OK))