Japanese translation of message catalog for Sawfish Window-Manager
修訂 | ffd378e47ff29c9830c7cb9d4262df58117fa14f (tree) |
---|---|
時間 | 2015-01-31 02:02:43 |
作者 | Chris 'Nano' Bratusek <Nanolx@user...> |
Commiter | Chris 'Nano' Bratusek |
Merge pull request #11 from hans1024/master
using NET_WM_ICON to get 16x16 icons
@@ -396,8 +396,8 @@ | ||
396 | 396 | (t cabinet:default-item-forground)))) |
397 | 397 | |
398 | 398 | (define (cabinet-item-format w) |
399 | - (let ((item (cons (if (window-icon-image w) | |
400 | - (window-icon-image w) | |
399 | + (let ((item (cons (if (window-icon-image w 32) | |
400 | + (window-icon-image w 32) | |
401 | 401 | (require 'rep.io.files) |
402 | 402 | (if (file-exists-p (concat (car (cdr image-load-path)) "/" "cabinet-missing.png")) |
403 | 403 | (make-image (concat (cdr image-load-path) "cabinet-missing.png")))) |
@@ -110,7 +110,7 @@ If W is nil previous window is removed." | ||
110 | 110 | |
111 | 111 | (when w |
112 | 112 | (let* ((text (make-text-item (window-info w) default-font)) |
113 | - (icon (let ((i (window-icon-image w))) | |
113 | + (icon (let ((i (window-icon-image w 32))) | |
114 | 114 | (and i (scale-image i (car icon-size) (cdr icon-size))))) |
115 | 115 | (icon-dims (if icon icon-size '(0 . 0))) |
116 | 116 | (win-size (cons (+ (car icon-dims) |
@@ -990,6 +990,49 @@ defines the color of its pixels. | ||
990 | 990 | return Qnil; |
991 | 991 | } |
992 | 992 | |
993 | +#ifdef HAVE_GDK_PIXBUF | |
994 | +static void | |
995 | +argbdata_to_pixdata (gulong * argb_data, int len, unsigned char ** pixdata) | |
996 | +{ | |
997 | + guchar *p; | |
998 | + guint argb; | |
999 | + guint rgba; | |
1000 | + int i; | |
1001 | + | |
1002 | + *pixdata = rep_alloc (len * 4); | |
1003 | + p = *pixdata; | |
1004 | + | |
1005 | + i = 0; | |
1006 | + while (i < len) | |
1007 | + { | |
1008 | + argb = argb_data[i]; | |
1009 | + rgba = (argb << 8) | (argb >> 24); | |
1010 | + | |
1011 | + *p = rgba >> 24; ++p; | |
1012 | + *p = (rgba >> 16) & 0xff; ++p; | |
1013 | + *p = (rgba >> 8) & 0xff; ++p; | |
1014 | + *p = rgba & 0xff; ++p; | |
1015 | + | |
1016 | + ++i; | |
1017 | + } | |
1018 | +} | |
1019 | + | |
1020 | +repv make_image_from_data (long * data, int size) | |
1021 | +{ | |
1022 | + unsigned char * pixdata; | |
1023 | + argbdata_to_pixdata(data, size * size, &pixdata); | |
1024 | + | |
1025 | + GdkPixbuf * img = gdk_pixbuf_new_from_data(pixdata, | |
1026 | + GDK_COLORSPACE_RGB, | |
1027 | + TRUE, 8, | |
1028 | + size, size, | |
1029 | + size * 4, | |
1030 | + free_pixbuf_data, | |
1031 | + pixdata); | |
1032 | + return make_image(img, Qnil); | |
1033 | +} | |
1034 | +#endif | |
1035 | + | |
993 | 1036 | DEFUN("tile-image", Ftile_image, Stile_image, (repv dst, repv src), rep_Subr2) /* |
994 | 1037 | ::doc:sawfish.wm.images#tile-image:: |
995 | 1038 | tile-image DEST-IMAGE SOURCE-IMAGE |
@@ -157,6 +157,7 @@ typedef struct lisp_window { | ||
157 | 157 | repv net_name, net_icon_name; |
158 | 158 | int frame_vis; |
159 | 159 | repv icon_image; |
160 | + int icon_size; | |
160 | 161 | |
161 | 162 | /* Frame data */ |
162 | 163 | Window frame; /* Reparenter window */ |
@@ -230,6 +230,9 @@ extern int image_channels (Lisp_Image *im); | ||
230 | 230 | extern void image_changed (Lisp_Image *im); |
231 | 231 | extern void images_init (void); |
232 | 232 | extern void images_kill (void); |
233 | +#ifdef HAVE_GDK_PIXBUF | |
234 | +extern repv make_image_from_data (long * data, int size); | |
235 | +#endif | |
233 | 236 | |
234 | 237 | /* from keys.c */ |
235 | 238 | extern repv Qglobal_keymap, Qunbound_key_hook, Qkeymap; |
@@ -1404,7 +1404,7 @@ out: | ||
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | DEFUN("window-icon-image", Fwindow_icon_image, |
1407 | - Swindow_icon_image, (repv win), rep_Subr1) /* | |
1407 | + Swindow_icon_image, (repv args), rep_SubrN) /* | |
1408 | 1408 | ::doc:sawfish.wm.windows.subrs#window-icon-image:: |
1409 | 1409 | window-icon-image WINDOW |
1410 | 1410 |
@@ -1412,10 +1412,59 @@ Returns an image object representing the icon currently associated with | ||
1412 | 1412 | WINDOW. Returns the symbol `nil' if no such image. |
1413 | 1413 | ::end:: */ |
1414 | 1414 | { |
1415 | + if (!rep_CONSP(args)) | |
1416 | + return rep_signal_missing_arg (1); | |
1417 | + repv win = rep_CAR(args); | |
1415 | 1418 | rep_DECLARE1 (win, WINDOWP); |
1416 | 1419 | |
1417 | - if (VWIN (win)->icon_image == rep_NULL) | |
1420 | + int iconsize = 16; | |
1421 | + if (rep_CONSP(rep_CDR(args)) && rep_INTP(rep_CAR(rep_CDR(args)))) | |
1418 | 1422 | { |
1423 | + iconsize = rep_INT(rep_CAR(rep_CDR(args))); | |
1424 | + } | |
1425 | + | |
1426 | + if (VWIN (win)->icon_image == rep_NULL || VWIN (win)->icon_size != iconsize) | |
1427 | + { | |
1428 | + VWIN (win)->icon_size = iconsize; | |
1429 | + | |
1430 | + #ifdef HAVE_GDK_PIXBUF | |
1431 | + if (!WINDOW_IS_GONE_P (VWIN (win))) | |
1432 | + { | |
1433 | + Atom actual_type; | |
1434 | + int actual_format; | |
1435 | + unsigned long nitems, bytes_after; | |
1436 | + union { | |
1437 | + unsigned long *l; | |
1438 | + unsigned char *c; | |
1439 | + } data; | |
1440 | + | |
1441 | + static Atom net_wm_icon = 0; | |
1442 | + | |
1443 | + if (net_wm_icon == 0) | |
1444 | + net_wm_icon = XInternAtom (dpy, "_NET_WM_ICON", False); | |
1445 | + | |
1446 | + data.l = 0; | |
1447 | + if (XGetWindowProperty (dpy, VWIN (win)->id, net_wm_icon, | |
1448 | + 0L, G_MAXLONG, False, AnyPropertyType, | |
1449 | + &actual_type, &actual_format, | |
1450 | + &nitems, &bytes_after, | |
1451 | + &data.c) == Success) | |
1452 | + { | |
1453 | + int i; | |
1454 | + for (i = 0; i < nitems; i += 2 + data.l[i] * data.l[i + 1]) | |
1455 | + if (data.l[i] == iconsize && data.l[i + 1] == iconsize) | |
1456 | + { | |
1457 | + VWIN (win)->icon_image = | |
1458 | + make_image_from_data(&(data.l[i + 2]), iconsize); | |
1459 | + XFree (data.l); | |
1460 | + return VWIN (win)->icon_image; | |
1461 | + } | |
1462 | + } | |
1463 | + if (data.l != 0) | |
1464 | + XFree (data.l); | |
1465 | + } | |
1466 | + #endif | |
1467 | + | |
1419 | 1468 | Window pixmap_id = 0, mask_id = 0; |
1420 | 1469 | |
1421 | 1470 | if (VWIN (win)->wmhints != 0) |