Add a style property ::activate_slider that allows themes to draw the

2006-03-10  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtkrange.c: Add a style property ::activate_slider that
	allows themes to draw the slider active while dragged.  (#311992,
	Benjamin Berg)

	* gtk/gtkcolorsel.c (gtk_color_selection_init): Fix two labels.
This commit is contained in:
Matthias Clasen 2006-03-11 04:09:38 +00:00 committed by Matthias Clasen
parent e040b7805c
commit 63985b018f
4 changed files with 45 additions and 4 deletions

View File

@ -1,5 +1,11 @@
2006-03-10 Matthias Clasen <mclasen@redhat.com> 2006-03-10 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrange.c: Add a style property ::activate_slider that
allows themes to draw the slider active while dragged. (#311992,
Benjamin Berg)
* gtk/gtkcolorsel.c (gtk_color_selection_init): Fix two labels.
* gtk-engine-check-abi.sh: Add a script to check that theme * gtk-engine-check-abi.sh: Add a script to check that theme
engines don't export any extra functions. engines don't export any extra functions.

View File

@ -1,5 +1,11 @@
2006-03-10 Matthias Clasen <mclasen@redhat.com> 2006-03-10 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkrange.c: Add a style property ::activate_slider that
allows themes to draw the slider active while dragged. (#311992,
Benjamin Berg)
* gtk/gtkcolorsel.c (gtk_color_selection_init): Fix two labels.
* gtk-engine-check-abi.sh: Add a script to check that theme * gtk-engine-check-abi.sh: Add a script to check that theme
engines don't export any extra functions. engines don't export any extra functions.

View File

@ -2067,7 +2067,7 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
} }
set_selected_palette (colorsel, 0, 0); set_selected_palette (colorsel, 0, 0);
priv->palette_frame = gtk_vbox_new (FALSE, 6); priv->palette_frame = gtk_vbox_new (FALSE, 6);
label = gtk_label_new_with_mnemonic (_("_Palette")); label = gtk_label_new_with_mnemonic (_("_Palette:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (priv->palette_frame), label, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->palette_frame), label, FALSE, FALSE, 0);

View File

@ -419,6 +419,13 @@ gtk_range_class_init (GtkRangeClass *class)
G_MAXINT, G_MAXINT,
0, 0,
GTK_PARAM_READABLE)); GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("activate_slider",
P_("Draw slider ACTIVE during drag"),
P_("With this option set to TRUE, sliders will be drawn ACTIVE and with shadow IN while they are dragged"),
FALSE,
G_PARAM_READABLE));
} }
static void static void
@ -1149,11 +1156,13 @@ gtk_range_expose (GtkWidget *widget,
GtkRange *range; GtkRange *range;
gboolean sensitive; gboolean sensitive;
GtkStateType state; GtkStateType state;
GtkShadowType shadow_type;
GdkRectangle expose_area; /* Relative to widget->allocation */ GdkRectangle expose_area; /* Relative to widget->allocation */
GdkRectangle area; GdkRectangle area;
gint focus_line_width = 0; gint focus_line_width = 0;
gint focus_padding = 0; gint focus_padding = 0;
gboolean touchscreen; gboolean touchscreen;
gboolean activate_slider;
g_object_get (gtk_widget_get_settings (widget), g_object_get (gtk_widget_get_settings (widget),
"gtk-touchscreen-mode", &touchscreen, "gtk-touchscreen-mode", &touchscreen,
@ -1211,6 +1220,8 @@ gtk_range_expose (GtkWidget *widget,
range->range_rect.height); range->range_rect.height);
} }
shadow_type = GTK_SHADOW_OUT;
if (!sensitive) if (!sensitive)
state = GTK_STATE_INSENSITIVE; state = GTK_STATE_INSENSITIVE;
else if (!touchscreen && range->layout->mouse_location == MOUSE_SLIDER) else if (!touchscreen && range->layout->mouse_location == MOUSE_SLIDER)
@ -1218,6 +1229,17 @@ gtk_range_expose (GtkWidget *widget,
else else
state = GTK_STATE_NORMAL; state = GTK_STATE_NORMAL;
if (range->layout->grab_location == MOUSE_SLIDER)
{
gtk_widget_style_get (widget, "activate_slider", &activate_slider, NULL);
if (activate_slider)
{
state = GTK_STATE_ACTIVE;
shadow_type = GTK_SHADOW_IN;
}
}
if (gdk_rectangle_intersect (&expose_area, if (gdk_rectangle_intersect (&expose_area,
&range->layout->slider, &range->layout->slider,
&area)) &area))
@ -1228,7 +1250,7 @@ gtk_range_expose (GtkWidget *widget,
gtk_paint_slider (widget->style, gtk_paint_slider (widget->style,
widget->window, widget->window,
state, state,
GTK_SHADOW_OUT, shadow_type,
&area, &area,
widget, widget,
GTK_RANGE_GET_CLASS (range)->slider_detail, GTK_RANGE_GET_CLASS (range)->slider_detail,
@ -1456,6 +1478,7 @@ gtk_range_button_press (GtkWidget *widget,
range->layout->mouse_location == MOUSE_SLIDER) range->layout->mouse_location == MOUSE_SLIDER)
{ {
gboolean need_value_update = FALSE; gboolean need_value_update = FALSE;
gboolean activate_slider;
/* Any button can be used to drag the slider, but you can start /* Any button can be used to drag the slider, but you can start
* dragging the slider with a trough click using button 2; * dragging the slider with a trough click using button 2;
@ -1502,11 +1525,17 @@ gtk_range_button_press (GtkWidget *widget,
range->slide_initial_coordinate = event->x; range->slide_initial_coordinate = event->x;
} }
range_grab_add (range, MOUSE_SLIDER, event->button);
gtk_widget_style_get (widget, "activate_slider", &activate_slider, NULL);
/* force a redraw, if the active slider is drawn differently to the prelight one */
if (activate_slider)
gtk_widget_queue_draw (widget);
if (need_value_update) if (need_value_update)
update_slider_position (range, event->x, event->y); update_slider_position (range, event->x, event->y);
range_grab_add (range, MOUSE_SLIDER, event->button);
return TRUE; return TRUE;
} }