Commit 0498dca8 authored by Michael Natterer's avatar Michael Natterer Committed by Michael Natterer

Bug 553765 – Add orientation API to GtkRange

2008-11-11  Michael Natterer  <mitch@imendio.com>

	Bug 553765 – Add orientation API to GtkRange

	* gtk/gtkrange.[ch]: implement the GtkOrientable interface. Add
	evil code that makes sure that the stepper_detail and slider_detail
	set in GtkRangeClass continue to work with the hacked subclasses
	below.

	* gtk/gtkscale.[ch]: swallow all code from GtkHScale and GtkVScale
	and add gtk_scale_new() and gtk_scale_new_with_range() which take
	a GtkOrientation argument. Set slider_detail to "Xscale" so above
	evil code works.

	* gtk/gtkscrollbar.[ch]: add gtk_scrollbar_new() which takes a
	GtkOrientation argument. Set stepper_detail to "Xscrollbar" so
	above evil code works.

	* gtk/gtkhscale.c
	* gtk/gtkvscale.c
	* gtk/gtkhscrollbar.c
	* gtk/gtkvscrollbar.c: remove all code except the constructor and
	call gtk_orientable_set_orientation() in init().

	* gtk/gtk.symbols: changed accordingly.


svn path=/trunk/; revision=21779
parent 4d8f9d2e
2008-11-11 Michael Natterer <mitch@imendio.com>
Bug 553765 – Add orientation API to GtkRange
* gtk/gtkrange.[ch]: implement the GtkOrientable interface. Add
evil code that makes sure that the stepper_detail and slider_detail
set in GtkRangeClass continue to work with the hacked subclasses
below.
* gtk/gtkscale.[ch]: swallow all code from GtkHScale and GtkVScale
and add gtk_scale_new() and gtk_scale_new_with_range() which take
a GtkOrientation argument. Set slider_detail to "Xscale" so above
evil code works.
* gtk/gtkscrollbar.[ch]: add gtk_scrollbar_new() which takes a
GtkOrientation argument. Set stepper_detail to "Xscrollbar" so
above evil code works.
* gtk/gtkhscale.c
* gtk/gtkvscale.c
* gtk/gtkhscrollbar.c
* gtk/gtkvscrollbar.c: remove all code except the constructor and
call gtk_orientable_set_orientation() in init().
* gtk/gtk.symbols: changed accordingly.
2008-11-11 Michael Natterer <mitch@imendio.com> 2008-11-11 Michael Natterer <mitch@imendio.com>
* gtk/gtktoolbar.h: move deprecated functions together, move * gtk/gtktoolbar.h: move deprecated functions together, move
......
...@@ -21,59 +21,45 @@ ...@@ -21,59 +21,45 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog * file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with * files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/ */
#include "config.h" #include "config.h"
#include <math.h> #include <math.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "gtkhscale.h" #include "gtkhscale.h"
#include "gtkintl.h" #include "gtkorientable.h"
#include "gtkalias.h" #include "gtkalias.h"
static gboolean gtk_hscale_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_hscale_get_layout_offsets (GtkScale *scale,
gint *x,
gint *y);
G_DEFINE_TYPE (GtkHScale, gtk_hscale, GTK_TYPE_SCALE) G_DEFINE_TYPE (GtkHScale, gtk_hscale, GTK_TYPE_SCALE)
static void static void
gtk_hscale_class_init (GtkHScaleClass *class) gtk_hscale_class_init (GtkHScaleClass *class)
{ {
GtkWidgetClass *widget_class; GtkRangeClass *range_class = GTK_RANGE_CLASS (class);
GtkRangeClass *range_class;
GtkScaleClass *scale_class;
widget_class = GTK_WIDGET_CLASS (class);
range_class = GTK_RANGE_CLASS (class);
scale_class = GTK_SCALE_CLASS (class);
range_class->slider_detail = "hscale"; range_class->slider_detail = "hscale";
scale_class->get_layout_offsets = gtk_hscale_get_layout_offsets;
widget_class->expose_event = gtk_hscale_expose;
} }
static void static void
gtk_hscale_init (GtkHScale *hscale) gtk_hscale_init (GtkHScale *hscale)
{ {
GtkRange *range; gtk_orientable_set_orientation (GTK_ORIENTABLE (hscale),
GTK_ORIENTATION_HORIZONTAL);
range = GTK_RANGE (hscale);
range->orientation = GTK_ORIENTATION_HORIZONTAL;
range->flippable = TRUE;
} }
GtkWidget* GtkWidget *
gtk_hscale_new (GtkAdjustment *adjustment) gtk_hscale_new (GtkAdjustment *adjustment)
{ {
return g_object_new (GTK_TYPE_HSCALE, "adjustment", adjustment, NULL); g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
NULL);
return g_object_new (GTK_TYPE_HSCALE,
"adjustment", adjustment,
NULL);
} }
/** /**
...@@ -81,19 +67,19 @@ gtk_hscale_new (GtkAdjustment *adjustment) ...@@ -81,19 +67,19 @@ gtk_hscale_new (GtkAdjustment *adjustment)
* @min: minimum value * @min: minimum value
* @max: maximum value * @max: maximum value
* @step: step increment (tick size) used with keyboard shortcuts * @step: step increment (tick size) used with keyboard shortcuts
* *
* Creates a new horizontal scale widget that lets the user input a * Creates a new horizontal scale widget that lets the user input a
* number between @min and @max (including @min and @max) with the * number between @min and @max (including @min and @max) with the
* increment @step. @step must be nonzero; it's the distance the * increment @step. @step must be nonzero; it's the distance the
* slider moves when using the arrow keys to adjust the scale value. * slider moves when using the arrow keys to adjust the scale value.
* *
* Note that the way in which the precision is derived works best if @step * Note that the way in which the precision is derived works best if @step
* is a power of ten. If the resulting precision is not suitable for your * is a power of ten. If the resulting precision is not suitable for your
* needs, use gtk_scale_set_digits() to correct it. * needs, use gtk_scale_set_digits() to correct it.
* *
* Return value: a new #GtkHScale * Return value: a new #GtkHScale
**/ **/
GtkWidget* GtkWidget *
gtk_hscale_new_with_range (gdouble min, gtk_hscale_new_with_range (gdouble min,
gdouble max, gdouble max,
gdouble step) gdouble step)
...@@ -108,127 +94,22 @@ gtk_hscale_new_with_range (gdouble min, ...@@ -108,127 +94,22 @@ gtk_hscale_new_with_range (gdouble min,
adj = gtk_adjustment_new (min, min, max, step, 10 * step, 0); adj = gtk_adjustment_new (min, min, max, step, 10 * step, 0);
if (fabs (step) >= 1.0 || step == 0.0) if (fabs (step) >= 1.0 || step == 0.0)
digits = 0;
else {
digits = abs ((gint) floor (log10 (fabs (step))));
if (digits > 5)
digits = 5;
}
scale = g_object_new (GTK_TYPE_HSCALE,
"adjustment", adj,
"digits", digits,
NULL);
return GTK_WIDGET (scale);
}
static gboolean
gtk_hscale_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkScale *scale;
scale = GTK_SCALE (widget);
/* We need to chain up _first_ so the various geometry members of
* GtkRange struct are updated.
*/
if (GTK_WIDGET_CLASS (gtk_hscale_parent_class)->expose_event)
GTK_WIDGET_CLASS (gtk_hscale_parent_class)->expose_event (widget, event);
if (scale->draw_value)
{ {
PangoLayout *layout; digits = 0;
gint x, y;
GtkStateType state_type;
layout = gtk_scale_get_layout (scale);
gtk_scale_get_layout_offsets (scale, &x, &y);
state_type = GTK_STATE_NORMAL;
if (!GTK_WIDGET_IS_SENSITIVE (scale))
state_type = GTK_STATE_INSENSITIVE;
gtk_paint_layout (widget->style,
widget->window,
state_type,
FALSE,
NULL,
widget,
"hscale",
x, y,
layout);
} }
else
return FALSE;
}
static void
gtk_hscale_get_layout_offsets (GtkScale *scale,
gint *x,
gint *y)
{
GtkWidget *widget;
GtkRange *range;
PangoLayout *layout;
PangoRectangle logical_rect;
gint value_spacing;
widget = GTK_WIDGET (scale);
layout = gtk_scale_get_layout (scale);
if (!layout)
{ {
*x = 0; digits = abs ((gint) floor (log10 (fabs (step))));
*y = 0; if (digits > 5)
digits = 5;
return;
} }
gtk_widget_style_get (widget, "value-spacing", &value_spacing, NULL); scale = g_object_new (GTK_TYPE_HSCALE,
"adjustment", adj,
range = GTK_RANGE (widget); "digits", digits,
scale = GTK_SCALE (widget); NULL);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
switch (scale->value_pos)
{
case GTK_POS_LEFT:
*x = range->range_rect.x - value_spacing - logical_rect.width;
*y = range->range_rect.y + (range->range_rect.height - logical_rect.height) / 2;
break;
case GTK_POS_RIGHT:
*x = range->range_rect.x + range->range_rect.width + value_spacing;
*y = range->range_rect.y + (range->range_rect.height - logical_rect.height) / 2;
break;
case GTK_POS_TOP:
*x = range->slider_start +
(range->slider_end - range->slider_start - logical_rect.width) / 2;
*x = CLAMP (*x, 0, widget->allocation.width - logical_rect.width);
*y = range->range_rect.y - logical_rect.height - value_spacing;
break;
case GTK_POS_BOTTOM:
*x = range->slider_start +
(range->slider_end - range->slider_start - logical_rect.width) / 2;
*x = CLAMP (*x, 0, widget->allocation.width - logical_rect.width);
*y = range->range_rect.y + range->range_rect.height + value_spacing;
break;
default:
g_return_if_reached ();
*x = 0;
*y = 0;
break;
}
*x += widget->allocation.x; return GTK_WIDGET (scale);
*y += widget->allocation.y;
} }
#define __GTK_HSCALE_C__ #define __GTK_HSCALE_C__
......
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog * file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with * files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/ */
#include "config.h" #include "config.h"
#include "gtkhscrollbar.h" #include "gtkhscrollbar.h"
#include "gdk/gdkkeysyms.h" #include "gtkorientable.h"
#include "gtkintl.h" #include "gtkintl.h"
#include "gtkalias.h" #include "gtkalias.h"
...@@ -42,23 +43,19 @@ gtk_hscrollbar_class_init (GtkHScrollbarClass *class) ...@@ -42,23 +43,19 @@ gtk_hscrollbar_class_init (GtkHScrollbarClass *class)
static void static void
gtk_hscrollbar_init (GtkHScrollbar *hscrollbar) gtk_hscrollbar_init (GtkHScrollbar *hscrollbar)
{ {
GtkRange *range; gtk_orientable_set_orientation (GTK_ORIENTABLE (hscrollbar),
GTK_ORIENTATION_HORIZONTAL);
range = GTK_RANGE (hscrollbar);
range->orientation = GTK_ORIENTATION_HORIZONTAL;
} }
GtkWidget* GtkWidget *
gtk_hscrollbar_new (GtkAdjustment *adjustment) gtk_hscrollbar_new (GtkAdjustment *adjustment)
{ {
GtkWidget *hscrollbar; g_return_val_if_fail (adjustment == NULL || GTK_IS_ADJUSTMENT (adjustment),
NULL);
hscrollbar = g_object_new (GTK_TYPE_HSCROLLBAR,
"adjustment", adjustment,
NULL);
return hscrollbar; return g_object_new (GTK_TYPE_HSCROLLBAR,
"adjustment", adjustment,
NULL);
} }
#define __GTK_HSCROLLBAR_C__ #define __GTK_HSCROLLBAR_C__
......
...@@ -26,15 +26,18 @@ ...@@ -26,15 +26,18 @@
*/ */
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <gdk/gdkkeysyms.h> #include <gdk/gdkkeysyms.h>
#include "gtkintl.h"
#include "gtkmain.h" #include "gtkmain.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
#include "gtkorientable.h"
#include "gtkrange.h" #include "gtkrange.h"
#include "gtkscrollbar.h" #include "gtkscrollbar.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h" #include "gtkalias.h"
#define SCROLL_DELAY_FACTOR 5 /* Scroll repeat multiplier */ #define SCROLL_DELAY_FACTOR 5 /* Scroll repeat multiplier */
...@@ -42,6 +45,7 @@ ...@@ -42,6 +45,7 @@
enum { enum {
PROP_0, PROP_0,
PROP_ORIENTATION,
PROP_UPDATE_POLICY, PROP_UPDATE_POLICY,
PROP_ADJUSTMENT, PROP_ADJUSTMENT,
PROP_INVERTED, PROP_INVERTED,
...@@ -110,6 +114,9 @@ struct _GtkRangeLayout ...@@ -110,6 +114,9 @@ struct _GtkRangeLayout
guint repaint_id; guint repaint_id;
gdouble fill_level; gdouble fill_level;
GQuark slider_detail_quark;
GQuark stepper_detail_quark;
}; };
...@@ -208,9 +215,12 @@ static gboolean gtk_range_key_press (GtkWidget *range, ...@@ -208,9 +215,12 @@ static gboolean gtk_range_key_press (GtkWidget *range,
GdkEventKey *event); GdkEventKey *event);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GtkRange, gtk_range, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE,
NULL))
static guint signals[LAST_SIGNAL]; static guint signals[LAST_SIGNAL];
G_DEFINE_ABSTRACT_TYPE (GtkRange, gtk_range, GTK_TYPE_WIDGET)
static void static void
gtk_range_class_init (GtkRangeClass *class) gtk_range_class_init (GtkRangeClass *class)
...@@ -225,6 +235,7 @@ gtk_range_class_init (GtkRangeClass *class) ...@@ -225,6 +235,7 @@ gtk_range_class_init (GtkRangeClass *class)
gobject_class->set_property = gtk_range_set_property; gobject_class->set_property = gtk_range_set_property;
gobject_class->get_property = gtk_range_get_property; gobject_class->get_property = gtk_range_get_property;
object_class->destroy = gtk_range_destroy; object_class->destroy = gtk_range_destroy;
widget_class->size_request = gtk_range_size_request; widget_class->size_request = gtk_range_size_request;
...@@ -331,6 +342,10 @@ gtk_range_class_init (GtkRangeClass *class) ...@@ -331,6 +342,10 @@ gtk_range_class_init (GtkRangeClass *class)
GTK_TYPE_SCROLL_TYPE, GTK_TYPE_SCROLL_TYPE,
G_TYPE_DOUBLE); G_TYPE_DOUBLE);
g_object_class_override_property (gobject_class,
PROP_ORIENTATION,
"orientation");
g_object_class_install_property (gobject_class, g_object_class_install_property (gobject_class,
PROP_UPDATE_POLICY, PROP_UPDATE_POLICY,
g_param_spec_enum ("update-policy", g_param_spec_enum ("update-policy",
...@@ -545,12 +560,18 @@ gtk_range_set_property (GObject *object, ...@@ -545,12 +560,18 @@ gtk_range_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkRange *range; GtkRange *range = GTK_RANGE (object);
range = GTK_RANGE (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_ORIENTATION:
range->orientation = g_value_get_enum (value);
range->layout->slider_detail_quark = 0;
range->layout->stepper_detail_quark = 0;
gtk_widget_queue_resize (GTK_WIDGET (range));
break;
case PROP_UPDATE_POLICY: case PROP_UPDATE_POLICY:
gtk_range_set_update_policy (range, g_value_get_enum (value)); gtk_range_set_update_policy (range, g_value_get_enum (value));
break; break;
...@@ -587,12 +608,13 @@ gtk_range_get_property (GObject *object, ...@@ -587,12 +608,13 @@ gtk_range_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GtkRange *range; GtkRange *range = GTK_RANGE (object);
range = GTK_RANGE (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_ORIENTATION:
g_value_set_enum (value, range->orientation);
break;
case PROP_UPDATE_POLICY: case PROP_UPDATE_POLICY:
g_value_set_enum (value, range->update_policy); g_value_set_enum (value, range->update_policy);
break; break;
...@@ -628,6 +650,7 @@ gtk_range_init (GtkRange *range) ...@@ -628,6 +650,7 @@ gtk_range_init (GtkRange *range)
{ {
GTK_WIDGET_SET_FLAGS (range, GTK_NO_WINDOW); GTK_WIDGET_SET_FLAGS (range, GTK_NO_WINDOW);
range->orientation = GTK_ORIENTATION_HORIZONTAL;
range->adjustment = NULL; range->adjustment = NULL;
range->update_policy = GTK_UPDATE_CONTINUOUS; range->update_policy = GTK_UPDATE_CONTINUOUS;
range->inverted = FALSE; range->inverted = FALSE;
...@@ -1319,6 +1342,58 @@ gtk_range_unmap (GtkWidget *widget) ...@@ -1319,6 +1342,58 @@ gtk_range_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget); GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget);
} }
static const gchar *
gtk_range_get_slider_detail (GtkRange *range)
{
const gchar *slider_detail;
if (range->layout->slider_detail_quark)
return g_quark_to_string (range->layout->slider_detail_quark);
slider_detail = GTK_RANGE_GET_CLASS (range)->slider_detail;
if (slider_detail && slider_detail[0] == 'X')
{
gchar *detail = g_strdup (slider_detail);
detail[0] = range->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v';
range->layout->slider_detail_quark = g_quark_from_string (detail);
g_free (detail);
return g_quark_to_string (range->layout->slider_detail_quark);
}
return slider_detail;
}
static const gchar *
gtk_range_get_stepper_detail (GtkRange *range)
{
const gchar *stepper_detail;
if (range->layout->stepper_detail_quark)
return g_quark_to_string (range->layout->stepper_detail_quark);
stepper_detail = GTK_RANGE_GET_CLASS (range)->stepper_detail;
if (stepper_detail && stepper_detail[0] == 'X')
{
gchar *detail = g_strdup (stepper_detail);
detail[0] = range->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v';
range->layout->stepper_detail_quark = g_quark_from_string (detail);
g_free (detail);
return g_quark_to_string (range->layout->stepper_detail_quark);
}
return stepper_detail;
}
static void static void
draw_stepper (GtkRange *range, draw_stepper (GtkRange *range,
GdkRectangle *rect, GdkRectangle *rect,
...@@ -1377,7 +1452,7 @@ draw_stepper (GtkRange *range, ...@@ -1377,7 +1452,7 @@ draw_stepper (GtkRange *range,
widget->window, widget->window,
state_type, shadow_type, state_type, shadow_type,
&intersection, widget, &intersection, widget,
GTK_RANGE_GET_CLASS (range)->stepper_detail, gtk_range_get_stepper_detail (range),
widget->allocation.x + rect->x, widget->allocation.x + rect->x,
widget->allocation.y + rect->y, widget->allocation.y + rect->y,
rect->width, rect->width,
...@@ -1407,7 +1482,7 @@ draw_stepper (GtkRange *range, ...@@ -1407,7 +1482,7 @@ draw_stepper (GtkRange *range,
widget->window, widget->window,
state_type, shadow_type, state_type, shadow_type,
&intersection, widget, &intersection, widget,
GTK_RANGE_GET_CLASS (range)->stepper_detail, gtk_range_get_stepper_detail (range),
arrow_type, arrow_type,
TRUE, TRUE,
arrow_x, arrow_y, arrow_width, arrow_height); arrow_x, arrow_y, arrow_width, arrow_height);
...@@ -1679,7 +1754,7 @@ gtk_range_expose (GtkWidget *widget, ...@@ -1679,7 +1754,7 @@ gtk_range_expose (GtkWidget *widget,
shadow_type, shadow_type,
&area, &area,
widget, widget,
GTK_RANGE_GET_CLASS (range)->slider_detail, gtk_range_get_slider_detail (range),
widget->allocation.x + range->layout->slider.x, widget->allocation.x + range->layout->slider.x,
widget->allocation.y + range->layout->slider.y, widget->allocation.y + range->layout->slider.y,
range->layout->slider.width, range->layout->slider.width,
......
...@@ -174,6 +174,7 @@ void gtk_range_set_fill_level (GtkRange *range ...@@ -174,6 +174,7 @@ void gtk_range_set_fill_level (GtkRange *range
gdouble fill_level); gdouble fill_level);
gdouble gtk_range_get_fill_level (GtkRange *range); gdouble gtk_range_get_fill_level (GtkRange *range);
/* internal API */
gdouble _gtk_range_get_wheel_delta (GtkRange *range, gdouble _gtk_range_get_wheel_delta (GtkRange *range,
GdkScrollDirection direction); GdkScrollDirection direction);
......
...@@ -22,17 +22,20 @@ ...@@ -22,17 +22,20 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog * file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with * files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/ */
#include "config.h" #include "config.h"
#include <math.h> #include <math.h>
#include "gtkintl.h" #include <stdlib.h>
#include "gdk/gdkkeysyms.h"
#include "gtkscale.h" #include "gtkscale.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
#include "gdk/gdkkeysyms.h"
#include "gtkbindings.h" #include "gtkbindings.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkintl.h"
#include "gtkalias.h" #include "gtkalias.h"
...@@ -65,23 +68,28 @@ enum { ...@@ -65,23 +68,28 @@ enum {
static guint signals[LAST_SIGNAL]; static guint signals[LAST_SIGNAL];
static void gtk_scale_set_property (GObject *object, static void gtk_scale_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_scale_get_property (GObject *object, static void gtk_scale_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec); GParamSpec *pspec);
static void gtk_scale_style_set (GtkWidget *widget, static void gtk_scale_style_set (GtkWidget *widget,
GtkStyle *previous); GtkStyle *previous);
static void gtk_scale_get_range_border (GtkRange *range, static void gtk_scale_get_range_border (GtkRange *range,
GtkBorder *border); GtkBorder *border);
static void gtk_scale_finalize (GObject *object); static void gtk_scale_finalize (GObject *object);
static void gtk_scale_screen_changed (GtkWidget *widget, static void gtk_scale_screen_changed (GtkWidget *widget,
GdkScreen *old_screen); GdkScreen *old_screen);
static gboolean gtk_scale_expose (GtkWidget *widget,
G_DEFINE_ABSTRACT_TYPE (GtkScale, gtk_scale, GTK_TYPE_RANGE) GdkEventExpose *event);
static void gtk_scale_real_get_layout_offsets (GtkScale *scale,
gint *x,
gint *y);
G_DEFINE_TYPE (GtkScale, gtk_scale, GTK_TYPE_RANGE)
static gboolean static gboolean
single_string_accumulator (GSignalInvocationHint *ihint, single_string_accumulator (GSignalInvocationHint *ihint,
...@@ -123,9 +131,13 @@ gtk_scale_class_init (GtkScaleClass *class) ...@@ -123,9 +131,13 @@ gtk_scale_class_init (GtkScaleClass *class)
widget_class->style_set = gtk_scale_style_set; widget_class->style_set = gtk_scale_style_set;
widget_class->screen_changed = gtk_scale_screen_changed; widget_class->screen_changed = gtk_scale_screen_changed;
widget_class->expose_event = gtk_scale_expose;
range_class->slider_detail = "Xscale";
range_class->get_range_border = gtk_scale_get_range_border; range_class->get_range_border = gtk_scale_get_range_border;
class->get_layout_offsets = gtk_scale_real_get_layout_offsets;
signals[FORMAT_VALUE] = signals[FORMAT_VALUE] =
g_signal_new (I_("format-value"), g_signal_new (I_("format-value"),
G_TYPE_FROM_CLASS (gobject_class), G_TYPE_FROM_CLASS (gobject_class),
...@@ -302,6 +314,37 @@ gtk_scale_class_init (GtkScaleClass *class) ...@@ -302,6 +314,37 @@ gtk_scale_class_init (GtkScaleClass *class)
g_type_class_add_private (gobject_class, sizeof (GtkScalePrivate)); g_type_class_add_private (gobject_class, sizeof (GtkScalePrivate));
} }
static void