Mercurial > hg > xemacs-beta
annotate src/native-gtk-toolbar.c @ 5276:dd2976af8783
Add some missing #includes, termcap.c, hopefully fixing Adam Sjoegren's build.
2010-09-18 Aidan Kehoe <kehoea@parhasard.net>
* termcap.c:
Add a couple of missing includes here, which should fix builds
that use this file. (I have no access to such builds, but Mats'
buildbot shows output that indicates they fail at link time since
DEVICE_BAUD_RATE and IS_DIRECTORY_SEP are available.)
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 18 Sep 2010 15:03:54 +0100 |
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 } |