diff --git a/ChangeLog b/ChangeLog index e0b92380c6..638ed8455b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index e0b92380c6..638ed8455b 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e0b92380c6..638ed8455b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e0b92380c6..638ed8455b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e0b92380c6..638ed8455b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e0b92380c6..638ed8455b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e0b92380c6..638ed8455b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,16 @@ +2001-03-22 Havoc Pennington + + * 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 * gtk/gtkitemfactory.[ch]: @@ -481,7 +494,6 @@ Fri Mar 9 09:31:55 2001 Tim Janik * gtk/gtktext.c (process_exposes): Use gtk_widget_send_expose instead of gtk_widget_event. ->>>>>>> 1.1811 Thu Mar 8 19:40:28 2001 Jonathan Blandford * gtk/gtktreeview.c (gtk_tree_view_destroy): Add destroy function. diff --git a/demos/gtk-demo/button_box.c b/demos/gtk-demo/button_box.c index 3cbdb09058..a0fae11226 100644 --- a/demos/gtk-demo/button_box.c +++ b/demos/gtk-demo/button_box.c @@ -28,13 +28,13 @@ create_bbox (gint horizontal, gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), layout); 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); - button = gtk_button_new_with_label ("Cancel"); + button = gtk_button_new_from_stock (GTK_STOCK_BUTTON_CANCEL); 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); return frame; diff --git a/demos/gtk-demo/dialog.c b/demos/gtk-demo/dialog.c index e5ce1ef82b..501503d5f9 100644 --- a/demos/gtk-demo/dialog.c +++ b/demos/gtk-demo/dialog.c @@ -36,6 +36,7 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data) GtkWidget *table; GtkWidget *local_entry1; GtkWidget *local_entry2; + GtkWidget *label; gint response; dialog = gtk_dialog_new_with_buttons ("Interactive Dialog", @@ -56,18 +57,25 @@ interactive_dialog_clicked (GtkButton *button, gpointer user_data) gtk_table_set_row_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_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); - gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new ("Entry 2"), - 0, 1, 1, 2); - local_entry1 = gtk_entry_new (); 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_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 (); 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_label_set_mnemonic_widget (GTK_LABEL (label), local_entry2); + gtk_widget_show_all (hbox); response = gtk_dialog_run (GTK_DIALOG (dialog)); @@ -89,7 +97,8 @@ do_dialog (void) GtkWidget *hbox; GtkWidget *button; GtkWidget *table; - + GtkWidget *label; + if (!window) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); @@ -108,7 +117,7 @@ do_dialog (void) /* Standard message dialog */ hbox = gtk_hbox_new (FALSE, 8); 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_FUNC (message_dialog_clicked), NULL); 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); 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_FUNC (interactive_dialog_clicked), NULL); 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_col_spacings (GTK_TABLE (table), 4); 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 (); 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 (); 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)) diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index 110c62567d..0dfb4b1e26 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -472,12 +472,11 @@ main (int argc, char **argv) gtk_notebook_append_page (GTK_NOTEBOOK (notebook), create_text (&info_buffer, FALSE), - gtk_label_new ("Info")); - + gtk_label_new_with_mnemonic ("_Info")); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), create_text (&source_buffer, TRUE), - gtk_label_new ("Source")); + gtk_label_new_with_mnemonic ("_Source")); tag = gtk_text_buffer_create_tag (info_buffer, "title", "font", "Sans 18", diff --git a/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c index 20ca271abd..21a91fd235 100644 --- a/demos/gtk-demo/panes.c +++ b/demos/gtk-demo/panes.c @@ -72,14 +72,14 @@ create_pane_options (GtkPaned *paned, gtk_table_attach_defaults (GTK_TABLE (table), label, 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, 0, 1, 1, 2); gtk_signal_connect (GTK_OBJECT (check_button), "toggled", GTK_SIGNAL_FUNC (toggle_resize), 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, 0, 1, 2, 3); 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, 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, 1, 2, 1, 2); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), @@ -101,7 +101,7 @@ create_pane_options (GtkPaned *paned, GTK_SIGNAL_FUNC (toggle_resize), 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, 1, 2, 2, 3); 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_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); frame = gtk_frame_new (NULL); diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index aa340021fd..a269f8634f 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -401,7 +401,7 @@ gtk_label_new (const gchar *str) * If characters in @str are preceded by an underscore, they are underlined * indicating that they represent a keyboard accelerator called a mnemonic. * 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* gtk_label_new_with_mnemonic (const gchar *str) @@ -484,14 +484,15 @@ gtk_label_hierarchy_changed (GtkWidget *widget) * @label: a #GtkLabel * @widget: the target #GtkWidget * - * If the label has been set so that it has an mnemonic key (using i.e. - * @gtk_label_set_markup_with_mnemonic, @gtk_label_set_text_with_mnemonic, - * @gtk_label_new_with_mnemonic or the use_underline property) the label can be - * associated with a widget that is the target of the mnemonic. When the label - * is inside a widget (like a #GtkButton or a #GtkNotebook tab) it is automatically - * associated with the correct widget, but sometimes (i.e. when the target is - * a #GtkEntry next to the label) you need to set it explicitly using this - * function. + * If the label has been set so that it has an mnemonic key (using + * i.e. gtk_label_set_markup_with_mnemonic(), + * gtk_label_set_text_with_mnemonic(), gtk_label_new_with_mnemonic() + * or the "use_underline" property) the label can be associated with a + * widget that is the target of the mnemonic. When the label is inside + * a widget (like a #GtkButton or a #GtkNotebook tab) it is + * automatically associated with the correct widget, but sometimes + * (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 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. * * 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 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 * indicating that they represent a keyboard accelerator called a mnemonic. * 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 gtk_label_set_text_with_mnemonic (GtkLabel *label, diff --git a/gtk/gtklabel.h b/gtk/gtklabel.h index 49a1626e2a..3e3d783e4a 100644 --- a/gtk/gtklabel.h +++ b/gtk/gtklabel.h @@ -102,12 +102,7 @@ void gtk_label_set_pattern (GtkLabel *label, const gchar *pattern); void gtk_label_set_line_wrap (GtkLabel *label, 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, const gchar *string); void gtk_label_set_mnemonic_widget (GtkLabel *label, @@ -133,6 +128,14 @@ void gtk_label_get_layout_offsets (GtkLabel *label, /* Deprecated */ void gtk_label_get (GtkLabel *label, 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 */ #ifdef __cplusplus diff --git a/gtk/gtkstock.c b/gtk/gtkstock.c index 60f3e9d6a8..5f3349dfb3 100644 --- a/gtk/gtkstock.c +++ b/gtk/gtkstock.c @@ -231,18 +231,18 @@ static GtkStockItem builtin_items [] = { GTK_STOCK_DIALOG_QUESTION, N_("Question"), 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_CANCEL, N_("Cancel"), 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_CLOSE, N_("_Close"), 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_CLOSE, N_("Close"), GDK_CONTROL_MASK, 'w', 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_NEW, N_("New"), GDK_CONTROL_MASK, 'n', 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_CLOSE, N_("_Close"), GDK_CONTROL_MASK, 'w', 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_NEW, N_("_New"), GDK_CONTROL_MASK, 'n', GETTEXT_PACKAGE }, + { GTK_STOCK_OPEN, N_("_Open"), GDK_CONTROL_MASK, 'o', GETTEXT_PACKAGE }, + { GTK_STOCK_SAVE, N_("_Save"), GDK_CONTROL_MASK, 's', GETTEXT_PACKAGE } }; static void diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 80a0c44d8c..d6bcf65df0 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -99,6 +99,27 @@ static void gtk_real_toolbar_orientation_changed (GtkToolbar *toolbar, static void gtk_real_toolbar_style_changed (GtkToolbar *toolbar, 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; @@ -740,6 +761,24 @@ gtk_toolbar_prepend_item (GtkToolbar *toolbar, 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 * gtk_toolbar_insert_item (GtkToolbar *toolbar, const char *text, @@ -750,11 +789,10 @@ gtk_toolbar_insert_item (GtkToolbar *toolbar, gpointer user_data, gint position) { - return gtk_toolbar_insert_element (toolbar, GTK_TOOLBAR_CHILD_BUTTON, - NULL, text, - tooltip_text, tooltip_private_text, - icon, callback, user_data, - position); + return gtk_toolbar_internal_insert_item (toolbar, + text, tooltip_text, tooltip_private_text, + icon, callback, user_data, + position, FALSE); } /** @@ -816,7 +854,10 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar, * @position: The position the button shall be inserted at. * -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* 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); - return gtk_toolbar_insert_item (toolbar, - item.label, - tooltip_text, - tooltip_private_text, - image, - callback, - user_data, - position); + return gtk_toolbar_internal_insert_item (toolbar, + item.label, + tooltip_text, + tooltip_private_text, + image, + callback, + user_data, + position, + TRUE); } else - return gtk_toolbar_insert_item (toolbar, - stock_id, - tooltip_text, - tooltip_private_text, - NULL, - callback, - user_data, - position); + return gtk_toolbar_internal_insert_item (toolbar, + stock_id, + tooltip_text, + tooltip_private_text, + NULL, + callback, + user_data, + position, + TRUE); } @@ -971,6 +1014,35 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar, GtkSignalFunc callback, gpointer user_data, 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; GtkWidget *box; @@ -1045,7 +1117,10 @@ gtk_toolbar_insert_element (GtkToolbar *toolbar, 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); if (toolbar->style != GTK_TOOLBAR_ICONS) gtk_widget_show (child->label);