Mercurial > emacs
comparison src/gtkutil.c @ 89943:4c90ffeb71c5
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221
Restore deleted tagline in etc/TUTORIAL.ru
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229
Remove TeX output files from the archive
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248
src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264
Update from CVS: lispref/display.texi: emacs -> Emacs.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275
Update from CVS: man/makefile.w32-in: Revert last change
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296
Allow restarting an existing debugger session that's exited
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328
Update from CVS: src/.gdbinit (xsymbol): Fix last change.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345
Tweak source regexps so that building in place won't cause problems
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352
Update from CVS: lisp/flymake.el: New file.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362
Support " [...]" style defaults in minibuffer-electric-default-mode
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363
(read-number): Use canonical format for default in prompt.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368
Improve display-supports-face-attributes-p on non-ttys
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369
Rewrite face-differs-from-default-p
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370
Move `display-supports-face-attributes-p' entirely into C code
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372
Simplify face-differs-from-default-p; don't consider :stipple.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374
(tty_supports_face_attributes_p): Ensure attributes differ from default
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377
(Fdisplay_supports_face_attributes_p): Work around bootstrapping problem
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381
Face merging cleanups
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385
src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396
Tweak arch tagging to make build/install-in-place less annoying
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397
Work around vc-arch problems when building eshell
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398
Tweak permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399
Tweak directory permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401
More build-in-place tweaking of arch tagging
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403
Yet more build-in-place tweaking of arch tagging
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410
Make sure image types are initialized for lookup too
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 28 Jun 2004 07:56:49 +0000 |
parents | 68c22ea6027c e4cfda8330d5 |
children | 59dcbfe97385 |
comparison
equal
deleted
inserted
replaced
89942:9cb747ae49af | 89943:4c90ffeb71c5 |
---|---|
227 { | 227 { |
228 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); | 228 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpy); |
229 return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR); | 229 return gdk_cursor_new_for_display (gdpy, GDK_LEFT_PTR); |
230 } | 230 } |
231 | 231 |
232 /* For the image defined in IMG, make and return a GdkPixmap for | 232 /* For the image defined in IMG, make and return a GtkImage. For displays with |
233 the pixmap in *GPIX, and a GdkBitmap for the mask in *GMASK. | 233 8 planes or less we must make a GdkPixbuf and apply the mask manually. |
234 If IMG has no mask, *GMASK is set to NULL. | 234 Otherwise the highlightning and dimming the tool bar code in GTK does |
235 The image is defined on the display where frame F is. */ | 235 will look bad. For display with more than 8 planes we just use the |
236 static void | 236 pixmap and mask directly. For monochrome displays, GTK doesn't seem |
237 xg_get_gdk_pixmap_and_mask (f, img, gpix, gmask) | 237 able to use external pixmaps, it looks bad whatever we do. |
238 The image is defined on the display where frame F is. | |
239 WIDGET is used to find the GdkColormap to use for the GdkPixbuf. | |
240 If OLD_WIDGET is NULL, a new widget is constructed and returned. | |
241 If OLD_WIDGET is not NULL, that widget is modified. */ | |
242 static GtkWidget * | |
243 xg_get_image_for_pixmap (f, img, widget, old_widget) | |
238 FRAME_PTR f; | 244 FRAME_PTR f; |
239 struct image *img; | 245 struct image *img; |
240 GdkPixmap **gpix; | 246 GtkWidget *widget; |
241 GdkBitmap **gmask; | 247 GtkImage *old_widget; |
242 { | 248 { |
249 GdkPixmap *gpix; | |
250 GdkPixmap *gmask; | |
243 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); | 251 GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (FRAME_X_DISPLAY (f)); |
244 | 252 |
245 *gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); | 253 gpix = gdk_pixmap_foreign_new_for_display (gdpy, img->pixmap); |
246 *gmask = img->mask ? | 254 gmask = img->mask ? gdk_pixmap_foreign_new_for_display (gdpy, img->mask) : 0; |
247 (GdkBitmap*) gdk_pixmap_foreign_new_for_display (gdpy, img->mask) | 255 |
248 : 0; | 256 if (x_screen_planes (f) > 8 || x_screen_planes (f) == 1) |
257 { | |
258 if (! old_widget) | |
259 old_widget = GTK_IMAGE (gtk_image_new_from_pixmap (gpix, gmask)); | |
260 else | |
261 gtk_image_set_from_pixmap (old_widget, gpix, gmask); | |
262 } | |
263 else | |
264 { | |
265 int x, y, width, height, rowstride, mask_rowstride; | |
266 GdkPixbuf *icon_buf, *tmp_buf; | |
267 guchar *pixels; | |
268 guchar *mask_pixels; | |
269 | |
270 gdk_drawable_get_size (gpix, &width, &height); | |
271 tmp_buf = gdk_pixbuf_get_from_drawable (NULL, | |
272 gpix, | |
273 gtk_widget_get_colormap (widget), | |
274 0, 0, 0, 0, width, height); | |
275 icon_buf = gdk_pixbuf_add_alpha (tmp_buf, FALSE, 0, 0, 0); | |
276 g_object_unref (G_OBJECT (tmp_buf)); | |
277 | |
278 if (gmask) | |
279 { | |
280 GdkPixbuf *mask_buf = gdk_pixbuf_get_from_drawable (NULL, | |
281 gmask, | |
282 NULL, | |
283 0, 0, 0, 0, | |
284 width, height); | |
285 guchar *pixels = gdk_pixbuf_get_pixels (icon_buf); | |
286 guchar *mask_pixels = gdk_pixbuf_get_pixels (mask_buf); | |
287 int rowstride = gdk_pixbuf_get_rowstride (icon_buf); | |
288 int mask_rowstride = gdk_pixbuf_get_rowstride (mask_buf); | |
289 int y; | |
290 | |
291 for (y = 0; y < height; ++y) | |
292 { | |
293 guchar *iconptr, *maskptr; | |
294 int x; | |
295 | |
296 iconptr = pixels + y * rowstride; | |
297 maskptr = mask_pixels + y * mask_rowstride; | |
298 | |
299 for (x = 0; x < width; ++x) | |
300 { | |
301 /* In a bitmap, RGB is either 255/255/255 or 0/0/0. Checking | |
302 just R is sufficient. */ | |
303 if (maskptr[0] == 0) | |
304 iconptr[3] = 0; /* 0, 1, 2 is R, G, B. 3 is alpha. */ | |
305 | |
306 iconptr += rowstride/width; | |
307 maskptr += mask_rowstride/width; | |
308 } | |
309 } | |
310 | |
311 g_object_unref (G_OBJECT (gmask)); | |
312 g_object_unref (G_OBJECT (mask_buf)); | |
313 } | |
314 | |
315 g_object_unref (G_OBJECT (gpix)); | |
316 | |
317 if (! old_widget) | |
318 old_widget = GTK_IMAGE (gtk_image_new_from_pixbuf (icon_buf)); | |
319 else | |
320 gtk_image_set_from_pixbuf (old_widget, icon_buf); | |
321 | |
322 g_object_unref (G_OBJECT (icon_buf)); | |
323 } | |
324 | |
325 return GTK_WIDGET (old_widget); | |
249 } | 326 } |
250 | 327 |
251 | 328 |
252 /* Set CURSOR on W and all widgets W contain. We must do like this | 329 /* Set CURSOR on W and all widgets W contain. We must do like this |
253 for scroll bars and menu because they create widgets internally, | 330 for scroll bars and menu because they create widgets internally, |
2758 GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); | 2835 GtkWidget *wscroll = xg_get_widget_from_map (scrollbar_id); |
2759 | 2836 |
2760 if (wscroll) | 2837 if (wscroll) |
2761 { | 2838 { |
2762 GtkWidget *wfixed = f->output_data.x->edit_widget; | 2839 GtkWidget *wfixed = f->output_data.x->edit_widget; |
2763 int winextra = canon_width > width ? (canon_width - width) / 2 : 0; | 2840 |
2764 int bottom = top + height; | 2841 gtk_container_set_reallocate_redraws (GTK_CONTAINER (wfixed), TRUE); |
2765 | 2842 |
2766 gint slider_width; | 2843 /* Move and resize to new values. */ |
2767 int oldtop, oldleft, oldbottom; | 2844 gtk_fixed_move (GTK_FIXED (wfixed), wscroll, left, top); |
2768 GtkRequisition req; | 2845 gtk_widget_set_size_request (wscroll, width, height); |
2769 | 2846 |
2770 /* Get old values. */ | 2847 /* Must force out update so changed scroll bars gets redrawn. */ |
2771 xg_find_top_left_in_fixed (wscroll, wfixed, &oldleft, &oldtop); | 2848 gdk_window_process_all_updates (); |
2772 gtk_widget_size_request (wscroll, &req); | 2849 |
2773 oldbottom = oldtop + req.height; | |
2774 | |
2775 /* Scroll bars in GTK has a fixed width, so if we say width 16, it | 2850 /* Scroll bars in GTK has a fixed width, so if we say width 16, it |
2776 will only be its fixed width (14 is default) anyway, the rest is | 2851 will only be its fixed width (14 is default) anyway, the rest is |
2777 blank. We are drawing the mode line across scroll bars when | 2852 blank. We are drawing the mode line across scroll bars when |
2778 the frame is split: | 2853 the frame is split: |
2779 |bar| |fringe| | 2854 |bar| |fringe| |
2797 Also, the canonical width may be wider than the width for the | 2872 Also, the canonical width may be wider than the width for the |
2798 scroll bar so that there is some space (typically 1 pixel) between | 2873 scroll bar so that there is some space (typically 1 pixel) between |
2799 the scroll bar and the edge of the window and between the scroll | 2874 the scroll bar and the edge of the window and between the scroll |
2800 bar and the fringe. */ | 2875 bar and the fringe. */ |
2801 | 2876 |
2802 if (oldtop != -1 && oldleft != -1) | 2877 XClearWindow (FRAME_X_DISPLAY (f), GTK_WIDGET_TO_X_WIN (wscroll)); |
2803 { | |
2804 int gtkextral, gtkextrah; | |
2805 int xl, xr, wbl, wbr; | |
2806 int bottomdiff, topdiff; | |
2807 | |
2808 gtk_widget_style_get (wscroll, "slider_width", &slider_width, NULL); | |
2809 gtkextral = width > slider_width ? (width - slider_width) / 2 : 0; | |
2810 gtkextrah = gtkextral ? (width - slider_width - gtkextral) : 0; | |
2811 | |
2812 xl = real_left; | |
2813 wbl = gtkextral + winextra; | |
2814 wbr = gtkextrah + winextra; | |
2815 xr = left + gtkextral + slider_width; | |
2816 bottomdiff = abs (oldbottom - bottom); | |
2817 topdiff = abs (oldtop - top); | |
2818 | |
2819 if (oldleft != left) | |
2820 { | |
2821 gdk_window_clear_area (wfixed->window, xl, top, wbl, height); | |
2822 gdk_window_clear_area (wfixed->window, xr, top, wbr, height); | |
2823 } | |
2824 | |
2825 if (oldtop > top) | |
2826 { | |
2827 gdk_window_clear_area (wfixed->window, xl, top, wbl, topdiff); | |
2828 gdk_window_clear_area (wfixed->window, xr, top, wbr, topdiff); | |
2829 } | |
2830 else if (oldtop < top) | |
2831 { | |
2832 gdk_window_clear_area (wfixed->window, xl, oldtop, wbl, topdiff); | |
2833 gdk_window_clear_area (wfixed->window, xr, oldtop, wbr, topdiff); | |
2834 } | |
2835 | |
2836 if (oldbottom > bottom) | |
2837 { | |
2838 gdk_window_clear_area (wfixed->window, xl, bottom, wbl, | |
2839 bottomdiff); | |
2840 gdk_window_clear_area (wfixed->window, xr, bottom, wbr, | |
2841 bottomdiff); | |
2842 } | |
2843 else if (oldbottom < bottom) | |
2844 { | |
2845 gdk_window_clear_area (wfixed->window, xl, oldbottom, wbl, | |
2846 bottomdiff); | |
2847 gdk_window_clear_area (wfixed->window, xr, oldbottom, wbr, | |
2848 bottomdiff); | |
2849 } | |
2850 } | |
2851 | |
2852 /* Move and resize to new values. */ | |
2853 gtk_fixed_move (GTK_FIXED (wfixed), wscroll, left, top); | |
2854 gtk_widget_set_size_request (wscroll, width, height); | |
2855 | |
2856 /* Must force out update so changed scroll bars gets redrawn. */ | |
2857 gdk_window_process_all_updates (); | |
2858 | 2878 |
2859 SET_FRAME_GARBAGED (f); | 2879 SET_FRAME_GARBAGED (f); |
2860 cancel_mouse_face (f); | 2880 cancel_mouse_face (f); |
2861 } | 2881 } |
2862 } | 2882 } |
3260 continue; | 3280 continue; |
3261 } | 3281 } |
3262 | 3282 |
3263 if (! wicon) | 3283 if (! wicon) |
3264 { | 3284 { |
3265 GdkPixmap *gpix; | 3285 GtkWidget *w = xg_get_image_for_pixmap (f, img, x->widget, NULL); |
3266 GdkBitmap *gmask; | 3286 |
3267 GtkWidget *w; | |
3268 | |
3269 xg_get_gdk_pixmap_and_mask (f, img, &gpix, &gmask); | |
3270 w = gtk_image_new_from_pixmap (gpix, gmask); | |
3271 gtk_toolbar_append_item (GTK_TOOLBAR (x->toolbar_widget), | 3287 gtk_toolbar_append_item (GTK_TOOLBAR (x->toolbar_widget), |
3272 0, 0, 0, | 3288 0, 0, 0, |
3273 w, | 3289 w, |
3274 GTK_SIGNAL_FUNC (xg_tool_bar_callback), | 3290 GTK_SIGNAL_FUNC (xg_tool_bar_callback), |
3275 (gpointer)i); | 3291 (gpointer)i); |
3322 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), | 3338 Pixmap old_img = (Pixmap)g_object_get_data (G_OBJECT (wimage), |
3323 XG_TOOL_BAR_IMAGE_DATA); | 3339 XG_TOOL_BAR_IMAGE_DATA); |
3324 g_list_free (chlist); | 3340 g_list_free (chlist); |
3325 | 3341 |
3326 if (old_img != img->pixmap) | 3342 if (old_img != img->pixmap) |
3327 { | 3343 (void) xg_get_image_for_pixmap (f, img, x->widget, wimage); |
3328 GdkPixmap *gpix; | |
3329 GdkBitmap *gmask; | |
3330 | |
3331 xg_get_gdk_pixmap_and_mask (f, img, &gpix, &gmask); | |
3332 gtk_image_set_from_pixmap (wimage, gpix, gmask); | |
3333 } | |
3334 | 3344 |
3335 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, | 3345 g_object_set_data (G_OBJECT (wimage), XG_TOOL_BAR_IMAGE_DATA, |
3336 (gpointer)img->pixmap); | 3346 (gpointer)img->pixmap); |
3337 | 3347 |
3338 gtk_widget_set_sensitive (wicon, enabled_p); | 3348 gtk_widget_set_sensitive (wicon, enabled_p); |