Commit e4e4aca0 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Fix #150125:

Mon Aug 16 01:35:25 2004  Matthias Clasen  <maclas@gmx.de>

	Fix #150125:

	* gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and
	change the default behaviour to focus on click.

	* gtk/gtkbutton.c (gtk_button_set_focus_on_click): Typo fix.
parent 44dc0b8a
Mon Aug 16 01:35:25 2004 Matthias Clasen <maclas@gmx.de>
Fix #150125:
* gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and
change the default behaviour to focus on click.
* gtk/gtkbutton.c (gtk_button_set_focus_on_click): Typo fix.
Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de> Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset): * gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset):
......
Mon Aug 16 01:35:25 2004 Matthias Clasen <maclas@gmx.de>
Fix #150125:
* gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and
change the default behaviour to focus on click.
* gtk/gtkbutton.c (gtk_button_set_focus_on_click): Typo fix.
Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de> Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset): * gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset):
......
Mon Aug 16 01:35:25 2004 Matthias Clasen <maclas@gmx.de>
Fix #150125:
* gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and
change the default behaviour to focus on click.
* gtk/gtkbutton.c (gtk_button_set_focus_on_click): Typo fix.
Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de> Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset): * gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset):
......
Mon Aug 16 01:35:25 2004 Matthias Clasen <maclas@gmx.de>
Fix #150125:
* gtk/gtkcombobox.[hc]: Add a ::focus-on-click property and
change the default behaviour to focus on click.
* gtk/gtkbutton.c (gtk_button_set_focus_on_click): Typo fix.
Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de> Mon Aug 16 01:03:08 2004 Matthias Clasen <maclas@gmx.de>
* gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset): * gtk/gtktextiter.c (gtk_text_iter_set_visible_line_offset):
......
...@@ -1420,7 +1420,7 @@ gtk_button_get_use_stock (GtkButton *button) ...@@ -1420,7 +1420,7 @@ gtk_button_get_use_stock (GtkButton *button)
/** /**
* gtk_button_set_focus_on_click: * gtk_button_set_focus_on_click:
* @button: a #GtkButton * @button: a #GtkButton
* @focus_on_click: whether the mouse grabs focus when clicked with the mouse * @focus_on_click: whether the button grabs focus when clicked with the mouse
* *
* Sets whether the button will grab focus when it is 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 * Making mouse clicks not grab focus is useful in places like toolbars where
......
...@@ -114,6 +114,7 @@ struct _GtkComboBoxPrivate ...@@ -114,6 +114,7 @@ struct _GtkComboBoxPrivate
guint is_cell_renderer : 1; guint is_cell_renderer : 1;
guint editing_canceled : 1; guint editing_canceled : 1;
guint auto_scroll : 1; guint auto_scroll : 1;
guint focus_on_click : 1;
GtkTreeViewRowSeparatorFunc row_separator_func; GtkTreeViewRowSeparatorFunc row_separator_func;
gpointer row_separator_data; gpointer row_separator_data;
...@@ -191,7 +192,8 @@ enum { ...@@ -191,7 +192,8 @@ enum {
PROP_COLUMN_SPAN_COLUMN, PROP_COLUMN_SPAN_COLUMN,
PROP_ACTIVE, PROP_ACTIVE,
PROP_ADD_TEAROFFS, PROP_ADD_TEAROFFS,
PROP_HAS_FRAME PROP_HAS_FRAME,
PROP_FOCUS_ON_CLICK
}; };
static GtkBinClass *parent_class = NULL; static GtkBinClass *parent_class = NULL;
...@@ -604,6 +606,14 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass) ...@@ -604,6 +606,14 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
TRUE, TRUE,
G_PARAM_READWRITE)); G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_FOCUS_ON_CLICK,
g_param_spec_boolean ("focus_on_click",
P_("Focus on click"),
P_("Whether the combo box grabs focus when it is clicked with the mouse"),
TRUE,
G_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class, gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("appears-as-list", g_param_spec_boolean ("appears-as-list",
P_("Appears as list"), P_("Appears as list"),
...@@ -653,6 +663,8 @@ gtk_combo_box_init (GtkComboBox *combo_box) ...@@ -653,6 +663,8 @@ gtk_combo_box_init (GtkComboBox *combo_box)
combo_box->priv->has_frame = TRUE; combo_box->priv->has_frame = TRUE;
combo_box->priv->is_cell_renderer = FALSE; combo_box->priv->is_cell_renderer = FALSE;
combo_box->priv->editing_canceled = FALSE; combo_box->priv->editing_canceled = FALSE;
combo_box->priv->auto_scroll = FALSE;
combo_box->priv->focus_on_click = TRUE;
} }
static void static void
...@@ -693,6 +705,10 @@ gtk_combo_box_set_property (GObject *object, ...@@ -693,6 +705,10 @@ gtk_combo_box_set_property (GObject *object,
combo_box->priv->has_frame = g_value_get_boolean (value); combo_box->priv->has_frame = g_value_get_boolean (value);
break; break;
case PROP_FOCUS_ON_CLICK:
combo_box->priv->focus_on_click = g_value_get_boolean (value);
break;
default: default:
break; break;
} }
...@@ -736,6 +752,10 @@ gtk_combo_box_get_property (GObject *object, ...@@ -736,6 +752,10 @@ gtk_combo_box_get_property (GObject *object,
g_value_set_boolean (value, combo_box->priv->has_frame); g_value_set_boolean (value, combo_box->priv->has_frame);
break; break;
case PROP_FOCUS_ON_CLICK:
g_value_set_boolean (value, combo_box->priv->focus_on_click);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
...@@ -2574,6 +2594,10 @@ gtk_combo_box_menu_button_press (GtkWidget *widget, ...@@ -2574,6 +2594,10 @@ gtk_combo_box_menu_button_press (GtkWidget *widget,
if (GTK_IS_MENU (combo_box->priv->popup_widget) && if (GTK_IS_MENU (combo_box->priv->popup_widget) &&
event->type == GDK_BUTTON_PRESS && event->button == 1) event->type == GDK_BUTTON_PRESS && event->button == 1)
{ {
if (combo_box->priv->focus_on_click &&
!GTK_WIDGET_HAS_FOCUS (combo_box->priv->button))
gtk_widget_grab_focus (combo_box->priv->button);
gtk_combo_box_menu_popup (combo_box, event->button, event->time); gtk_combo_box_menu_popup (combo_box, event->button, event->time);
return TRUE; return TRUE;
...@@ -3180,6 +3204,10 @@ gtk_combo_box_list_button_pressed (GtkWidget *widget, ...@@ -3180,6 +3204,10 @@ gtk_combo_box_list_button_pressed (GtkWidget *widget,
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button))) gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (combo_box->priv->button)))
return FALSE; return FALSE;
if (combo_box->priv->focus_on_click &&
!GTK_WIDGET_HAS_FOCUS (combo_box->priv->button))
gtk_widget_grab_focus (combo_box->priv->button);
gtk_combo_box_popup (combo_box); gtk_combo_box_popup (combo_box);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (combo_box->priv->button),
...@@ -4891,3 +4919,51 @@ gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box, ...@@ -4891,3 +4919,51 @@ gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box,
} }
/**
* gtk_combo_box_set_focus_on_click:
* @combo: a #GtkComboBox
* @focus_on_click: whether the combo box grabs focus when clicked
* with the mouse
*
* Sets whether the combo box 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.
*
* Since: 2.6
**/
void
gtk_combo_box_set_focus_on_click (GtkComboBox *combo,
gboolean focus_on_click)
{
g_return_if_fail (GTK_IS_COMBO_BOX (combo));
focus_on_click = focus_on_click != FALSE;
if (combo->priv->focus_on_click != focus_on_click)
{
combo->priv->focus_on_click = focus_on_click;
g_object_notify (G_OBJECT (combo), "focus_on_click");
}
}
/**
* gtk_combo_box_get_focus_on_click:
* @combo: a #GtkComboBox
*
* Returns whether the combo box grabs focus when it is clicked
* with the mouse. See gtk_combo_box_set_focus_on_click().
*
* Return value: %TRUE if the combo box grabs focus when it is
* clicked with the mouse.
*
* Since: 2.6
**/
gboolean
gtk_combo_box_get_focus_on_click (GtkComboBox *combo)
{
g_return_val_if_fail (GTK_IS_COMBO_BOX (combo), FALSE);
return combo->priv->focus_on_click;
}
...@@ -79,6 +79,9 @@ void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, ...@@ -79,6 +79,9 @@ void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box,
gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box); gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box);
void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box, void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box,
gboolean add_tearoffs); gboolean add_tearoffs);
gboolean gtk_combo_box_get_focus_on_click (GtkComboBox *combo);
void gtk_combo_box_set_focus_on_click (GtkComboBox *combo,
gboolean focus_on_click);
/* get/set active item */ /* get/set active item */
gint gtk_combo_box_get_active (GtkComboBox *combo_box); gint gtk_combo_box_get_active (GtkComboBox *combo_box);
......
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