[9345] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] RE: accelerator example

daemon@ATHENA.MIT.EDU (Damon Chaplin)
Fri Oct 16 06:29:36 1998

From: "Damon Chaplin" <DAChaplin@email.msn.com>
To: <gtk-list@redhat.com>
Date: Fri, 16 Oct 1998 11:34:12 +0100
In-Reply-To: <Pine.LNX.3.96.981015182018.18588L-100000@turing.idc.ul.ie>
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com


> anyone got any sample code that shows how to use accelerators properly?
> I just need one example, and I'll be ok.

This is for GTK 1.0.x. It adds an accelerator to a menu item:

  GtkAcceleratorTable *accelerator_table;

  accelerator_table = gtk_accelerator_table_new ();
  gtk_window_add_accelerator_table (GTK_WINDOW (win_main), accelerator_table);

  menuitem = gtk_menu_item_new_with_label (_("Open..."));
  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
		      GTK_SIGNAL_FUNC (on_project_open), NULL);
  gtk_widget_install_accelerator (menuitem, accelerator_table,
				  "activate", 'O', GDK_CONTROL_MASK);

GTK 1.1.x is more like:

  GtkAccelGroup *accel_group;
  accel_group = gtk_accel_group_get_default ();

  menuitem = gtk_menu_item_new_with_label (_("Open..."));
  gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
		      GTK_SIGNAL_FUNC (on_project_open), NULL);
  gtk_widget_add_accelerator (menuitem, "activate", accel_group,
			      'O', GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);


Damon


-- 
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post