From 64bfd817ae5e2e8afc232062f24ca548034f02ec Mon Sep 17 00:00:00 2001 From: gabrielfin Date: Sat, 22 Jun 2019 17:52:18 -0300 Subject: [PATCH] [window-buttons] Fix for unfocused state not showing --- window-buttons-applet/window-button.vala | 18 ++++++++++-------- .../window-buttons-applet.vala | 18 +++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/window-buttons-applet/window-button.vala b/window-buttons-applet/window-button.vala index c95ad99..0adcea5 100644 --- a/window-buttons-applet/window-button.vala +++ b/window-buttons-applet/window-button.vala @@ -81,7 +81,7 @@ namespace WindowWidgets{ } } - public void update(bool reset = false){ + public void update(bool theme_change = false){ IconType type; if(_button_type == WindowButtonType.MINIMIZE) @@ -96,7 +96,7 @@ namespace WindowWidgets{ IconState state; - if(!reset && _window != null && !_window.is_active()) + if(_window != null && !_window.is_active()) state = IconState.UNFOCUSED; else state = IconState.FOCUSED; @@ -104,6 +104,14 @@ namespace WindowWidgets{ Gdk.Pixbuf? icon = theme.get_icon(type, state, _current_action); + // If this is a new theme, and it doesn't have an icon for the current state and action, then reset + // everything, otherwise we would be showing the icons of the old theme + if(theme_change && icon == null){ + state = IconState.FOCUSED; + _current_action = IconAction.NORMAL; + + icon = theme.get_icon(type, state, _current_action); + } if(icon != null){ icon = icon.scale_simple(_icon_size, _icon_size, Gdk.InterpType.HYPER); @@ -123,12 +131,6 @@ namespace WindowWidgets{ this.update(); } - public void reload(){ - _current_action = IconAction.NORMAL; - - this.update(true); - } - } public enum WindowButtonType{ diff --git a/window-buttons-applet/window-buttons-applet.vala b/window-buttons-applet/window-buttons-applet.vala index 43c1e66..e6fceb6 100644 --- a/window-buttons-applet/window-buttons-applet.vala +++ b/window-buttons-applet/window-buttons-applet.vala @@ -60,7 +60,7 @@ namespace WindowButtonsApplet{ if((Wnck.WindowActions.CLOSE & actions)>0){ CLOSE.set_visible(true); CLOSE.window = window; - CLOSE.reload(); + CLOSE.update(); } else CLOSE.set_visible(false); } @@ -68,7 +68,7 @@ namespace WindowButtonsApplet{ if((Wnck.WindowActions.MINIMIZE & actions)>0){ MINIMIZE.set_visible(true); MINIMIZE.window = window; - MINIMIZE.reload(); + MINIMIZE.update(); } else MINIMIZE.set_visible(false); } @@ -76,7 +76,7 @@ namespace WindowButtonsApplet{ if((Wnck.WindowActions.MAXIMIZE & actions)>0){ MAXIMIZE.set_visible(true); MAXIMIZE.window = window; - MAXIMIZE.reload(); + MAXIMIZE.update(); } else MAXIMIZE.set_visible(false); } } @@ -160,15 +160,15 @@ namespace WindowButtonsApplet{ CLOSE.theme = theme; if(enabled_buttons.close) - CLOSE.reload(); + CLOSE.update(true); MINIMIZE.theme = theme; if(enabled_buttons.minimize) - MINIMIZE.reload(); + MINIMIZE.update(true); MAXIMIZE.theme = theme; if(enabled_buttons.maximize) - MAXIMIZE.reload(); + MAXIMIZE.update(true); } @@ -178,15 +178,15 @@ namespace WindowButtonsApplet{ CLOSE.icon_size = size; if(this.enabled_buttons.close == true) - CLOSE.reload(); + CLOSE.update(); MINIMIZE.icon_size = size; if(this.enabled_buttons.minimize == true) - MINIMIZE.reload(); + MINIMIZE.update(); MAXIMIZE.icon_size = size; if(this.enabled_buttons.maximize == true) - MAXIMIZE.reload(); + MAXIMIZE.update(); }