Re: New accelerator API



> To: "Padraig O'Briain" <Padraig Obriain Sun COM>
> Cc: gtk-devel-list gnome org, timj gtk org
> Subject: Re: New accelerator API
> User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
> MIME-Version: 1.0
> 
> 
> "Padraig O'Briain" <Padraig Obriain Sun COM> writes:
> 
> > Is it possible to determine the accelerator associated with a menu item 
using 
> > the new API?
> 
> Not quite - GtkAccelLabel uses a GtkWidget private function:
> 
>  _gtk_widget_get_accel_closures (accel_label->accel_widget);
> 
> To do this. This lack most likely needs to be fixed.
> 
> Regards,
>                                         Owen

I have used the code snippet below to find the accelerator, if any, for a menu 
item. It seems to produde the correct results for the menu items in testgtk.

Padraig

------------- Begin Included Message -------------

      parent = gtk_widget_get_parent (item);
      if (GTK_IS_MENU (parent))
        {
          GtkAccelGroup *group;
          gint i;

          group = gtk_menu_get_accel_group (GTK_MENU (parent));
          for (i = 0; i < group->n_accels; i++)
            {
              GtkAccelGroupEntry *entry;
              GClosure *closure;

              entry = &group->priv_accels[i];
              closure = entry->closure;
              if (closure->data == item)
                {
                   GtkAccelKey key;
                   key = entry->key;

                   accelerator = gtk_accelerator_name (key.accel_key,
                                                       key.accel_mods);
                   break;
                }
            }
        }

------------- End Included Message -------------




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]