Index: gtkbutton.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbutton.c,v
retrieving revision 1.88
diff -u -p -u -r1.88 gtkbutton.c
--- gtkbutton.c	10 Dec 2002 21:39:53 -0000	1.88
+++ gtkbutton.c	2 Apr 2003 20:57:36 -0000
@@ -61,7 +61,8 @@ enum {
   PROP_LABEL,
   PROP_RELIEF,
   PROP_USE_UNDERLINE,
-  PROP_USE_STOCK
+  PROP_USE_STOCK,
+  PROP_FOCUS_ON_CLICK
 };
 
 static void gtk_button_class_init     (GtkButtonClass   *klass);
@@ -208,6 +209,14 @@ gtk_button_class_init (GtkButtonClass *k
                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
   
   g_object_class_install_property (gobject_class,
+                                   PROP_FOCUS_ON_CLICK,
+                                   g_param_spec_boolean ("focus_on_click",
+							 _("Focus on click"),
+							 _("Whether the button grabs focus when it is clicked with the mouse"),
+							 TRUE,
+							 G_PARAM_READWRITE));
+  
+  g_object_class_install_property (gobject_class,
                                    PROP_RELIEF,
                                    g_param_spec_enum ("relief",
                                                       _("Border relief"),
@@ -313,6 +322,7 @@ gtk_button_init (GtkButton *button)
   button->use_underline = FALSE;
   button->depressed = FALSE;
   button->depress_on_activate = TRUE;
+  button->focus_on_click = TRUE;
 }
 
 static void
@@ -384,6 +394,9 @@ gtk_button_set_property (GObject        
     case PROP_USE_STOCK:
       gtk_button_set_use_stock (button, g_value_get_boolean (value));
       break;
+    case PROP_FOCUS_ON_CLICK:
+      gtk_button_set_focus_on_click (button, g_value_get_boolean (value));
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -414,6 +427,9 @@ gtk_button_get_property (GObject        
     case PROP_USE_STOCK:
       g_value_set_boolean (value, button->use_stock);
       break;
+    case PROP_FOCUS_ON_CLICK:
+      g_value_set_boolean (value, button->focus_on_click);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -938,7 +954,7 @@ gtk_button_button_press (GtkWidget      
     {
       button = GTK_BUTTON (widget);
 
-      if (!GTK_WIDGET_HAS_FOCUS (widget))
+      if (button->focus_on_click && !GTK_WIDGET_HAS_FOCUS (widget))
 	gtk_widget_grab_focus (widget);
 
       if (event->button == 1)
@@ -1235,6 +1251,41 @@ gtk_button_get_use_stock (GtkButton *but
   g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
   
   return button->use_stock;
+}
+
+/**
+ * gtk_button_set_focus_on_click:
+ * @button: a #GtkButton
+ * @focus_on_click: whether the mouse grabs focus when clicked with the mouse
+ * 
+ * If @focus_on_click is %FALSE, the button will not grab focus when it is
+ * clicked with the mouse. This is useful in places like toolbars where you
+ * don't want the keyboard focus removed from the main area of the application.
+ **/
+void
+gtk_button_set_focus_on_click (GtkButton *button,
+			       gboolean   focus_on_click)
+{
+  g_return_if_fail (GTK_IS_BUTTON (button));
+  
+  button->focus_on_click = focus_on_click != FALSE;
+  if (button->focus_on_click)
+    g_object_notify (G_OBJECT (button), "focus_on_click");
+}
+
+/**
+ * gtk_button_get_focus_on_click:
+ * @button: a #GtkButton
+ * 
+ * Returns %TRUE if the button grabs focus when it is clicked with the mouse,
+ * %FALSE if it doesn't.
+ **/
+gboolean
+gtk_button_get_focus_on_click (GtkButton *button)
+{
+  g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
+  
+  return button->focus_on_click;
 }
 
 /**
Index: gtkbutton.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkbutton.h,v
retrieving revision 1.25
diff -u -p -u -r1.25 gtkbutton.h
--- gtkbutton.h	11 Oct 2002 22:57:11 -0000	1.25
+++ gtkbutton.h	2 Apr 2003 20:57:36 -0000
@@ -66,6 +66,7 @@ struct _GtkButton
   guint use_stock : 1;
   guint depressed : 1;
   guint depress_on_activate : 1;
+  guint focus_on_click : 1;
 };
 
 struct _GtkButtonClass
@@ -97,28 +98,32 @@ void           gtk_button_released      
 void           gtk_button_clicked           (GtkButton      *button);
 void           gtk_button_enter             (GtkButton      *button);
 void           gtk_button_leave             (GtkButton      *button);
-void           gtk_button_set_relief        (GtkButton      *button,
-					     GtkReliefStyle  newstyle);
-GtkReliefStyle gtk_button_get_relief        (GtkButton      *button);
-
-void                  gtk_button_set_label         (GtkButton   *button,
-						    const gchar *label);
-G_CONST_RETURN gchar *gtk_button_get_label         (GtkButton   *button);
-void                  gtk_button_set_use_underline (GtkButton   *button,
-						    gboolean     use_underline);
-gboolean              gtk_button_get_use_underline (GtkButton   *button);
-void                  gtk_button_set_use_stock     (GtkButton   *button,
-						    gboolean     use_stock);
-gboolean              gtk_button_get_use_stock     (GtkButton   *button);
-
-void _gtk_button_set_depressed (GtkButton    *button,
-				gboolean      depressed);
-void _gtk_button_paint         (GtkButton    *button,
-				GdkRectangle *area,
-				GtkStateType  state_type,
-				GtkShadowType shadow_type,
-				const gchar  *main_detail,
-				const gchar  *default_detail);
+
+void                  gtk_button_set_relief         (GtkButton      *button,
+						     GtkReliefStyle  newstyle);
+GtkReliefStyle        gtk_button_get_relief         (GtkButton      *button);
+void                  gtk_button_set_label          (GtkButton      *button,
+						     const gchar    *label);
+G_CONST_RETURN gchar *gtk_button_get_label          (GtkButton      *button);
+void                  gtk_button_set_use_underline  (GtkButton      *button,
+						     gboolean        use_underline);
+gboolean              gtk_button_get_use_underline  (GtkButton      *button);
+void                  gtk_button_set_use_stock      (GtkButton      *button,
+						     gboolean        use_stock);
+gboolean              gtk_button_get_use_stock      (GtkButton      *button);
+void                  gtk_button_set_focus_on_click (GtkButton      *button,
+						     gboolean        focus_on_click);
+gboolean              gtk_button_get_focus_on_click (GtkButton      *button);
+
+
+void _gtk_button_set_depressed             (GtkButton     *button,
+					    gboolean       depressed);
+void _gtk_button_paint                     (GtkButton     *button,
+					    GdkRectangle  *area,
+					    GtkStateType   state_type,
+					    GtkShadowType  shadow_type,
+					    const gchar   *main_detail,
+					    const gchar   *default_detail);
 
 #ifdef __cplusplus
 }
