Re: Signal on mouse over menu item?

2005-11-26 Thread Daniel Pekelharing
On Sat, 2005-11-26 at 14:29 +, John Cupitt wrote:
> Hi again,
> 
> It works with hand-made menus too. You need to have an accel group and
> path for each item.
> 
> I make one accel group per top-level window, then attach each item in
> that window which might have an accelerator to that group. The path
> names each item (eg. "/File/Open") soGTK can save and
> restore accelerators correctly.
> 
> Here's my app's code for menu items:
> 
> http://cvs.sourceforge.net/viewcvs.py/vips/nip2-7.11/src/toolview.c?rev=1.1.1.1&view=markup
> 
> and for menus:
> 
> http://cvs.sourceforge.net/viewcvs.py/vips/nip2-7.11/src/toolkitview.c?rev=1.1.1.1&view=markup
> 
> There's more stuff in there for building menu trees which hang off UI
> manager trees, don't know if that's useful for you.
> 
> John

hmm, I have not been setting a path for my menus..
I guess that must be my problem, this will require some
code-rethinking..

It looks like the easiest way out though!

Thanks for the help and the code snippets!

Now back to work...

-- 
Daniel Pekelharing
<[EMAIL PROTECTED]>

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread John Cupitt
On 11/26/05, Daniel Pekelharing <[EMAIL PROTECTED]> wrote:
> Only it doesn't seem to work for me?
> I even tried gtk_rc_parse_string("gtk-can-change-accels = 1");
>
> Perhaps it's because I have a manually constructed menu?
> Do you know if menu withinit only works with UI manager?

Hi again,

It works with hand-made menus too. You need to have an accel group and
path for each item.

I make one accel group per top-level window, then attach each item in
that window which might have an accelerator to that group. The path
names each item (eg. "/File/Open") soGTK can save and
restore accelerators correctly.

Here's my app's code for menu items:

http://cvs.sourceforge.net/viewcvs.py/vips/nip2-7.11/src/toolview.c?rev=1.1.1.1&view=markup

and for menus:

http://cvs.sourceforge.net/viewcvs.py/vips/nip2-7.11/src/toolkitview.c?rev=1.1.1.1&view=markup

There's more stuff in there for building menu trees which hang off UI
manager trees, don't know if that's useful for you.

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread Daniel Pekelharing
On Sat, 2005-11-26 at 13:33 +, John Cupitt wrote:
> Ah, OK, you're in luck, GTK has a very nice system like this already built in.
> 
> Just add
> 
>   gtk-can-change-accels = 1
> 
> To your .gtkrc and all your gtk applications will have programmable
> accelerators. You select the menu item you want to set an accelerator
> for, press CTRL-SHIFT-K or whatever, and that combination is now bound
> to that action. It updates the menu item text to show the shortcut,
> and removes that shortcut from any other menu items which also have
> that set.
> 
> You'll need to be able to load and save your edited shortcuts: see
> gtk_accel_map_load() and gtk_accel_map_save(). I'd like a
> reset-to-defaults call, but I've never found it :-(
> 
> Rather than asking people to edit their .gtkrc, I have the
> gtk-can-change-accels line in my application's resource file, which I
> think is frowned on. Oh well.
> 
> John

That sounds pretty cool!

Only it doesn't seem to work for me?
I even tried gtk_rc_parse_string("gtk-can-change-accels = 1");

Perhaps it's because I have a manually constructed menu?
Do you know if it only works with UI manager?

Thanks again!
-- 
Daniel Pekelharing
<[EMAIL PROTECTED]>

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread John Cupitt
On 11/26/05, Daniel Pekelharing <[EMAIL PROTECTED]> wrote:
> I'm trying to implement a system for making the accelerators adjustable
> in a easy way. I'm working on a 3D Animation app, and I've picked up
> (from forums and such) that 3D designers are rather particular about
> having flexibility on keyboard shortcuts...

Ah, OK, you're in luck, GTK has a very nice system like this already built in.

Just add

  gtk-can-change-accels = 1

To your .gtkrc and all your gtk applications will have programmable
accelerators. You select the menu item you want to set an accelerator
for, press CTRL-SHIFT-K or whatever, and that combination is now bound
to that action. It updates the menu item text to show the shortcut,
and removes that shortcut from any other menu items which also have
that set.

You'll need to be able to load and save your edited shortcuts: see
gtk_accel_map_load() and gtk_accel_map_save(). I'd like a
reset-to-defaults call, but I've never found it :-(

Rather than asking people to edit their .gtkrc, I have the
gtk-can-change-accels line in my application's resource file, which I
think is frowned on. Oh well.

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread Daniel Pekelharing
On Sat, 2005-11-26 at 13:04 +, John Cupitt wrote:
> I'm not sure, but perhaps GTK's programmable accelerator system is
> taking the keypress events before you see them?
> 
> I'd wonder about the wisdom of doing this (though of course I don't
> know what or why you need keypresses). It sounds like you might be
> wandering away from the expected behaviour for a GTK application and
> you're likely to confuse users more than help them. Is there some way
> you can get the effect you want and stay within the HIG?
> 
> John

I'm trying to implement a system for making the accelerators adjustable
in a easy way. I'm working on a 3D Animation app, and I've picked up
(from forums and such) that 3D designers are rather particular about
having flexibility on keyboard shortcuts...

I actually posted a question about it some days ago:

On Thu, 2005-11-17 at 18:41 +0200, Daniel Pekelharing wrote: 
> Hi all,
> 
> I'm wondering, how easy would it be to set up my program to have easily
> adjustable accelerator key mappings?
> 
> It would be nice to have a setup similar to a lot of programs - where
> the user just hovers the mouse over the menu item, presses insert and
> then the desired shortcut key..
> 
> Has anyone accomplished this sort of thing, or have any links to a
> tutorial ?
-- 
Daniel Pekelharing
<[EMAIL PROTECTED]>

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread John Cupitt
On 11/26/05, Daniel Pekelharing <[EMAIL PROTECTED]> wrote:
> I need to receive any keys pressed whilst a menu item is selected ...
>
> I connect a menu item with "key-press-event", but it seems to do
> nothing, even though Gtk doesn't spit out the usual:
> "signal x is invalid for instance y"...

I'm not sure, but perhaps GTK's programmable accelerator system is
taking the keypress events before you see them?

I'd wonder about the wisdom of doing this (though of course I don't
know what or why you need keypresses). It sounds like you might be
wandering away from the expected behaviour for a GTK application and
you're likely to confuse users more than help them. Is there some way
you can get the effect you want and stay within the HIG?

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread Daniel Pekelharing
On Sat, 2005-11-26 at 11:18 +0200, Daniel Pekelharing wrote:
> On Sat, 2005-11-26 at 09:08 +, John Cupitt wrote:
> > On 11/26/05, Daniel Pekelharing <[EMAIL PROTECTED]> wrote:
> > > Is there a signal on a GtkMenuItem that gets called when the cursor is
> > > moved onto the item?
> > 
> > I use "select" for when a menu item is highlit but before it is activated.
> > 
> > John
> 
> That seems to be what I was looking for.. Thanks!

I have another problem...

I need to receive any keys pressed whilst a menu item is selected ...

I connect a menu item with "key-press-event", but it seems to do
nothing, even though Gtk doesn't spit out the usual:
"signal x is invalid for instance y"...

Any ideas what might be blocking the key press signals?

Thanks!

-- 
Daniel Pekelharing
<[EMAIL PROTECTED]>

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread Daniel Pekelharing
On Sat, 2005-11-26 at 09:08 +, John Cupitt wrote:
> On 11/26/05, Daniel Pekelharing <[EMAIL PROTECTED]> wrote:
> > Is there a signal on a GtkMenuItem that gets called when the cursor is
> > moved onto the item?
> 
> I use "select" for when a menu item is highlit but before it is activated.
> 
> John

That seems to be what I was looking for.. Thanks!
-- 
Daniel Pekelharing
<[EMAIL PROTECTED]>

___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Signal on mouse over menu item?

2005-11-26 Thread John Cupitt
On 11/26/05, Daniel Pekelharing <[EMAIL PROTECTED]> wrote:
> Is there a signal on a GtkMenuItem that gets called when the cursor is
> moved onto the item?

I use "select" for when a menu item is highlit but before it is activated.

John
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list