mnemonics fixes



I just committed the following fixes to libbonoboui (head branch). The bonobo-ui-sync-menu.c part of the patch correctly sets mnemonics on the menu item labels, allowing keyboard navigation (before the labels were underlined, but no mnemonic was set).

The bonobo-ui-config-widget.c part changes some buttons to use mnemonics as well.

James.

--
Email: james daa com au
WWW:   http://www.daa.com.au/~james/

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libbonoboui/ChangeLog,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -p -r1.195 -r1.196
--- ChangeLog	2001/12/07 19:37:06	1.195
+++ ChangeLog	2001/12/08 16:48:13	1.196
@@ -1,3 +1,11 @@
+2001-12-09  James Henstridge  <james daa com au>
+
+	* bonobo/bonobo-ui-config-widget.c (widgets_init): use mnemonics
+	for button labels here as well.
+
+	* bonobo/bonobo-ui-sync-menu.c (impl_bonobo_ui_sync_menu_state):
+	just call gtk_label_set_use_underline() to set up the mnemonic.
+
 2001-12-07  jacob berkman  <jacob ximian com>
 
 	* bonobo/Makefile.am: some fixes to generated files
Index: bonobo/bonobo-ui-config-widget.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-ui-config-widget.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -p -r1.10 -r1.11
--- bonobo/bonobo-ui-config-widget.c	2001/11/04 23:09:31	1.10
+++ bonobo/bonobo-ui-config-widget.c	2001/12/08 16:48:16	1.11
@@ -246,7 +246,6 @@ widgets_init (BonoboUIConfigWidget *conf
 	GtkWidget *frame6;
 	GtkWidget *vbox7;
 	GSList *visible_group = NULL;
-	guint key;
 	GtkWidget *frame7;
 	GtkWidget *toolbar_list;
 	GtkWidget *frame5;
@@ -269,31 +268,21 @@ widgets_init (BonoboUIConfigWidget *conf
 	vbox7 = gtk_vbox_new (FALSE, 0);
 	gtk_container_add (GTK_CONTAINER (frame6), vbox7);
 
-	priv->show = gtk_radio_button_new_with_label (visible_group, "");
-	key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (priv->show)->child),
-						  _("_Show"));
-	gtk_widget_add_accelerator (priv->show, "clicked", accel_group,
-				    key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
+	priv->show = gtk_radio_button_new_with_mnemonic (visible_group,
+							 _("_Show"));
 	gtk_signal_connect (GTK_OBJECT (priv->show), "clicked",
 			    (GtkSignalFunc) show_hide_cb, config);
 	visible_group = gtk_radio_button_group (GTK_RADIO_BUTTON (priv->show));
 	gtk_box_pack_start (GTK_BOX (vbox7), priv->show, FALSE, FALSE, 0);
 
-	priv->hide = gtk_radio_button_new_with_label (visible_group, "");
-	key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (priv->hide)->child),
-						   _("_Hide"));
-	gtk_widget_add_accelerator (priv->hide, "clicked", accel_group,
-				    key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
+	priv->hide = gtk_radio_button_new_with_mnemonic (visible_group,
+							 _("_Hide"));
 	gtk_signal_connect (GTK_OBJECT (priv->hide), "clicked",
 			    (GtkSignalFunc) show_hide_cb, config);
 	visible_group = gtk_radio_button_group (GTK_RADIO_BUTTON (priv->hide));
 	gtk_box_pack_start (GTK_BOX (vbox7), priv->hide, FALSE, FALSE, 0);
 
-	priv->tooltips = gtk_check_button_new_with_label ("");
-	key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (priv->tooltips)->child),
-						  _("_View tooltips"));
-	gtk_widget_add_accelerator (priv->tooltips, "clicked", accel_group,
-				    key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
+	priv->tooltips = gtk_check_button_new_with_mnemonic (_("_View tooltips"));
 	gtk_box_pack_start (GTK_BOX (vbox6), priv->tooltips, FALSE, FALSE, 0);
 	gtk_signal_connect (GTK_OBJECT (priv->tooltips), "clicked",
 			    (GtkSignalFunc) tooltips_cb, config);
@@ -316,31 +305,20 @@ widgets_init (BonoboUIConfigWidget *conf
 	priv->right_attrs = vbox5 = gtk_vbox_new (FALSE, 0);
 	gtk_container_add (GTK_CONTAINER (frame5), vbox5);
 
-	priv->icon = gtk_radio_button_new_with_label (look_group, "");
-	key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (priv->icon)->child),
-						  _("_Icon"));
-	gtk_widget_add_accelerator (priv->icon, "clicked", accel_group,
-				    key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
+	priv->icon = gtk_radio_button_new_with_mnemonic (look_group,
+							 _("_Icon"));
 	gtk_signal_connect (GTK_OBJECT (priv->icon), "clicked",
 			    (GtkSignalFunc) look_cb, config);
 	look_group = gtk_radio_button_group (GTK_RADIO_BUTTON (priv->icon));
 	gtk_box_pack_start (GTK_BOX (vbox5), priv->icon, FALSE, FALSE, 0);
 
-	priv->icon_and_text = gtk_radio_button_new_with_label (look_group, "");
-	key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (priv->icon_and_text)->child),
-						  _("_Text and Icon"));
-	gtk_widget_add_accelerator (priv->icon_and_text, "clicked", accel_group,
-				    key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
+	priv->icon_and_text = gtk_radio_button_new_with_mnemonic (look_group, _("_Text and Icon"));
 	gtk_signal_connect (GTK_OBJECT (priv->icon_and_text), "clicked",
 			    (GtkSignalFunc) look_cb, config);
 	look_group = gtk_radio_button_group (GTK_RADIO_BUTTON (priv->icon_and_text));
 	gtk_box_pack_start (GTK_BOX (vbox5), priv->icon_and_text, FALSE, FALSE, 0);
 
-	priv->priority_text = gtk_radio_button_new_with_label (look_group, "");
-	key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (priv->priority_text)->child),
-						  _("_Priority text only"));
-	gtk_widget_add_accelerator (priv->priority_text, "clicked", accel_group,
-				    key, GDK_MOD1_MASK, (GtkAccelFlags) 0);
+	priv->priority_text = gtk_radio_button_new_with_mnemonic (look_group, _("_Priority text only"));
 	gtk_signal_connect (GTK_OBJECT (priv->priority_text), "clicked",
 			    (GtkSignalFunc) look_cb, config);
 	look_group = gtk_radio_button_group (GTK_RADIO_BUTTON (priv->priority_text));
Index: bonobo/bonobo-ui-sync-menu.c
===================================================================
RCS file: /cvs/gnome/libbonoboui/bonobo/bonobo-ui-sync-menu.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -p -r1.23 -r1.24
--- bonobo/bonobo-ui-sync-menu.c	2001/11/04 23:09:31	1.23
+++ bonobo/bonobo-ui-sync-menu.c	2001/12/08 16:48:16	1.24
@@ -375,11 +375,13 @@ impl_bonobo_ui_sync_menu_state (BonoboUI
 
 	if ((label_attr = bonobo_ui_engine_get_attr (node, cmd_node, "label"))) {
 		GtkWidget *label;
-		guint      keyval;
 
 		if (!label_same (GTK_BIN (menu_widget), label_attr)) {
 			label = gtk_accel_label_new (label_attr);
 
+			/* this widget has a mnemonic */
+			gtk_label_set_use_underline (GTK_LABEL (label), TRUE);
+
 			/* Setup the widget. */
 			gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
 			gtk_widget_show (label);
@@ -394,28 +396,6 @@ impl_bonobo_ui_sync_menu_state (BonoboUI
 			gtk_container_add (GTK_CONTAINER (menu_widget), label);
 			gtk_accel_label_set_accel_widget (
 				GTK_ACCEL_LABEL (label), menu_widget);
-			
-			keyval = gtk_label_parse_uline (GTK_LABEL (label), label_attr);
-			
-#ifdef FIXME
-			if (keyval != GDK_VoidSymbol) {
-				if (GTK_IS_MENU (parent))
-					gtk_widget_add_accelerator (
-						menu_widget, "activate_item",
-						gtk_menu_ensure_uline_accel_group (
-							GTK_MENU (parent)),
-						keyval, 0, 0);
-				
-				else if (GTK_IS_MENU_BAR (parent) &&
-					 sync_menu->accel_group != NULL)
-					gtk_widget_add_accelerator (
-						menu_widget, "activate_item",
-						sync_menu->accel_group,
-						keyval, GDK_MOD1_MASK, 0);
-				else
-					g_warning ("Adding accelerator went bananas");
-			}
-#endif
 		} /* else
 			g_warning ("No change in label '%s'", label_attr); */
 


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