summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Valavanis <valavanisalex@gmail.com>2012-01-06 00:44:17 +0000
committerAlex Valavanis <valavanisalex@gmail.com>2012-01-06 00:44:17 +0000
commita6eeea52037e555b85631f3006c0d0da1b93fcb0 (patch)
tree3f29d61198b992deaa9678a7d2458b16b8b1ff8c /src
parentadd toolbutton menu action type. now the add extremum node buttons are somewh... (diff)
downloadinkscape-a6eeea52037e555b85631f3006c0d0da1b93fcb0.tar.gz
inkscape-a6eeea52037e555b85631f3006c0d0da1b93fcb0.zip
More GSEAL stuff
(bzr r10850)
Diffstat (limited to 'src')
-rw-r--r--src/widgets/ruler.cpp66
-rw-r--r--src/widgets/select-toolbar.cpp20
-rw-r--r--src/widgets/sp-color-scales.cpp7
-rw-r--r--src/widgets/sp-color-wheel-selector.cpp7
-rw-r--r--src/widgets/sp-widget.cpp24
5 files changed, 79 insertions, 45 deletions
diff --git a/src/widgets/ruler.cpp b/src/widgets/ruler.cpp
index 7baa0a172..796a50876 100644
--- a/src/widgets/ruler.cpp
+++ b/src/widgets/ruler.cpp
@@ -79,11 +79,15 @@ sp_hruler_class_init (SPHRulerClass *klass)
static void
sp_hruler_init (SPHRuler *hruler)
{
- GtkWidget *widget;
+ GtkWidget *widget;
+ GtkRequisition requisition;
+ GtkStyle *style;
widget = GTK_WIDGET (hruler);
- widget->requisition.width = widget->style->xthickness * 2 + 1;
- widget->requisition.height = widget->style->ythickness * 2 + RULER_HEIGHT;
+ gtk_widget_get_requisition (widget, &requisition);
+ style = gtk_widget_get_style (widget);
+ requisition.width = style->xthickness * 2 + 1;
+ requisition.height = style->ythickness * 2 + RULER_HEIGHT;
}
@@ -97,17 +101,21 @@ static gint
sp_hruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkRuler *ruler;
+ GtkRuler *ruler;
+ gdouble lower, upper, max_size;
+ GtkAllocation allocation;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (SP_IS_HRULER (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
ruler = GTK_RULER (widget);
+ gtk_ruler_get_range (ruler, &lower, &upper, NULL, &max_size);
+ gtk_widget_get_allocation (widget, &allocation);
double x = event->x; //Although event->x is double according to the docs, it only appears to return integers
- double pos = ruler->lower + (ruler->upper - ruler->lower) * (x + UNUSED_PIXELS) / (widget->allocation.width + 2*UNUSED_PIXELS);
+ double pos = lower + (upper - lower) * (x + UNUSED_PIXELS) / (allocation.width + 2*UNUSED_PIXELS);
- gtk_ruler_set_range(ruler, ruler->lower, ruler->upper, pos, ruler->max_size);
+ gtk_ruler_set_range(ruler, lower, upper, pos, max_size);
return FALSE;
}
@@ -166,11 +174,15 @@ sp_vruler_class_init (SPVRulerClass *klass)
static void
sp_vruler_init (SPVRuler *vruler)
{
- GtkWidget *widget;
+ GtkWidget *widget;
+ GtkRequisition requisition;
+ GtkStyle *style;
widget = GTK_WIDGET (vruler);
- widget->requisition.width = widget->style->xthickness * 2 + RULER_WIDTH;
- widget->requisition.height = widget->style->ythickness * 2 + 1;
+ gtk_widget_get_requisition (widget, &requisition);
+ style = gtk_widget_get_style (widget);
+ requisition.width = style->xthickness * 2 + RULER_WIDTH;
+ requisition.height = style->ythickness * 2 + 1;
g_object_set(G_OBJECT(vruler), "orientation", GTK_ORIENTATION_VERTICAL, NULL);
}
@@ -186,17 +198,21 @@ static gint
sp_vruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
- GtkRuler *ruler;
+ GtkRuler *ruler;
+ gdouble lower, upper, max_size;
+ GtkAllocation allocation;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (SP_IS_VRULER (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
ruler = GTK_RULER (widget);
+ gtk_ruler_get_range (ruler, &lower, &upper, NULL, &max_size);
+ gtk_widget_get_allocation (widget, &allocation);
double y = event->y; //Although event->y is double according to the docs, it only appears to return integers
- double pos = ruler->lower + (ruler->upper - ruler->lower) * (y + UNUSED_PIXELS) / (widget->allocation.height + 2*UNUSED_PIXELS);
+ double pos = lower + (upper - lower) * (y + UNUSED_PIXELS) / (allocation.height + 2*UNUSED_PIXELS);
- gtk_ruler_set_range(ruler, ruler->lower, ruler->upper, pos, ruler->max_size);
+ gtk_ruler_set_range(ruler, lower, upper, pos, max_size);
return FALSE;
}
@@ -204,7 +220,8 @@ sp_vruler_motion_notify (GtkWidget *widget,
static void
sp_vruler_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
- requisition->width = widget->style->xthickness * 2 + RULER_WIDTH;
+ GtkStyle *style = gtk_widget_get_style (widget);
+ requisition->width = style->xthickness * 2 + RULER_WIDTH;
}
static void
@@ -231,6 +248,8 @@ sp_ruler_common_draw_ticks (GtkRuler *ruler)
gint text_dimension;
gint pos;
GtkOrientation orientation;
+ GtkStyle *style;
+ GtkAllocation allocation;
g_return_if_fail (ruler != NULL);
@@ -239,7 +258,8 @@ sp_ruler_common_draw_ticks (GtkRuler *ruler)
g_object_get(G_OBJECT(ruler), "orientation", &orientation, NULL);
widget = GTK_WIDGET (ruler);
- gc = widget->style->fg_gc[GTK_STATE_NORMAL];
+ style = gtk_widget_get_style (widget);
+ gc = style->fg_gc[GTK_STATE_NORMAL];
pango_context = gtk_widget_get_pango_context (widget);
pango_layout = pango_layout_new (pango_context);
@@ -249,22 +269,24 @@ sp_ruler_common_draw_ticks (GtkRuler *ruler)
pango_font_description_free (fs);
digit_height = (int) floor (RULER_FONT_SIZE * RULER_FONT_VERTICAL_SPACING / PANGO_SCALE + 0.5);
- xthickness = widget->style->xthickness;
- ythickness = widget->style->ythickness;
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
+ gtk_widget_get_allocation (widget, &allocation);
+
if (orientation == GTK_ORIENTATION_HORIZONTAL) {
- width = widget->allocation.width; // in pixels; is apparently 2 pixels shorter than the canvas at each end
- height = widget->allocation.height;
+ width = allocation.width; // in pixels; is apparently 2 pixels shorter than the canvas at each end
+ height = allocation.height;
} else {
- width = widget->allocation.height;
- height = widget->allocation.width;
+ width = allocation.height;
+ height = allocation.width;
}
- gtk_paint_box (widget->style, ruler->backing_store,
+ gtk_paint_box (style, ruler->backing_store,
GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, widget,
orientation == GTK_ORIENTATION_HORIZONTAL ? "hruler" : "vruler",
0, 0,
- widget->allocation.width, widget->allocation.height);
+ allocation.width, allocation.height);
upper = ruler->upper / ruler->metric->pixels_per_unit; // upper and lower are expressed in ruler units
lower = ruler->lower / ruler->metric->pixels_per_unit;
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index 38346ce56..83cbe98ff 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -187,20 +187,20 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw)
GtkAdjustment* a_h = GTK_ADJUSTMENT( g_object_get_data( G_OBJECT(spw), "height" ) );
if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) {
- x0 = sp_units_get_pixels (a_x->value, unit);
- y0 = sp_units_get_pixels (a_y->value, unit);
- x1 = x0 + sp_units_get_pixels (a_w->value, unit);
- xrel = sp_units_get_pixels (a_w->value, unit) / bbox_user->dimensions()[Geom::X];
- y1 = y0 + sp_units_get_pixels (a_h->value, unit);
- yrel = sp_units_get_pixels (a_h->value, unit) / bbox_user->dimensions()[Geom::Y];
+ x0 = sp_units_get_pixels (gtk_adjustment_get_value (a_x), unit);
+ y0 = sp_units_get_pixels (gtk_adjustment_get_value (a_y), unit);
+ x1 = x0 + sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit);
+ xrel = sp_units_get_pixels (gtk_adjustment_get_value (a_w), unit) / bbox_user->dimensions()[Geom::X];
+ y1 = y0 + sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit);
+ yrel = sp_units_get_pixels (gtk_adjustment_get_value (a_h), unit) / bbox_user->dimensions()[Geom::Y];
} else {
- double const x0_propn = a_x->value * unit.unittobase;
+ double const x0_propn = gtk_adjustment_get_value (a_x) * unit.unittobase;
x0 = bbox_user->min()[Geom::X] * x0_propn;
- double const y0_propn = a_y->value * unit.unittobase;
+ double const y0_propn = gtk_adjustment_get_value (a_y) * unit.unittobase;
y0 = y0_propn * bbox_user->min()[Geom::Y];
- xrel = a_w->value * unit.unittobase;
+ xrel = gtk_adjustment_get_value (a_w) * unit.unittobase;
x1 = x0 + xrel * bbox_user->dimensions()[Geom::X];
- yrel = a_h->value * unit.unittobase;
+ yrel = gtk_adjustment_get_value (a_h) * unit.unittobase;
y1 = y0 + yrel * bbox_user->dimensions()[Geom::Y];
}
diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp
index c07e44aa6..eaf81f240 100644
--- a/src/widgets/sp-color-scales.cpp
+++ b/src/widgets/sp-color-scales.cpp
@@ -255,13 +255,14 @@ void ColorScales::_recalcColor( gboolean changing )
/* Helpers for setting color value */
gfloat ColorScales::getScaled( const GtkAdjustment *a )
{
- gfloat val = a->value / a->upper;
+ gfloat val = gtk_adjustment_get_value (const_cast<GtkAdjustment*>(a))
+ / gtk_adjustment_get_upper (const_cast<GtkAdjustment*>(a));
return val;
}
void ColorScales::setScaled( GtkAdjustment *a, gfloat v )
{
- gfloat val = v * a->upper;
+ gfloat val = v * gtk_adjustment_get_upper (a);
gtk_adjustment_set_value( a, val );
}
@@ -269,7 +270,7 @@ void ColorScales::_setRangeLimit( gdouble upper )
{
_rangeLimit = upper;
for ( gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++ ) {
- _a[i]->upper = upper;
+ gtk_adjustment_set_upper (_a[i], upper);
gtk_adjustment_changed( _a[i] );
}
}
diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp
index 89008288a..a16f70500 100644
--- a/src/widgets/sp-color-wheel-selector.cpp
+++ b/src/widgets/sp-color-wheel-selector.cpp
@@ -283,8 +283,11 @@ void ColorWheelSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorW
{
// TODO check this. It looks questionable:
// if a value is entered between 0 and 1 exclusive, normalize it to (int) 0..255 or 0..100
- if (adjustment->value > 0.0 && adjustment->value < 1.0) {
- gtk_adjustment_set_value( adjustment, floor ((adjustment->value) * adjustment->upper + 0.5) );
+ gdouble value = gtk_adjustment_get_value (adjustment);
+ gdouble upper = gtk_adjustment_get_upper (adjustment);
+
+ if (value > 0.0 && value < 1.0) {
+ gtk_adjustment_set_value( adjustment, floor (value * upper + 0.5) );
}
ColorWheelSelector* wheelSelector = (ColorWheelSelector*)(SP_COLOR_SELECTOR(cs)->base);
diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp
index ef8a6c03c..97af9c7fa 100644
--- a/src/widgets/sp-widget.cpp
+++ b/src/widgets/sp-widget.cpp
@@ -181,12 +181,14 @@ sp_widget_hide (GtkWidget *widget)
static gint
sp_widget_expose (GtkWidget *widget, GdkEventExpose *event)
{
- GtkBin *bin;
+ GtkBin *bin;
+ GtkWidget *child;
bin = GTK_BIN (widget);
+ child = gtk_bin_get_child (bin);
- if ( bin->child ) {
- gtk_container_propagate_expose (GTK_CONTAINER(widget), bin->child, event);
+ if (child) {
+ gtk_container_propagate_expose (GTK_CONTAINER(widget), child, event);
}
/*
if ((bin->child) && (!gtk_widget_get_has_window (bin->child))) {
@@ -202,17 +204,23 @@ sp_widget_expose (GtkWidget *widget, GdkEventExpose *event)
static void
sp_widget_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
- if (((GtkBin *) widget)->child)
- gtk_widget_size_request (((GtkBin *) widget)->child, requisition);
+ GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child = gtk_bin_get_child (bin);
+
+ if (child)
+ gtk_widget_size_request (child, requisition);
}
static void
sp_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
- widget->allocation = *allocation;
+ GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child = gtk_bin_get_child (bin);
+
+ gtk_widget_set_allocation (widget, allocation);
- if (((GtkBin *) widget)->child)
- gtk_widget_size_allocate (((GtkBin *) widget)->child, allocation);
+ if (child)
+ gtk_widget_size_allocate (child, allocation);
}
/* Methods */