Skip to content

Commit e23ebeb

Browse files
committed
Merge branch 'master' of i2pgit.org:i2p-hackers/i2p.i2p into i2p.i2p.2.2.1-xor-messageIDs-as-interface-change
2 parents ed51f15 + 63f2ae3 commit e23ebeb

File tree

10 files changed

+458
-10
lines changed

10 files changed

+458
-10
lines changed

apps/desktopgui/src/net/i2p/desktopgui/ExternalMain.java

+87-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
import net.i2p.app.ClientAppManager;
1414
import net.i2p.app.ClientApp;
1515
import net.i2p.app.ClientAppState;
16+
import net.i2p.app.MenuCallback;
17+
import net.i2p.app.MenuHandle;
18+
import net.i2p.app.MenuService;
1619
import net.i2p.app.NotificationService;
1720
import net.i2p.util.Log;
1821
import net.i2p.util.SystemVersion;
@@ -24,7 +27,7 @@
2427
*
2528
* @since 0.9.54
2629
*/
27-
public class ExternalMain implements ClientApp, NotificationService {
30+
public class ExternalMain implements ClientApp, NotificationService, MenuService {
2831

2932
private final I2PAppContext _appContext;
3033
private final ClientAppManager _mgr;
@@ -60,7 +63,6 @@ public static void main(String[] args) {
6063
* @throws AWTException on startup error, including systray not supported
6164
*/
6265
private synchronized void startUp() throws Exception {
63-
final TrayManager trayManager;
6466
boolean useSwingDefault = !(SystemVersion.isWindows() || SystemVersion.isMac());
6567
boolean useSwing = _appContext.getProperty(PROP_SWING, useSwingDefault);
6668
_trayManager = new ExternalTrayManager(_appContext, useSwing);
@@ -200,6 +202,89 @@ public boolean update(int id, String title, String message, String path) {
200202
return false;
201203
}
202204

205+
/////// MenuService methods
206+
207+
/**
208+
* Menu will start out shown and enabled, in the root menu
209+
*
210+
* @param message for the menu, translated
211+
* @param callback fired on click
212+
* @return null on error
213+
* @since 0.9.59
214+
*/
215+
public MenuHandle addMenu(String message, MenuCallback callback) {
216+
return addMenu(message, callback, null);
217+
}
218+
219+
/**
220+
* Menu will start out enabled, as a submenu
221+
*
222+
* @param message for the menu, translated
223+
* @param callback fired on click
224+
* @param parent the parent menu this will be a submenu of, or null for top level
225+
* @return null on error
226+
* @since 0.9.59
227+
*/
228+
public MenuHandle addMenu(String message, MenuCallback callback, MenuHandle parent) {
229+
if (_trayManager == null)
230+
return null;
231+
return _trayManager.addMenu(message, callback, parent);
232+
}
233+
234+
/**
235+
* @since 0.9.59
236+
*/
237+
public void removeMenu(MenuHandle item) {
238+
if (_trayManager == null)
239+
return;
240+
_trayManager.removeMenu(item);
241+
}
242+
243+
/**
244+
* @since 0.9.59
245+
*/
246+
public void showMenu(MenuHandle item) {
247+
if (_trayManager == null)
248+
return;
249+
_trayManager.showMenu(item);
250+
}
251+
252+
/**
253+
* @since 0.9.59
254+
*/
255+
public void hideMenu(MenuHandle item) {
256+
if (_trayManager == null)
257+
return;
258+
_trayManager.hideMenu(item);
259+
}
260+
261+
/**
262+
* @since 0.9.59
263+
*/
264+
public void enableMenu(MenuHandle item) {
265+
if (_trayManager == null)
266+
return;
267+
_trayManager.enableMenu(item);
268+
}
269+
270+
/**
271+
* @since 0.9.59
272+
*/
273+
public void disableMenu(MenuHandle item) {
274+
if (_trayManager == null)
275+
return;
276+
_trayManager.disableMenu(item);
277+
}
278+
279+
/**
280+
* @since 0.9.59
281+
*/
282+
public void updateMenu(String message, MenuHandle item) {
283+
if (_trayManager == null)
284+
return;
285+
_trayManager.updateMenu(message, item);
286+
}
287+
203288
/////// ClientApp methods
204289

205290
public synchronized void startup() {

apps/desktopgui/src/net/i2p/desktopgui/Main.java

+87-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import net.i2p.app.ClientAppManager;
1818
import net.i2p.app.ClientAppState;
1919
import static net.i2p.app.ClientAppState.*;
20+
import net.i2p.app.MenuCallback;
21+
import net.i2p.app.MenuHandle;
22+
import net.i2p.app.MenuService;
2023
import net.i2p.app.NotificationService;
2124
import net.i2p.desktopgui.router.RouterManager;
2225
import net.i2p.router.RouterContext;
@@ -29,7 +32,7 @@
2932
/**
3033
* The main class of the application.
3134
*/
32-
public class Main implements RouterApp, NotificationService {
35+
public class Main implements RouterApp, NotificationService, MenuService {
3336

3437
// non-null
3538
private final I2PAppContext _appContext;
@@ -245,6 +248,89 @@ public boolean update(int id, String title, String message, String path) {
245248
return false;
246249
}
247250

251+
/////// MenuService methods
252+
253+
/**
254+
* Menu will start out shown and enabled, in the root menu
255+
*
256+
* @param message for the menu, translated
257+
* @param callback fired on click
258+
* @return null on error
259+
* @since 0.9.59
260+
*/
261+
public MenuHandle addMenu(String message, MenuCallback callback) {
262+
return addMenu(message, callback, null);
263+
}
264+
265+
/**
266+
* Menu will start out enabled, as a submenu
267+
*
268+
* @param message for the menu, translated
269+
* @param callback fired on click
270+
* @param parent the parent menu this will be a submenu of, or null for top level
271+
* @return null on error
272+
* @since 0.9.59
273+
*/
274+
public MenuHandle addMenu(String message, MenuCallback callback, MenuHandle parent) {
275+
if (_trayManager == null)
276+
return null;
277+
return _trayManager.addMenu(message, callback, parent);
278+
}
279+
280+
/**
281+
* @since 0.9.59
282+
*/
283+
public void removeMenu(MenuHandle item) {
284+
if (_trayManager == null)
285+
return;
286+
_trayManager.removeMenu(item);
287+
}
288+
289+
/**
290+
* @since 0.9.59
291+
*/
292+
public void showMenu(MenuHandle item) {
293+
if (_trayManager == null)
294+
return;
295+
_trayManager.showMenu(item);
296+
}
297+
298+
/**
299+
* @since 0.9.59
300+
*/
301+
public void hideMenu(MenuHandle item) {
302+
if (_trayManager == null)
303+
return;
304+
_trayManager.hideMenu(item);
305+
}
306+
307+
/**
308+
* @since 0.9.59
309+
*/
310+
public void enableMenu(MenuHandle item) {
311+
if (_trayManager == null)
312+
return;
313+
_trayManager.enableMenu(item);
314+
}
315+
316+
/**
317+
* @since 0.9.59
318+
*/
319+
public void disableMenu(MenuHandle item) {
320+
if (_trayManager == null)
321+
return;
322+
_trayManager.disableMenu(item);
323+
}
324+
325+
/**
326+
* @since 0.9.59
327+
*/
328+
public void updateMenu(String message, MenuHandle item) {
329+
if (_trayManager == null)
330+
return;
331+
_trayManager.updateMenu(message, item);
332+
}
333+
248334
/////// ClientApp methods
249335

250336
/** @since 0.9.26 */

0 commit comments

Comments
 (0)