Changeset 196cf48


Ignore:
Timestamp:
May 5, 2016 4:39:41 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
390b2d4
Parents:
8c1f7a4
Message:

DTG: Remove Swing DesktopguiConfigurationFrame? as it's
completely inconsistent with the AWT SystemTray? menus;
move to the AWT menu as a submenu.
This was the last of the Swing UI elements,
mathias ripped out the all of them in Nov. 2010, but
then added this one in Feb. 2011.
Remove LookAndFeel? setting, only works for Swing.

Location:
apps/desktopgui/src/net/i2p/desktopgui
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • apps/desktopgui/src/net/i2p/desktopgui/ExternalTrayManager.java

    r8c1f7a4 r196cf48  
    2121class ExternalTrayManager extends TrayManager {
    2222       
    23     public ExternalTrayManager(I2PAppContext ctx) {
    24         super(ctx);
     23    public ExternalTrayManager(I2PAppContext ctx, Main main) {
     24        super(ctx, main);
    2525    }
    2626
  • apps/desktopgui/src/net/i2p/desktopgui/InternalTrayManager.java

    r8c1f7a4 r196cf48  
    77
    88import javax.swing.SwingWorker;
    9 import net.i2p.desktopgui.gui.DesktopguiConfigurationFrame;
    109
    1110import net.i2p.desktopgui.router.RouterManager;
     
    2524    private final Log log;
    2625
    27     public InternalTrayManager(RouterContext ctx) {
    28         super(ctx);
     26    public InternalTrayManager(RouterContext ctx, Main main) {
     27        super(ctx, main);
    2928        _context = ctx;
    3029        log = ctx.logManager().getLog(InternalTrayManager.class);
     
    5958            }
    6059        });
    61         MenuItem desktopguiConfigurationLauncher = new MenuItem(_t("Configure desktopgui"));
    62         desktopguiConfigurationLauncher.addActionListener(new ActionListener() {
     60        PopupMenu desktopguiConfigurationLauncher = new PopupMenu(_t("Configure I2P System Tray"));
     61        MenuItem configSubmenu = new MenuItem(_t("Disable"));
     62        configSubmenu.addActionListener(new ActionListener() {
    6363
    6464            @Override
     
    6868                    @Override
    6969                    protected Object doInBackground() throws Exception {
    70                         new DesktopguiConfigurationFrame(_context).setVisible(true);
     70                        configureDesktopgui(false);
    7171                        return null;
    7272                    }
     
    115115        popup.add(browserLauncher);
    116116        popup.addSeparator();
     117        desktopguiConfigurationLauncher.add(configSubmenu);
    117118        popup.add(desktopguiConfigurationLauncher);
    118119        popup.addSeparator();
     
    122123        return popup;
    123124    }
     125
     126    /**
     127     *  @since 0.9.26 from removed gui/DesktopguiConfigurationFrame
     128     */
     129    private void configureDesktopgui(boolean enable) {
     130        String property = "desktopgui.enabled";
     131        String value = Boolean.toString(enable);
     132        try {
     133
     134            _context.router().saveConfig(property, value);
     135            if (!enable) {
     136                // TODO popup that explains how to re-enable in console
     137                _main.shutdown(null);
     138            }
     139        } catch (Exception ex) {
     140            log.error("Error saving config", ex);
     141        }
     142    }
    124143}
  • apps/desktopgui/src/net/i2p/desktopgui/Main.java

    r8c1f7a4 r196cf48  
    66
    77import javax.swing.SwingUtilities;
    8 import javax.swing.UIManager;
    9 import javax.swing.UnsupportedLookAndFeelException;
    108
    119import net.i2p.I2PAppContext;
     
    6462        final TrayManager trayManager;
    6563        if (_context != null)
    66             trayManager = new InternalTrayManager(_context);
     64            trayManager = new InternalTrayManager(_context, this);
    6765        else
    68             trayManager = new ExternalTrayManager(_appContext);
     66            trayManager = new ExternalTrayManager(_appContext, this);
    6967        trayManager.startManager();
    7068        _trayManager = trayManager;
     
    106104            return;
    107105        }
    108         try {
    109             //UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
    110             //for (int i = 0; i < lafs.length; i++) {
    111             //    System.out.println("LAF " + i + ": " + lafs[i].getName() + ' ' + lafs[i].getClassName());
    112             //}
    113             String laf = UIManager.getSystemLookAndFeelClassName();
    114             //System.out.println("Default: " + laf);
    115             UIManager.setLookAndFeel(laf);
    116             //laf = UIManager.getCrossPlatformLookAndFeelClassName();
    117             //System.out.println("Cross-Platform: " + laf);
    118             //UIManager.setLookAndFeel(laf);
    119             //UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
    120         } catch (ClassNotFoundException ex) {
    121             log.log(Log.ERROR, null, ex);
    122         } catch (InstantiationException ex) {
    123             log.log(Log.ERROR, null, ex);
    124         } catch (IllegalAccessException ex) {
    125             log.log(Log.ERROR, null, ex);
    126         } catch (UnsupportedLookAndFeelException ex) {
    127             log.log(Log.ERROR, null, ex);
    128         } catch (Error ex) {
    129             // on permissions error (different user)
    130             // Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
    131             log.log(Log.ERROR, "No permissions? Different user?", ex);
    132             changeState(START_FAILED, "No permissions? Different user?", new RuntimeException(ex));
    133             return;
    134         }
    135        
     106
    136107        // TODO process args with getopt if needed
    137108       
  • apps/desktopgui/src/net/i2p/desktopgui/TrayManager.java

    r8c1f7a4 r196cf48  
    1919
    2020    protected final I2PAppContext _appContext;
     21    protected final Main _main;
    2122    ///The tray area, or null if unsupported
    2223    protected SystemTray tray;
     
    2728     * Instantiate tray manager.
    2829     */
    29     protected TrayManager(I2PAppContext ctx) {
     30    protected TrayManager(I2PAppContext ctx, Main main) {
    3031        _appContext = ctx;
     32        _main = main;
    3133    }
    3234   
Note: See TracChangeset for help on using the changeset viewer.