summarylogtreecommitdiffstats
path: root/instance-controls.patch
blob: b639b265ea76f021274fc3676292e4b32e21b223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
diff --git a/lib/Items/ApplicationDockItem.vala b/lib/Items/ApplicationDockItem.vala
index a58dbed..ba9c7c8 100644
--- a/lib/Items/ApplicationDockItem.vala
+++ b/lib/Items/ApplicationDockItem.vala
@@ -459,7 +459,7 @@ namespace Plank
 				
 				foreach (var view in windows) {
 					unowned Bamf.Window? window = (view as Bamf.Window);
-					if (window == null || window.get_transient () != null)
+					if (window == null)
 						continue;
 					
 					Gtk.MenuItem window_item;
@@ -469,13 +469,35 @@ namespace Plank
 					
 					if (pbuf != null)
 						window_item = create_literal_menu_item_with_pixbuf (window_name, pbuf);
-					else 
+					else
 						window_item = create_literal_menu_item (window_name, Icon);
 					
-					if (window.is_active ())
-						window_item.set_sensitive (false);
-					else
-						window_item.activate.connect (() => WindowControl.focus_window (window, event_time));
+					//instance "Close"
+					Gdk.Pixbuf close_icon = Gtk.IconTheme.get_default ().load_icon ("window-close-symbolic", Gtk.IconSize.MENU, 0);
+					Gtk.MenuItem close_item = create_literal_menu_item_with_pixbuf ("Close", close_icon);
+					close_item.activate.connect (() => WindowControl.close_window (window, event_time));
+					
+					//instance "Switch to"
+					Gdk.Pixbuf switch_icon = Gtk.IconTheme.get_default ().load_icon ("go-next-symbolic", Gtk.IconSize.MENU, 0);
+					Gtk.MenuItem switch_item = create_literal_menu_item_with_pixbuf ("Switch to", switch_icon);
+					switch_item.activate.connect (() => WindowControl.focus_window (window, event_time));
+					
+					//instance "Minimize"
+					Gdk.Pixbuf minimize_icon = Gtk.IconTheme.get_default ().load_icon ("window-minimize-symbolic", Gtk.IconSize.MENU, 0);
+					Gtk.MenuItem minimize_item = create_literal_menu_item_with_pixbuf ("Minimize", minimize_icon);
+					minimize_item.activate.connect (() => minimized_active (window, minimize_item, switch_item));
+					
+					//instance control submenu
+					var control_menu = new Gtk.Menu ();
+					control_menu.append (close_item);
+					control_menu.append (minimize_item);
+					control_menu.append (switch_item);
+					close_item.show();
+					if (!window.is_active ())
+						switch_item.show();
+					else if (window.get_transient () == null)
+						minimize_item.show();
+					window_item.set_submenu (control_menu);
 					
 					items.add (window_item);
 				}
@@ -484,6 +506,13 @@ namespace Plank
 			return items;
 		}
 		
+		public static void minimized_active (Bamf.Window window, Gtk.MenuItem minimize_item, Gtk.MenuItem switch_item)
+		{
+			WindowControl.minimize_window (window);
+			minimize_item.hide();
+			switch_item.show();
+		}
+		
 		/**
 		 * {@inheritDoc}
 		 */
diff --git a/lib/Services/WindowControl.vala b/lib/Services/WindowControl.vala
index e387612..db2997b 100644
--- a/lib/Services/WindowControl.vala
+++ b/lib/Services/WindowControl.vala
@@ -225,6 +225,32 @@ namespace Plank
 			}
 		}
 		
+		public static void close_window (Bamf.Window window, uint32 event_time)
+		{
+			Wnck.Screen.get_default ();
+			unowned Wnck.Window w = Wnck.Window.@get (window.get_xid ());
+			
+			warn_if_fail (w != null);
+			
+			if (w == null)
+				return;
+
+			w.close (event_time);
+		}
+		
+		public static void minimize_window (Bamf.Window window)
+		{
+			Wnck.Screen.get_default ();
+			unowned Wnck.Window w = Wnck.Window.@get (window.get_xid ());
+			
+			warn_if_fail (w != null);
+			
+			if (w == null)
+				return;
+
+			w.minimize ();
+		}
+		
 		public static void focus_window (Bamf.Window window, uint32 event_time)
 		{
 			Wnck.Screen.get_default ();