{"thread":{"id":"16344","subject":"[PATCH] gitk: try to set program icon","startedAt":"2008-11-15T23:45:45Z","lastAt":"2008-11-16T02:41:39Z","messageCount":3,"participants":["Giuseppe Bilotta"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"95910","messageId":"1226792745-18408-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"16344","inReplyTo":null,"subject":"[PATCH] gitk: try to set program icon","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2008-11-15T23:45:45Z","receivedAt":"2008-11-15T23:45:45Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"We add the git icon in three formats (.xbm, .ico, .ppm), which we try to\nset as window icon.\n---\n\nUgh. This rather simple patch cost me _way_ more time than I expected to\ndedicate to it. Making those pesky iconbitmap and iconphoto commands do what\nthey were supposed to do is not as trivial as it seems. Thanks the people on\nFreenode/#tcl for giving me a hand in understading they very restricted way in\nwhich they could work.\n\nAlso, I'm not really sure the gitk program path itself is the best place to put\nthe icon files in, but I couldn't think of a better place so feel free to\nsuggest alternatives (it's a real pity that you can't embed the icon data in\nthe program itself).\n\n gitk-git/Makefile |    3 +++\n gitk-git/gitk     |    9 +++++++++\n gitk-git/gitk.ico |  Bin 0 -> 318 bytes\n gitk-git/gitk.ppm |  Bin 0 -> 781 bytes\n gitk-git/gitk.xbm |    6 ++++++\n 5 files changed, 18 insertions(+), 0 deletions(-)\n create mode 100644 gitk-git/gitk.ico\n create mode 100644 gitk-git/gitk.ppm\n create mode 100644 gitk-git/gitk.xbm\n\ndiff --git a/gitk-git/Makefile b/gitk-git/Makefile\nindex e1b6045..a55f905 100644\n--- a/gitk-git/Makefile\n+++ b/gitk-git/Makefile\n@@ -31,6 +31,7 @@ endif\n PO_TEMPLATE = po/gitk.pot\n ALL_POFILES = $(wildcard po/*.po)\n ALL_MSGFILES = $(subst .po,.msg,$(ALL_POFILES))\n+LOGO_FILES = gitk.ico gitk.xbm gitk.ppm\n \n ifndef V\n \tQUIET          = @\n@@ -43,8 +44,10 @@ install:: all\n \t$(INSTALL) -m 755 gitk-wish '$(DESTDIR_SQ)$(bindir_SQ)'/gitk\n \t$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(msgsdir_SQ)'\n \t$(foreach p,$(ALL_MSGFILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(msgsdir_SQ)' &&) true\n+\t$(foreach p,$(LOGO_FILES), $(INSTALL) -m 644 $p '$(DESTDIR_SQ)$(bindir_SQ)' &&) true\n \n uninstall::\n+\t$(foreach p,$(LOGO_FILES), $(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/$(notdir $p) &&) true\n \t$(foreach p,$(ALL_MSGFILES), $(RM) '$(DESTDIR_SQ)$(msgsdir_SQ)'/$(notdir $p) &&) true\n \t$(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk\n \ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 3353f4a..25cf627 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -10797,6 +10797,15 @@ set lserial 0\n set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == \"true\"}]\n setcoords\n makewindow\n+# try to set the window icon, testing the logos from the worst to the best\n+# quality. XBM is likely to fail on Windows, ICO is likely to fail on other\n+# systems, and PPM with iconphoto only works for 8.4.9 or later\n+catch { wm iconbitmap . @[file join [file dirname [file normalize $argv0]] gitk.xbm] }\n+catch { wm iconbitmap . @[file join [file dirname [file normalize $argv0]] gitk.ico] }\n+catch {\n+\timage create photo gitlogo -file [file join [file dirname [file normalize $argv0]] gitk.ppm]\n+\twm iconphoto . -default gitlogo\n+}\n # wait for the window to become visible\n tkwait visibility .\n wm title . \"[file tail $argv0]: [file tail [pwd]]\"\ndiff --git a/gitk-git/gitk.ico b/gitk-git/gitk.ico\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..db349141ec3f510d98751fc117ff63eb4fc465c0\nGIT binary patch\nliteral 318\nzcmb7;u?~PB5JL-bbGgIB8JYM@Kg~bGR>MNVK*{Tc_J#ujpPA7&)Bv0SDlw9Ya_J_=\np{-aI+&sVh8AXZgo@^Ym@^W;wJQ<3sf8Bxc^KF5CcU%hwSe*yPC7a#xt\n\nliteral 0\nHcmV?d00001\n\ndiff --git a/gitk-git/gitk.ppm b/gitk-git/gitk.ppm\nnew file mode 100644\nindex 0000000000000000000000000000000000000000..b6ea231fc8eb12827dced0cee8390bd0a2a424d1\nGIT binary patch\nliteral 781\nzcmWGA<1#c;Ff`*bGBxG;Kk~o<1_n3+`X0^(GBCNAA_UdbAw(G(7=Q?F5iwl28VCay\nX7icDa1!%GmH^5CJh6{K0U|;|M>w9nk\n\nliteral 0\nHcmV?d00001\n\ndiff --git a/gitk-git/gitk.xbm b/gitk-git/gitk.xbm\nnew file mode 100644\nindex 0000000..ce5871d\n--- /dev/null\n+++ b/gitk-git/gitk.xbm\n@@ -0,0 +1,6 @@\n+#define gitk_width 16\n+#define gitk_height 16\n+static char gitk_bits[] = {\n+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDE, 0x7B, \n+  0xDE, 0x7B, 0x00, 0x00, 0x00, 0x00, 0x8C, 0x31, 0xDE, 0x7B, 0xDE, 0x7B, \n+  0x8C, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };\n-- \n1.5.6.5\n"},{"id":"95924","messageId":"cb7bb73a0811151814va151c32ud5e940820ff92011@mail.gmail.com","threadId":"16344","inReplyTo":"1226792745-18408-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCH] gitk: try to set program icon","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2008-11-16T02:14:25Z","receivedAt":"2008-11-16T02:14:25Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Sun, Nov 16, 2008 at 12:45 AM, Giuseppe Bilotta\n<giuseppe.bilotta@gmail.com> wrote:\n> We add the git icon in three formats (.xbm, .ico, .ppm), which we try to\n> set as window icon.\n\n[snip]\n\nScratch this. I've seen how it's done in git-gui, and I think that's a\nbetter way to do it. I've provided a patch for git-gui to introduce\nthe icon under X, so I'll just use something like that, maybe using wm\niconphoto for all platforms.\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"},{"id":"95925","messageId":"1226803299-26474-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"16344","inReplyTo":"cb7bb73a0811151814va151c32ud5e940820ff92011@mail.gmail.com","subject":"[PATCH] gitk: try to provide a window icon","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2008-11-16T02:41:39Z","receivedAt":"2008-11-16T02:41:39Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"Try to set up a 16x16 Tk photo image (based on the git logo) and use it\na window icon. Wrap the code in a catch because it may fail in earlier\nTcl/Tk 8.4 releases that don't provide 'wm iconphoto'.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n gitk-git/gitk |   20 ++++++++++++++++++++\n 1 files changed, 20 insertions(+), 0 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 3353f4a..6b671a6 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -10797,6 +10797,26 @@ set lserial 0\n set isworktree [expr {[exec git rev-parse --is-inside-work-tree] == \"true\"}]\n setcoords\n makewindow\n+catch {\n+\timage create photo gitlogo      -width 16 -height 16\n+\n+\timage create photo gitlogominus -width  4 -height  2\n+\tgitlogominus put #C00000 -to 0 0 4 2\n+\tgitlogo copy gitlogominus -to  1 5\n+\tgitlogo copy gitlogominus -to  6 5\n+\tgitlogo copy gitlogominus -to 11 5\n+\timage delete gitlogominus\n+\n+\timage create photo gitlogoplus  -width  4 -height  4\n+\tgitlogoplus  put #008000 -to 1 0 3 4\n+\tgitlogoplus  put #008000 -to 0 1 4 3\n+\tgitlogo copy gitlogoplus  -to  1 9\n+\tgitlogo copy gitlogoplus  -to  6 9\n+\tgitlogo copy gitlogoplus  -to 11 9\n+\timage delete gitlogoplus\n+\n+\twm iconphoto . -default gitlogo\n+}\n # wait for the window to become visible\n tkwait visibility .\n wm title . \"[file tail $argv0]: [file tail [pwd]]\"\n-- \n1.5.6.5\n"}]}