From 7d71d881510abc4d0848d0ae02d3cba83ce56eac Mon Sep 17 00:00:00 2001 From: gabrielfin Date: Sat, 8 Jun 2019 15:21:18 -0300 Subject: [PATCH] [window-buttons] Detect which fallback theme to use ...according to color of user's theme --- .../mate-window-applets/{ => Black}/close.png | Bin .../{ => Black}/close_prelight.png | Bin .../mate-window-applets/{ => Black}/maximize.png | Bin .../{ => Black}/maximize_prelight.png | Bin .../mate-window-applets/{ => Black}/minimize.png | Bin .../{ => Black}/minimize_prelight.png | Bin .../{ => Black}/unmaximize.png | Bin .../{ => Black}/unmaximize_prelight.png | Bin data/pixmaps/mate-window-applets/White/close.png | Bin 0 -> 1056 bytes .../mate-window-applets/White/close_prelight.png | Bin 0 -> 1345 bytes .../mate-window-applets/White/maximize.png | Bin 0 -> 745 bytes .../White/maximize_prelight.png | Bin 0 -> 808 bytes .../mate-window-applets/White/minimize.png | Bin 0 -> 512 bytes .../White/minimize_prelight.png | Bin 0 -> 608 bytes .../mate-window-applets/White/unmaximize.png | Bin 0 -> 1366 bytes .../White/unmaximize_prelight.png | Bin 0 -> 1408 bytes window-buttons-applet/window-buttons-applet.vala | 12 +++++++++--- window-buttons-applet/window-buttons-theme.vala | 15 +++++++++++---- 18 files changed, 20 insertions(+), 7 deletions(-) rename data/pixmaps/mate-window-applets/{ => Black}/close.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/close_prelight.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/maximize.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/maximize_prelight.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/minimize.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/minimize_prelight.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/unmaximize.png (100%) rename data/pixmaps/mate-window-applets/{ => Black}/unmaximize_prelight.png (100%) create mode 100644 data/pixmaps/mate-window-applets/White/close.png create mode 100644 data/pixmaps/mate-window-applets/White/close_prelight.png create mode 100644 data/pixmaps/mate-window-applets/White/maximize.png create mode 100644 data/pixmaps/mate-window-applets/White/maximize_prelight.png create mode 100644 data/pixmaps/mate-window-applets/White/minimize.png create mode 100644 data/pixmaps/mate-window-applets/White/minimize_prelight.png create mode 100644 data/pixmaps/mate-window-applets/White/unmaximize.png create mode 100644 data/pixmaps/mate-window-applets/White/unmaximize_prelight.png diff --git a/data/pixmaps/mate-window-applets/close.png b/data/pixmaps/mate-window-applets/Black/close.png similarity index 100% rename from data/pixmaps/mate-window-applets/close.png rename to data/pixmaps/mate-window-applets/Black/close.png diff --git a/data/pixmaps/mate-window-applets/close_prelight.png b/data/pixmaps/mate-window-applets/Black/close_prelight.png similarity index 100% rename from data/pixmaps/mate-window-applets/close_prelight.png rename to data/pixmaps/mate-window-applets/Black/close_prelight.png diff --git a/data/pixmaps/mate-window-applets/maximize.png b/data/pixmaps/mate-window-applets/Black/maximize.png similarity index 100% rename from data/pixmaps/mate-window-applets/maximize.png rename to data/pixmaps/mate-window-applets/Black/maximize.png diff --git a/data/pixmaps/mate-window-applets/maximize_prelight.png b/data/pixmaps/mate-window-applets/Black/maximize_prelight.png similarity index 100% rename from data/pixmaps/mate-window-applets/maximize_prelight.png rename to data/pixmaps/mate-window-applets/Black/maximize_prelight.png diff --git a/data/pixmaps/mate-window-applets/minimize.png b/data/pixmaps/mate-window-applets/Black/minimize.png similarity index 100% rename from data/pixmaps/mate-window-applets/minimize.png rename to data/pixmaps/mate-window-applets/Black/minimize.png diff --git a/data/pixmaps/mate-window-applets/minimize_prelight.png b/data/pixmaps/mate-window-applets/Black/minimize_prelight.png similarity index 100% rename from data/pixmaps/mate-window-applets/minimize_prelight.png rename to data/pixmaps/mate-window-applets/Black/minimize_prelight.png diff --git a/data/pixmaps/mate-window-applets/unmaximize.png b/data/pixmaps/mate-window-applets/Black/unmaximize.png similarity index 100% rename from data/pixmaps/mate-window-applets/unmaximize.png rename to data/pixmaps/mate-window-applets/Black/unmaximize.png diff --git a/data/pixmaps/mate-window-applets/unmaximize_prelight.png b/data/pixmaps/mate-window-applets/Black/unmaximize_prelight.png similarity index 100% rename from data/pixmaps/mate-window-applets/unmaximize_prelight.png rename to data/pixmaps/mate-window-applets/Black/unmaximize_prelight.png diff --git a/data/pixmaps/mate-window-applets/White/close.png b/data/pixmaps/mate-window-applets/White/close.png new file mode 100644 index 0000000000000000000000000000000000000000..79c860f47423b8a7cf7cbaa52a9ce656e2ad82f5 GIT binary patch literal 1056 zcmeAS@N?(olHy`uVBq!ia0vp^KR}p+4M-lmsLc(e*pj^6T^Rm@;DWu&Cj&(|3p^r= z85p>QL70(Y)*K0-AbW|YuPggQ78y}f@X^nEp!tq|fWU_Zw!tvtvzo(9p;{(T97#-kJNe{2eRy#fk5Wi!J!z!p~RCKyh&yn7FAqNF1mGAufD( zvMi6x*an>D^_7f=JW+>$Ax8K#(n?!x!@pB z6_3n?2X8JvnRS~L$TTQ$XfF1d{J4pkjSp;OBbb521i8RL)BC>Oub;_vHK!GiZ2qOZ z3E{C>GD2qCx%uY30D4~)=rQM}XJrQuf^1!o(wtqyaRca}ibX&}c`iPfCBtL_Q|oND zL#>?~K1*tsP;l`DPzgo}XC1{EB~>xQxw3aL_(;o4gwo$3O?g6gw|fD~I^f zp*cIxWGBdJ2@ilyGY`osf@*2YFF4x^R0a-mlO506f_&dK0bL3V&Yx`8?+7e82@OS! z>knp0H<D>F!L2+ffjh&dIAl_B^d>Gd0A)Ofd(5WHbL=w5ET6oCYa%7 z@Ka>Uwy*AQetk=TC8%?TXZL>l4RdP)Tl)NG*MP=CQskWMSpb5+Zaz@5o3Q*~ lsrt;>GU752FEj@4We``5o!L9fH3gJWJzf1=);T3K0RWkCo7w;X literal 0 HcmV?d00001 diff --git a/data/pixmaps/mate-window-applets/White/close_prelight.png b/data/pixmaps/mate-window-applets/White/close_prelight.png new file mode 100644 index 0000000000000000000000000000000000000000..57c10430285238770d6236aed5ba5b54abcb228e GIT binary patch literal 1345 zcmZWpZA@BM7{=f(qJlWGtO5Mk+#uWHG#gZ`b?C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umH$4l zaW7uQ_h7c4aKiz{MrI~<7CsIc0gFHWvl6WArS2SJi7Rk;&~U&Jh>@g0N)*5nU_pdF zg#r`_7CxAPAk|1ZK(;_^f(bSgYyJ*Skb@fMJ~=ScNZ9wz(z=JN?DJpXbRLSiw07PH z9rklAGjC1dyrZoT4j`ECpaDy!myyF7HAvB7hCK7pVg?jtdpu?(tTbRmi~MD~7_vTb Vd~-hAwGfozJYD@<);T3K0RXZ!$x#3R literal 0 HcmV?d00001 diff --git a/data/pixmaps/mate-window-applets/White/maximize_prelight.png b/data/pixmaps/mate-window-applets/White/maximize_prelight.png new file mode 100644 index 0000000000000000000000000000000000000000..de70882a2164f4b3da343fd270579813b1b93c3a GIT binary patch literal 808 zcmeAS@N?(olHy`uVBq!ia0vp^KR}p+4M-lmsLc(e*pj^6U4S$Y{B+)352QE?JR*x3 z7`TN&n2}-D90{Nxdx@v7EBiwh88LJ9%c{@*0)=EVLn2C?^K)}k^GbkR1_tM%)Wnk1 z6ovB4k_-iRPv3wPy;ODv2BscQ7srr_TW{|=@--QVxCYLD`EUE5m?o7F%`bB{GOvlL z^Hf;&mb+rvc2$N(W+rwPJ`NcH3x$Fk=Qps}m%nmsR(V}B@$-3~BQF!0z|sgM4i6d* zI07*vLLWpgNP@Ak8CgQ10AwggqOr0~H6l8?yMYsE6U;U&I*^S5T8yv*VHDJ2kc-yj z%lz=s6`pJ{{aH6B-?kSxU3K`~zI}SLQf4;i?#<;;vna@EDz@FN!NOM^S905I+lvQs zVBbUBL)cn`BcTCN|M~0xgMS}d&v@joipzd^T(;`UshMfIe`+ar>mdKI;Vst0EUe67XSbN literal 0 HcmV?d00001 diff --git a/data/pixmaps/mate-window-applets/White/minimize.png b/data/pixmaps/mate-window-applets/White/minimize.png new file mode 100644 index 0000000000000000000000000000000000000000..9193380ec3737a9b659730e9312d031067a01f02 GIT binary patch literal 512 zcmeAS@N?(olHy`uVBq!ia0vp^KR}p+4M-lmsLc(e*pj^6U4S$Y{B+)352QE?JR*x3 z7`TN&n2}-D90{Nxdx@v7EBiwh8F3bw>Fo^nfI_mFArU3c`MJ5Nc_lzD1A}u>YGO%h zib8p2Nrr;Er*A-tUMf2S17nJ(i(^Q|t+$sqaxxh3FgsfRe!nK?!KIdh>#KxoM8R5z z0wG-`HTj6^hk^rllMf$v{h;62e1Nf$nTef+k3&Yl0)!O`93C`41Q8Mn1t=0Md@vml o)s8S7AY&j#!Hgl!d~nd^?Al(#(pL5T|924A)78&qol`;+0BU$!1^@s6 literal 0 HcmV?d00001 diff --git a/data/pixmaps/mate-window-applets/White/minimize_prelight.png b/data/pixmaps/mate-window-applets/White/minimize_prelight.png new file mode 100644 index 0000000000000000000000000000000000000000..ca8e652698a240af17f11970d2dc28b95d3d5241 GIT binary patch literal 608 zcmeAS@N?(olHy`uVBq!ia0vp^KR}p+4M-lmsLc(e*pj^6U4S$Y{B+)352QE?JR*x3 z7`TN&n2}-D90{Nxdx@v7EBiwh8F4PT=UhHDKq1-8kcblJ{M_8syb>Unfx)>bHL)Z$ zMWH;iBtya7(>EYRFO{8vf$@l^i(^Q|t+#g#`C1eN90CpR{XcahLTW`x+Jn7iv(L_Y zub}d-5NyIwAU?F4{oLbTyYb%c)y};gQQo&dy!>=v7YiQ~yVkBhEYQL70(Y)*K0-AbW|YuPggQ78x-WtBYq&ZvzU+W`;zRIOpf)rskCZxeN@>MX8A; zsVNHOnI#zt?w-B@DSD~w3=Ay0JY5_^DsH{KdoVBBRif=-zRdQ}s09mS6%}u6cqp~w zKX<}mv5k$aOS3YknDxC)ylB{Srjyqb_f0uB3m<*9UVr{Z;oYEYUV~+=f(-{4 z8=0BdS@`apxy12o^%SGmx1Z}9e0u;F2gz~B2v{f-I6MGhxCDm`LINb%3^NI&8m0rP z8e#=R5MmVE7-aJs4me^r{{Xwj*05lPYOwte<7~zCmh$|S*)t_5>v!Vcm(0!@cbfw; z+fye^R^gvqGxN!JmHe!=xBE-fb-v}DephnW`cH2C?qB(l*}B#DvoG@T-`Y0!?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B*AEOfBsU)3A;%$eZ0mRD$Y=jzOqNbj_uS|8Y1!LJPZmZ0k1s11dA%*=MoGEC z--o5Q^*z_^{%qfJIrrAOlKbUX&K6Ep*?KL!`q3WacKqFf^Z$3qmKzq{`K)qYZCZBk+S5@^dN_Tzy{dex$x%P@l5AH~Mf7z{?2g)=vHX1dx+GpJVf86PG z#hr(hGST2Xik63{o)t;S>S!efj;wxXQBbxi>jqYEF$5|j5>DOM%8>t|YFTmuR1kW) L`njxgN@xNAp3+aL literal 0 HcmV?d00001 diff --git a/window-buttons-applet/window-buttons-applet.vala b/window-buttons-applet/window-buttons-applet.vala index de48788..c3ed6d7 100644 --- a/window-buttons-applet/window-buttons-applet.vala +++ b/window-buttons-applet/window-buttons-applet.vala @@ -24,13 +24,17 @@ namespace WindowButtonsApplet{ protected EnabledButtons enabled_buttons = EnabledButtons(); + private Gtk.StyleContext* applet_style_context; + // Constructor - public ButtonsApplet(Gtk.Orientation orient){ + public ButtonsApplet(Gtk.Orientation orient, Gtk.StyleContext* applet_style_context){ Object(orientation: orient); this.set_homogeneous(true); + this.applet_style_context = applet_style_context; + this.change_layout(); this.change_theme(); this.change_spacing(); @@ -150,7 +154,9 @@ namespace WindowButtonsApplet{ public void change_theme(){ string theme_name = marco_gsettings.get_string("theme"); - WindowButtonsTheme theme = new WindowButtonsTheme(theme_name); + Gdk.RGBA fg_color = applet_style_context->get_color(Gtk.StateFlags.ACTIVE); + + WindowButtonsTheme theme = new WindowButtonsTheme(theme_name, fg_color); CLOSE.theme = theme; if(enabled_buttons.close) @@ -251,7 +257,7 @@ namespace WindowButtonsApplet{ Gtk.Window settings = builder.get_object("Settings") as Gtk.Window; Gtk.Window about = builder.get_object("About") as Gtk.Window; - var widget_container = new ButtonsApplet(Gtk.Orientation.HORIZONTAL); + var widget_container = new ButtonsApplet(Gtk.Orientation.HORIZONTAL, applet.get_style_context()); widget_container.show(); widget_container.change_orient(applet.get_orient()); diff --git a/window-buttons-applet/window-buttons-theme.vala b/window-buttons-applet/window-buttons-theme.vala index e4e6edf..18ce7a5 100644 --- a/window-buttons-applet/window-buttons-theme.vala +++ b/window-buttons-applet/window-buttons-theme.vala @@ -9,7 +9,7 @@ namespace WindowWidgets { private string[,] _state_names; private string[,] _action_names; - public WindowButtonsTheme(string name){ + public WindowButtonsTheme(string name, Gdk.RGBA fg_color){ _pixbufs = new Gdk.Pixbuf[ IconType.TYPES, IconState.STATES, @@ -47,7 +47,7 @@ namespace WindowWidgets { if( _pixbufs[IconType.CLOSE, IconState.FOCUSED, IconAction.NORMAL] == null || _pixbufs[IconType.MINIMIZE, IconState.FOCUSED, IconAction.NORMAL] == null || _pixbufs[IconType.MAXIMIZE, IconState.FOCUSED, IconAction.NORMAL] == null ) { - load_fallback_icons(); + load_fallback_icons(fg_color); } } @@ -158,8 +158,15 @@ namespace WindowWidgets { return _pixbufs[type, state, action]; } - private void load_fallback_icons(){ - string[] paths = {"/usr/share/pixmaps/mate-window-applets"}; + private void load_fallback_icons(Gdk.RGBA fg_color){ + double lum = 0.299*fg_color.red + 0.587*fg_color.green + 0.114*fg_color.blue; + string theme; + if(lum > 0.5) + theme = "White"; + else + theme = "Black"; + + string[] paths = {"/usr/share/pixmaps/mate-window-applets/" + theme}; load_icons(paths); }