handle mnemonics in the stock item label

2001-03-22  Havoc Pennington  <hp@pobox.com>

	* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
	the stock item label

	* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs

	* gtk/gtkstock.c (builtin_items): add mnemonics where missing

	* demos/gtk-demo/*.c: Add mnemonics all over the place

	* gtk/gtklabel.h: mark parse_uline deprecated
This commit is contained in:
Havoc Pennington
2001-03-22 06:45:57 +00:00
committed by Havoc Pennington
parent e042310560
commit 6e58fd1ee3
15 changed files with 259 additions and 76 deletions

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -1,3 +1,16 @@
2001-03-22 Havoc Pennington <hp@pobox.com>
* gtk/gtktoolbar.c (gtk_toolbar_insert_stock): handle mnemonics in
the stock item label
* gtk/gtklabel.c: s/@gtk_func/gtk_func()/ in docs
* gtk/gtkstock.c (builtin_items): add mnemonics where missing
* demos/gtk-demo/*.c: Add mnemonics all over the place
* gtk/gtklabel.h: mark parse_uline deprecated
2001-03-21 Alexander Larsson <alexl@redhat.com> 2001-03-21 Alexander Larsson <alexl@redhat.com>
* gtk/gtkitemfactory.[ch]: * gtk/gtkitemfactory.[ch]:
@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik <timj@gtk.org>
* gtk/gtktext.c (process_exposes): * gtk/gtktext.c (process_exposes):
Use gtk_widget_send_expose instead of gtk_widget_event. Use gtk_widget_send_expose instead of gtk_widget_event.
>>>>>>> 1.1811
Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com> Thu Mar 8 19:40:28 2001 Jonathan Blandford <jrb@redhat.com>
* gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function.

View File

@ -28,13 +28,13 @@ create_bbox (gint horizontal,
gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout); gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout);
gtk_box_set_spacing (GTK_BOX (bbox), spacing); gtk_box_set_spacing (GTK_BOX (bbox), spacing);
button = gtk_button_new_with_label ("OK"); button = gtk_button_new_from_stock (GTK_STOCK_BUTTON_OK);
gtk_container_add (GTK_CONTAINER (bbox), button); gtk_container_add (GTK_CONTAINER (bbox), button);
button = gtk_button_new_with_label ("Cancel"); button = gtk_button_new_from_stock (GTK_STOCK_BUTTON_CANCEL);
gtk_container_add (GTK_CONTAINER (bbox), button); gtk_container_add (GTK_CONTAINER (bbox), button);
button = gtk_button_new_with_label ("Help"); button = gtk_button_new_from_stock (GTK_STOCK_HELP);
gtk_container_add (GTK_CONTAINER (bbox), button); gtk_container_add (GTK_CONTAINER (bbox), button);
return frame; return frame;

View File

@ -36,6 +36,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
GtkWidget *table; GtkWidget *table;
GtkWidget *local_entry1; GtkWidget *local_entry1;
GtkWidget *local_entry2; GtkWidget *local_entry2;
GtkWidget *label;
gint response; gint response;
dialog = gtk_dialog_new_with_buttons ("Interactive Dialog", dialog = gtk_dialog_new_with_buttons ("Interactive Dialog",
@ -56,17 +57,24 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data)
gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 4);
gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new ("Entry 1"), label = gtk_label_new_with_mnemonic ("_Entry 1");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 0, 1); 0, 1, 0, 1);
gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new ("Entry 2"),
0, 1, 1, 2);
local_entry1 = gtk_entry_new (); local_entry1 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1))); gtk_entry_set_text (GTK_ENTRY (local_entry1), gtk_entry_get_text (GTK_ENTRY (entry1)));
gtk_table_attach_defaults (GTK_TABLE (table), local_entry1, 1, 2, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), local_entry1, 1, 2, 0, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry1);
label = gtk_label_new_with_mnemonic ("E_ntry 2");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 1, 2);
local_entry2 = gtk_entry_new (); local_entry2 = gtk_entry_new ();
gtk_entry_set_text (GTK_ENTRY (local_entry2), gtk_entry_get_text (GTK_ENTRY (entry2))); gtk_entry_set_text (GTK_ENTRY (local_entry2), gtk_entry_get_text (GTK_ENTRY (entry2)));
gtk_table_attach_defaults (GTK_TABLE (table), local_entry2, 1, 2, 1, 2); gtk_table_attach_defaults (GTK_TABLE (table), local_entry2, 1, 2, 1, 2);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry2);
gtk_widget_show_all (hbox); gtk_widget_show_all (hbox);
response = gtk_dialog_run (GTK_DIALOG (dialog)); response = gtk_dialog_run (GTK_DIALOG (dialog));
@ -89,6 +97,7 @@ do_dialog (void)
GtkWidget *hbox; GtkWidget *hbox;
GtkWidget *button; GtkWidget *button;
GtkWidget *table; GtkWidget *table;
GtkWidget *label;
if (!window) if (!window)
{ {
@ -108,7 +117,7 @@ do_dialog (void)
/* Standard message dialog */ /* Standard message dialog */
hbox = gtk_hbox_new (FALSE, 8); hbox = gtk_hbox_new (FALSE, 8);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Message Dialog"); button = gtk_button_new_with_mnemonic ("_Message Dialog");
gtk_signal_connect (GTK_OBJECT (button), "clicked", gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (message_dialog_clicked), NULL); GTK_SIGNAL_FUNC (message_dialog_clicked), NULL);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
@ -120,7 +129,7 @@ do_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
vbox2 = gtk_vbox_new (FALSE, 0); vbox2 = gtk_vbox_new (FALSE, 0);
button = gtk_button_new_with_label ("Interactive Dialog"); button = gtk_button_new_with_mnemonic ("_Interactive Dialog");
gtk_signal_connect (GTK_OBJECT (button), "clicked", gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (interactive_dialog_clicked), NULL); GTK_SIGNAL_FUNC (interactive_dialog_clicked), NULL);
gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, FALSE, 0);
@ -130,13 +139,25 @@ do_dialog (void)
gtk_table_set_row_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 4);
gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_col_spacings (GTK_TABLE (table), 4);
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0);
gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new ("Entry 1"), 0, 1, 0, 1);
gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new ("Entry 2"), 0, 1, 1, 2); label = gtk_label_new_with_mnemonic ("_Entry 1");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 0, 1);
entry1 = gtk_entry_new (); entry1 = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1); gtk_table_attach_defaults (GTK_TABLE (table), entry1, 1, 2, 0, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry1);
label = gtk_label_new_with_mnemonic ("E_ntry 2");
gtk_table_attach_defaults (GTK_TABLE (table),
label,
0, 1, 1, 2);
entry2 = gtk_entry_new (); entry2 = gtk_entry_new ();
gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2); gtk_table_attach_defaults (GTK_TABLE (table), entry2, 1, 2, 1, 2);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry2);
} }
if (!GTK_WIDGET_VISIBLE (window)) if (!GTK_WIDGET_VISIBLE (window))

View File

@ -472,12 +472,11 @@ main (int argc, char **argv)
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
create_text (&info_buffer, FALSE), create_text (&info_buffer, FALSE),
gtk_label_new ("Info")); gtk_label_new_with_mnemonic ("_Info"));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
create_text (&source_buffer, TRUE), create_text (&source_buffer, TRUE),
gtk_label_new ("Source")); gtk_label_new_with_mnemonic ("_Source"));
tag = gtk_text_buffer_create_tag (info_buffer, "title", tag = gtk_text_buffer_create_tag (info_buffer, "title",
"font", "Sans 18", "font", "Sans 18",

View File

@ -72,14 +72,14 @@ create_pane_options (GtkPaned *paned,
gtk_table_attach_defaults (GTK_TABLE (table), label, gtk_table_attach_defaults (GTK_TABLE (table), label,
0, 1, 0, 1); 0, 1, 0, 1);
check_button = gtk_check_button_new_with_label ("Resize"); check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 1, 2); 0, 1, 1, 2);
gtk_signal_connect (GTK_OBJECT (check_button), "toggled", gtk_signal_connect (GTK_OBJECT (check_button), "toggled",
GTK_SIGNAL_FUNC (toggle_resize), GTK_SIGNAL_FUNC (toggle_resize),
paned->child1); paned->child1);
check_button = gtk_check_button_new_with_label ("Shrink"); check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
0, 1, 2, 3); 0, 1, 2, 3);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
@ -92,7 +92,7 @@ create_pane_options (GtkPaned *paned,
gtk_table_attach_defaults (GTK_TABLE (table), label, gtk_table_attach_defaults (GTK_TABLE (table), label,
1, 2, 0, 1); 1, 2, 0, 1);
check_button = gtk_check_button_new_with_label ("Resize"); check_button = gtk_check_button_new_with_mnemonic ("_Resize");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 1, 2); 1, 2, 1, 2);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
@ -101,7 +101,7 @@ create_pane_options (GtkPaned *paned,
GTK_SIGNAL_FUNC (toggle_resize), GTK_SIGNAL_FUNC (toggle_resize),
paned->child2); paned->child2);
check_button = gtk_check_button_new_with_label ("Shrink"); check_button = gtk_check_button_new_with_mnemonic ("_Shrink");
gtk_table_attach_defaults (GTK_TABLE (table), check_button, gtk_table_attach_defaults (GTK_TABLE (table), check_button,
1, 2, 2, 3); 1, 2, 2, 3);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
@ -149,7 +149,7 @@ do_panes (void)
gtk_widget_set_usize (frame, 60, 60); gtk_widget_set_usize (frame, 60, 60);
gtk_paned_add1 (GTK_PANED (hpaned), frame); gtk_paned_add1 (GTK_PANED (hpaned), frame);
button = gtk_button_new_with_label ("Hi there"); button = gtk_button_new_with_mnemonic ("_Hi there");
gtk_container_add (GTK_CONTAINER(frame), button); gtk_container_add (GTK_CONTAINER(frame), button);
frame = gtk_frame_new (NULL); frame = gtk_frame_new (NULL);

View File

@ -401,7 +401,7 @@ gtk_label_new (const gchar *str)
* If characters in @str are preceded by an underscore, they are underlined * If characters in @str are preceded by an underscore, they are underlined
* indicating that they represent a keyboard accelerator called a mnemonic. * indicating that they represent a keyboard accelerator called a mnemonic.
* The mnemonic key can be used to activate another widget, chosen automatically, * The mnemonic key can be used to activate another widget, chosen automatically,
* or explicitly using @gtk_label_set_mnemonic_widget. * or explicitly using gtk_label_set_mnemonic_widget().
**/ **/
GtkWidget* GtkWidget*
gtk_label_new_with_mnemonic (const gchar *str) gtk_label_new_with_mnemonic (const gchar *str)
@ -484,14 +484,15 @@ gtk_label_hierarchy_changed (GtkWidget *widget)
* @label: a #GtkLabel * @label: a #GtkLabel
* @widget: the target #GtkWidget * @widget: the target #GtkWidget
* *
* If the label has been set so that it has an mnemonic key (using i.e. * If the label has been set so that it has an mnemonic key (using
* @gtk_label_set_markup_with_mnemonic, @gtk_label_set_text_with_mnemonic, * i.e. gtk_label_set_markup_with_mnemonic(),
* @gtk_label_new_with_mnemonic or the use_underline property) the label can be * gtk_label_set_text_with_mnemonic(), gtk_label_new_with_mnemonic()
* associated with a widget that is the target of the mnemonic. When the label * or the "use_underline" property) the label can be associated with a
* is inside a widget (like a #GtkButton or a #GtkNotebook tab) it is automatically * widget that is the target of the mnemonic. When the label is inside
* associated with the correct widget, but sometimes (i.e. when the target is * a widget (like a #GtkButton or a #GtkNotebook tab) it is
* a #GtkEntry next to the label) you need to set it explicitly using this * automatically associated with the correct widget, but sometimes
* function. * (i.e. when the target is a #GtkEntry next to the label) you need to
* set it explicitly using this function.
* *
* The target widget will be accelerated by emitting "activate_mnemonic" on it. * The target widget will be accelerated by emitting "activate_mnemonic" on it.
* The default handler for this signal will activate the widget if there are no * The default handler for this signal will activate the widget if there are no
@ -724,7 +725,7 @@ gtk_label_set_markup (GtkLabel *label,
* indicating that they represent a keyboard accelerator called a mnemonic. * indicating that they represent a keyboard accelerator called a mnemonic.
* *
* The mnemonic key can be used to activate another widget, chosen automatically, * The mnemonic key can be used to activate another widget, chosen automatically,
* or explicitly using @gtk_label_set_mnemonic_widget. * or explicitly using gtk_label_set_mnemonic_widget().
**/ **/
void void
gtk_label_set_markup_with_mnemonic (GtkLabel *label, gtk_label_set_markup_with_mnemonic (GtkLabel *label,
@ -1395,7 +1396,7 @@ gtk_label_parse_uline (GtkLabel *label,
* If characters in @str are preceded by an underscore, they are underlined * If characters in @str are preceded by an underscore, they are underlined
* indicating that they represent a keyboard accelerator called a mnemonic. * indicating that they represent a keyboard accelerator called a mnemonic.
* The mnemonic key can be used to activate another widget, chosen automatically, * The mnemonic key can be used to activate another widget, chosen automatically,
* or explicitly using @gtk_label_set_mnemonic_widget. * or explicitly using gtk_label_set_mnemonic_widget().
**/ **/
void void
gtk_label_set_text_with_mnemonic (GtkLabel *label, gtk_label_set_text_with_mnemonic (GtkLabel *label,

View File

@ -102,12 +102,7 @@ void gtk_label_set_pattern (GtkLabel *label,
const gchar *pattern); const gchar *pattern);
void gtk_label_set_line_wrap (GtkLabel *label, void gtk_label_set_line_wrap (GtkLabel *label,
gboolean wrap); gboolean wrap);
/* Convenience function to set the name and pattern by parsing
* a string with embedded underscores, and return the appropriate
* key symbol for the accelerator.
*/
guint gtk_label_parse_uline (GtkLabel *label,
const gchar *string);
void gtk_label_set_text_with_mnemonic (GtkLabel *label, void gtk_label_set_text_with_mnemonic (GtkLabel *label,
const gchar *string); const gchar *string);
void gtk_label_set_mnemonic_widget (GtkLabel *label, void gtk_label_set_mnemonic_widget (GtkLabel *label,
@ -133,6 +128,14 @@ void gtk_label_get_layout_offsets (GtkLabel *label,
/* Deprecated */ /* Deprecated */
void gtk_label_get (GtkLabel *label, void gtk_label_get (GtkLabel *label,
char **str); char **str);
/* Convenience function to set the name and pattern by parsing
* a string with embedded underscores, and return the appropriate
* key symbol for the accelerator.
*/
guint gtk_label_parse_uline (GtkLabel *label,
const gchar *string);
#endif /* GTK_DISABLE_DEPRECATED */ #endif /* GTK_DISABLE_DEPRECATED */
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -231,18 +231,18 @@ static GtkStockItem builtin_items [] =
{ GTK_STOCK_DIALOG_QUESTION, N_("Question"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_DIALOG_QUESTION, N_("Question"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_BUTTON_APPLY, N_("_Apply"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BUTTON_APPLY, N_("_Apply"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_BUTTON_OK, N_("OK"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BUTTON_OK, N_("_OK"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_BUTTON_CANCEL, N_("Cancel"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BUTTON_CANCEL, N_("_Cancel"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_BUTTON_CLOSE, N_("_Close"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BUTTON_CLOSE, N_("_Close"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_BUTTON_YES, N_("_Yes"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BUTTON_YES, N_("_Yes"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_BUTTON_NO, N_("_No"), 0, 0, GETTEXT_PACKAGE }, { GTK_STOCK_BUTTON_NO, N_("_No"), 0, 0, GETTEXT_PACKAGE },
{ GTK_STOCK_CLOSE, N_("Close"), GDK_CONTROL_MASK, 'w', GETTEXT_PACKAGE }, { GTK_STOCK_CLOSE, N_("_Close"), GDK_CONTROL_MASK, 'w', GETTEXT_PACKAGE },
{ GTK_STOCK_QUIT, N_("Quit"), GDK_CONTROL_MASK, 'q', GETTEXT_PACKAGE }, { GTK_STOCK_QUIT, N_("_Quit"), GDK_CONTROL_MASK, 'q', GETTEXT_PACKAGE },
{ GTK_STOCK_HELP, N_("Help"), GDK_CONTROL_MASK, 'h', GETTEXT_PACKAGE }, { GTK_STOCK_HELP, N_("_Help"), GDK_CONTROL_MASK, 'h', GETTEXT_PACKAGE },
{ GTK_STOCK_NEW, N_("New"), GDK_CONTROL_MASK, 'n', GETTEXT_PACKAGE }, { GTK_STOCK_NEW, N_("_New"), GDK_CONTROL_MASK, 'n', GETTEXT_PACKAGE },
{ GTK_STOCK_OPEN, N_("Open"), GDK_CONTROL_MASK, 'o', GETTEXT_PACKAGE }, { GTK_STOCK_OPEN, N_("_Open"), GDK_CONTROL_MASK, 'o', GETTEXT_PACKAGE },
{ GTK_STOCK_SAVE, N_("Save"), GDK_CONTROL_MASK, 's', GETTEXT_PACKAGE } { GTK_STOCK_SAVE, N_("_Save"), GDK_CONTROL_MASK, 's', GETTEXT_PACKAGE }
}; };
static void static void

View File

@ -99,6 +99,27 @@ static void gtk_real_toolbar_orientation_changed (GtkToolbar *toolbar,
static void gtk_real_toolbar_style_changed (GtkToolbar *toolbar, static void gtk_real_toolbar_style_changed (GtkToolbar *toolbar,
GtkToolbarStyle style); GtkToolbarStyle style);
static GtkWidget * gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
GtkToolbarChildType type,
GtkWidget *widget,
const char *text,
const char *tooltip_text,
const char *tooltip_private_text,
GtkWidget *icon,
GtkSignalFunc callback,
gpointer user_data,
gint position,
gboolean has_mnemonic);
static GtkWidget * gtk_toolbar_internal_insert_item (GtkToolbar *toolbar,
const char *text,
const char *tooltip_text,
const char *tooltip_private_text,
GtkWidget *icon,
GtkSignalFunc callback,
gpointer user_data,
gint position,
gboolean has_mnemonic);
static GtkContainerClass *parent_class; static GtkContainerClass *parent_class;
@ -740,6 +761,24 @@ gtk_toolbar_prepend_item (GtkToolbar *toolbar,
0); 0);
} }
static GtkWidget *
gtk_toolbar_internal_insert_item (GtkToolbar *toolbar,
const char *text,
const char *tooltip_text,
const char *tooltip_private_text,
GtkWidget *icon,
GtkSignalFunc callback,
gpointer user_data,
gint position,
gboolean has_mnemonic)
{
return gtk_toolbar_internal_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON,
NULL, text,
tooltip_text, tooltip_private_text,
icon, callback, user_data,
position, has_mnemonic);
}
GtkWidget * GtkWidget *
gtk_toolbar_insert_item (GtkToolbar *toolbar, gtk_toolbar_insert_item (GtkToolbar *toolbar,
const char *text, const char *text,
@ -750,11 +789,10 @@ gtk_toolbar_insert_item (GtkToolbar *toolbar,
gpointer user_data, gpointer user_data,
gint position) gint position)
{ {
return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON, return gtk_toolbar_internal_insert_item (toolbar,
NULL, text, text, tooltip_text, tooltip_private_text,
tooltip_text, tooltip_private_text, icon, callback, user_data,
icon, callback, user_data, position, FALSE);
position);
} }
/** /**
@ -816,7 +854,10 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar,
* @position: The position the button shall be inserted at. * @position: The position the button shall be inserted at.
* -1 means at the end. * -1 means at the end.
* *
* Inserts a stock item at the specified position of the toolbar. * Inserts a stock item at the specified position of the toolbar. If
* @stock_id is not a known stock item ID, it's inserted verbatim,
* except that underscores are used to mark mnemonics (see
* gtk_label_new_with_mnemonic()).
*/ */
GtkWidget* GtkWidget*
gtk_toolbar_insert_stock (GtkToolbar *toolbar, gtk_toolbar_insert_stock (GtkToolbar *toolbar,
@ -834,24 +875,26 @@ gtk_toolbar_insert_stock (GtkToolbar *toolbar,
{ {
image = gtk_image_new_from_stock (stock_id, toolbar->icon_size); image = gtk_image_new_from_stock (stock_id, toolbar->icon_size);
return gtk_toolbar_insert_item (toolbar, return gtk_toolbar_internal_insert_item (toolbar,
item.label, item.label,
tooltip_text, tooltip_text,
tooltip_private_text, tooltip_private_text,
image, image,
callback, callback,
user_data, user_data,
position); position,
TRUE);
} }
else else
return gtk_toolbar_insert_item (toolbar, return gtk_toolbar_internal_insert_item (toolbar,
stock_id, stock_id,
tooltip_text, tooltip_text,
tooltip_private_text, tooltip_private_text,
NULL, NULL,
callback, callback,
user_data, user_data,
position); position,
TRUE);
} }
@ -971,6 +1014,35 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
GtkSignalFunc callback, GtkSignalFunc callback,
gpointer user_data, gpointer user_data,
gint position) gint position)
{
g_return_val_if_fail (toolbar != NULL, NULL);
g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), NULL);
if (type == GTK_TOOLBAR_CHILD_WIDGET)
{
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
}
else if (type != GTK_TOOLBAR_CHILD_RADIOBUTTON)
g_return_val_if_fail (widget == NULL, NULL);
gtk_toolbar_internal_insert_element (toolbar, type, widget, text,
tooltip_text, tooltip_private_text,
icon, callback, user_data,
position, FALSE);
}
static GtkWidget *
gtk_toolbar_internal_insert_element (GtkToolbar *toolbar,
GtkToolbarChildType type,
GtkWidget *widget,
const char *text,
const char *tooltip_text,
const char *tooltip_private_text,
GtkWidget *icon,
GtkSignalFunc callback,
gpointer user_data,
gint position,
gboolean has_mnemonic)
{ {
GtkToolbarChild *child; GtkToolbarChild *child;
GtkWidget *box; GtkWidget *box;
@ -1045,7 +1117,10 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar,
if (text) if (text)
{ {
child->label = gtk_label_new (text); if (has_mnemonic)
child->label = gtk_label_new_with_mnemonic (text);
else
child->label = gtk_label_new (text);
gtk_box_pack_end (GTK_BOX (box), child->label, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (box), child->label, FALSE, FALSE, 0);
if (toolbar->style != GTK_TOOLBAR_ICONS) if (toolbar->style != GTK_TOOLBAR_ICONS)
gtk_widget_show (child->label); gtk_widget_show (child->label);