Commit b5d8a668 authored by Soeren Sandmann's avatar Soeren Sandmann Committed by Søren Sandmann Pedersen

add property focus_on_click

Wed Apr  2 23:02:26 2003  Soeren Sandmann  <sandmann@daimi.au.dk>

	* gtk/gtkbutton.[ch] (gtk_button_class_init): add property
	focus_on_click

	* gtk/gtkwindow.c (gtk_window_focus): make arrow keyboard
	navigation not wrap around.
parent 8653097b
Wed Apr 2 23:02:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkbutton.[ch] (gtk_button_class_init): add property
focus_on_click
* gtk/gtkwindow.c (gtk_window_focus): make arrow keyboard
navigation not wrap around.
2003-04-02 Matthias Clasen <maclas@gmx.de>
* gtk/gtkprogress.c (gtk_progress_get_percentage_from_value):
......
Wed Apr 2 23:02:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkbutton.[ch] (gtk_button_class_init): add property
focus_on_click
* gtk/gtkwindow.c (gtk_window_focus): make arrow keyboard
navigation not wrap around.
2003-04-02 Matthias Clasen <maclas@gmx.de>
* gtk/gtkprogress.c (gtk_progress_get_percentage_from_value):
......
Wed Apr 2 23:02:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkbutton.[ch] (gtk_button_class_init): add property
focus_on_click
* gtk/gtkwindow.c (gtk_window_focus): make arrow keyboard
navigation not wrap around.
2003-04-02 Matthias Clasen <maclas@gmx.de>
* gtk/gtkprogress.c (gtk_progress_get_percentage_from_value):
......
Wed Apr 2 23:02:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkbutton.[ch] (gtk_button_class_init): add property
focus_on_click
* gtk/gtkwindow.c (gtk_window_focus): make arrow keyboard
navigation not wrap around.
2003-04-02 Matthias Clasen <maclas@gmx.de>
* gtk/gtkprogress.c (gtk_progress_get_percentage_from_value):
......
Wed Apr 2 23:02:26 2003 Soeren Sandmann <sandmann@daimi.au.dk>
* gtk/gtkbutton.[ch] (gtk_button_class_init): add property
focus_on_click
* gtk/gtkwindow.c (gtk_window_focus): make arrow keyboard
navigation not wrap around.
2003-04-02 Matthias Clasen <maclas@gmx.de>
* gtk/gtkprogress.c (gtk_progress_get_percentage_from_value):
......
......@@ -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);
......@@ -207,6 +208,14 @@ gtk_button_class_init (GtkButtonClass *klass)
FALSE,
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",
......@@ -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 *object,
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 *object,
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 *widget,
{
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)
......@@ -1237,6 +1253,50 @@ gtk_button_get_use_stock (GtkButton *button)
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
*
* Sets whether the button will grab focus when it is clicked with the mouse.
* Making mouse clicks not grab focus 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));
focus_on_click = focus_on_click != FALSE;
if (button->focus_on_click != focus_on_click)
{
button->focus_on_click = focus_on_click;
g_object_notify (G_OBJECT (button), "focus_on_click");
}
}
/**
* gtk_button_get_focus_on_click:
* @button: a #GtkButton
*
* Returns whether the button grabs focus when it is clicked with the mouse.
* See gtk_button_set_focus_on_click().
*
* Return value: %TRUE if the button grabs focus when it is clicked with
* the mouse.
**/
gboolean
gtk_button_get_focus_on_click (GtkButton *button)
{
g_return_val_if_fail (GTK_IS_BUTTON (button), FALSE);
return button->focus_on_click;
}
/**
* _gtk_button_set_depressed:
* @button: a #GtkButton
......
......@@ -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 (GtkButton *button);
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
}
......
......@@ -4305,6 +4305,14 @@ gtk_window_focus (GtkWidget *widget,
if (window->focus_widget)
{
if (direction == GTK_DIR_LEFT ||
direction == GTK_DIR_RIGHT ||
direction == GTK_DIR_UP ||
direction == GTK_DIR_DOWN)
{
return FALSE;
}
/* Wrapped off the end, clear the focus setting for the toplpevel */
parent = window->focus_widget->parent;
while (parent)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment