From 6c04935d9bab1f8d73188d1d7d5b296cbb9360a3 Mon Sep 17 00:00:00 2001 From: gabrielfin Date: Sat, 22 Jun 2019 17:01:54 -0300 Subject: [PATCH] Fix: applets not updating when closing background window --- window-buttons-applet/window-buttons-applet.vala | 12 +++++++++++- window-menu-applet/window-menu-applet.vala | 12 +++++++++++- window-title-applet/window-title-applet.vala | 12 +++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/window-buttons-applet/window-buttons-applet.vala b/window-buttons-applet/window-buttons-applet.vala index e6fceb6..d590a53 100644 --- a/window-buttons-applet/window-buttons-applet.vala +++ b/window-buttons-applet/window-buttons-applet.vala @@ -38,6 +38,7 @@ namespace WindowButtonsApplet{ this.change_layout(); this.change_theme(); this.change_spacing(); + this.change_behaviour(); this.marco_gsettings.changed["theme"].connect(this.change_theme); this.gsettings.changed["spacing"].connect(this.change_spacing); @@ -206,6 +207,15 @@ namespace WindowButtonsApplet{ this.set_spacing(spacing); } + public void change_behaviour(){ + string behaviour = gsettings.get_string("behaviour"); + + Wnck.Screen.get_default().window_closed.disconnect( reload ); + + if(behaviour == "topmost-maximized") + Wnck.Screen.get_default().window_closed.connect( reload ); + } + private Wnck.Window get_current_window(){ Wnck.Window* win = null; string behaviour = gsettings.get_string("behaviour"); @@ -284,7 +294,7 @@ namespace WindowButtonsApplet{ widget_container.gsettings.changed["buttons-layout"].connect(widget_container.change_layout); widget_container.gsettings.changed["spacing"].connect( (key) => { widget_container.change_size(applet.get_size()); } ); widget_container.gsettings.changed["padding"].connect( (key) => { widget_container.change_size(applet.get_size()); } ); - widget_container.gsettings.changed["behaviour"].connect( (key) => { widget_container.reload(); } ); + widget_container.gsettings.changed["behaviour"].connect( () => { widget_container.change_behaviour(); widget_container.reload(); } ); applet.setup_menu(menu,action_group); settings.delete_event.connect( (event) => { settings.hide() ; return true ; } ); diff --git a/window-menu-applet/window-menu-applet.vala b/window-menu-applet/window-menu-applet.vala index 576f903..2af2999 100644 --- a/window-menu-applet/window-menu-applet.vala +++ b/window-menu-applet/window-menu-applet.vala @@ -65,6 +65,15 @@ namespace WindowMenuApplet{ } + public void change_behaviour(){ + string behaviour = gsettings.get_string("behaviour"); + + Wnck.Screen.get_default().window_closed.disconnect( reload ); + + if(behaviour == "topmost-maximized") + Wnck.Screen.get_default().window_closed.connect( reload ); + } + private Wnck.Window get_current_window(){ Wnck.Window* win = null; string behaviour = gsettings.get_string("behaviour"); @@ -102,6 +111,7 @@ namespace WindowMenuApplet{ button = new WindowMenuButton(); + change_behaviour(); change_orient(applet); Gtk.Builder builder = new Gtk.Builder(); @@ -133,7 +143,7 @@ namespace WindowMenuApplet{ menu += """"""; gsettings.bind("behaviour",builder.get_object("behaviour"),"active_id",SettingsBindFlags.DEFAULT); - gsettings.changed["behaviour"].connect( (key) => { reload(); } ); + gsettings.changed["behaviour"].connect( () => { change_behaviour(); reload(); } ); applet.add(button); applet.setup_menu(menu,action_group); diff --git a/window-title-applet/window-title-applet.vala b/window-title-applet/window-title-applet.vala index 36cb1a9..7938946 100644 --- a/window-title-applet/window-title-applet.vala +++ b/window-title-applet/window-title-applet.vala @@ -48,6 +48,15 @@ namespace WindowTitleApplet{ } } + public void change_behaviour(){ + string behaviour = gsettings.get_string("behaviour"); + + Wnck.Screen.get_default().window_closed.disconnect( reload ); + + if(behaviour == "topmost-maximized") + Wnck.Screen.get_default().window_closed.connect( reload ); + } + private Wnck.Window get_current_window(){ Wnck.Window* win = null; string behaviour = gsettings.get_string("behaviour"); @@ -98,6 +107,7 @@ namespace WindowTitleApplet{ title = new Gtk.Label(""); title.ellipsize = Pango.EllipsizeMode.END; + change_behaviour(); reload(); //title.set_label(Wnck.Screen.get_default().get_active_window().get_name()); @@ -131,7 +141,7 @@ namespace WindowTitleApplet{ menu += """"""; gsettings.bind("behaviour",builder.get_object("behaviour"),"active_id",SettingsBindFlags.DEFAULT); - gsettings.changed["behaviour"].connect( (key) => { reload(); } ); + gsettings.changed["behaviour"].connect( () => { change_behaviour(); reload(); } ); applet.set_flags(MatePanel.AppletFlags.EXPAND_MINOR | MatePanel.AppletFlags.EXPAND_MAJOR);