{"thread":{"id":"31626","subject":"[PATCH] gitk: Work around empty back and forward images when buttons are disabled","startedAt":"2012-09-22T07:46:48Z","lastAt":"2012-09-23T07:00:15Z","messageCount":2,"participants":["Stefan Haller","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"199733","messageId":"1348300008-90717-1-git-send-email-stefan@haller-berlin.de","threadId":"31626","inReplyTo":null,"subject":"[PATCH] gitk: Work around empty back and forward images when buttons are disabled","fromName":"Stefan Haller","fromEmail":"stefan@haller-berlin.de","sentAt":"2012-09-22T07:46:48Z","receivedAt":"2012-09-22T07:46:48Z","isPatch":true,"sender":{"key":"stefan@haller-berlin.de","avatar":"https://avatars.githubusercontent.com/u/1225667?v=4"},"body":"On Mac, the back and forward buttons show an empty rectange instead of\na grayed-out arrow when they are disabled. The reason is a Tk bug on Mac\nthat causes disabled images not to draw correctly (not to draw at all,\nthat is); see\n<https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.tcl/V-nW1JBq0eU>.\n\nTo work around this, we explicitly provide gray images for the disabled\nstate; I think this looks better than the default stipple effect that you\nget on Windows as well, but that may be a matter of taste.\n\nSigned-off-by: Stefan Haller <stefan@haller-berlin.de>\n---\n gitk | 17 +++++++++++------\n 1 file changed, 11 insertions(+), 6 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex d93bd99..e7723db 100755\n--- a/gitk\n+++ b/gitk\n@@ -2161,7 +2161,7 @@ proc makewindow {} {\n     trace add variable sha1string write sha1change\n     pack $sha1entry -side left -pady 2\n \n-    image create bitmap bm-left -data {\n+    set bm_left_data {\n \t#define left_width 16\n \t#define left_height 16\n \tstatic unsigned char left_bits[] = {\n@@ -2169,7 +2169,7 @@ proc makewindow {} {\n \t0x0e, 0x00, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x0e, 0x00, 0x1c, 0x00,\n \t0x38, 0x00, 0x70, 0x00, 0xe0, 0x00, 0xc0, 0x01};\n     }\n-    image create bitmap bm-right -data {\n+    set bm_right_data {\n \t#define right_width 16\n \t#define right_height 16\n \tstatic unsigned char right_bits[] = {\n@@ -2177,11 +2177,16 @@ proc makewindow {} {\n \t0x00, 0x38, 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0x00, 0x38, 0x00, 0x1c,\n \t0x00, 0x0e, 0x00, 0x07, 0x80, 0x03, 0xc0, 0x01};\n     }\n-    ${NS}::button .tf.bar.leftbut -image bm-left -command goback \\\n-\t-state disabled -width 26\n+    image create bitmap bm-left -data $bm_left_data\n+    image create bitmap bm-left-gray -data $bm_left_data -foreground \"#999\"\n+    image create bitmap bm-right -data $bm_right_data\n+    image create bitmap bm-right-gray -data $bm_right_data -foreground \"#999\"\n+\n+    ${NS}::button .tf.bar.leftbut -image [list bm-left disabled bm-left-gray] \\\n+\t-command goback -state disabled -width 26\n     pack .tf.bar.leftbut -side left -fill y\n-    ${NS}::button .tf.bar.rightbut -image bm-right -command goforw \\\n-\t-state disabled -width 26\n+    ${NS}::button .tf.bar.rightbut -image [list bm-right disabled bm-right-gray] \\\n+\t-command goforw -state disabled -width 26\n     pack .tf.bar.rightbut -side left -fill y\n \n     ${NS}::label .tf.bar.rowlabel -text [mc \"Row\"]\n-- \n1.7.12.1.399.gae20e0d\n"},{"id":"199751","messageId":"20120923070015.GC15889@bloggs.ozlabs.ibm.com","threadId":"31626","inReplyTo":"1348300008-90717-1-git-send-email-stefan@haller-berlin.de","subject":"Re: [PATCH] gitk: Work around empty back and forward images when buttons are disabled","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2012-09-23T07:00:15Z","receivedAt":"2012-09-23T07:00:15Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Sat, Sep 22, 2012 at 09:46:48AM +0200, Stefan Haller wrote:\n> On Mac, the back and forward buttons show an empty rectange instead of\n> a grayed-out arrow when they are disabled. The reason is a Tk bug on Mac\n> that causes disabled images not to draw correctly (not to draw at all,\n> that is); see\n> <https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.tcl/V-nW1JBq0eU>.\n> \n> To work around this, we explicitly provide gray images for the disabled\n> state; I think this looks better than the default stipple effect that you\n> get on Windows as well, but that may be a matter of taste.\n> \n> Signed-off-by: Stefan Haller <stefan@haller-berlin.de>\n\nThanks, applied.\n\nPaul.\n"}]}