diff --git a/ChangeLog b/ChangeLog index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 0cfd5a1289..ca4c76331b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,9 @@ +Fri Feb 22 14:08:38 2002 Soeren Sandmann + + * gtk/gtkradiobutton.c, gtk/gtkcheckbutton.c, gtkbutton.h, + gtktogglebutton.c: feedback when check and radio buttons are + depressed. + 2002-02-22 Matthias Clasen * gtk/gtktreeview.c (gtk_tree_view_set_reorderable): @@ -33,6 +39,7 @@ Thu Feb 21 16:51:17 2002 Owen Taylor * gtk/gtkmenushell.c (gtk_menu_shell_key_press): Use _gtk_window_activate_key(), gtk_bindings_activate_event(). +>>>>>>> 1.3066 Thu Feb 21 12:24:22 2002 Owen Taylor * gtk/gtkctree.c (gtk_ctree_class_init): Remove some workarounds diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index 86701f9fee..7a50b67ced 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -306,6 +306,7 @@ gtk_button_init (GtkButton *button) button->use_stock = FALSE; button->use_underline = FALSE; button->depressed = FALSE; + button->depress_on_activate = TRUE; } static void @@ -1069,6 +1070,7 @@ gtk_real_button_activate (GtkButton *button) button); button->button_down = TRUE; gtk_button_update_state (button); + gtk_widget_queue_draw (GTK_WIDGET (button)); } } } @@ -1088,6 +1090,7 @@ gtk_button_finish_activate (GtkButton *button, button->button_down = FALSE; gtk_button_update_state (button); + gtk_widget_queue_draw (GTK_WIDGET (button)); if (do_it) gtk_button_clicked (button); @@ -1257,12 +1260,15 @@ gtk_button_update_state (GtkButton *button) gboolean depressed; GtkStateType new_state; - depressed = button->button_down && (button->in_button || button->activate_timeout); + if (button->activate_timeout) + depressed = button->depress_on_activate; + else + depressed = button->in_button && button->button_down; - if (!button->button_down && button->in_button) + if (button->in_button && (!button->button_down || !depressed)) new_state = GTK_STATE_PRELIGHT; else - new_state = depressed ? GTK_STATE_ACTIVE: GTK_STATE_NORMAL; + new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; _gtk_button_set_depressed (button, depressed); gtk_widget_set_state (GTK_WIDGET (button), new_state); diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h index ccc227aef4..728c933e3a 100644 --- a/gtk/gtkbutton.h +++ b/gtk/gtkbutton.h @@ -65,6 +65,7 @@ struct _GtkButton guint use_underline : 1; guint use_stock : 1; guint depressed : 1; + guint depress_on_activate : 1; }; struct _GtkButtonClass diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 5ad62e7e0e..6d91153076 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -114,6 +114,7 @@ gtk_check_button_init (GtkCheckButton *check_button) GTK_WIDGET_SET_FLAGS (check_button, GTK_NO_WINDOW); GTK_WIDGET_UNSET_FLAGS (check_button, GTK_RECEIVES_DEFAULT); GTK_TOGGLE_BUTTON (check_button)->draw_indicator = TRUE; + GTK_BUTTON (check_button)->depress_on_activate = FALSE; } GtkWidget* @@ -369,75 +370,75 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button, GdkRectangle *area) { GtkWidget *widget; + GtkButton *button; GtkToggleButton *toggle_button; GtkStateType state_type; GtkShadowType shadow_type; - GdkRectangle restrict_area; - GdkRectangle new_area; - gint width, height; gint x, y; gint indicator_size; gint indicator_spacing; gint focus_width; gint focus_pad; gboolean interior_focus; - GdkWindow *window; - - widget = GTK_WIDGET (check_button); - toggle_button = GTK_TOGGLE_BUTTON (check_button); if (GTK_WIDGET_DRAWABLE (check_button)) { - window = widget->window; - + widget = GTK_WIDGET (check_button); + button = GTK_BUTTON (check_button); + toggle_button = GTK_TOGGLE_BUTTON (check_button); + gtk_widget_style_get (widget, "interior_focus", &interior_focus, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing); - - state_type = GTK_WIDGET_STATE (widget); - if (state_type != GTK_STATE_NORMAL && - state_type != GTK_STATE_PRELIGHT) - state_type = GTK_STATE_NORMAL; - - restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; - restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; - restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width); - restrict_area.height = widget->allocation.height - ( 2 * GTK_CONTAINER (widget)->border_width); - - if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) - { - if (state_type != GTK_STATE_NORMAL) - gtk_paint_flat_box (widget->style, window, state_type, - GTK_SHADOW_ETCHED_OUT, - area, widget, "checkbutton", - new_area.x, new_area.y, - new_area.width, new_area.height); - } - + x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width; y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2; - width = indicator_size; - height = indicator_size; if (!interior_focus) x += focus_width + focus_pad; - state_type = GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget); - if (GTK_TOGGLE_BUTTON (widget)->inconsistent) + if (toggle_button->inconsistent) shadow_type = GTK_SHADOW_ETCHED_IN; - else if (GTK_TOGGLE_BUTTON (widget)->active) + else if (toggle_button->active) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; + if (button->activate_timeout || (button->button_down && button->in_button)) + state_type = GTK_STATE_ACTIVE; + else if (button->in_button) + state_type = GTK_STATE_PRELIGHT; + else + state_type = GTK_STATE_NORMAL; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - x = widget->allocation.x + widget->allocation.width - (width + x - widget->allocation.x); + x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x); - gtk_paint_check (widget->style, window, + if (GTK_WIDGET_STATE (toggle_button) == GTK_STATE_PRELIGHT) + { + GdkRectangle restrict_area; + GdkRectangle new_area; + + restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; + restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; + restrict_area.width = widget->allocation.width - (2 * GTK_CONTAINER (widget)->border_width); + restrict_area.height = widget->allocation.height - (2 * GTK_CONTAINER (widget)->border_width); + + if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) + { + gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT, + GTK_SHADOW_ETCHED_OUT, + area, widget, "checkbutton", + new_area.x, new_area.y, + new_area.width, new_area.height); + } + } + + gtk_paint_check (widget->style, widget->window, state_type, shadow_type, area, widget, "checkbutton", - x, y, width, height); + x, y, indicator_size, indicator_size); } } diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c index bc672a768a..50498e929b 100644 --- a/gtk/gtkradiobutton.c +++ b/gtk/gtkradiobutton.c @@ -114,6 +114,8 @@ gtk_radio_button_init (GtkRadioButton *radio_button) GTK_TOGGLE_BUTTON (radio_button)->active = TRUE; + GTK_BUTTON (radio_button)->depress_on_activate = FALSE; + radio_button->group = g_slist_prepend (NULL, radio_button); _gtk_button_set_depressed (GTK_BUTTON (radio_button), TRUE); @@ -579,15 +581,13 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, GtkToggleButton *toggle_button; GtkStateType state_type; GtkShadowType shadow_type; - GdkRectangle restrict_area; - GdkRectangle new_area; gint x, y; gint indicator_size, indicator_spacing; gint focus_width; gint focus_pad; gboolean interior_focus; - if (GTK_WIDGET_VISIBLE (check_button) && GTK_WIDGET_MAPPED (check_button)) + if (GTK_WIDGET_DRAWABLE (check_button)) { widget = GTK_WIDGET (check_button); button = GTK_BUTTON (check_button); @@ -599,46 +599,51 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button, "focus-padding", &focus_pad, NULL); - state_type = GTK_WIDGET_STATE (widget); - if ((state_type != GTK_STATE_NORMAL) && - (state_type != GTK_STATE_PRELIGHT)) - state_type = GTK_STATE_NORMAL; - _gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing); - restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; - restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; - restrict_area.width = widget->allocation.width - ( 2 * GTK_CONTAINER (widget)->border_width); - restrict_area.height = widget->allocation.height - ( 2 * GTK_CONTAINER (widget)->border_width); - - if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) - { - if (state_type != GTK_STATE_NORMAL) - gtk_paint_flat_box(widget->style, widget->window, state_type, - GTK_SHADOW_ETCHED_OUT, - area, widget, "radiobutton", - new_area.x, new_area.y, - new_area.width, new_area.height); - } - x = widget->allocation.x + indicator_spacing + GTK_CONTAINER (widget)->border_width; y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2; if (!interior_focus) x += focus_width + focus_pad; - - state_type = GTK_WIDGET_STATE (widget) == GTK_STATE_ACTIVE ? GTK_STATE_NORMAL : GTK_WIDGET_STATE (widget); - if (GTK_TOGGLE_BUTTON (widget)->active) + + if (toggle_button->inconsistent) + shadow_type = GTK_SHADOW_ETCHED_IN; + else if (toggle_button->active) shadow_type = GTK_SHADOW_IN; else shadow_type = GTK_SHADOW_OUT; - if (GTK_TOGGLE_BUTTON (widget)->inconsistent) - shadow_type = GTK_SHADOW_ETCHED_IN; - + if (button->activate_timeout || (button->button_down && button->in_button)) + state_type = GTK_STATE_ACTIVE; + else if (button->in_button) + state_type = GTK_STATE_PRELIGHT; + else + state_type = GTK_STATE_NORMAL; + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x); + if (GTK_WIDGET_STATE (toggle_button) == GTK_STATE_PRELIGHT) + { + GdkRectangle restrict_area; + GdkRectangle new_area; + + restrict_area.x = widget->allocation.x + GTK_CONTAINER (widget)->border_width; + restrict_area.y = widget->allocation.y + GTK_CONTAINER (widget)->border_width; + restrict_area.width = widget->allocation.width - (2 * GTK_CONTAINER (widget)->border_width); + restrict_area.height = widget->allocation.height - (2 * GTK_CONTAINER (widget)->border_width); + + if (gdk_rectangle_intersect (area, &restrict_area, &new_area)) + { + gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT, + GTK_SHADOW_ETCHED_OUT, + area, widget, "checkbutton", + new_area.x, new_area.y, + new_area.width, new_area.height); + } + } + gtk_paint_option (widget->style, widget->window, state_type, shadow_type, area, widget, "radiobutton", diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index 0b159e5a02..27088291da 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -162,6 +162,7 @@ gtk_toggle_button_init (GtkToggleButton *toggle_button) { toggle_button->active = FALSE; toggle_button->draw_indicator = FALSE; + GTK_BUTTON (toggle_button)->depress_on_activate = TRUE; } @@ -246,6 +247,17 @@ gtk_toggle_button_get_property (GObject *object, } } +static void +gtk_toggle_button_update_depress_on_activate (GtkToggleButton *toggle_button) +{ + GtkButton *button = GTK_BUTTON (toggle_button); + + if (toggle_button->draw_indicator || toggle_button->inconsistent) + button->depress_on_activate = FALSE; + else + button->depress_on_activate = !toggle_button->active; +} + void gtk_toggle_button_set_mode (GtkToggleButton *toggle_button, gboolean draw_indicator) @@ -262,6 +274,8 @@ gtk_toggle_button_set_mode (GtkToggleButton *toggle_button, { toggle_button->draw_indicator = draw_indicator; + gtk_toggle_button_update_depress_on_activate (toggle_button); + if (GTK_WIDGET_VISIBLE (toggle_button)) gtk_widget_queue_resize (GTK_WIDGET (toggle_button)); @@ -344,6 +358,7 @@ gtk_toggle_button_set_inconsistent (GtkToggleButton *toggle_button, { toggle_button->inconsistent = setting; + gtk_toggle_button_update_depress_on_activate (toggle_button); gtk_toggle_button_update_state (GTK_BUTTON (toggle_button)); gtk_widget_queue_draw (GTK_WIDGET (toggle_button)); @@ -405,6 +420,7 @@ gtk_toggle_button_pressed (GtkButton *button) button->button_down = TRUE; gtk_toggle_button_update_state (button); + gtk_widget_queue_draw (GTK_WIDGET (button)); } static void @@ -418,6 +434,7 @@ gtk_toggle_button_released (GtkButton *button) gtk_button_clicked (button); gtk_toggle_button_update_state (button); + gtk_widget_queue_draw (GTK_WIDGET (button)); } } @@ -427,6 +444,8 @@ gtk_toggle_button_clicked (GtkButton *button) GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (button); toggle_button->active = !toggle_button->active; + gtk_toggle_button_update_depress_on_activate (toggle_button); + gtk_toggle_button_toggled (toggle_button); gtk_toggle_button_update_state (button); @@ -448,10 +467,10 @@ gtk_toggle_button_update_state (GtkButton *button) else depressed = toggle_button->active; - if (!button->button_down && button->in_button) + if (button->in_button && (!button->button_down || toggle_button->draw_indicator)) new_state = GTK_STATE_PRELIGHT; else - new_state = depressed ? GTK_STATE_ACTIVE: GTK_STATE_NORMAL; + new_state = depressed ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL; _gtk_button_set_depressed (button, depressed); gtk_widget_set_state (GTK_WIDGET (toggle_button), new_state);