Author: jannis Date: 2008-07-18 00:28:43 +0000 (Fri, 18 Jul 2008) New Revision: 27334
Modified: xfce4-settings/trunk/ChangeLog xfce4-settings/trunk/TODO xfce4-settings/trunk/dialogs/keyboard-settings/main.c xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c Log: * dialogs/keyboard-settings/main.c: Fix some issues with multiple row selection in the shortcuts tree view. Properly destroy the command dialog when adding a new command but pressing the cancel button in the command dialog. * dialogs/keyboard-settings/shortcut-dialog.c: Remove the "No shortcut" button as we don't support empty shortcut properties anyway. Modified: xfce4-settings/trunk/ChangeLog =================================================================== --- xfce4-settings/trunk/ChangeLog 2008-07-17 22:01:30 UTC (rev 27333) +++ xfce4-settings/trunk/ChangeLog 2008-07-18 00:28:43 UTC (rev 27334) @@ -1,3 +1,13 @@ +2008-07-18 Jannis Pohlmann <[EMAIL PROTECTED]> + + * dialogs/keyboard-settings/main.c: Fix some issues with multiple row + selection in the shortcuts tree view. Properly destroy the command + dialog when adding a new command but pressing the cancel button in + the command dialog. + * dialogs/keyboard-settings/shortcut-dialog.c: Remove the "No + shortcut" button as we don't support empty shortcut properties + anyway. + 2008-07-17 Nick Schermer <[EMAIL PROTECTED]> * dialogs/display-settings/Makefile.am, Modified: xfce4-settings/trunk/TODO =================================================================== --- xfce4-settings/trunk/TODO 2008-07-17 22:01:30 UTC (rev 27333) +++ xfce4-settings/trunk/TODO 2008-07-18 00:28:43 UTC (rev 27334) @@ -1,6 +1,7 @@ Keyboard settings ------------------------------------------------------------------------ + * Use XfceTitledDialog for the ShortcutDialog. * The default values of the sliders don't make sence. I think we should also show the slider value and add a tooltip to the slide what the value actually stands for, like in the mouse dialog. Modified: xfce4-settings/trunk/dialogs/keyboard-settings/main.c =================================================================== --- xfce4-settings/trunk/dialogs/keyboard-settings/main.c 2008-07-17 22:01:30 UTC (rev 27333) +++ xfce4-settings/trunk/dialogs/keyboard-settings/main.c 2008-07-18 00:28:43 UTC (rev 27334) @@ -59,10 +59,7 @@ -gboolean opt_version = FALSE; - - - +static gboolean opt_version = FALSE; static GOptionEntry entries[] = { { "version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &opt_version, N_("Version information"), NULL }, { NULL } @@ -70,6 +67,14 @@ +struct TreeViewInfo +{ + GtkTreeView *view; + GtkTreeIter *iter; +}; + + + static void keyboard_settings_box_sensitivity (GtkToggleButton *button, GtkWidget *box) @@ -146,9 +151,9 @@ static gboolean -keyboard_settings_validate_shortcut (ShortcutDialog *dialog, - const gchar *shortcut, - GtkTreeView *tree_view) +keyboard_settings_validate_shortcut (ShortcutDialog *dialog, + const gchar *shortcut, + struct TreeViewInfo *info) { GtkTreeSelection *selection; GtkTreeModel *model; @@ -157,31 +162,40 @@ gchar *current_shortcut; gchar *property; -#if 1 - /* Ignore raw 'Return' since that may have been used to activate the shortcut row */ - if (G_UNLIKELY (g_utf8_collate (shortcut, "Return") == 0 - || g_utf8_collate (shortcut, "space") == 0)) + /* Ignore raw 'Return' and 'space' since that may have been used to activate the shortcut row */ + if (G_UNLIKELY (g_utf8_collate (shortcut, "Return") == 0 || g_utf8_collate (shortcut, "space") == 0)) return FALSE; -#endif - selection = gtk_tree_view_get_selection (tree_view); + /* Build property name */ + property = g_strdup_printf ("/%s", shortcut); - if (G_LIKELY (gtk_tree_selection_get_selected (selection, &model, &iter))) + if (G_LIKELY (info->iter != NULL)) { - gtk_tree_model_get (model, &iter, SHORTCUT_COLUMN, ¤t_shortcut, -1); + /* Get shortcut of the row we're currently editing */ + gtk_tree_model_get (gtk_tree_view_get_model (info->view), info->iter, SHORTCUT_COLUMN, ¤t_shortcut, -1); - property = g_strdup_printf ("/%s", shortcut); - + /* Don't accept the shortcut if it already is being used somewhere else (and not by the current row) */ if (G_UNLIKELY (xfconf_channel_has_property (kbd_channel, property) && g_utf8_collate (current_shortcut, shortcut) != 0)) { xfce_err (_("Keyboard shortcut '%s' is already being used for something else."), shortcut); shortcut_accepted = FALSE; } - - g_free (property); + + /* Free shortcut string */ g_free (current_shortcut); } + else + { + if (G_UNLIKELY (xfconf_channel_has_property (kbd_channel, property))) + { + xfce_err (_("Keyboard shortcut '%s' is already being used for something else."), shortcut); + shortcut_accepted = FALSE; + } + } + /* Free strings */ + g_free (property); + return shortcut_accepted; } @@ -190,24 +204,26 @@ static void keyboard_settings_add_shortcut (GtkTreeView *tree_view) { - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *dialog; - const gchar *shortcut = NULL; - gboolean finished = FALSE; - gchar *command = NULL; - gchar *property; - gint response; + struct TreeViewInfo info; + GtkTreeModel *model; + GtkTreeIter iter; + GtkWidget *shortcut_dialog; + GtkWidget *command_dialog; + const gchar *shortcut = NULL; + gboolean finished = FALSE; + gchar *command = NULL; + gchar *property; + gint response; /* Create command dialog */ - dialog = command_dialog_new (NULL, NULL); + command_dialog = command_dialog_new (NULL, NULL); /* Run command dialog until a vaild (non-empty) command is entered or the dialog is cancelled */ do { - response = command_dialog_run (COMMAND_DIALOG (dialog), GTK_WIDGET (tree_view)); + response = command_dialog_run (COMMAND_DIALOG (command_dialog), GTK_WIDGET (tree_view)); - if (G_UNLIKELY (response == GTK_RESPONSE_OK && g_utf8_strlen (command_dialog_get_command (COMMAND_DIALOG (dialog)), -1) == 0)) + if (G_UNLIKELY (response == GTK_RESPONSE_OK && g_utf8_strlen (command_dialog_get_command (COMMAND_DIALOG (command_dialog)), -1) == 0)) xfce_err (_("Short command may not be empty.")); else finished = TRUE; @@ -215,48 +231,55 @@ while (!finished); /* Abort if the dialog was cancelled */ - if (G_UNLIKELY (response == GTK_RESPONSE_CANCEL)) - return; + if (G_UNLIKELY (response == GTK_RESPONSE_OK)) + { + /* Get the command */ + command = g_strdup (command_dialog_get_command (COMMAND_DIALOG (command_dialog))); - /* Get the command */ - command = g_strdup (command_dialog_get_command (COMMAND_DIALOG (dialog))); + /* Hide the command dialog */ + gtk_widget_hide (command_dialog); - /* Destroy the dialog */ - gtk_widget_destroy (dialog); + /* Prepare tree view info */ + info.view = tree_view; + info.iter = NULL; - /* Create shortcut dialog */ - dialog = shortcut_dialog_new (command); - g_signal_connect (dialog, "validate-shortcut", G_CALLBACK (keyboard_settings_validate_shortcut), tree_view); + /* Create shortcut dialog */ + shortcut_dialog = shortcut_dialog_new (command); + g_signal_connect (shortcut_dialog, "validate-shortcut", G_CALLBACK (keyboard_settings_validate_shortcut), &info); - /* Run shortcut dialog until a valid shortcut is entered or the dialog is cancelled */ - response = shortcut_dialog_run (SHORTCUT_DIALOG (dialog), GTK_WIDGET (tree_view)); + /* Run shortcut dialog until a valid shortcut is entered or the dialog is cancelled */ + response = shortcut_dialog_run (SHORTCUT_DIALOG (shortcut_dialog), GTK_WIDGET (tree_view)); - /* Only continue if the shortcut dialog succeeded */ - if (G_LIKELY (response == GTK_RESPONSE_OK)) - { - /* Get shortcut */ - shortcut = shortcut_dialog_get_shortcut (SHORTCUT_DIALOG (dialog)); + /* Only continue if the shortcut dialog succeeded */ + if (G_LIKELY (response == GTK_RESPONSE_OK)) + { + /* Get shortcut */ + shortcut = shortcut_dialog_get_shortcut (SHORTCUT_DIALOG (shortcut_dialog)); - /* Get tree view list store */ - model = gtk_tree_view_get_model (tree_view); + /* Get tree view list store */ + model = gtk_tree_view_get_model (tree_view); - /* Append new row to the list store */ - gtk_list_store_append (GTK_LIST_STORE (model), &iter); + /* Append new row to the list store */ + gtk_list_store_append (GTK_LIST_STORE (model), &iter); - /* Set row values */ - gtk_list_store_set (GTK_LIST_STORE (model), &iter, SHORTCUT_COLUMN, shortcut, ACTION_COLUMN, command, -1); + /* Set row values */ + gtk_list_store_set (GTK_LIST_STORE (model), &iter, SHORTCUT_COLUMN, shortcut, ACTION_COLUMN, command, -1); - /* Save the new shortcut to xfconf */ - property = g_strdup_printf ("/%s", shortcut); - xfconf_channel_set_array (kbd_channel, property, G_TYPE_STRING, "execute", G_TYPE_STRING, command, G_TYPE_INVALID); - g_free (property); + /* Save the new shortcut to xfconf */ + property = g_strdup_printf ("/%s", shortcut); + xfconf_channel_set_array (kbd_channel, property, G_TYPE_STRING, "execute", G_TYPE_STRING, command, G_TYPE_INVALID); + g_free (property); + } + + /* Destroy the shortcut dialog */ + gtk_widget_destroy (shortcut_dialog); + + /* Free command string */ + g_free (command); } /* Destroy the shortcut dialog */ - gtk_widget_destroy (dialog); - - /* Free command string */ - g_free (command); + gtk_widget_destroy (command_dialog); } @@ -322,15 +345,16 @@ keyboard_settings_edit_shortcut (GtkTreeView *tree_view, GtkTreePath *path) { - GtkTreeModel *model; - GtkTreeIter iter; - GtkWidget *dialog; - const gchar *new_shortcut; - gchar *current_shortcut; - gchar *action; - gchar *old_property; - gchar *new_property; - gint response; + struct TreeViewInfo info; + GtkTreeModel *model; + GtkTreeIter iter; + GtkWidget *dialog; + const gchar *new_shortcut; + gchar *current_shortcut; + gchar *action; + gchar *old_property; + gchar *new_property; + gint response; /* Get tree view model */ model = gtk_tree_view_get_model (tree_view); @@ -341,12 +365,16 @@ /* Read current shortcut from the activated row */ gtk_tree_model_get (model, &iter, SHORTCUT_COLUMN, ¤t_shortcut, ACTION_COLUMN, &action, -1); + /* Prepare tree view info */ + info.view = tree_view; + info.iter = &iter; + /* Request a new shortcut from the user */ dialog = shortcut_dialog_new (action); - g_signal_connect (dialog, "validate-shortcut", G_CALLBACK (keyboard_settings_validate_shortcut), tree_view); + g_signal_connect (dialog, "validate-shortcut", G_CALLBACK (keyboard_settings_validate_shortcut), &info); response = shortcut_dialog_run (SHORTCUT_DIALOG (dialog), GTK_WIDGET (tree_view)); - if (G_LIKELY (response != GTK_RESPONSE_CANCEL)) + if (G_LIKELY (response == GTK_RESPONSE_OK)) { /* Build property name */ old_property = g_strdup_printf ("/%s", current_shortcut); @@ -417,7 +445,7 @@ dialog = command_dialog_new (shortcut, current_action); response = command_dialog_run (COMMAND_DIALOG (dialog), GTK_WIDGET (tree_view)); - if (G_LIKELY (response != GTK_RESPONSE_CANCEL)) + if (G_LIKELY (response == GTK_RESPONSE_OK)) { /* Get the action entered by the user */ new_action = command_dialog_get_command (COMMAND_DIALOG (dialog)); Modified: xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c =================================================================== --- xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c 2008-07-17 22:01:30 UTC (rev 27333) +++ xfce4-settings/trunk/dialogs/keyboard-settings/shortcut-dialog.c 2008-07-18 00:28:43 UTC (rev 27334) @@ -233,11 +233,6 @@ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CANCEL); gtk_widget_show (button); - /* Create clear button */ - button = GTK_WIDGET (xfce_create_mixed_button (GTK_STOCK_CLEAR, _("No shortcut"))); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_NO); - gtk_widget_show (button); - hbox = gtk_hbox_new (FALSE, 12); gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox); _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits