[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian

In case of a misunderstanding: when I say “the shell remains open”, I’m talking about the FileDialog’s Shell; not the parent Shell (which is never made visible !)

 


De : platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] De la part de Stéphane WASSERHARDT
Envoyé : jeudi 29 octobre 2009 17:57
À : 'Eclipse Platform SWT component developers list.'
Objet : RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian

 

Yes I know I have to close the shell: take a look at the code I provided, I close the shell in a “finally” block (and in an useless “asyncExec Runnable”). But note that I never open the shell before! This may be the problem, but I don’t want to show an empty shell just to open a FileDialog.

In fact, the application has no UI until I open the FileDialog, the application is only meant to show FileDialogs (and some little other things) when asked.

And that’s why it’s “system modal”: I have another running application which must not be active while the FileDialog is open. I know this can seem a bit mysterious, but I cannot do it another way: I must have two independent applications since each one is run under distinct user accounts (but on the same computer)… If you want more details about this, I can explain it...

 

If there are no workarounds, I think I’ll have to open this “useless Shell” before showing the dialog. I already tried to set its size to (0, 0) and open it, but GTK doesn’t like to show 0-sized widgets…

 


De : platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] De la part de Bogdan Gheorghe
Envoyé : jeudi 29 octobre 2009 17:25
À : Eclipse Platform SWT component developers list.
Objet : RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian

 


You have to explicitly close the shell, it won't close for free - try the attached snippet below. BTW, I'm not sure why you are parenting the dialog on a SYSTEM_MODAL, ON_TOP shell - this seems wrong. System modal means modal to all other windows on your desktop! A  FileDialog will be modal to all other shells in your app (depending on which version of GTK you are running, a shell might seem to take focus, but you shouldn't be able to click on any other controls. If you can please open a bug).


public static void main(String[] args) {
       
        Display display = new Display();
        final Shell shell = new Shell(display, SWT.ON_TOP | SWT.SYSTEM_MODAL);
        shell.setLayout(new GridLayout(1, false));
        shell.setBounds(50, 50, 100, 100);
        shell.open();
               
        final FileDialog dialog = new FileDialog(shell, SWT.OPEN);
        String s= dialog.open();
        System.out.println(s);
        if (s != null) {
                shell.close();
        }
       
        while (!shell.isDisposed()) {
                if (!display.readAndDispatch())
                        display.sleep();
        }
        display.dispose();
}

From:

Stéphane WASSERHARDT <stephane.wasserhardt@xxxxxxxxxxxx>

To:

"'Eclipse Platform SWT component developers list.'" <platform-swt-dev@xxxxxxxxxxx>

Date:

10/28/2009 10:03 AM

Subject:

RE: [platform-swt-dev] FileDialog/DirectoryDialog under Debian

Sent by:

platform-swt-dev-bounces@xxxxxxxxxxx

 





I just tried with SWT.NONE instead of SYSTEM_MODAL and ON_TOP, but this didn’t change anything L
 

 



De : platform-swt-dev-bounces@xxxxxxxxxxx [mailto:platform-swt-dev-bounces@xxxxxxxxxxx] De la part de Stéphane WASSERHARDT
Envoyé :
mercredi 28 octobre 2009 14:50
À :
SWT
Objet :
[platform-swt-dev] FileDialog/DirectoryDialog under Debian

 
Hello,
 
I have a problem with both FileDialog and DirectoryDialog under Debian Lenny (GTK2) : when such dialog is closed (either when double clicking an item, using select or cancel button, or simply closing it), the “open” method returns with the expected result, but the shell remains open !
The shell is not repainted anymore, so it seems to be “disposed”, but it’s still visible…
Moreover, if I open another file or directory dialog, the previous one disappears!
Note that the parent shell is created with style “SWT.SYSTEM_MODAL | SWT.ON_TOP” (and I’d like to keep this style…)
 
I tried with both SWT 3.4.2 and SWT 3.5.1…
 
Here is the code I’m using :
 
// The following Shell is not made visible. We only show the file dialog.
final Shell shell = new Shell(display, SWT.SYSTEM_MODAL | SWT.ON_TOP);
            try {
                  final FileDialog fd = new FileDialog(shell, SWT.OPEN);
 
// ... Setting of file dialog properties : text, filterPath, etc. ...
 
                  fd.open(); // Opens correctly, and return normally, but the dialog remains open !
 
// Get the correct result.
                  final String[] selectedFiles = fd.getFileNames();
 
                  // ... Process the result ...
 
            } finally {
                  // I tried to close the parent shell in a async runnable just in case... But it doesn’t change anything.
                  display.asyncExec(new Runnable() {
                        @Override
                        public void run() {
                             shell.close();
                             shell.dispose();
                        }
                  });
            }
 
I’m currently trying to remove “SWT.SYSTEM_MODAL | SWT.ON_TOP” just to see if it changes something, but I really need the dialog to be displayed on top and to block other running applications…
 
Any help is welcome! Thanks in advance!
 
Stephane_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/platform-swt-dev