1. Trapping menu clicks in GTK2

Irv, or anyone else with GTK2 experience:

  How do you trap menu selections?  I tried applying the code for the quit
button from button.exu to a File-->Quit menu choice, but it didn't work.  Any
help is as always appreciated.

Michael J. Sabal

new topic     » topic index » view message » categorize

2. Re: Trapping menu clicks in GTK2

Michael J. Sabal wrote:
> 
> 
> Irv, or anyone else with GTK2 experience:
> 
>   How do you trap menu selections?  I tried applying the code for the quit
> button from button.exu to a File-->Quit menu choice, but it didn't work.  Any
> help is as always appreciated.

Here's a clip from a working program.
bar and filemenu are defined as atoms, fileitem is an object, since 
it grows as the menu items are added.
the db: items are, of course, from "include db_file.e as db" , ,
where db_file.e has handlers to connect to database.e functions.
For example: db:create references a global constant 'create' in db_file.e ...

function Create()
-- call db_create()
return NULL
end function
global constant create = call_back(routine_id("Create"))


So, then you can hook that call into the menu item as shown below:

bar = menubar()
pack(panel,bar,0,0,0)

filemenu = menuitem("_File")
 fileitem  = choice("gtk-new",db:create,0)
 fileitem &= choice("gtk-open",db:open,0)
 fileitem &= choice("gtk-close",db:close,0)
 separator()
 fileitem &= choice("gtk-quit",quit,win)
 set_submenu(filemenu)
 setMenuItems(fileitem,{1,1,0})


The zero passed as the last parameter is usually unused, but whatever is 
there will be passed to the function being called, so you could pass 
a value if it would help.

Perhaps if you had a 'help' function, you could declare several menu 
items which all called the same routine, but passed a different number, 
to show different bits of information. 

Hope that helps, 
Irv

new topic     » goto parent     » topic index » view message » categorize

3. Re: Trapping menu clicks in GTK2

irv mullins wrote:
> 
> 
> Michael J. Sabal wrote:
> > 
> > 
> > Irv, or anyone else with GTK2 experience:
> > 
> >   How do you trap menu selections?  I tried applying the code for the quit

Err. please ignore the line:
setMenuItems(fileitem,{1,1,0})


That calls a routine earlier in the program, not a part of EuGTK. 
Sorry if it was confusing. 

Irv

new topic     » goto parent     » topic index » view message » categorize

4. Re: Trapping menu clicks in GTK2

Hi Michael,
I'll paste some code from a program i made using Irv's GTK2 Wrappers, i hope it
helps:

function ShowHarvText(atom ctl, atom data)
end function
constant show_harvtext = call_back(routine_id("ShowHarvText"))

hout3 = button("Calcular")
when(hout3,"clicked",show_harvtext,0)


Best Regards,
	Guillermo Bonvehi

On Fri, 23 Apr 2004 14:51:45 -0700
"Michael J. Sabal" <guest at RapidEuphoria.com> wrote:

> 
> 
> posted by: Michael J. Sabal <m_sabal at yahoo.com>
> 
> Irv, or anyone else with GTK2 experience:
> 
>   How do you trap menu selections?  I tried applying the code for the quit
> button from button.exu to a File-->Quit menu choice, but it didn't work.  Any
> help is as always appreciated.
> 
> Michael J. Sabal

new topic     » goto parent     » topic index » view message » categorize

5. Re: Trapping menu clicks in GTK2

Guillermo Bonvehi wrote:
> 
> Hi Michael,
> 	I'll paste some code from a program i made using Irv's GTK2 Wrappers, i hope
> it
> helps:

This is correct for buttons, and most other controls, but not for menu 
items, as they handle their own signals. See my previous example for menus.

Rob: when we reply and "quote original text", it copies the html markup 
as well. Is there a way around this?

> <font color="#330033"></font>
> <font color="#0000FF">function </font><font
> color="#330033">ShowHarvText(</font><font color="#FF00FF">atom </font><font
> color="#330033">ctl, </font><font color="#FF00FF">atom </font><font
> color="#330033">data)</font>
> <font color="#0000FF">end function</font>
> <font color="#0000FF">constant </font><font color="#330033">show_harvtext =
> call_back(</font><font color="#FF00FF">routine_id</font><font
> color="#993333">(</font><font color="#00A033">"ShowHarvText"</font><font
> color="#993333">)</font><font color="#330033">)</font>
> <font color="#330033"></font>
> <font color="#330033">hout3 = button(</font><font
> color="#00A033">"Calcular"</font><font color="#330033">)</font>
> <font color="#330033">when(hout3,</font><font
> color="#00A033">"clicked"</font><font color="#330033">,show_harvtext,0)</font>
> <font color="#330033"></font>
> 

> 
>

new topic     » goto parent     » topic index » view message » categorize

6. Re: Trapping menu clicks in GTK2

irv mullins wrote:

> Rob: when we reply and "quote original text", it copies the html markup 
> as well. Is there a way around this?

Oops: I guess that is a non-issue. The html only shows up in the 
textarea when we quote, once it gets to the forum, it looks ok.

<b><i>Hmmm</i></b>

Irv

new topic     » goto parent     » topic index » view message » categorize

7. Re: Trapping menu clicks in GTK2

Irv wrote:

> posted by: irv mullins <irvm at ellijay.com>
>
> irv mullins wrote:
>
>> Rob: when we reply and "quote original text", it copies the html markup
>> as well. Is there a way around this?
>
> Oops: I guess that is a non-issue. The html only shows up in the
> textarea when we quote, once it gets to the forum, it looks ok.
>
> <b><i>Hmmm</i></b>
>
> Irv

My mail client received your previous message _with_ its HTML tags. sad
(This one too, but this is no real HTML here.)

Regards,
   Juergen

-- 
 /"\  ASCII ribbon campain
 \ /  against HTML in
  X   e-mail and news,
 / \  and unneeded MIME

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu