GTK help; get OK button & CheckBoxes. (SOLVED)

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

GTK help; get OK button & CheckBoxes. (SOLVED)

#1 Post by sunburnt »

I'm writing a GTK app. that's a Samba share auto boot mounter, with a NoteBook widget (TabPanel) on it.
There's a Tab for each Samba Host & each Tab's Panel has CheckBoxes, one for each brousable Share on that Host.
I've got working Bash code that gives all the Hosts & the brousable Shares that each Host offers.

I need to tell if the OK or Cancel button is clicked, & to set & test the state of the CheckBoxes.

The action tags can run Bash scripts & that's all the luck I've had, is there other "if true enable:" type commands?
It doesn't seem like variables set in the action tags are carried out, exporting them doesn't work either.
I"ve looked at Web sites & docs & it's always obtuse examples, nothing like the simple code I've just described.

I tried:

#! /bin/bash
job ()
{
echo "OK Button Pressed."
return
}

.........
...........
<button ok>
<variable>OKBUTTON</variable>
<action>job</action>
</button>
<button cancel></button>

The action "job" doesn't call the function "job", it reports: "sh: job: not found".
But this is how the GTK web site shows to do it (kind of).
Last edited by sunburnt on Sun 09 Apr 2006, 11:04, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#2 Post by sunburnt »

In xterm the GTK app. reports the state of the checkboxes & exit mode, like so:

0="false"
OK=""
docs="true"
public="false"
EXIT=OK

The OK="" shows no state for the OK button after it's been clicked
I've tried using <action>if true then:CHK_${i}=${S}</action> but it says: not found.
I've tried testing variables with: echo "XXX $docs", & XXX is output.
What are the names of the variables that I use to get the states of the OK button & the checkboxes?
OR... is there another method for testing the widgets states?

I'd like to test the states of the checkboxes AFTER & ONLY if the OK button is clicked.
I've got the checkboxes being set to checked or unchecked... now for the rest of it.
I'm not sure how to get the <action> to set a variable that I can use later in the script.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#3 Post by sunburnt »

After another day of work, I finally found a Debian web page saying GTK variables are sent to stdout.
Looking into Bash's stdout, I added the stdout redirection code in various places till it worked.
The last line at the end of the GTK code then looks like this:

gtkdialog2 --program=MAIN_DIALOG 1> /tmp/gtk-stdout

The added part is: 1> /tmp/gtk-stdout
/tmp/gtk-stdout is the file that GTK's variables are written to.

Now why didn't the examples have that, & also explain what's going on?

If there's enough intrest in GTKdialog programming by noobs, maybe I'll make a HowTo.

Post Reply