Mercurial > hg > xemacs-beta
comparison src/native-gtk-toolbar.c @ 5178:97eb4942aec8
merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Mon, 29 Mar 2010 21:28:13 -0500 |
parents | 8b2f75cecb89 d372b17f63ce |
children | 308d34e9f07d |
comparison
equal
deleted
inserted
replaced
5177:b785049378e3 | 5178:97eb4942aec8 |
---|---|
1 /* toolbar implementation -- GTK interface. | 1 /* toolbar implementation -- GTK interface. |
2 Copyright (C) 2000 Aaron Lehmann | 2 Copyright (C) 2000 Aaron Lehmann |
3 Copyright (C) 2010 Ben Wing. | |
3 | 4 |
4 This file is part of XEmacs. | 5 This file is part of XEmacs. |
5 | 6 |
6 XEmacs is free software; you can redistribute it and/or modify it | 7 XEmacs is free software; you can redistribute it and/or modify it |
7 under the terms of the GNU General Public License as published by the | 8 under the terms of the GNU General Public License as published by the |
30 #include "faces.h" | 31 #include "faces.h" |
31 #include "frame.h" | 32 #include "frame.h" |
32 #include "toolbar.h" | 33 #include "toolbar.h" |
33 #include "window.h" | 34 #include "window.h" |
34 | 35 |
35 #define SET_TOOLBAR_WAS_VISIBLE_FLAG(frame, pos, flag) \ | 36 static void |
36 do { \ | 37 gtk_clear_toolbar (struct frame *f, enum edge_pos pos); |
37 switch (pos) \ | |
38 { \ | |
39 case TOP_TOOLBAR: \ | |
40 (frame)->top_toolbar_was_visible = flag; \ | |
41 break; \ | |
42 case BOTTOM_TOOLBAR: \ | |
43 (frame)->bottom_toolbar_was_visible = flag; \ | |
44 break; \ | |
45 case LEFT_TOOLBAR: \ | |
46 (frame)->left_toolbar_was_visible = flag; \ | |
47 break; \ | |
48 case RIGHT_TOOLBAR: \ | |
49 (frame)->right_toolbar_was_visible = flag; \ | |
50 break; \ | |
51 default: \ | |
52 ABORT (); \ | |
53 } \ | |
54 } while (0) | |
55 | |
56 static void | |
57 gtk_clear_toolbar (struct frame *f, enum toolbar_pos pos); | |
58 | 38 |
59 static void | 39 static void |
60 gtk_toolbar_callback (GtkWidget *UNUSED (w), gpointer user_data) | 40 gtk_toolbar_callback (GtkWidget *UNUSED (w), gpointer user_data) |
61 { | 41 { |
62 struct toolbar_button *tb = (struct toolbar_button *) user_data; | 42 struct toolbar_button *tb = (struct toolbar_button *) user_data; |
64 call0 (tb->callback); | 44 call0 (tb->callback); |
65 } | 45 } |
66 | 46 |
67 | 47 |
68 static void | 48 static void |
69 gtk_output_toolbar (struct frame *f, enum toolbar_pos pos) | 49 gtk_output_toolbar (struct frame *f, enum edge_pos pos) |
70 { | 50 { |
71 GtkWidget *toolbar; | 51 GtkWidget *toolbar; |
72 Lisp_Object button, window, glyph, instance; | 52 Lisp_Object button, window, glyph, instance; |
73 unsigned int checksum = 0; | 53 unsigned int checksum = 0; |
74 struct window *w; | 54 struct window *w; |
112 function to use as a callback. */ | 92 function to use as a callback. */ |
113 | 93 |
114 { | 94 { |
115 gtk_clear_toolbar (f, pos); | 95 gtk_clear_toolbar (f, pos); |
116 FRAME_GTK_TOOLBAR_WIDGET (f)[pos] = toolbar = | 96 FRAME_GTK_TOOLBAR_WIDGET (f)[pos] = toolbar = |
117 gtk_toolbar_new (((pos == TOP_TOOLBAR) || (pos == BOTTOM_TOOLBAR)) ? | 97 gtk_toolbar_new (((pos == TOP_EDGE) || (pos == BOTTOM_EDGE)) ? |
118 GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, | 98 GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, |
119 GTK_TOOLBAR_BOTH); | 99 GTK_TOOLBAR_BOTH); |
120 } | 100 } |
121 | 101 |
122 if (NILP (w->toolbar_buttons_captioned_p)) | 102 if (NILP (w->toolbar_buttons_captioned_p)) |
191 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), FRAME_GTK_TOOLBAR_WIDGET (f)[pos],x, y); | 171 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), FRAME_GTK_TOOLBAR_WIDGET (f)[pos],x, y); |
192 gtk_widget_show_all (FRAME_GTK_TOOLBAR_WIDGET (f)[pos]); | 172 gtk_widget_show_all (FRAME_GTK_TOOLBAR_WIDGET (f)[pos]); |
193 } | 173 } |
194 | 174 |
195 static void | 175 static void |
196 gtk_clear_toolbar (struct frame *f, enum toolbar_pos pos) | 176 gtk_clear_toolbar (struct frame *f, enum edge_pos pos) |
197 { | 177 { |
198 FRAME_GTK_TOOLBAR_CHECKSUM (f, pos) = 0; | 178 FRAME_GTK_TOOLBAR_CHECKSUM (f, pos) = 0; |
199 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0); | 179 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0); |
200 if (FRAME_GTK_TOOLBAR_WIDGET(f)[pos]) | 180 if (FRAME_GTK_TOOLBAR_WIDGET(f)[pos]) |
201 gtk_widget_destroy (FRAME_GTK_TOOLBAR_WIDGET(f)[pos]); | 181 gtk_widget_destroy (FRAME_GTK_TOOLBAR_WIDGET(f)[pos]); |
202 } | 182 } |
203 | 183 |
204 static void | 184 static void |
205 gtk_output_frame_toolbars (struct frame *f) | 185 gtk_output_frame_toolbars (struct frame *f) |
206 { | 186 { |
207 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)) | 187 enum edge_pos pos; |
208 gtk_output_toolbar (f, TOP_TOOLBAR); | 188 |
209 else if (f->top_toolbar_was_visible) | 189 EDGE_POS_LOOP (pos) |
210 gtk_clear_toolbar (f, TOP_TOOLBAR); | 190 { |
211 | 191 if (FRAME_REAL_TOOLBAR_VISIBLE (f, pos)) |
212 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)) | 192 gtk_output_toolbar (f, pos); |
213 gtk_output_toolbar (f, BOTTOM_TOOLBAR); | 193 else if (f->toolbar_was_visible[pos]) |
214 else if (f->bottom_toolbar_was_visible) | 194 gtk_clear_toolbar (f, pos); |
215 gtk_clear_toolbar (f, LEFT_TOOLBAR); | 195 } |
216 | |
217 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f)) | |
218 gtk_output_toolbar (f, LEFT_TOOLBAR); | |
219 else if (f->left_toolbar_was_visible) | |
220 gtk_clear_toolbar (f, LEFT_TOOLBAR); | |
221 | |
222 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f)) | |
223 gtk_output_toolbar (f, RIGHT_TOOLBAR); | |
224 else if (f->right_toolbar_was_visible) | |
225 gtk_clear_toolbar (f, RIGHT_TOOLBAR); | |
226 } | 196 } |
227 | 197 |
228 static void | 198 static void |
229 gtk_initialize_frame_toolbars (struct frame *UNUSED (f)) | 199 gtk_initialize_frame_toolbars (struct frame *UNUSED (f)) |
230 { | 200 { |