]> git.pld-linux.org Git - packages/vim.git/blob - 6.2.260
- removed conflict with 6.2.259
[packages/vim.git] / 6.2.260
1 To: vim-dev@vim.org
2 Subject: Patch 6.2.260
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 6.2.260
11 Problem:    GTK 2: Can't quit a dialog with <Esc>.
12             GTK 1 and 2: <Enter> always gives a result, even when the default
13             button has been disabled.
14 Solution:   Handle these keys explicitly.  When no default button is specified
15             use the first one (works mostly like it was before).
16 Files:      src/gui_gtk.c
17
18
19 *** ../vim-6.2.259/src/gui_gtk.c        Sun Feb 15 13:08:28 2004
20 --- src/gui_gtk.c       Thu Feb 12 12:46:10 2004
21 ***************
22 *** 1512,1517 ****
23 --- 1512,1518 ----
24   typedef struct _CancelData
25   {
26       int               *status;
27 +     int               ignore_enter;
28       GtkWidget *dialog;
29   } CancelData;
30   
31 ***************
32 *** 1530,1535 ****
33 --- 1531,1540 ----
34       static int
35   dlg_key_press_event(GtkWidget * widget, GdkEventKey * event, CancelData *data)
36   {
37 +     /* Ignore hitting Enter when there is no default button. */
38 +     if (data->ignore_enter && event->keyval == GDK_Return)
39 +       return TRUE;
40
41       if (event->keyval != GDK_Escape && event->keyval != GDK_Return)
42         return FALSE;
43   
44 ***************
45 *** 1820,1825 ****
46 --- 1825,1831 ----
47   
48       vim_free(names);
49   
50 +     cancel_data.ignore_enter = FALSE;
51       if (butcount > 0)
52       {
53         --def_but;              /* 1 is first button */
54 ***************
55 *** 1830,1835 ****
56 --- 1836,1844 ----
57             gtk_widget_grab_focus(button[def_but]);
58             gtk_widget_grab_default(button[def_but]);
59         }
60 +       else
61 +           /* No default, ignore hitting Enter. */
62 +           cancel_data.ignore_enter = TRUE;
63       }
64   
65       if (textfield != NULL)
66 ***************
67 *** 2103,2118 ****
68    * GUI used to work this way, and I consider the impact on UI consistency
69    * low enough to justify implementing this as a special Vim feature.
70    */
71   /*ARGSUSED2*/
72       static gboolean
73   dialog_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
74   {
75 !     if ((event->state & gtk_accelerator_get_default_mod_mask()) == 0)
76       {
77         return gtk_window_mnemonic_activate(
78                    GTK_WINDOW(widget), event->keyval,
79                    gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget)));
80       }
81       return FALSE; /* continue emission */
82   }
83   
84 --- 2112,2149 ----
85    * GUI used to work this way, and I consider the impact on UI consistency
86    * low enough to justify implementing this as a special Vim feature.
87    */
88 + typedef struct _DialogInfo
89 + {
90 +     int               ignore_enter;       /* no default button, ignore "Enter" */
91 +     int               noalt;              /* accept accelerators without Alt */
92 +     GtkDialog *dialog;            /* Widget of the dialog */
93 + } DialogInfo;
94
95   /*ARGSUSED2*/
96       static gboolean
97   dialog_key_press_event_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
98   {
99 !     DialogInfo *di = (DialogInfo *)data;
100
101 !     /* Ignore hitting "Enter" if there is no default button. */
102 !     if (di->ignore_enter && event->keyval == GDK_Return)
103 !       return TRUE;
104
105 !     /* Close the dialog when hitting "Esc". */
106 !     if (event->keyval == GDK_Escape)
107 !     {
108 !       gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT);
109 !       return TRUE;
110 !     }
111
112 !     if (di->noalt
113 !             && (event->state & gtk_accelerator_get_default_mod_mask()) == 0)
114       {
115         return gtk_window_mnemonic_activate(
116                    GTK_WINDOW(widget), event->keyval,
117                    gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget)));
118       }
119
120       return FALSE; /* continue emission */
121   }
122   
123 ***************
124 *** 2128,2135 ****
125 --- 2159,2168 ----
126       GtkWidget *entry = NULL;
127       char_u    *text;
128       int               response;
129 +     DialogInfo  dialoginfo;
130   
131       dialog = create_message_dialog(type, title, message);
132 +     dialoginfo.dialog = GTK_DIALOG(dialog);
133       dialog_add_buttons(GTK_DIALOG(dialog), buttons);
134   
135       if (textfield != NULL)
136 ***************
137 *** 2151,2168 ****
138   
139         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
140                            alignment, TRUE, FALSE, 0);
141       }
142       else
143 !     {
144 !       /* Allow activation of mnemonic accelerators without pressing <Alt>.
145 !        * For safety, connect this signal handler only if the dialog has
146 !        * no other other interaction widgets but buttons. */
147 !       g_signal_connect(G_OBJECT(dialog), "key_press_event",
148 !                        G_CALLBACK(&dialog_key_press_event_cb), NULL);
149 !     }
150   
151       if (def_but > 0)
152         gtk_dialog_set_default_response(GTK_DIALOG(dialog), def_but);
153   
154       /* Show the mouse pointer if it's currently hidden. */
155       gui_mch_mousehide(FALSE);
156 --- 2184,2207 ----
157   
158         gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),
159                            alignment, TRUE, FALSE, 0);
160 +       dialoginfo.noalt = FALSE;
161       }
162       else
163 !       dialoginfo.noalt = TRUE;
164
165 !     /* Allow activation of mnemonic accelerators without pressing <Alt> when
166 !      * there is no textfield.  Handle pressing Enter and Esc. */
167 !     g_signal_connect(G_OBJECT(dialog), "key_press_event",
168 !                        G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo);
169   
170       if (def_but > 0)
171 +     {
172         gtk_dialog_set_default_response(GTK_DIALOG(dialog), def_but);
173 +       dialoginfo.ignore_enter = FALSE;
174 +     }
175 +     else
176 +       /* No default button, ignore pressing Enter. */
177 +       dialoginfo.ignore_enter = TRUE;
178   
179       /* Show the mouse pointer if it's currently hidden. */
180       gui_mch_mousehide(FALSE);
181 *** ../vim-6.2.259/src/version.c        Sun Feb 15 13:37:22 2004
182 --- src/version.c       Sun Feb 15 13:39:01 2004
183 ***************
184 *** 639,640 ****
185 --- 639,642 ----
186   {   /* Add new patch number below this line */
187 + /**/
188 +     260,
189   /**/
190
191 -- 
192 hundred-and-one symptoms of being an internet addict:
193 146. You experience ACTUAL physical withdrawal symptoms when away
194      from your 'puter and the net.
195
196  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
197 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
198 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
199  \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
This page took 0.038322 seconds and 3 git commands to generate.