gtkdialog problem: child window not opening consistently

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

gtkdialog problem: child window not opening consistently

#1 Post by lstandish »

Hi, I am working on an gtkdialog interface to my bash (rsync-based) hardlinking backup program 'snap2'. (http://www.linuxbackups.org/snap2). I am very close to finishing a major new release, which features GUI setup of SSL public key authentication for backing up to a remote server. The next release will include a Puppy pet package. I am developing this on Debian Lenny.

I have having a mysterious problem with launching a child gtkdialog window using an "About" button. Here's the simple button code:

Code: Select all

<button><label>About snap2</label><action type="launch">ABOUT_DIALOG</action></button>
It works fine when the 'About' button is on any of my gtkdialog windows EXCEPT the main window. When I put the button on the main window, when it is clicked the button stays depressed and hangs the program.

My overall code structure, simplified, looks like this:

(initialize variables, including ABOUT_DIALOG)

while true
do

(build up main window gtkdialog XML in MAIN_DIALOG)

I=$IFS; IFS=""
for STATEMENTS in $(gtkdialog --program=MAIN_DIALOG); do
eval $STATEMENTS
done
IFS=$I

(do different things according to buttons pressed and options checked. In some cases new gtkdialogs are built to give messages or get user input. The 'About' dialog works fine in these windows!)

done

The endless loop which puts up MAIN_DIALOG is exited with a break command.

Note that I am not using a menu.

I can't see any reason why the 'About' button should fail to open a new window, while exactly the same button code opens the About window fine in any gtkdialog window except the main one.

Any help would be greatly appreciated. I can email the full program code (which is contained in a single file), but at 31.8K it is probably too much to post here.

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#2 Post by mcewanw »

Are you exporting the ABOUT_DIALOG variable to the environment in such a way that your main dialog can see it?
github mcewanw

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#3 Post by lstandish »

Yes, it is exported and visible when gtkdialog is invoked. I will soon post the code as an attachment here, but I am currently reworking the code to solve another bug.

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

gtkdialog child windows trouble - pet package posted

#4 Post by lstandish »

Here is the release 3.2-4 of snap2 rotating snapshot backup program, posted here to request help on a problem with opening a child gtkdialog. See my previous post in this thread. I have started a Puppy project page with details on this brand new program. It is intended for Puppy 4.3.1.

The 'About snap2' button code (see lines 502-503) will not open a child gtkdialog from the main window, while the exact same button/dialog code works in other windows!

Also, xterm is a dependency to snap2. Of course, I'd like to allow rxvt. I'm using xterm to open a child terminal window to run a shell script, like this:
$XTERM -e "snap2shell snapshot $settingsdir" &
(where $XTERM is the detected terminal emulator - so far it appears that only xterm works, also on Debian.)

I suspect the problem is related to environmental variables - ?

PS I just checked installation of the package and it ignores the xterm dependency, perhaps because /usr/bin/xterm exists as a symbolic link on Puppy 4.3.1. To run snap2, pet package 'xterm' must be installed manually.
Attachments
snap2-3.2-4.pet
(32.14 KiB) Downloaded 823 times
Last edited by lstandish on Sat 26 Dec 2009, 17:28, edited 1 time in total.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#5 Post by 8-bit »

I installed xterm and your pet, uncommented and moved the ABOUT line, and ran it from a terminal to see if it kicked back any error messages. When I clicked on the about button, part of the main window would disappear, but no about screen was displayed.
Top from another terminal would show my processor using 50 percent and the program was unresponsive.
If I then opened yet another terminal and killed that process, the program would recover so I could shut it down.
I did a Snapshot backup of root to a 4 gig usb stick and it was extra slow.
Addition of a progress bar would let the user know that the backup was still in progress.
I also had a few false starts since the destination directory brouse button would pop up a help dialog to press an Add button, but the selection would be gone when one closed the help dialog window.
I tried various ways to try to get the ABOUT button to work correctly from the main program window, but with no good results.
To do this, I used modified, for your program, examples from the tutorial here in HOWTO - GTKdialog-tips by Zigbert.

I will check into it more later.

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

snap2 version update

#6 Post by lstandish »

Thanks, 8-bit, for looking at this.

I extensively rewrote the GUI code since the release of snap2 that you tried. The current release is 3.2-4. After pretty extensive testing I have not been able to find any problems. I changed the attachment in this thread to the newer version. Please try the new version. I also opened a project page for it here.

If you did a snapshot backup to a USB flash memory and it was slow, it could be the flash memory is relatively slow. I find that Lexar brand is much faster than most other brands. However, after the first snapshot-type backup, you should find subsequent backups are fast even to a slow USB drive, since only modified and new files are transmitted. Note that you can also back up to a remote server.

On the issue with the child help dialog not opening, I now suspect a bug in gtkdialog. As a workaround, until there is a better solution, I made the help button on the main screen close the parent dialog before putting up the help dialog. In fact, it now loads the content of a text file. If anyone discovers the problem with the child help dialog, I'd be glad to know about it. The commented-out button code, which should be moved to the dialog XML above for testing, is at line 478.
Last edited by lstandish on Sun 27 Dec 2009, 03:07, edited 1 time in total.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#7 Post by 8-bit »

The closewindow option does not seem to work.
When the About button is clicked in a child process, the about snap window opens and a close and website button are displayed.
The close button does not work.
I closed that window by clicking on the "X" that one would use to close any window.
The new layout is better and for a user with lower display settings, ex. 800x600, it will have a better chance of displaying properly.

Keep up the good work and visit the HOW-TO Gtkdialog-tips for possible tips also.

I get this initial message in Xterm on starting a backup.
"Warning: Cannot convert string "nil2" to type FontStruct"

Also, the Xterm window comes up behind the main program window and so the user may never see the message of: Press return to close this window.

Later
Last edited by 8-bit on Sat 26 Dec 2009, 19:45, edited 1 time in total.

User avatar
Patriot
Posts: 733
Joined: Thu 15 Jan 2009, 19:04

Re: snap2 version update

#8 Post by Patriot »

Hmmm .....

lstandish,

I didn't get to see the earlier codes ... so, by looking at the recent code above, the about_dialog assignments needs to be declared earlier ... see if this very minor re-arrangements below helps overcome your qualms about the about box ..... ;)


Rgds
Attachments
snap2.tar.gz
(10.33 KiB) Downloaded 709 times

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#9 Post by lstandish »

Patriot, thanks for lending a hand. I tried the version you sent, and find that the 'About' button still does the same. That is, it 'hangs' gtkdialog. CPU use skyrockets, like an endless loop somewhere. The strange thing is that the exact same 'about' dialog box code works fine when invoked from gtkdialog instances OTHER than the main one.

8-bit, I am unable to duplicate your trouble with the 'Close' button in the "About" dialog. It closes just fine for me. I am however using the Debian gtkdialog for development, not Puppy's gtkdialog3. I'll try this again on Puppy and report back.

Could the problem with the xterm window appearing *behind* the main window be due to low screen resolution? Or, it could be that Puppy's window manager is not as efficient at placing the windows as KDE's is. I am developing on Debian running KDE with a 1280x1024 pixel monitor, and all new gtkdialog windows are always very visible, usually to one side of the main dialog.

Do you see the xterm error "Warning: Cannot convert string "nil2" to type FontStruct" when you invoke xterm directly (not running snap2)? I have never seen this error, either on Debian Lenny or on Puppy 4.3.1.

On your suggestion to add a progress bar, I think that would not be possible since rsync does not provide any useful feedback on file transmission progress - at least, not without messing up the generation of logfiles. If the child xterm that appears when a backup in invoked is not behind the main window, I think the progress bar should not be necessary, since it will be obvious that rsync is doing its thing. (Note that once backups are configured, snap2 can be invoked non-interactively via cron or via a menu entry.)

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#10 Post by 8-bit »

In the ABOUT_DIALOG code, the line:
<button><label>Close</label><action type=\"closewindow\">ABOUT_DIALOG</action></button>

does not work for me. The window stays open when clicking on close.
Could this be due to trying to close it from inside of the ABOUT_DIALOG call?
Also, the line "Warning: Cannot convert string "nil2" to type FontStruct" is shown when the Xterm window is first opened in doing a backup.
The backup continues though and ends with "Press Return to close window.
The Xterm window is displayed behind the main program window and stays until it is given priority and return is pressed.
And I did install Xterm and the window says Xterm in the header.

Also, that Warning message only shows in an rxvt window that I used to start snap2.
A lot of times, an error message that seems invisible will show when one starts a program from a terminal.

User avatar
Patriot
Posts: 733
Joined: Thu 15 Jan 2009, 19:04

#11 Post by Patriot »

Hmmm .....

lstandish,

Kindly state your gtkdialog version ... I ran this snap2 pet on puppy412 and gtkdialog3-0.7.20 ... done several test runs with the about box enabled in the main dialog (as per my posted codes above) but I cannot duplicate the peak cpu usage/hang situation ... I clicked on the about box everywhere it appears and they worked just fine ..... Apart from the msgbox fix (for aboutbox) earlier, others seems ok ... Also did a quick test with gtkdialog2-0.5.98 which does not work with snap2 .....

Can't get to the p431 yet ... maybe give it a test run on it later .... If possible, could you give some brief steps on how to make it peaked/hang? Did I miss anything to make it bork properly?


Rgds

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#12 Post by lstandish »

Patriot,

I've confirmed that the hang upon clicking the 'About' button happens in Puppy 4.3.1, both in my original code with 'About' button enabled on the main menu, and in your version with the ABOUT_DIALOG definition moved.

Puppy 4.3.1 uses gtkdialog 0.7.20. This is the same version number given by my gtkdialog on Debian, the only difference being that it is called gtkdialog3 on Puppy.

So, it looks like a problem that happens only in p 4.3.1, or in a Puppy version later than 4.1.2. However, it also happens in Debian Lenny. I think it must be something in the recent GTK+ libraries upon which gtkdialog is based.

8-bit, are you also using Puppy 4.3.1? I can't duplicate the 'Cannot convert string "nil2" to type FontStruct"' error you see in xterm.

Do you think it would be better to have the main snap2 window close while a backup is being run, rather than run the backup as a separate process in its own xterm window? Also, 8-bit, did you try a *second* snapshot backup of /root, to see how fast the hard-linked rsync backups are? (This sort of discussion should probably be done on this forum's snap2 project page)

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#13 Post by 8-bit »

I am trying to run snap2 from Puppy Linux 4.3.1 scsi kernel 2.6.30.5.
And the problems are as stated.
I posted an example program in HOWTO GTKdialog-tips that uses gtkdialog2. The closewindow option seems to work with it consistently from a child process.
But it does not recognize launch as an option.
As to the Warning message, that is shown only in rxvt that I was using to start the program and appears upon doing a backup.
And the second backup was a lot faster.

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#14 Post by lstandish »

8-bit,
My Puppy 4.3.1 uses kernel 2.6.30.5 #1 SMP. Maybe the slight kernel difference explains the non-working 'Close' button in the 'About snap2' child dialog. I have tried opening the 'About snap2' dialog from everywhere I can ('Exclusions for Selected...', 'Delete Selected...', and '...Source Path Editor', all on the 'DIRECTORIES TO BACK UP' tab), and the 'Close' button works every time.

However, based on your report, and until a consistent solution is found for gtkdialog3, I'll remove the 'About snap2' child dialog for snap2 version 3.2-5. Or maybe I'll just remove the 'Close' button (the window could still be closed with the 'X' in the corner.)

On the 'Cannot convert string "nil2" to type FontStruct"' error, I was able to duplicate it by first starting a rxvt terminal and running snap2 from there, as you said. I think it is basically a clash between rxvt and xterm. Since one would not normally start snap2 from rxvt, I think the warning message can be safely ignored.

By the way, when you installed snap2, you got a snap2 menu entry. Look in 'Utility.' For version 3.2-5 I will add a second menu entry (which the Debian/Ubuntu version already has): one to execute a snapshot backup non-interactively (without the GUI).

I'd welcome any suggestions for improving the program, but please post them at http://www.murga-linux.com/puppy/viewtopic.php?t=50402

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#15 Post by lstandish »

2 gtkdialog issue were brought up in this thread. One appears to be resolved, the other isn't.

RESOLVED: 'closewindow' now working in child window, reported by 8-bit. It turns out 8-bit was using a patched version of gtkdialog which appears to have broken closewindow.

UNRESOLVED: As illustrated in the snap2 code (see download available above), a child window cannot be opened from the main snap2 gtkdialog, whereas it can from other gtkdialogs. The simple button code is :

<button><label>About snap2</label><action type="launch">ABOUT_DIALOG</action></button>

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#16 Post by 8-bit »

I had borked my gtkdialog3. I uninstalled the version that caused the problem and reinstalled the version with the patch by Patriot that fixes closing of a child dialog window from the child or from the main program.
I also found the correct syntax to use closewindow in a program as per HOWTO-gtkdialog-tips.
As to the other problem with the launch of ABOUT_DIALOG, I will try to investigate that further. Maybe do a run with the debug option and see if anything surfaces.
I may use that code line in a small gtkdialog3 script and see if the bug still surfaces.

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#17 Post by lstandish »

Here's a weird thing: I tried making a stripped-down version of snap2 - just keeping the loop, and a very simple gtkdialog including the 'about' button, and that way the about button worked!

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#18 Post by 8-bit »

I did that too.
Compare mine that was broken into separate lines for ease of reading code to yours.
It is attached.
Notice that I added a line <variable>ABOUT_DIALOG</variable>
Placement of that is important!
I also changed <action type="/closewindow"/>ABOUT_DIALOG</action>
to <action type="closewindow">ABOUT_DIALOG</action>.
A suggestion is to NOT make the ABOUT_DIALOG one line.
It is easier to check for errors if it is broken up as I did.
Sorry for no indentation. I was in a hurry.

It worked fine in the small script that has two CHILD processes.
Attachments
snap_about_dialog.tar.gz
My test script.
(934 Bytes) Downloaded 689 times

User avatar
lstandish
Posts: 126
Joined: Fri 06 Jun 2008, 13:22

#19 Post by lstandish »

gktdialog ships with some example code, and one of them illustrates launching a child dialog. The code is essentially the same. I think that some gtkdialog feature I am using in snap2 (such as notebook, checkbox, etc.) is triggering the glitch. I ought to investigate further, but I am packaging up a new snap2 version. The new version has the main dialog close during backup, to draw the user's attention to the xterm window where the backup is happening. I also made compressed logfiles optional and made the names mirror.log and snapshot.log. Thanks for your feeback, 8-bit!

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#20 Post by 8-bit »

I wonder if the changing of MAIN_DIALOG is confusing the call.
I had noticed that you changed it conditionally for various actions to be done by your program.
Also, have you tried putting a For Statements in MAIN_DIALOG etc in the short test script to see what happens or make a dummy conditional MAIN_DIALOG change in the short test script to see if that is what is affecting the launch call.

Post Reply