Hi, This patch improves HIG compliance when compiled with FEAT_GUI_GNOME:
* Close confirmation dialogs use "Save/Discard/Cancel" instead of "Yes/No/Cancel" * GTK_STOCK_SAVE used for "Save" * Default button placed at end of message dialog, with order passed in set as alternative button order vim_dialog_yesnocancel() is renamed to vim_dialog_savediscardcancel(), because that's all it's used for. Same for vim_dialog_yesnoallcancel(). Also attached is a patch to disable guioptions="t" (tearoff menus) when compiled with FEAT_GUI_GNOME, also for desktop consistency. Ed
--- vim7/src/ex_cmds2.c 2007/01/06 17:32:00 1.1 +++ vim7/src/ex_cmds2.c 2007/01/06 18:16:08 @@ -1369,9 +1369,9 @@ dialog_changed(buf, checkall) (buf->b_fname != NULL) ? buf->b_fname : (char_u *)_("Untitled")); if (checkall) - ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1); + ret = vim_dialog_savediscardallcancel(VIM_QUESTION, NULL, buff, 1); else - ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); + ret = vim_dialog_savediscardcancel(VIM_QUESTION, NULL, buff, 1); if (ret == VIM_YES) { --- vim7/src/message.c 2007/01/06 17:32:00 1.1 +++ vim7/src/message.c 2007/01/06 19:34:08 @@ -3599,7 +3599,7 @@ vim_dialog_yesno(type, title, message, d } int -vim_dialog_yesnocancel(type, title, message, dflt) +vim_dialog_savediscardcancel(type, title, message, dflt) int type; char_u *title; char_u *message; @@ -3608,7 +3608,12 @@ vim_dialog_yesnocancel(type, title, mess switch (do_dialog(type, title == NULL ? (char_u *)_("Question") : title, message, - (char_u *)_("&Yes\n&No\n&Cancel"), dflt, NULL)) +#ifdef FEAT_GUI_GNOME + (char_u *)_("&Save\n&Discard\n&Cancel"), +#else + (char_u *)_("&Yes\n&No\n&Cancel"), +#endif + dflt, NULL)) { case 1: return VIM_YES; case 2: return VIM_NO; @@ -3617,7 +3622,7 @@ vim_dialog_yesnocancel(type, title, mess } int -vim_dialog_yesnoallcancel(type, title, message, dflt) +vim_dialog_savediscardallcancel(type, title, message, dflt) int type; char_u *title; char_u *message; @@ -3626,7 +3631,11 @@ vim_dialog_yesnoallcancel(type, title, m switch (do_dialog(type, title == NULL ? (char_u *)"Question" : title, message, +#ifdef FEAT_GUI_GNOME + (char_u *)_("&Save\n&Discard\nSave &all\nD&iscard all\n&Cancel"), +#else (char_u *)_("&Yes\n&No\nSave &All\n&Discard All\n&Cancel"), +#endif dflt, NULL)) { case 1: return VIM_YES; --- vim7/src/gui_gtk.c 2007/01/06 17:33:18 1.1 +++ vim7/src/gui_gtk.c 2007/01/06 19:11:31 @@ -2121,13 +2121,17 @@ button_equal(const char *a, const char * } static void -dialog_add_buttons(GtkDialog *dialog, char_u *button_string) +dialog_add_buttons(GtkDialog *dialog, char_u *button_string, int def_but) { char **ok; char **ync; /* "yes no cancel" */ + char **save; char **buttons; int n_buttons = 0; int idx; +#ifdef FEAT_GUI_GNOME + char *def_label = NULL; +#endif button_string = vim_strsave(button_string); /* must be writable */ if (button_string == NULL) @@ -2153,6 +2157,7 @@ dialog_add_buttons(GtkDialog *dialog, ch */ ok = split_button_translation(N_("&Ok")); ync = split_button_translation(N_("&Yes\n&No\n&Cancel")); + save = split_button_translation(N_("&Save")); buttons = split_button_string(button_string, &n_buttons); /* @@ -2176,28 +2181,54 @@ dialog_add_buttons(GtkDialog *dialog, ch * since anyone can create their own dialogs using Vim functions. * Thus we have to check for those too. */ - if (ok != NULL && ync != NULL) /* almost impossible to fail */ + if (ok != NULL && ync != NULL && save != NULL) /* almost impossible to fail */ { if (button_equal(label, ok[0])) label = GTK_STOCK_OK; else if (button_equal(label, ync[0])) label = GTK_STOCK_YES; else if (button_equal(label, ync[1])) label = GTK_STOCK_NO; else if (button_equal(label, ync[2])) label = GTK_STOCK_CANCEL; + else if (button_equal(label, save[0])) label = GTK_STOCK_SAVE; else if (button_equal(label, "Ok")) label = GTK_STOCK_OK; else if (button_equal(label, "Yes")) label = GTK_STOCK_YES; else if (button_equal(label, "No")) label = GTK_STOCK_NO; else if (button_equal(label, "Cancel")) label = GTK_STOCK_CANCEL; + else if (button_equal(label, "Save")) label = GTK_STOCK_SAVE; + } +#ifdef FEAT_GUI_GNOME + if (idx == def_but) { + def_label = label; + continue; } +#endif label8 = CONVERT_TO_UTF8((char_u *)label); gtk_dialog_add_button(dialog, (const gchar *)label8, idx); CONVERT_TO_UTF8_FREE(label8); } +#ifdef FEAT_GUI_GNOME + if (def_label != NULL) { + char_u *label8; + int *idx_arr; + + label8 = CONVERT_TO_UTF8((char_u *)def_label); + gtk_dialog_add_button(dialog, (const gchar *)label8, def_but); + CONVERT_TO_UTF8_FREE(label8); + idx_arr = (int *) alloc((sizeof (int)) * n_buttons); + for (idx = 1; idx <= n_buttons; ++idx) + idx_arr[idx-1] = idx; + gtk_dialog_set_alternative_button_order_from_array(dialog, n_buttons, idx_arr); + vim_free(idx_arr); + } +#endif if (ok != NULL) vim_free(*ok); if (ync != NULL) vim_free(*ync); + if (save != NULL) + vim_free(*save); vim_free(ok); vim_free(ync); + vim_free(save); vim_free(buttons); vim_free(button_string); } @@ -2255,7 +2286,7 @@ gui_mch_dialog(int type, /* type of dialog = create_message_dialog(type, title, message); dialoginfo.dialog = GTK_DIALOG(dialog); - dialog_add_buttons(GTK_DIALOG(dialog), buttons); + dialog_add_buttons(GTK_DIALOG(dialog), buttons, def_but); if (textfield != NULL) { --- vim7/src/proto/message.pro 2007/01/06 18:44:35 1.1 +++ vim7/src/proto/message.pro 2007/01/06 18:45:58 @@ -65,7 +65,7 @@ extern void msg_advance __ARGS((int col) extern int do_dialog __ARGS((int type, char_u *title, char_u *message, char_u *buttons, int dfltbutton, char_u *textfield)); extern void display_confirm_msg __ARGS((void)); extern int vim_dialog_yesno __ARGS((int type, char_u *title, char_u *message, int dflt)); -extern int vim_dialog_yesnocancel __ARGS((int type, char_u *title, char_u *message, int dflt)); -extern int vim_dialog_yesnoallcancel __ARGS((int type, char_u *title, char_u *message, int dflt)); +extern int vim_dialog_savediscardcancel __ARGS((int type, char_u *title, char_u *message, int dflt)); +extern int vim_dialog_savediscardallcancel __ARGS((int type, char_u *title, char_u *message, int dflt)); extern char_u *do_browse __ARGS((int flags, char_u *title, char_u *dflt, char_u *ext, char_u *initdir, char_u *filter, buf_T *buf)); /* vim: set ft=c : */
--- vim7/src/option.c 2007/01/06 18:47:11 1.1 +++ vim7/src/option.c 2007/01/06 18:47:52 @@ -1242,7 +1242,11 @@ static struct vimoption #if defined(FEAT_GUI) (char_u *)&p_go, PV_NONE, # if defined(UNIX) && !defined(MACOS) +# if defined(FEAT_GUI_GNOME) + {(char_u *)"aegimrLT", (char_u *)0L} +# else {(char_u *)"aegimrLtT", (char_u *)0L} +# endif # else {(char_u *)"egmrLtT", (char_u *)0L} # endif