summarylogtreecommitdiffstats
path: root/appindicator.patch
blob: 2f5f6cda5e4e3bbb8d243c202e547603b7cde06c (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
Index: /trunk/gnome-rdp/configure.ac
===================================================================
--- /trunk/gnome-rdp/configure.ac (revision 263)
+++ /trunk/gnome-rdp/configure.ac (revision 264)
@@ -50,6 +50,7 @@
 PKG_CHECK_MODULES([GLIB_SHARP_20], [glib-sharp-2.0])
 PKG_CHECK_MODULES([GLADE_SHARP_20], [glade-sharp-2.0])
 PKG_CHECK_MODULES([GNOME_KEYRING_SHARP_10], [gnome-keyring-sharp-1.0])
+PKG_CHECK_MODULES([APPINDICATOR_SHARP_01], [appindicator-sharp-0.1])
 
 dnl package checks, per config
 
Index: /trunk/gnome-rdp/MainWindow.cs
===================================================================
--- /trunk/gnome-rdp/MainWindow.cs (revision 257)
+++ /trunk/gnome-rdp/MainWindow.cs (revision 264)
@@ -31,14 +31,18 @@
 using GnomeRDP.Vnc;
 
+using AppIndicator;
+
 namespace GnomeRDP
 {
 	public partial class MainWindow: Gtk.Window
 	{			
-		private StatusIcon statusIcon;
+		private ApplicationIndicator applicationIndicator;
 		private Gtk.Action actionQuit;
+		private Gtk.Action actionToggleVisible;
+		private bool hideOnDelete = false;
 				
 		private const string sessionKey = "Session";
 		
-		public MainWindow(): base (Gtk.WindowType.Toplevel)
+		public MainWindow (): base (Gtk.WindowType.Toplevel)
 		{
 			Build ();
@@ -46,72 +50,80 @@
 			this.DeleteEvent += (s, e) =>
 			{
-				Visible = false;
-				e.RetVal = true;
+				if (hideOnDelete) 
+				{
+					Visible = false;
+					e.RetVal = true;
+				}
 			};
 			
-			this.actionQuit = new Gtk.Action("QuitAction", "Quit");
-			this.actionQuit.Activated+= (s, e) => Application.Quit();
+			this.actionQuit = new Gtk.Action ("QuitAction", "Quit");
+			this.actionQuit.Activated += (s, e) => Application.Quit ();
+		
+			this.actionToggleVisible = new Gtk.Action("ToggleVisibleAction", "Show/Hide");
+			this.actionToggleVisible.Activated += (s, e) => { this.Visible = !this.Visible; };
+
+			this.applicationIndicator = new ApplicationIndicator ("gnome-rdp", "gnome-rdp", Category.ApplicationStatus);
+			this.applicationIndicator.ConnectionChanged += (s, e) => { hideOnDelete = this.applicationIndicator.Connected; };
 			
-			this.statusIcon = new StatusIcon(ResourceLoader.Find(ResourceLoader.Icons.gnomeRdp));
-			this.statusIcon.Visible = true;
-			this.statusIcon.Tooltip = "GnomeRDP";
-			this.statusIcon.Activate += OnStatusIcon_Activate;
-			this.statusIcon.PopupMenu += OnStatusIcon_PopupMenu;	
-
+			this.applicationIndicator.Menu = CreateMenu();
+			this.applicationIndicator.Status = Status.Active;
+						
 			this.Icon = ResourceLoader.Find(ResourceLoader.Icons.gnomeRdp);
 		}
-		
-		private void OnStatusIcon_Activate(object sender, EventArgs e)
+
+		public void UpdateMenu()
 		{
-			Visible = !Visible;
+			Menu oldMenu = this.applicationIndicator.Menu;
+			
+			this.applicationIndicator.Menu = CreateMenu();
+			
+			oldMenu.Dispose();
 		}
-		
-		private void OnStatusIcon_PopupMenu(object sender, PopupMenuArgs e)
+										
+		private Menu CreateMenu()
 		{
-			try
-			{
-				Menu topMenu = new Menu();
-				topMenu.Popup();
+			Menu topMenu = new Menu();
+			
+			topMenu.Append(actionToggleVisible.CreateMenuItem());
+			topMenu.Append(new SeparatorMenuItem());
 				
-				foreach (var group in Program.SessionCollection.Groups) 
-				{	
-					MenuItem groupMenu = new MenuItem(group);
-					topMenu.Append(groupMenu);
-					
-					Menu subMenu = new Menu();
-					foreach(var session in Program.SessionCollection.Items.Where(s => s.Group == group).OrderBy(s => s.Server))
-					{
-						MenuItem menuItem = new MenuItem(session.MenuFormat);
-						menuItem.TooltipText = session.Tooltip;
-						menuItem.Activated += PopupMenuItem_Activated;
-						menuItem.Data[sessionKey] = session;
-											
-						subMenu.Append(menuItem);
-					}
-					groupMenu.Submenu = subMenu;
-				}
-
-				topMenu.Append(new SeparatorMenuItem());
-
-				foreach (var session in Program.SessionCollection.Items.Where(s => string.IsNullOrEmpty(s.Group)).OrderBy(s => s.Server)) 
+			foreach (var group in Program.SessionCollection.Groups) 
+			{	
+				MenuItem groupMenu = new MenuItem(group);
+				
+				Menu subMenu = new Menu();
+				foreach(var session in Program.SessionCollection.Items.Where(s => s.Group == group).OrderBy(s => s.Server))
 				{
 					MenuItem menuItem = new MenuItem(session.MenuFormat);
 					menuItem.TooltipText = session.Tooltip;
 					menuItem.Activated += PopupMenuItem_Activated;
-					menuItem.Data[sessionKey] = session;					
-					
-					topMenu.Append(menuItem);
+					menuItem.Data[sessionKey] = session;
+										
+					subMenu.Append(menuItem);
 				}
+				groupMenu.Submenu = subMenu;
+
+				topMenu.Append(groupMenu);
+			}
+
+			topMenu.Append(new SeparatorMenuItem());
+
+			foreach (var session in Program.SessionCollection.Items.Where(s => string.IsNullOrEmpty(s.Group)).OrderBy(s => s.Server)) 
+			{
+				MenuItem menuItem = new MenuItem(session.MenuFormat);
+				menuItem.TooltipText = session.Tooltip;
+				menuItem.Activated += PopupMenuItem_Activated;
+				menuItem.Data[sessionKey] = session;					
 				
-				topMenu.Append(new SeparatorMenuItem());
-				topMenu.Append(actionQuit.CreateMenuItem());
-				topMenu.ShowAll();
-//				topMenu.Popup();
+				topMenu.Append(menuItem);
 			}
-			catch
-			{
-			}
-		}	
-		
+			
+			topMenu.Append(new SeparatorMenuItem());
+			topMenu.Append(actionQuit.CreateMenuItem());
+			
+			topMenu.ShowAll();
+			return topMenu;
+		}
+				
 		private void PopupMenuItem_Activated(object sender, EventArgs e)
 		{
@@ -126,20 +138,4 @@
 			}
 		}
-		
-		protected virtual void OnNewRdpActionActivated (object sender, System.EventArgs e)
-		{
-		}
-		
-		protected virtual void OnNewVncActionActivated (object sender, System.EventArgs e)
-		{
-		}
-		
-		protected virtual void OnNewSshActionActivated (object sender, System.EventArgs e)
-		{
-		}
-		
-		
-		
-		
 	}
 }
Index: /trunk/gnome-rdp/ChangeLog
===================================================================
--- /trunk/gnome-rdp/ChangeLog (revision 262)
+++ /trunk/gnome-rdp/ChangeLog (revision 264)
@@ -1,2 +1,11 @@
+2011-11-02  James P Michels III  <jmichels@bluefintrading.com>
+
+	* Program.cs:
+	* gnome-rdp.sln:
+	* MainWindow.cs:
+	* gnome-rdp.csproj:
+	* gui.stetic:
+	* SessionsWidget.cs: Changes to support AppIndicator
+
 2011-05-22  James P Michels III  <james.p.michels@gmail.com>
 
Index: /trunk/gnome-rdp/Sessions/SessionsWidget.cs
===================================================================
--- /trunk/gnome-rdp/Sessions/SessionsWidget.cs (revision 257)
+++ /trunk/gnome-rdp/Sessions/SessionsWidget.cs (revision 264)
@@ -205,4 +205,5 @@
 				}
 				
+				Program.UpdateMainWindowMenu();
 			}
 			catch (Exception ex)
Index: /trunk/gnome-rdp/gtk-gui/gui.stetic
===================================================================
--- /trunk/gnome-rdp/gtk-gui/gui.stetic (revision 261)
+++ /trunk/gnome-rdp/gtk-gui/gui.stetic (revision 264)
@@ -7,5 +7,6 @@
   <import>
     <widget-library name="glade-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
-    <widget-library name="../bin/Debug/gnome-rdp.exe" internal="true" />
+    <widget-library name="appindicator-sharp, Version=0.2.0.0, Culture=neutral, PublicKeyToken=bcae265d1c7ab4c2" />
+    <widget-library name="../bin/Release/gnome-rdp.exe" internal="true" />
   </import>
   <widget class="Gtk.Window" id="GnomeRDP.MainWindow" design-size="798 565">
Index: /trunk/gnome-rdp/Program.cs
===================================================================
--- /trunk/gnome-rdp/Program.cs (revision 261)
+++ /trunk/gnome-rdp/Program.cs (revision 264)
@@ -196,5 +196,14 @@
 			});
 		}
-				
+		
+		public static void UpdateMainWindowMenu()
+		{
+			GLib.Timeout.Add(0, () =>
+			{
+				mainWindow.UpdateMenu();
+				return false;
+			});
+		}		
+		
 		public static void SetMainWindowVisible(bool visible)
 		{