diff --git a/data/org.mate.window-applets.gschema.xml b/data/org.mate.window-applets.gschema.xml
index daa7ee9..f350370 100644
--- a/data/org.mate.window-applets.gschema.xml
+++ b/data/org.mate.window-applets.gschema.xml
@@ -1,8 +1,16 @@
+
+
+
+
+
+
+
+
true
@@ -39,6 +47,29 @@
Whether the applet should control maximized windows only
+
+ 'active-always'
+ Which window is controlled by the applet
+
+
+
+
+
+
+
+ 'active-always'
+ Which window is controlled by the applet
+
+
+
+
+
diff --git a/window-buttons-applet/dialog.ui b/window-buttons-applet/dialog.ui
index e053ddb..9e13dee 100644
--- a/window-buttons-applet/dialog.ui
+++ b/window-buttons-applet/dialog.ui
@@ -1,5 +1,5 @@
-
+
-
-
-
100
@@ -53,6 +53,15 @@
GDK_STRUCTURE_MASK | GDK_SCROLL_MASK
center
static
+
+
+
True
@@ -283,7 +292,7 @@
True
False
start
- Control only maximized window :
+ Behaviour:
True
@@ -293,15 +302,19 @@
-
+
True
True
center
+
+ - Always control active window
+ - Only control active window when maximized
+ - Control top-most maximized window
+
False
True
- 2
1
@@ -314,14 +327,5 @@
-
-
-
diff --git a/window-buttons-applet/window-buttons-applet.vala b/window-buttons-applet/window-buttons-applet.vala
index 9f20fb9..fdd1df6 100644
--- a/window-buttons-applet/window-buttons-applet.vala
+++ b/window-buttons-applet/window-buttons-applet.vala
@@ -81,30 +81,21 @@ namespace WindowButtonsApplet{
}
public void reload(){
- bool control_maximized_window = gsettings.get_boolean("control-maximized-window");
prev_window = window;
- prev_window->actions_changed.disconnect(reload);
- prev_window->state_changed.disconnect(reload);
- Wnck.Screen.get_default().force_update();
- window = Wnck.Screen.get_default().get_active_window();
+ if(prev_window != null){
+ prev_window->actions_changed.disconnect(reload);
+ prev_window->state_changed.disconnect(reload);
+ }
+
+ window = get_current_window();
if(window != null){
window->actions_changed.connect(reload);
window->state_changed.connect(reload);
- if(control_maximized_window){
- if(window->is_maximized())reload_actions(window);
- else{
- CLOSE.set_visible(false);
- MINIMIZE.set_visible(false);
- MAXIMIZE.set_visible(false);
- }
- }
- else{
- reload_actions(window);
- }
+ reload_actions(window);
}
else {
CLOSE.set_visible(false);
@@ -205,6 +196,35 @@ namespace WindowButtonsApplet{
this.set_spacing(spacing);
}
+ private Wnck.Window get_current_window(){
+ Wnck.Window* win = null;
+ string behaviour = gsettings.get_string("behaviour");
+
+ Wnck.Screen.get_default().force_update();
+
+ switch(behaviour){
+ case "active-always":
+ win = Wnck.Screen.get_default().get_active_window();
+ break;
+ case "active-maximized":
+ win = Wnck.Screen.get_default().get_active_window();
+ if(!win->is_maximized())
+ win = null;
+ break;
+ case "topmost-maximized":
+ List windows = Wnck.Screen.get_default().get_windows_stacked().copy();
+ windows.reverse();
+ foreach(Wnck.Window* w in windows) {
+ if(w->is_maximized()){
+ win = w;
+ break;
+ }
+ }
+ break;
+ }
+
+ return win;
+ }
}
private bool factory(MatePanel.Applet applet,string iid){
@@ -249,14 +269,14 @@ namespace WindowButtonsApplet{
widget_container.gsettings.bind("theme",builder.get_object("theme"),"text",SettingsBindFlags.DEFAULT);
widget_container.gsettings.bind("spacing",builder.get_object("spacing"),"value",SettingsBindFlags.DEFAULT);
widget_container.gsettings.bind("padding",builder.get_object("padding"),"value",SettingsBindFlags.DEFAULT);
- widget_container.gsettings.bind("control-maximized-window",builder.get_object("control-maximized-window"),"state",SettingsBindFlags.DEFAULT);
+ widget_container.gsettings.bind("behaviour",builder.get_object("behaviour"),"active_id",SettingsBindFlags.DEFAULT);
widget_container.gsettings.changed["use-marco-layout"].connect(widget_container.change_layout);
widget_container.gsettings.changed["buttons-layout"].connect(widget_container.change_layout);
widget_container.gsettings.changed["theme"].connect(widget_container.change_theme);
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["control-maximized-window"].connect( (key) => { widget_container.reload(); } );
+ widget_container.gsettings.changed["behaviour"].connect( (key) => { widget_container.reload(); } );
applet.setup_menu(menu,action_group);
settings.delete_event.connect( (event) => { settings.hide() ; return true ; } );
diff --git a/window-menu-applet/dialog.ui b/window-menu-applet/dialog.ui
index 20b3b87..a2225d5 100644
--- a/window-menu-applet/dialog.ui
+++ b/window-menu-applet/dialog.ui
@@ -1,5 +1,5 @@
-
+
@@ -13,6 +13,15 @@
https://github.com/ubuntu-mate/mate-window-applets
gpl-3-0
+
+
+
False
@@ -28,14 +37,71 @@
+
+
+ False
+ GDK_STRUCTURE_MASK | GDK_SCROLL_MASK
+ center
+ static
+
+
+ True
+ False
+ vertical
+ 4
+ True
+
+
+ True
+ False
+
+
+ True
+ False
+ start
+ Behaviour:
+
+
+ True
+ True
+ 2
+ 0
+
+
+
+
+ True
+ True
+ center
+
+ - Always control active window
+ - Only control active window when maximized
+ - Control top-most maximized window
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ 5
+
+
+
+
diff --git a/window-menu-applet/window-menu-applet.vala b/window-menu-applet/window-menu-applet.vala
index 51dd8dd..4ff17a8 100644
--- a/window-menu-applet/window-menu-applet.vala
+++ b/window-menu-applet/window-menu-applet.vala
@@ -1,22 +1,32 @@
using WindowWidgets;
namespace WindowMenuApplet{
- public void reload(WindowWidgets.WindowMenuButton button){
- Wnck.Screen.get_default().force_update();
- Wnck.Window *window = Wnck.Screen.get_default().get_active_window();
+ WindowWidgets.WindowMenuButton button;
+ Wnck.Window *window;
+
+ GLib.Settings gsettings;
+
+ public void reload(){
if(window != null){
- button.window = window;
+ window->icon_changed.disconnect(button.icon_set);
+ window->actions_changed.disconnect(button.menu_set);
+ }
- button.icon_set();
- button.menu_set();
+ window = get_current_window();
+ button.window = window;
+
+ button.icon_set();
+ button.menu_set();
+
+ if(window != null){
window->icon_changed.connect(button.icon_set);
window->actions_changed.connect(button.menu_set);
}
}
- public void change_orient(WindowWidgets.WindowMenuButton button,MatePanel.Applet applet){
+ public void change_orient(MatePanel.Applet applet){
MatePanel.AppletOrient orient = applet.get_orient();
switch(orient){
case MatePanel.AppletOrient.UP:
@@ -35,16 +45,48 @@ namespace WindowMenuApplet{
break;
}
- reload(button);
+ reload();
}
+
+ private Wnck.Window get_current_window(){
+ Wnck.Window* win = null;
+ string behaviour = gsettings.get_string("behaviour");
+
+ Wnck.Screen.get_default().force_update();
+
+ switch(behaviour){
+ case "active-always":
+ win = Wnck.Screen.get_default().get_active_window();
+ break;
+ case "active-maximized":
+ win = Wnck.Screen.get_default().get_active_window();
+ if(!win->is_maximized())
+ win = null;
+ break;
+ case "topmost-maximized":
+ List windows = Wnck.Screen.get_default().get_windows_stacked().copy();
+ windows.reverse();
+ foreach(Wnck.Window* w in windows) {
+ if(w->is_maximized()){
+ win = w;
+ break;
+ }
+ }
+ break;
+ }
+
+ return win;
+ }
private bool factory(MatePanel.Applet applet,string iid){
if(iid != "WindowMenuApplet")return false;
- WindowMenuButton button = new WindowMenuButton();
+ gsettings = new GLib.Settings("org.mate.window-applets.window-menu");
+
+ button = new WindowMenuButton();
- change_orient(button,applet);
+ change_orient(applet);
Gtk.Builder builder = new Gtk.Builder();
@@ -60,28 +102,37 @@ namespace WindowMenuApplet{
stdout.printf("Error: %s\n", e.message);
}
+ Gtk.Window settings = builder.get_object("Settings") as Gtk.Window;
Gtk.Window about = builder.get_object("About") as Gtk.Window;
Gtk.ActionGroup action_group = new Gtk.ActionGroup("action_group");
+ Gtk.Action settings_action = new Gtk.Action("settings","Settings",null,Gtk.Stock.PREFERENCES);
Gtk.Action about_action = new Gtk.Action("about","About",null,Gtk.Stock.ABOUT);
+ action_group.add_action(settings_action);
action_group.add_action(about_action);
- string menu = """""";
+ string menu = """""";
+ menu += """""";
+ gsettings.bind("behaviour",builder.get_object("behaviour"),"active_id",SettingsBindFlags.DEFAULT);
+ gsettings.changed["behaviour"].connect( (key) => { reload(); } );
+
applet.add(button);
applet.setup_menu(menu,action_group);
+ settings.delete_event.connect( (event) => { settings.hide() ; return true ; } );
about.delete_event.connect( (event) => { about.hide() ; return true ; } );
+ settings_action.activate.connect( () => { settings.present() ; } );
about_action.activate.connect( () => { about.present() ; } );
- applet.change_orient.connect( () => { change_orient(button,applet) ; } );
+ applet.change_orient.connect( () => { change_orient(applet) ; } );
applet.show_all();
- Wnck.Screen.get_default().active_window_changed.connect( (window) => { reload(button); });
+ Wnck.Screen.get_default().active_window_changed.connect( reload );
return true;
}
diff --git a/window-menu-applet/window-menu-button.vala b/window-menu-applet/window-menu-button.vala
index 2255731..3d576f0 100644
--- a/window-menu-applet/window-menu-button.vala
+++ b/window-menu-applet/window-menu-button.vala
@@ -42,20 +42,20 @@ namespace WindowWidgets{
_icon = _icon.scale_simple(_icon_size,_icon_size,Gdk.InterpType.HYPER);
button_image.set_from_pixbuf(_icon);
}
+ else {
+ button_image.clear();
+ }
}
public void menu_set(){
- if(_window != null){
- if(_window.get_class_instance_name() != "desktop_window"){
- this.set_popup(new Wnck.ActionMenu(_window));
- this.set_sensitive(true);
- }
- else{
- this.get_popup().detach();
- this.set_sensitive(false);
- }
-
+ if(_window != null && _window.get_class_instance_name() != "desktop_window"){
+ this.set_popup(new Wnck.ActionMenu(_window));
+ this.set_sensitive(true);
+ }
+ else{
+ this.get_popup().detach();
+ this.set_sensitive(false);
}
}
diff --git a/window-title-applet/dialog.ui b/window-title-applet/dialog.ui
index fca8d5e..3ffc67a 100644
--- a/window-title-applet/dialog.ui
+++ b/window-title-applet/dialog.ui
@@ -1,5 +1,5 @@
-
+
@@ -13,6 +13,15 @@
https://github.com/ubuntu-mate/mate-window-applets
gpl-3-0
+
+
+
False
@@ -28,14 +37,71 @@
+
+
+ False
+ GDK_STRUCTURE_MASK | GDK_SCROLL_MASK
+ center
+ static
+
+
+ True
+ False
+ vertical
+ 4
+ True
+
+
+ True
+ False
+
+
+ True
+ False
+ start
+ Behaviour:
+
+
+ True
+ True
+ 2
+ 0
+
+
+
+
+ True
+ True
+ center
+
+ - Always control active window
+ - Only control active window when maximized
+ - Control top-most maximized window
+
+
+
+ False
+ True
+ 1
+
+
+
+
+ False
+ True
+ 5
+
+
+
+
diff --git a/window-title-applet/window-title-applet.vala b/window-title-applet/window-title-applet.vala
index 53ce175..f0b6ff9 100644
--- a/window-title-applet/window-title-applet.vala
+++ b/window-title-applet/window-title-applet.vala
@@ -1,37 +1,74 @@
namespace WindowTitleApplet{
Gtk.Label title;
- Wnck.Window *active_window;
+ Wnck.Window *window;
+
+ GLib.Settings gsettings;
public void reload(){
- if(active_window != null){
- active_window->name_changed.disconnect(update);
+ if(window != null){
+ window->name_changed.disconnect(update);
}
- Wnck.Screen.get_default().force_update();
- active_window = Wnck.Screen.get_default().get_active_window();
+ window = get_current_window();
- if(active_window != null){
- update();
+ update();
- active_window->name_changed.connect(update);
+ if(window != null){
+ window->name_changed.connect(update);
}
}
public void update(){
- title.set_label(active_window->get_name());
- stdout.printf("set_label: %s\n", active_window->get_name());
+ if(window != null){
+ title.set_label(window->get_name());
+ stdout.printf("set_label: %s\n", window->get_name());
+ } else {
+ title.set_label("");
+ stdout.printf("set_label: ''\n");
+ }
+ }
+
+ private Wnck.Window get_current_window(){
+ Wnck.Window* win = null;
+ string behaviour = gsettings.get_string("behaviour");
+
+ Wnck.Screen.get_default().force_update();
+
+ switch(behaviour){
+ case "active-always":
+ win = Wnck.Screen.get_default().get_active_window();
+ break;
+ case "active-maximized":
+ win = Wnck.Screen.get_default().get_active_window();
+ if(!win->is_maximized())
+ win = null;
+ break;
+ case "topmost-maximized":
+ List windows = Wnck.Screen.get_default().get_windows_stacked().copy();
+ windows.reverse();
+ foreach(Wnck.Window* w in windows) {
+ if(w->is_maximized()){
+ win = w;
+ break;
+ }
+ }
+ break;
+ }
+
+ return win;
}
-
private bool factory(MatePanel.Applet applet,string iid){
if(iid != "WindowTitleApplet")return false;
+ gsettings = new GLib.Settings("org.mate.window-applets.window-title");
+
title = new Gtk.Label("");
reload();
- title.set_label(Wnck.Screen.get_default().get_active_window().get_name());
+ //title.set_label(Wnck.Screen.get_default().get_active_window().get_name());
Gtk.Builder builder = new Gtk.Builder();
@@ -47,24 +84,32 @@ namespace WindowTitleApplet{
stdout.printf("Error: %s\n", e.message);
}
+ Gtk.Window settings = builder.get_object("Settings") as Gtk.Window;
Gtk.Window about = builder.get_object("About") as Gtk.Window;
Gtk.ActionGroup action_group = new Gtk.ActionGroup("action_group");
+ Gtk.Action settings_action = new Gtk.Action("settings","Settings",null,Gtk.Stock.PREFERENCES);
Gtk.Action about_action = new Gtk.Action("about","About",null,Gtk.Stock.ABOUT);
+ action_group.add_action(settings_action);
action_group.add_action(about_action);
- string menu = """""";
+ string menu = """""";
+ menu += """""";
+ gsettings.bind("behaviour",builder.get_object("behaviour"),"active_id",SettingsBindFlags.DEFAULT);
+ gsettings.changed["behaviour"].connect( (key) => { reload(); } );
applet.set_flags(MatePanel.AppletFlags.EXPAND_MAJOR);
applet.add(title);
applet.setup_menu(menu,action_group);
+ settings.delete_event.connect( (event) => { settings.hide() ; return true ; } );
about.delete_event.connect( (event) => { about.hide() ; return true ; } );
+ settings_action.activate.connect( () => { settings.present() ; } );
about_action.activate.connect( () => { about.present() ; } );
//applet.change_size.connect();