port GtkMisc, GtkRange, GtkScale and GtkScaleButton to RI
min/max for GtkMisc min/max for GtkRange min/max for GtkScale fixed gtkscale.c fixed gtkrange.c fixed gtkmisc.c
This commit is contained in:
committed by
Davyd Madeley
parent
151e5c58a8
commit
fda93a2977
@@ -2598,6 +2598,7 @@ gtk_misc_set_alignment
|
||||
gtk_misc_set_padding
|
||||
gtk_misc_get_alignment
|
||||
gtk_misc_get_padding
|
||||
gtk_misc_get_padding_unit
|
||||
<SUBSECTION Standard>
|
||||
GTK_MISC
|
||||
GTK_IS_MISC
|
||||
|
||||
@@ -2538,6 +2538,7 @@ gtk_message_dialog_get_image
|
||||
#if IN_FILE(__GTK_MISC_C__)
|
||||
gtk_misc_get_alignment
|
||||
gtk_misc_get_padding
|
||||
gtk_misc_get_padding_unit
|
||||
gtk_misc_get_type G_GNUC_CONST
|
||||
gtk_misc_set_alignment
|
||||
gtk_misc_set_padding
|
||||
|
||||
121
gtk/gtkmisc.c
121
gtk/gtkmisc.c
@@ -40,6 +40,14 @@ enum {
|
||||
PROP_YPAD
|
||||
};
|
||||
|
||||
#define GTK_MISC_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTK_TYPE_MISC, GtkMiscPrivate))
|
||||
|
||||
struct _GtkMiscPrivate
|
||||
{
|
||||
GtkSize xpad_unit;
|
||||
GtkSize ypad_unit;
|
||||
};
|
||||
|
||||
static void gtk_misc_realize (GtkWidget *widget);
|
||||
static void gtk_misc_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -50,6 +58,7 @@ static void gtk_misc_get_property (GObject *object,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gtk_misc_unit_changed (GtkWidget *widget);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GtkMisc, gtk_misc, GTK_TYPE_WIDGET)
|
||||
|
||||
@@ -66,6 +75,7 @@ gtk_misc_class_init (GtkMiscClass *class)
|
||||
gobject_class->get_property = gtk_misc_get_property;
|
||||
|
||||
widget_class->realize = gtk_misc_realize;
|
||||
widget_class->unit_changed = gtk_misc_unit_changed;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_XALIGN,
|
||||
@@ -89,32 +99,33 @@ gtk_misc_class_init (GtkMiscClass *class)
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_XPAD,
|
||||
g_param_spec_int ("xpad",
|
||||
P_("X pad"),
|
||||
P_("The amount of space to add on the left and right of the widget, in pixels"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
gtk_param_spec_size ("xpad",
|
||||
P_("X pad"),
|
||||
P_("The amount of space to add on the left and right of the widget, in pixels"),
|
||||
0, G_MAXINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_YPAD,
|
||||
g_param_spec_int ("ypad",
|
||||
P_("Y pad"),
|
||||
P_("The amount of space to add on the top and bottom of the widget, in pixels"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READWRITE));
|
||||
gtk_param_spec_size ("ypad",
|
||||
P_("Y pad"),
|
||||
P_("The amount of space to add on the top and bottom of the widget, in pixels"),
|
||||
0, G_MAXINT, 0,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (GtkMiscPrivate));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_misc_init (GtkMisc *misc)
|
||||
{
|
||||
GtkMiscPrivate *priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
misc->xalign = 0.5;
|
||||
misc->yalign = 0.5;
|
||||
misc->xpad = 0;
|
||||
misc->ypad = 0;
|
||||
priv->xpad_unit = 0;
|
||||
priv->ypad_unit = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -124,8 +135,10 @@ gtk_misc_set_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkMisc *misc;
|
||||
GtkMiscPrivate *priv;
|
||||
|
||||
misc = GTK_MISC (object);
|
||||
priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@@ -136,10 +149,10 @@ gtk_misc_set_property (GObject *object,
|
||||
gtk_misc_set_alignment (misc, misc->xalign, g_value_get_float (value));
|
||||
break;
|
||||
case PROP_XPAD:
|
||||
gtk_misc_set_padding (misc, g_value_get_int (value), misc->ypad);
|
||||
gtk_misc_set_padding (misc, gtk_value_get_size (value), priv->ypad_unit);
|
||||
break;
|
||||
case PROP_YPAD:
|
||||
gtk_misc_set_padding (misc, misc->xpad, g_value_get_int (value));
|
||||
gtk_misc_set_padding (misc, priv->xpad_unit, gtk_value_get_size (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@@ -154,8 +167,10 @@ gtk_misc_get_property (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GtkMisc *misc;
|
||||
GtkMiscPrivate *priv;
|
||||
|
||||
misc = GTK_MISC (object);
|
||||
priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
@@ -166,10 +181,10 @@ gtk_misc_get_property (GObject *object,
|
||||
g_value_set_float (value, misc->yalign);
|
||||
break;
|
||||
case PROP_XPAD:
|
||||
g_value_set_int (value, misc->xpad);
|
||||
gtk_value_set_size (value, priv->xpad_unit, misc);
|
||||
break;
|
||||
case PROP_YPAD:
|
||||
g_value_set_int (value, misc->ypad);
|
||||
gtk_value_set_size (value, priv->ypad_unit, misc);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
@@ -244,33 +259,36 @@ gtk_misc_get_alignment (GtkMisc *misc,
|
||||
|
||||
void
|
||||
gtk_misc_set_padding (GtkMisc *misc,
|
||||
gint xpad,
|
||||
gint ypad)
|
||||
GtkSize xpad,
|
||||
GtkSize ypad)
|
||||
{
|
||||
GtkMiscPrivate *priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
GtkRequisition *requisition;
|
||||
|
||||
g_return_if_fail (GTK_IS_MISC (misc));
|
||||
|
||||
if (xpad < 0)
|
||||
if (gtk_widget_size_to_pixel (misc, xpad) < 0)
|
||||
xpad = 0;
|
||||
if (ypad < 0)
|
||||
if (gtk_widget_size_to_pixel (misc, ypad) < 0)
|
||||
ypad = 0;
|
||||
|
||||
if ((xpad != misc->xpad) || (ypad != misc->ypad))
|
||||
if ((xpad != priv->xpad_unit) || (ypad != priv->ypad_unit))
|
||||
{
|
||||
g_object_freeze_notify (G_OBJECT (misc));
|
||||
if (xpad != misc->xpad)
|
||||
if (xpad != priv->xpad_unit)
|
||||
g_object_notify (G_OBJECT (misc), "xpad");
|
||||
|
||||
if (ypad != misc->ypad)
|
||||
if (ypad != priv->ypad_unit)
|
||||
g_object_notify (G_OBJECT (misc), "ypad");
|
||||
|
||||
requisition = &(GTK_WIDGET (misc)->requisition);
|
||||
requisition->width -= misc->xpad * 2;
|
||||
requisition->height -= misc->ypad * 2;
|
||||
|
||||
misc->xpad = xpad;
|
||||
misc->ypad = ypad;
|
||||
misc->xpad = gtk_widget_size_to_pixel (misc, xpad);
|
||||
misc->ypad = gtk_widget_size_to_pixel (misc, ypad);
|
||||
priv->xpad_unit = xpad;
|
||||
priv->ypad_unit = ypad;
|
||||
|
||||
requisition->width += misc->xpad * 2;
|
||||
requisition->height += misc->ypad * 2;
|
||||
@@ -296,12 +314,43 @@ gtk_misc_get_padding (GtkMisc *misc,
|
||||
gint *xpad,
|
||||
gint *ypad)
|
||||
{
|
||||
GtkMiscPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_MISC (misc));
|
||||
|
||||
priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
|
||||
if (xpad)
|
||||
*xpad = misc->xpad;
|
||||
*xpad = gtk_widget_size_to_pixel (misc, priv->xpad_unit);
|
||||
if (ypad)
|
||||
*ypad = misc->ypad;
|
||||
*ypad = gtk_widget_size_to_pixel (misc, priv->ypad_unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_misc_get_padding_unit:
|
||||
* @misc: a #GtkMisc
|
||||
* @xpad: location to store padding in the X direction, or %NULL
|
||||
* @ypad: location to store padding in the Y direction, or %NULL
|
||||
*
|
||||
* Like gtk_misc_get_padding() but preserves the unit.
|
||||
*
|
||||
* Since: 2.14
|
||||
**/
|
||||
void
|
||||
gtk_misc_get_padding_unit (GtkMisc *misc,
|
||||
GtkSize *xpad,
|
||||
GtkSize *ypad)
|
||||
{
|
||||
GtkMiscPrivate *priv;
|
||||
|
||||
g_return_if_fail (GTK_IS_MISC (misc));
|
||||
|
||||
priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
|
||||
if (xpad)
|
||||
*xpad = priv->xpad_unit;
|
||||
if (ypad)
|
||||
*ypad = priv->ypad_unit;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -339,5 +388,19 @@ gtk_misc_realize (GtkWidget *widget)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_misc_unit_changed (GtkWidget *widget)
|
||||
{
|
||||
GtkMisc *misc = GTK_MISC (widget);
|
||||
GtkMiscPrivate *priv = GTK_MISC_GET_PRIVATE (misc);
|
||||
|
||||
misc->xpad = gtk_widget_size_to_pixel (misc, priv->xpad_unit);
|
||||
misc->ypad = gtk_widget_size_to_pixel (misc, priv->ypad_unit);
|
||||
|
||||
/* must chain up */
|
||||
if (GTK_WIDGET_CLASS (gtk_misc_parent_class)->unit_changed != NULL)
|
||||
GTK_WIDGET_CLASS (gtk_misc_parent_class)->unit_changed (widget);
|
||||
}
|
||||
|
||||
#define __GTK_MISC_C__
|
||||
#include "gtkaliasdef.c"
|
||||
|
||||
@@ -47,6 +47,7 @@ G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkMisc GtkMisc;
|
||||
typedef struct _GtkMiscClass GtkMiscClass;
|
||||
typedef struct _GtkMiscPrivate GtkMiscPrivate;
|
||||
|
||||
struct _GtkMisc
|
||||
{
|
||||
@@ -73,11 +74,14 @@ void gtk_misc_get_alignment (GtkMisc *misc,
|
||||
gfloat *xalign,
|
||||
gfloat *yalign);
|
||||
void gtk_misc_set_padding (GtkMisc *misc,
|
||||
gint xpad,
|
||||
gint ypad);
|
||||
GtkSize xpad,
|
||||
GtkSize ypad);
|
||||
void gtk_misc_get_padding (GtkMisc *misc,
|
||||
gint *xpad,
|
||||
gint *ypad);
|
||||
void gtk_misc_get_padding_unit (GtkMisc *misc,
|
||||
GtkSize *xpad,
|
||||
GtkSize *ypad);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -448,29 +448,23 @@ gtk_range_class_init (GtkRangeClass *class)
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("slider-width",
|
||||
P_("Slider Width"),
|
||||
P_("Width of scrollbar or scale thumb"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
14,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("slider-width",
|
||||
P_("Slider Width"),
|
||||
P_("Width of scrollbar or scale thumb"),
|
||||
0, G_MAXINT, GTK_SIZE_ONE_TWELFTH_EM (14),
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("trough-border",
|
||||
P_("Trough Border"),
|
||||
P_("Spacing between thumb/steppers and outer trough bevel"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
1,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("trough-border",
|
||||
P_("Trough Border"),
|
||||
P_("Spacing between thumb/steppers and outer trough bevel"),
|
||||
0, G_MAXINT, GTK_SIZE_ONE_TWELFTH_EM (1),
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("stepper-size",
|
||||
P_("Stepper Size"),
|
||||
P_("Length of step buttons at ends"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
14,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("stepper-size",
|
||||
P_("Stepper Size"),
|
||||
P_("Length of step buttons at ends"),
|
||||
0, G_MAXINT, GTK_SIZE_ONE_TWELFTH_EM (14),
|
||||
GTK_PARAM_READABLE));
|
||||
/**
|
||||
* GtkRange:stepper-spacing:
|
||||
*
|
||||
@@ -480,29 +474,23 @@ gtk_range_class_init (GtkRangeClass *class)
|
||||
* stepper-spacing won't have any effect if there are no steppers.
|
||||
*/
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("stepper-spacing",
|
||||
P_("Stepper Spacing"),
|
||||
P_("Spacing between step buttons and thumb"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("stepper-spacing",
|
||||
P_("Stepper Spacing"),
|
||||
P_("Spacing between step buttons and thumb"),
|
||||
0, G_MAXINT, 0,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("arrow-displacement-x",
|
||||
P_("Arrow X Displacement"),
|
||||
P_("How far in the x direction to move the arrow when the button is depressed"),
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("arrow-displacement-x",
|
||||
P_("Arrow X Displacement"),
|
||||
P_("How far in the x direction to move the arrow when the button is depressed"),
|
||||
0, G_MAXINT, 0,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("arrow-displacement-y",
|
||||
P_("Arrow Y Displacement"),
|
||||
P_("How far in the y direction to move the arrow when the button is depressed"),
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
0,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("arrow-displacement-y",
|
||||
P_("Arrow Y Displacement"),
|
||||
P_("How far in the y direction to move the arrow when the button is depressed"),
|
||||
0, G_MAXINT, 0,
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_boolean ("activate-slider",
|
||||
@@ -661,7 +649,7 @@ gtk_range_init (GtkRange *range)
|
||||
range->update_policy = GTK_UPDATE_CONTINUOUS;
|
||||
range->inverted = FALSE;
|
||||
range->flippable = FALSE;
|
||||
range->min_slider_size = 1;
|
||||
range->min_slider_size = GTK_SIZE_ONE_TWELFTH_EM (1);
|
||||
range->has_stepper_a = FALSE;
|
||||
range->has_stepper_b = FALSE;
|
||||
range->has_stepper_c = FALSE;
|
||||
@@ -2935,7 +2923,7 @@ gtk_range_calc_request (GtkRange *range,
|
||||
|
||||
n_steppers = n_steppers_ab + n_steppers_cd;
|
||||
|
||||
slider_length = range->min_slider_size;
|
||||
slider_length = gtk_widget_size_to_pixel (range, range->min_slider_size);
|
||||
|
||||
range_rect->x = 0;
|
||||
range_rect->y = 0;
|
||||
@@ -3159,11 +3147,11 @@ gtk_range_calc_layout (GtkRange *range,
|
||||
height = ((bottom - top) * (range->adjustment->page_size /
|
||||
(range->adjustment->upper - range->adjustment->lower)));
|
||||
else
|
||||
height = range->min_slider_size;
|
||||
height = gtk_widget_size_to_pixel (range, range->min_slider_size);
|
||||
|
||||
if (height < range->min_slider_size ||
|
||||
if (height < gtk_widget_size_to_pixel (range, range->min_slider_size) ||
|
||||
range->slider_size_fixed)
|
||||
height = range->min_slider_size;
|
||||
height = gtk_widget_size_to_pixel (range, range->min_slider_size);
|
||||
|
||||
height = MIN (height, layout->trough.height);
|
||||
|
||||
@@ -3308,11 +3296,11 @@ gtk_range_calc_layout (GtkRange *range,
|
||||
width = ((right - left) * (range->adjustment->page_size /
|
||||
(range->adjustment->upper - range->adjustment->lower)));
|
||||
else
|
||||
width = range->min_slider_size;
|
||||
width = gtk_widget_size_to_pixel (range, range->min_slider_size);
|
||||
|
||||
if (width < range->min_slider_size ||
|
||||
if (width < gtk_widget_size_to_pixel (range, range->min_slider_size) ||
|
||||
range->slider_size_fixed)
|
||||
width = range->min_slider_size;
|
||||
width = gtk_widget_size_to_pixel (range, range->min_slider_size);
|
||||
|
||||
width = MIN (width, layout->trough.width);
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ static gboolean gtk_scale_expose (GtkWidget *widget,
|
||||
static void gtk_scale_real_get_layout_offsets (GtkScale *scale,
|
||||
gint *x,
|
||||
gint *y);
|
||||
static void gtk_scale_unit_changed (GtkWidget *widget);
|
||||
|
||||
G_DEFINE_ABSTRACT_TYPE (GtkScale, gtk_scale, GTK_TYPE_RANGE)
|
||||
|
||||
@@ -155,6 +156,7 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
widget_class->screen_changed = gtk_scale_screen_changed;
|
||||
widget_class->expose_event = gtk_scale_expose;
|
||||
widget_class->size_request = gtk_scale_size_request;
|
||||
widget_class->unit_changed = gtk_scale_unit_changed;
|
||||
|
||||
range_class->slider_detail = "Xscale";
|
||||
range_class->get_range_border = gtk_scale_get_range_border;
|
||||
@@ -222,22 +224,18 @@ gtk_scale_class_init (GtkScaleClass *class)
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("slider-length",
|
||||
P_("Slider Length"),
|
||||
P_("Length of scale's slider"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
31,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("slider-length",
|
||||
P_("Slider Length"),
|
||||
P_("Length of scale's slider"),
|
||||
0, G_MAXINT, GTK_SIZE_ONE_TWELFTH_EM (31),
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
gtk_widget_class_install_style_property (widget_class,
|
||||
g_param_spec_int ("value-spacing",
|
||||
P_("Value spacing"),
|
||||
P_("Space between value text and the slider/trough area"),
|
||||
0,
|
||||
G_MAXINT,
|
||||
2,
|
||||
GTK_PARAM_READABLE));
|
||||
gtk_param_spec_size ("value-spacing",
|
||||
P_("Value spacing"),
|
||||
P_("Space between value text and the slider/trough area"),
|
||||
0, G_MAXINT, GTK_SIZE_ONE_TWELFTH_EM (2),
|
||||
GTK_PARAM_READABLE));
|
||||
|
||||
/* All bindings (even arrow keys) are on both h/v scale, because
|
||||
* blind users etc. don't care about scale orientation.
|
||||
@@ -854,14 +852,14 @@ static void
|
||||
gtk_scale_style_set (GtkWidget *widget,
|
||||
GtkStyle *previous)
|
||||
{
|
||||
gint slider_length;
|
||||
GtkSize slider_length;
|
||||
GtkRange *range;
|
||||
|
||||
range = GTK_RANGE (widget);
|
||||
|
||||
gtk_widget_style_get (widget,
|
||||
"slider-length", &slider_length,
|
||||
NULL);
|
||||
gtk_widget_style_get_unit (widget,
|
||||
"slider-length", &slider_length,
|
||||
NULL);
|
||||
|
||||
range->min_slider_size = slider_length;
|
||||
|
||||
@@ -1355,6 +1353,14 @@ gtk_scale_add_mark (GtkScale *scale,
|
||||
gtk_widget_queue_resize (GTK_WIDGET (scale));
|
||||
}
|
||||
|
||||
gtk_scale_unit_changed (GtkWidget *widget)
|
||||
{
|
||||
/* must chain up */
|
||||
if (GTK_WIDGET_CLASS (gtk_scale_parent_class)->unit_changed != NULL)
|
||||
GTK_WIDGET_CLASS (gtk_scale_parent_class)->unit_changed (widget);
|
||||
|
||||
_gtk_scale_clear_layout (GTK_SCALE (widget));
|
||||
}
|
||||
|
||||
#define __GTK_SCALE_C__
|
||||
#include "gtkaliasdef.c"
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
#include "gtkintl.h"
|
||||
#include "gtkalias.h"
|
||||
|
||||
#define SCALE_SIZE 100
|
||||
#define SCALE_SIZE GTK_SIZE_ONE_TWELFTH_EM(100)
|
||||
#define CLICK_TIMEOUT 250
|
||||
|
||||
enum
|
||||
@@ -125,6 +125,7 @@ static gboolean gtk_scale_button_scroll (GtkWidget *widget,
|
||||
GdkEventScroll *event);
|
||||
static void gtk_scale_button_screen_changed (GtkWidget *widget,
|
||||
GdkScreen *previous_screen);
|
||||
static void gtk_scale_button_unit_changed (GtkWidget *widget);
|
||||
static gboolean gtk_scale_button_press (GtkWidget *widget,
|
||||
GdkEventButton *event);
|
||||
static gboolean gtk_scale_button_key_release (GtkWidget *widget,
|
||||
@@ -183,6 +184,7 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass)
|
||||
widget_class->key_release_event = gtk_scale_button_key_release;
|
||||
widget_class->scroll_event = gtk_scale_button_scroll;
|
||||
widget_class->screen_changed = gtk_scale_button_screen_changed;
|
||||
widget_class->unit_changed = gtk_scale_button_unit_changed;
|
||||
|
||||
/**
|
||||
* GtkScaleButton:orientation:
|
||||
@@ -943,9 +945,9 @@ gtk_scale_popup (GtkWidget *widget,
|
||||
y += widget->allocation.y;
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
|
||||
gtk_window_move (GTK_WINDOW (priv->dock), x, y - (SCALE_SIZE / 2));
|
||||
gtk_window_move (GTK_WINDOW (priv->dock), x, y - (gtk_widget_size_to_pixel (widget, SCALE_SIZE) / 2));
|
||||
else
|
||||
gtk_window_move (GTK_WINDOW (priv->dock), x - (SCALE_SIZE / 2), y);
|
||||
gtk_window_move (GTK_WINDOW (priv->dock), x - (gtk_widget_size_to_pixel (widget, SCALE_SIZE) / 2), y);
|
||||
|
||||
gtk_widget_show_all (priv->dock);
|
||||
|
||||
@@ -968,9 +970,9 @@ gtk_scale_popup (GtkWidget *widget,
|
||||
|
||||
x += (widget->allocation.width - priv->dock->allocation.width) / 2;
|
||||
y -= startoff;
|
||||
y -= GTK_RANGE (priv->scale)->min_slider_size / 2;
|
||||
y -= gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size) / 2;
|
||||
m = priv->scale->allocation.height -
|
||||
GTK_RANGE (priv->scale)->min_slider_size;
|
||||
gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size);
|
||||
y -= m * (1.0 - v);
|
||||
}
|
||||
else
|
||||
@@ -979,9 +981,9 @@ gtk_scale_popup (GtkWidget *widget,
|
||||
|
||||
x -= startoff;
|
||||
y += (widget->allocation.height - priv->dock->allocation.height) / 2;
|
||||
x -= GTK_RANGE (priv->scale)->min_slider_size / 2;
|
||||
x -= gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size) / 2;
|
||||
m = priv->scale->allocation.width -
|
||||
GTK_RANGE (priv->scale)->min_slider_size;
|
||||
gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size);
|
||||
x -= m * v;
|
||||
}
|
||||
|
||||
@@ -1061,15 +1063,15 @@ gtk_scale_popup (GtkWidget *widget,
|
||||
{
|
||||
e->x = priv->scale->allocation.width / 2;
|
||||
m = priv->scale->allocation.height -
|
||||
GTK_RANGE (priv->scale)->min_slider_size;
|
||||
e->y = ((1.0 - v) * m) + GTK_RANGE (priv->scale)->min_slider_size / 2;
|
||||
gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size);
|
||||
e->y = ((1.0 - v) * m) + gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
e->y = priv->scale->allocation.height / 2;
|
||||
m = priv->scale->allocation.width -
|
||||
GTK_RANGE (priv->scale)->min_slider_size;
|
||||
e->x = (v * m) + GTK_RANGE (priv->scale)->min_slider_size / 2;
|
||||
gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size);
|
||||
e->x = (v * m) + gtk_widget_size_to_pixel (widget, GTK_RANGE (priv->scale)->min_slider_size) / 2;
|
||||
}
|
||||
|
||||
gtk_widget_event (priv->scale, (GdkEvent *) e);
|
||||
@@ -1413,12 +1415,14 @@ gtk_scale_button_scale_new (GtkScaleButton *button)
|
||||
|
||||
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
|
||||
{
|
||||
gtk_widget_set_size_request (GTK_WIDGET (scale), -1, SCALE_SIZE);
|
||||
gtk_widget_set_size_request (GTK_WIDGET (scale), -1,
|
||||
gtk_widget_size_to_pixel (button, SCALE_SIZE));
|
||||
gtk_range_set_inverted (GTK_RANGE (scale), TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_set_size_request (GTK_WIDGET (scale), SCALE_SIZE, -1);
|
||||
gtk_widget_set_size_request (GTK_WIDGET (scale),
|
||||
gtk_widget_size_to_pixel (button, SCALE_SIZE), -1);
|
||||
gtk_range_set_inverted (GTK_RANGE (scale), FALSE);
|
||||
}
|
||||
|
||||
@@ -1564,5 +1568,18 @@ gtk_scale_button_scale_value_changed (GtkRange *range)
|
||||
g_object_notify (G_OBJECT (button), "value");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_button_unit_changed (GtkWidget *widget)
|
||||
{
|
||||
GtkScaleButton *scale_button = GTK_SCALE_BUTTON (widget);
|
||||
|
||||
/* must chain up */
|
||||
if (GTK_WIDGET_CLASS (gtk_scale_button_parent_class)->unit_changed != NULL)
|
||||
GTK_WIDGET_CLASS (gtk_scale_button_parent_class)->unit_changed (widget);
|
||||
|
||||
gtk_scale_button_update_icon (scale_button);
|
||||
}
|
||||
|
||||
|
||||
#define __GTK_SCALE_BUTTON_C__
|
||||
#include "gtkaliasdef.c"
|
||||
|
||||
Reference in New Issue
Block a user