Add task-bar icon
authorH.G. Muller <h.g.muller@hccnet.nl>
Sun, 21 Oct 2012 21:04:49 +0000 (23:04 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Tue, 6 Nov 2012 13:15:20 +0000 (14:15 +0100)
Funny enough it was necessary to swap the two svg icons to make this work!

svg/icon_black.svg
svg/icon_white.svg
xboard.c

index b969e5e..0656cd8 100644 (file)
@@ -34,8 +34,8 @@
      id="rect2827"
      style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
   <path
-     d="M 0,0 0,100 100,100 100,0 0,0 z m 45.84375,5.09375 c 3.782737,-0.6304527 5.035226,7.582845 8.1875,8.84375 5.043643,1.891369 10.112586,1.878976 15.15625,5.03125 C 84.948871,29.056036 89.97818,48.602714 92.5,65.625 c 1.26091,6.935012 1.875,13.877489 1.875,20.8125 0,1.891369 0.63591,5.676595 -0.625,6.9375 -1.89137,2.521832 -11.347726,1.25 -14.5,1.25 l -37.8125,0 c -4.41319,0 -11.974213,1.903762 -11.34375,-5.03125 C 33.246024,73.832369 51.525786,66.891834 52.15625,50.5 46.482154,54.91318 39.543643,56.80556 34.5,61.21875 30.717273,64.371024 27.563988,70.665678 23.78125,73.1875 21.259429,74.448405 18.729656,73.178072 17.46875,70.65625 11.164201,72.547619 4.869536,68.153751 5.5,61.21875 c 0.630452,-8.195928 6.311023,-14.502488 10.09375,-21.4375 2.521822,-4.413179 1.889881,-8.83682 3.78125,-13.25 1.260905,-3.152284 4.395334,-5.035226 5.65625,-8.1875 1.891359,-2.521821 -2.527274,-10.1031785 0.625,-12.625 3.152274,-2.5218214 10.739094,6.321928 12,8.84375 2.521821,-1.891358 5.035226,-8.8382973 8.1875,-9.46875 z m 7.5625,12.3125 c -0.844442,0.01991 -1.703778,0.135185 -2.53125,0.3125 1.891368,3.782737 5.691476,3.139892 8.84375,5.03125 4.41319,1.260916 7.566476,5.035226 10.71875,8.1875 9.456833,11.978654 13.875,30.900332 13.875,46.03125 0,5.674096 -1.284205,14.5 6.28125,14.5 0,-20.805024 -1.879988,-44.758963 -15.75,-61.78125 C 70.272949,23.973994 61.569191,17.213759 53.40625,17.40625 z m -16.5,1 c -2.429623,0.100201 -5.635854,1.309687 -6.1875,4.34375 1.260905,0 3.145345,0.0055 4.40625,-0.625 6.737993,-2.127784 4.90505,-3.84758 1.78125,-3.71875 z m -3.875,8.5625 c -4.749346,0.198245 -8.478301,4.691417 -7.375,9.65625 l 1.28125,-3.15625 c 3.782737,0.630453 5.661703,-1.248512 5.03125,-5.03125 l 3.15625,-0.65625 0,-0.625 c -0.709262,-0.157615 -1.415272,-0.215821 -2.09375,-0.1875 z m 22.28125,14.0625 c -2.521822,1.260906 -3.15625,4.415679 -3.15625,6.9375 l 1.25,0 1.90625,-6.9375 z m -41,15.125 c -3.152274,0 -3.777284,6.317953 -0.625,5.6875 3.152275,-0.630452 4.407728,-5.6875 0.625,-5.6875 z m 6.9375,6.3125 -3.15625,5.6875 1.90625,0.625 1.875,-6.3125 -0.625,0 z"
+     d="m 37.649136,14.554159 c 2.521821,-1.891358 5.043643,-8.8263698 8.195917,-9.4568225 3.782737,-0.6304527 5.043643,7.5654645 8.195917,8.8263695 5.043643,1.891369 10.087285,1.891369 15.130949,5.043643 15.761371,10.087286 20.805014,29.631394 23.326835,46.65368 1.260916,6.935012 1.891369,13.870013 1.891369,20.805024 0,1.891369 0.630453,5.674096 -0.630453,6.935001 -1.891368,2.521832 -11.348201,1.260916 -14.500475,1.260916 l -37.827322,0 c -4.41319,0 -11.978654,1.891369 -11.348191,-5.043643 3.152274,-15.761381 21.435466,-22.696382 22.06593,-39.088216 -5.674096,4.41318 -12.609107,6.304549 -17.65275,10.717739 -3.782727,3.152274 -6.935001,9.456822 -10.717739,11.978644 -2.521821,1.260905 -5.043642,0 -6.304548,-2.521822 C 11.170027,72.556041 4.8654681,68.142851 5.4959314,61.20785 6.1263841,53.011922 11.80048,46.707374 15.583206,39.772362 18.105028,35.359183 17.474575,30.945993 19.365944,26.532813 20.626849,23.380529 23.779123,21.48917 25.040039,18.336896 26.931398,15.815075 22.518218,8.2496107 25.670492,5.7277892 28.822766,3.2059678 36.38823,12.032337 37.649136,14.554159 z m 13.23956,3.152274 c 1.891368,3.782737 5.674095,3.152285 8.826369,5.043643 4.41319,1.260916 7.565486,5.043643 10.71776,8.195917 9.456833,11.978654 13.870012,30.892309 13.870012,46.023227 0,5.674096 -1.260905,14.500476 6.304549,14.500476 0,-20.805024 -1.891359,-44.762322 -15.761371,-61.784609 C 69.802372,23.380529 59.715065,15.815075 50.888696,17.706433 z m -32.783668,50.436418 1.891369,0.630452 1.891368,-6.304548 -0.630463,0 z m -4.41318,-6.304549 c 3.152274,-0.630452 4.41318,-5.674095 0.630453,-5.674095 -3.152274,0 -3.782737,6.304548 -0.630453,5.674095 z m 38.457764,-13.870012 1.260905,0 1.891369,-6.935012 c -2.521822,1.260906 -3.152274,4.413191 -3.152274,6.935012 z m -26.47912,-11.348202 1.260906,-3.152274 c 3.782737,0.630453 5.674095,-1.260905 5.043642,-5.043643 l 3.152274,-0.630452 0,-0.630453 c -5.674095,-1.260916 -10.717738,3.782727 -9.456822,9.456822 z m 5.043643,-13.870012 c 1.260905,0 3.152274,0 4.413179,-0.630453 11.978655,-3.782727 -3.152274,-6.304548 -4.413179,0.630453 z"
      inkscape:connector-curvature="0"
-     id="rect2946"
-     style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
+     id="BlackKnight"
+     style="stroke-width:1px" />
 </svg>
index 0656cd8..b969e5e 100644 (file)
@@ -34,8 +34,8 @@
      id="rect2827"
      style="color:#000000;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
   <path
-     d="m 37.649136,14.554159 c 2.521821,-1.891358 5.043643,-8.8263698 8.195917,-9.4568225 3.782737,-0.6304527 5.043643,7.5654645 8.195917,8.8263695 5.043643,1.891369 10.087285,1.891369 15.130949,5.043643 15.761371,10.087286 20.805014,29.631394 23.326835,46.65368 1.260916,6.935012 1.891369,13.870013 1.891369,20.805024 0,1.891369 0.630453,5.674096 -0.630453,6.935001 -1.891368,2.521832 -11.348201,1.260916 -14.500475,1.260916 l -37.827322,0 c -4.41319,0 -11.978654,1.891369 -11.348191,-5.043643 3.152274,-15.761381 21.435466,-22.696382 22.06593,-39.088216 -5.674096,4.41318 -12.609107,6.304549 -17.65275,10.717739 -3.782727,3.152274 -6.935001,9.456822 -10.717739,11.978644 -2.521821,1.260905 -5.043642,0 -6.304548,-2.521822 C 11.170027,72.556041 4.8654681,68.142851 5.4959314,61.20785 6.1263841,53.011922 11.80048,46.707374 15.583206,39.772362 18.105028,35.359183 17.474575,30.945993 19.365944,26.532813 20.626849,23.380529 23.779123,21.48917 25.040039,18.336896 26.931398,15.815075 22.518218,8.2496107 25.670492,5.7277892 28.822766,3.2059678 36.38823,12.032337 37.649136,14.554159 z m 13.23956,3.152274 c 1.891368,3.782737 5.674095,3.152285 8.826369,5.043643 4.41319,1.260916 7.565486,5.043643 10.71776,8.195917 9.456833,11.978654 13.870012,30.892309 13.870012,46.023227 0,5.674096 -1.260905,14.500476 6.304549,14.500476 0,-20.805024 -1.891359,-44.762322 -15.761371,-61.784609 C 69.802372,23.380529 59.715065,15.815075 50.888696,17.706433 z m -32.783668,50.436418 1.891369,0.630452 1.891368,-6.304548 -0.630463,0 z m -4.41318,-6.304549 c 3.152274,-0.630452 4.41318,-5.674095 0.630453,-5.674095 -3.152274,0 -3.782737,6.304548 -0.630453,5.674095 z m 38.457764,-13.870012 1.260905,0 1.891369,-6.935012 c -2.521822,1.260906 -3.152274,4.413191 -3.152274,6.935012 z m -26.47912,-11.348202 1.260906,-3.152274 c 3.782737,0.630453 5.674095,-1.260905 5.043642,-5.043643 l 3.152274,-0.630452 0,-0.630453 c -5.674095,-1.260916 -10.717738,3.782727 -9.456822,9.456822 z m 5.043643,-13.870012 c 1.260905,0 3.152274,0 4.413179,-0.630453 11.978655,-3.782727 -3.152274,-6.304548 -4.413179,0.630453 z"
+     d="M 0,0 0,100 100,100 100,0 0,0 z m 45.84375,5.09375 c 3.782737,-0.6304527 5.035226,7.582845 8.1875,8.84375 5.043643,1.891369 10.112586,1.878976 15.15625,5.03125 C 84.948871,29.056036 89.97818,48.602714 92.5,65.625 c 1.26091,6.935012 1.875,13.877489 1.875,20.8125 0,1.891369 0.63591,5.676595 -0.625,6.9375 -1.89137,2.521832 -11.347726,1.25 -14.5,1.25 l -37.8125,0 c -4.41319,0 -11.974213,1.903762 -11.34375,-5.03125 C 33.246024,73.832369 51.525786,66.891834 52.15625,50.5 46.482154,54.91318 39.543643,56.80556 34.5,61.21875 30.717273,64.371024 27.563988,70.665678 23.78125,73.1875 21.259429,74.448405 18.729656,73.178072 17.46875,70.65625 11.164201,72.547619 4.869536,68.153751 5.5,61.21875 c 0.630452,-8.195928 6.311023,-14.502488 10.09375,-21.4375 2.521822,-4.413179 1.889881,-8.83682 3.78125,-13.25 1.260905,-3.152284 4.395334,-5.035226 5.65625,-8.1875 1.891359,-2.521821 -2.527274,-10.1031785 0.625,-12.625 3.152274,-2.5218214 10.739094,6.321928 12,8.84375 2.521821,-1.891358 5.035226,-8.8382973 8.1875,-9.46875 z m 7.5625,12.3125 c -0.844442,0.01991 -1.703778,0.135185 -2.53125,0.3125 1.891368,3.782737 5.691476,3.139892 8.84375,5.03125 4.41319,1.260916 7.566476,5.035226 10.71875,8.1875 9.456833,11.978654 13.875,30.900332 13.875,46.03125 0,5.674096 -1.284205,14.5 6.28125,14.5 0,-20.805024 -1.879988,-44.758963 -15.75,-61.78125 C 70.272949,23.973994 61.569191,17.213759 53.40625,17.40625 z m -16.5,1 c -2.429623,0.100201 -5.635854,1.309687 -6.1875,4.34375 1.260905,0 3.145345,0.0055 4.40625,-0.625 6.737993,-2.127784 4.90505,-3.84758 1.78125,-3.71875 z m -3.875,8.5625 c -4.749346,0.198245 -8.478301,4.691417 -7.375,9.65625 l 1.28125,-3.15625 c 3.782737,0.630453 5.661703,-1.248512 5.03125,-5.03125 l 3.15625,-0.65625 0,-0.625 c -0.709262,-0.157615 -1.415272,-0.215821 -2.09375,-0.1875 z m 22.28125,14.0625 c -2.521822,1.260906 -3.15625,4.415679 -3.15625,6.9375 l 1.25,0 1.90625,-6.9375 z m -41,15.125 c -3.152274,0 -3.777284,6.317953 -0.625,5.6875 3.152275,-0.630452 4.407728,-5.6875 0.625,-5.6875 z m 6.9375,6.3125 -3.15625,5.6875 1.90625,0.625 1.875,-6.3125 -0.625,0 z"
      inkscape:connector-curvature="0"
-     id="BlackKnight"
-     style="stroke-width:1px" />
+     id="rect2946"
+     style="color:#000000;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
 </svg>
index 68dd7ca..0ac3a44 100644 (file)
--- a/xboard.c
+++ b/xboard.c
@@ -254,6 +254,11 @@ char *layoutName;
 
 char installDir[] = "."; // [HGM] UCI: needed for UCI; probably needs run-time initializtion
 
+/* pixbufs */
+static GdkPixbuf       *mainwindowIcon=NULL;
+static GdkPixbuf       *WhiteIcon=NULL;
+static GdkPixbuf       *BlackIcon=NULL;
+
 typedef unsigned int BoardSize;
 BoardSize boardSize;
 Boolean chessProgram;
@@ -1298,18 +1303,13 @@ main (int argc, char **argv)
     InitMenuMarkers();
 
     /*
-     * Create an icon.
+     * Create an icon. (Use two icons, to indicate whther it is white's or black's turn.)
      */
-#ifdef TODO_GTK
-    ReadBitmap(&wIconPixmap, "icon_white.bm",
-              icon_white_bits, icon_white_width, icon_white_height);
-    ReadBitmap(&bIconPixmap, "icon_black.bm",
-              icon_black_bits, icon_black_width, icon_black_height);
-    iconPixmap = wIconPixmap;
-    i = 0;
-    XtSetArg(args[i], XtNiconPixmap, iconPixmap);  i++;
-    XtSetValues(shellWidget, args, i);
-#endif
+    WhiteIcon  = gdk_pixbuf_new_from_file(SVGDIR "/icon_white.svg", NULL);
+    BlackIcon  = gdk_pixbuf_new_from_file(SVGDIR "/icon_black.svg", NULL);
+    mainwindowIcon = WhiteIcon;
+    gtk_window_set_icon(GTK_WINDOW(shellWidget), mainwindowIcon);
+
 
     /*
      * Create a cursor for the board widget.
@@ -2240,22 +2240,16 @@ DisplayTimerLabel (Option *opt, char *color, long timer, int highlight)
     g_free(markup);
 }
 
-#ifdef TODO_GTK
-static Pixmap *clockIcons[] = { &wIconPixmap, &bIconPixmap };
-#endif
+static GdkPixbuf **clockIcons[] = { &WhiteIcon, &BlackIcon };
 
 void
 SetClockIcon (int color)
 {
-#ifdef TODO_GTK
-    Arg args[16];
-    Pixmap pm = *clockIcons[color];
-    if (iconPixmap != pm) {
-       iconPixmap = pm;
-       XtSetArg(args[0], XtNiconPixmap, iconPixmap);
-       XtSetValues(shellWidget, args, 1);
+    GdkPixbuf *pm = *clockIcons[color];
+    if (mainwindowIcon != pm) {
+        mainwindowIcon = pm;
+       gtk_window_set_icon(GTK_WINDOW(shellWidget), mainwindowIcon);
     }
-#endif
 }
 
 #define INPUT_SOURCE_BUF_SIZE 8192