Mercurial > hg > xemacs-beta
annotate src/native-gtk-toolbar.c @ 5307:c096d8051f89
Have NATNUMP give t for positive bignums; check limits appropriately.
src/ChangeLog addition:
2010-11-20 Aidan Kehoe <kehoea@parhasard.net>
* abbrev.c (Fexpand_abbrev):
* alloc.c:
* alloc.c (Fmake_list):
* alloc.c (Fmake_vector):
* alloc.c (Fmake_bit_vector):
* alloc.c (Fmake_byte_code):
* alloc.c (Fmake_string):
* alloc.c (vars_of_alloc):
* bytecode.c (UNUSED):
* bytecode.c (Fbyte_code):
* chartab.c (decode_char_table_range):
* cmds.c (Fself_insert_command):
* data.c (check_integer_range):
* data.c (Fnatnump):
* data.c (Fnonnegativep):
* data.c (Fstring_to_number):
* elhash.c (hash_table_size_validate):
* elhash.c (decode_hash_table_size):
* eval.c (Fbacktrace_frame):
* event-stream.c (lisp_number_to_milliseconds):
* event-stream.c (Faccept_process_output):
* event-stream.c (Frecent_keys):
* event-stream.c (Fdispatch_event):
* events.c (Fmake_event):
* events.c (Fevent_timestamp):
* events.c (Fevent_timestamp_lessp):
* events.h:
* events.h (struct command_builder):
* file-coding.c (gzip_putprop):
* fns.c:
* fns.c (check_sequence_range):
* fns.c (Frandom):
* fns.c (Fnthcdr):
* fns.c (Flast):
* fns.c (Fnbutlast):
* fns.c (Fbutlast):
* fns.c (Fmember):
* fns.c (Ffill):
* fns.c (Freduce):
* fns.c (replace_string_range_1):
* fns.c (Freplace):
* font-mgr.c (Ffc_pattern_get):
* frame-msw.c (msprinter_set_frame_properties):
* glyphs.c (check_valid_xbm_inline):
* indent.c (Fmove_to_column):
* intl-win32.c (mswindows_multibyte_to_unicode_putprop):
* lisp.h:
* lisp.h (ARRAY_DIMENSION_LIMIT):
* lread.c (decode_mode_1):
* mule-ccl.c (ccl_get_compiled_code):
* number.h:
* process-unix.c (unix_open_multicast_group):
* process.c (Fset_process_window_size):
* profile.c (Fstart_profiling):
* unicode.c (Funicode_to_char):
Change NATNUMP to return 1 for positive bignums; changes uses of
it and of CHECK_NATNUM appropriately, usually by checking for an
integer in an appropriate range.
Add array-dimension-limit and use it in #'make-vector,
#'make-string. Add array-total-size-limit, array-rank-limit while
we're at it, for the sake of any Common Lisp-oriented code that
uses these limits.
Rename check_int_range to check_integer_range, have it take
Lisp_Objects (and thus bignums) instead.
Remove bignum_butlast(), just set int_n to an appropriately large
integer if N is a bignum.
Accept bignums in check_sequence_range(), change the functions
that use check_sequence_range() appropriately.
Move the definition of NATNUMP() to number.h; document why it's a
reasonable name, contradicting an old comment.
tests/ChangeLog addition:
2010-11-20 Aidan Kehoe <kehoea@parhasard.net>
* automated/lisp-tests.el:
* automated/lisp-tests.el (featurep):
* automated/lisp-tests.el (wrong-type-argument):
* automated/mule-tests.el (featurep):
Check for args-out-of-range errors instead of wrong-type-argument
errors in various places when code is handed a large bignum
instead of a fixnum.
Also check for the wrong-type-argument errors when giving the same
code a non-integer value.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 20 Nov 2010 16:49:11 +0000 |
parents | 97eb4942aec8 |
children | 308d34e9f07d |
rev | line source |
---|---|
462 | 1 /* toolbar implementation -- GTK interface. |
2 Copyright (C) 2000 Aaron Lehmann | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
3 Copyright (C) 2010 Ben Wing. |
462 | 4 |
5 This file is part of XEmacs. | |
6 | |
7 XEmacs is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
9 Free Software Foundation; either version 2, or (at your option) any | |
10 later version. | |
11 | |
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
18 along with XEmacs; see the file COPYING. If not, write to | |
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 Boston, MA 02111-1307, USA. */ | |
21 | |
22 /* Synched up with: Not in FSF. */ | |
23 | |
24 #include <config.h> | |
25 #include "lisp.h" | |
26 | |
27 #include "console-gtk.h" | |
28 #include "glyphs-gtk.h" | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
29 #include "fontcolor-gtk.h" |
462 | 30 |
31 #include "faces.h" | |
32 #include "frame.h" | |
33 #include "toolbar.h" | |
34 #include "window.h" | |
35 | |
36 static void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
37 gtk_clear_toolbar (struct frame *f, enum edge_pos pos); |
462 | 38 |
39 static void | |
2286 | 40 gtk_toolbar_callback (GtkWidget *UNUSED (w), gpointer user_data) |
462 | 41 { |
42 struct toolbar_button *tb = (struct toolbar_button *) user_data; | |
43 | |
44 call0 (tb->callback); | |
45 } | |
46 | |
47 | |
48 static void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
49 gtk_output_toolbar (struct frame *f, enum edge_pos pos) |
462 | 50 { |
51 GtkWidget *toolbar; | |
52 Lisp_Object button, window, glyph, instance; | |
53 unsigned int checksum = 0; | |
54 struct window *w; | |
55 int x, y, bar_width, bar_height, vert; | |
56 int cur_x, cur_y; | |
57 | |
58 window = FRAME_LAST_NONMINIBUF_WINDOW (f); | |
59 w = XWINDOW (window); | |
60 | |
61 get_toolbar_coords (f, pos, &x, &y, &bar_width, &bar_height, &vert, 0); | |
62 | |
63 /* Get the toolbar and delete the old widgets in it */ | |
64 button = FRAME_TOOLBAR_BUTTONS (f, pos); | |
65 | |
66 /* First loop over all of the buttons to determine how many there | |
67 are. This loop will also make sure that all instances are | |
68 instantiated so when we actually output them they will come up | |
69 immediately. */ | |
70 while (!NILP (button)) | |
71 { | |
72 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | |
73 checksum = HASH4 (checksum, | |
74 internal_hash (get_toolbar_button_glyph(w, tb), 0), | |
75 internal_hash (tb->callback, 0), | |
76 0 /* width */); | |
77 button = tb->next; | |
78 } | |
79 | |
80 /* Only do updates if the toolbar has changed, or this is the first | |
81 time we have drawn it in this position | |
82 */ | |
83 if (FRAME_GTK_TOOLBAR_WIDGET (f)[pos] && | |
84 FRAME_GTK_TOOLBAR_CHECKSUM (f, pos) == checksum) | |
85 { | |
86 return; | |
87 } | |
88 | |
89 /* Loop through buttons and add them to our toolbar. | |
90 This code ignores the button dimensions as we let GTK handle that :) | |
91 Attach the toolbar_button struct to the toolbar button so we know what | |
92 function to use as a callback. */ | |
93 | |
94 { | |
95 gtk_clear_toolbar (f, pos); | |
96 FRAME_GTK_TOOLBAR_WIDGET (f)[pos] = toolbar = | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
97 gtk_toolbar_new (((pos == TOP_EDGE) || (pos == BOTTOM_EDGE)) ? |
462 | 98 GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, |
99 GTK_TOOLBAR_BOTH); | |
100 } | |
101 | |
102 if (NILP (w->toolbar_buttons_captioned_p)) | |
103 gtk_toolbar_set_style (toolbar, GTK_TOOLBAR_ICONS); | |
104 else | |
105 gtk_toolbar_set_style (toolbar, GTK_TOOLBAR_BOTH); | |
106 | |
107 FRAME_GTK_TOOLBAR_CHECKSUM(f, pos) = checksum; | |
108 button = FRAME_TOOLBAR_BUTTONS (f, pos); | |
109 | |
110 cur_x = 0; | |
111 cur_y = 0; | |
112 | |
113 while (!NILP (button)) | |
114 { | |
115 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | |
116 | |
117 if (tb->blank) | |
118 { | |
119 /* It is a blank space... we do not pay attention to the | |
120 size, because the GTK toolbar does not allow us to | |
121 specify different spacings. *sigh* | |
122 */ | |
123 gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); | |
124 } | |
125 else | |
126 { | |
127 /* It actually has a glyph associated with it! What WILL | |
128 they think of next? | |
129 */ | |
130 glyph = tb->up_glyph; | |
131 | |
132 /* #### It is currently possible for users to trash us by directly | |
133 changing the toolbar glyphs. Avoid crashing in that case. */ | |
134 if (GLYPHP (glyph)) | |
793 | 135 instance = glyph_image_instance (glyph, window, |
136 ERROR_ME_DEBUG_WARN, 1); | |
462 | 137 else |
138 instance = Qnil; | |
139 | |
140 if (IMAGE_INSTANCEP(instance)) | |
141 { | |
142 GtkWidget *pixmapwid; | |
143 GdkPixmap *pixmap; | |
144 GdkBitmap *mask; | |
145 char *tooltip = NULL; | |
146 | |
147 if (STRINGP (tb->help_string)) | |
148 tooltip = XSTRING_DATA (tb->help_string); | |
149 | |
150 pixmap = XIMAGE_INSTANCE_GTK_PIXMAP(instance); | |
151 mask = XIMAGE_INSTANCE_GTK_MASK(instance); | |
152 pixmapwid = gtk_pixmap_new (pixmap, mask); | |
153 | |
154 gtk_widget_set_usize (pixmapwid, tb->width, tb->height); | |
155 | |
156 gtk_toolbar_append_item (GTK_TOOLBAR(toolbar), NULL, tooltip, NULL, | |
157 pixmapwid, gtk_toolbar_callback, (gpointer) tb); | |
158 } | |
159 } | |
160 cur_x += vert ? 0 : tb->width; | |
161 cur_y += vert ? tb->height : 0; | |
162 /* Who's idea was it to use a linked list for toolbar buttons? */ | |
163 button = tb->next; | |
164 } | |
165 | |
166 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 1); | |
167 | |
168 x -= vert ? 3 : 2; | |
169 y -= vert ? 2 : 3; | |
170 | |
171 gtk_fixed_put (GTK_FIXED (FRAME_GTK_TEXT_WIDGET (f)), FRAME_GTK_TOOLBAR_WIDGET (f)[pos],x, y); | |
172 gtk_widget_show_all (FRAME_GTK_TOOLBAR_WIDGET (f)[pos]); | |
173 } | |
174 | |
175 static void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
176 gtk_clear_toolbar (struct frame *f, enum edge_pos pos) |
462 | 177 { |
178 FRAME_GTK_TOOLBAR_CHECKSUM (f, pos) = 0; | |
179 SET_TOOLBAR_WAS_VISIBLE_FLAG (f, pos, 0); | |
180 if (FRAME_GTK_TOOLBAR_WIDGET(f)[pos]) | |
181 gtk_widget_destroy (FRAME_GTK_TOOLBAR_WIDGET(f)[pos]); | |
182 } | |
183 | |
184 static void | |
185 gtk_output_frame_toolbars (struct frame *f) | |
186 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
187 enum edge_pos pos; |
462 | 188 |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
189 EDGE_POS_LOOP (pos) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
190 { |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
191 if (FRAME_REAL_TOOLBAR_VISIBLE (f, pos)) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
192 gtk_output_toolbar (f, pos); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
193 else if (f->toolbar_was_visible[pos]) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
194 gtk_clear_toolbar (f, pos); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
2500
diff
changeset
|
195 } |
462 | 196 } |
197 | |
198 static void | |
2286 | 199 gtk_initialize_frame_toolbars (struct frame *UNUSED (f)) |
462 | 200 { |
201 stderr_out ("We should draw toolbars\n"); | |
202 } | |
203 | |
204 | |
205 /************************************************************************/ | |
206 /* initialization */ | |
207 /************************************************************************/ | |
208 | |
209 void | |
210 console_type_create_toolbar_gtk (void) | |
211 { | |
212 CONSOLE_HAS_METHOD (gtk, output_frame_toolbars); | |
213 CONSOLE_HAS_METHOD (gtk, initialize_frame_toolbars); | |
214 } |