Commit fcd346a2 authored by Michael Natterer's avatar Michael Natterer 😴

Build with GSEAL_ENABLE with a few exceptions

Use the new accessors in GTK+ 2.18 and #undef GSEAL_ENABLE where
accessors are missing or where I'm not quite sure how to fix the
stuff yet.
parent ee48b7b0
......@@ -177,24 +177,29 @@ gimp_cell_renderer_color_get_size (GtkCellRenderer *cell,
GimpCellRendererColor *color = GIMP_CELL_RENDERER_COLOR (cell);
gint calc_width;
gint calc_height;
gfloat xalign;
gfloat yalign;
gint xpad;
gint ypad;
gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (widget),
color->size, &calc_width, &calc_height);
gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
if (cell_area && calc_width > 0 && calc_height > 0)
{
if (x_offset)
{
*x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
1.0 - cell->xalign : cell->xalign) *
1.0 - xalign : xalign) *
(cell_area->width - calc_width));
*x_offset = MAX (*x_offset, 0) + cell->xpad;
*x_offset = MAX (*x_offset, 0) + xpad;
}
if (y_offset)
{
*y_offset = (cell->yalign *
(cell_area->height - calc_height));
*y_offset = MAX (*y_offset, 0) + cell->ypad;
*y_offset = (yalign * (cell_area->height - calc_height));
*y_offset = MAX (*y_offset, 0) + ypad;
}
}
else
......@@ -206,9 +211,9 @@ gimp_cell_renderer_color_get_size (GtkCellRenderer *cell,
}
if (width)
*width = calc_width + 2 * cell->xpad;
*width = calc_width + 2 * xpad;
if (height)
*height = calc_height + 2 * cell->ypad;
*height = calc_height + 2 * ypad;
}
static void
......@@ -222,6 +227,8 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
{
GimpCellRendererColor *color = GIMP_CELL_RENDERER_COLOR (cell);
GdkRectangle rect;
gint xpad;
gint ypad;
gimp_cell_renderer_color_get_size (cell, widget, cell_area,
&rect.x,
......@@ -229,10 +236,12 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
&rect.width,
&rect.height);
rect.x += cell_area->x + cell->xpad;
rect.y += cell_area->y + cell->ypad;
rect.width -= 2 * cell->xpad;
rect.height -= 2 * cell->ypad;
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
rect.x += cell_area->x + xpad;
rect.y += cell_area->y + ypad;
rect.width -= 2 * xpad;
rect.height -= 2 * ypad;
if (rect.width > 2 && rect.height > 2)
{
......@@ -273,8 +282,8 @@ gimp_cell_renderer_color_render (GtkCellRenderer *cell,
rect.x + 0.5, rect.y + 0.5,
rect.width - 1, rect.height - 1);
if (! cell->sensitive ||
GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE)
if (! gtk_cell_renderer_get_sensitive (cell) ||
! gtk_widget_is_sensitive (widget))
{
state = GTK_STATE_INSENSITIVE;
}
......
......@@ -224,6 +224,10 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
gint calc_height;
gint pixbuf_width;
gint pixbuf_height;
gfloat xalign;
gfloat yalign;
gint xpad;
gint ypad;
if (! toggle->stock_id)
{
......@@ -235,6 +239,9 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
return;
}
gtk_cell_renderer_get_alignment (cell, &xalign, &yalign);
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
if (! toggle->pixbuf)
gimp_cell_renderer_toggle_create_pixbuf (toggle, widget);
......@@ -242,9 +249,9 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
pixbuf_height = gdk_pixbuf_get_height (toggle->pixbuf);
calc_width = (pixbuf_width +
(gint) cell->xpad * 2 + style->xthickness * 2);
(gint) xpad * 2 + style->xthickness * 2);
calc_height = (pixbuf_height +
(gint) cell->ypad * 2 + style->ythickness * 2);
(gint) ypad * 2 + style->ythickness * 2);
if (width)
*width = calc_width;
......@@ -257,14 +264,14 @@ gimp_cell_renderer_toggle_get_size (GtkCellRenderer *cell,
if (x_offset)
{
*x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ?
(1.0 - cell->xalign) : cell->xalign) *
(1.0 - xalign) : xalign) *
(cell_area->width - calc_width));
*x_offset = MAX (*x_offset, 0);
}
if (y_offset)
{
*y_offset = cell->yalign * (cell_area->height - calc_height);
*y_offset = yalign * (cell_area->height - calc_height);
*y_offset = MAX (*y_offset, 0);
}
}
......@@ -285,6 +292,8 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
GdkRectangle draw_rect;
GtkStateType state;
gboolean active;
gint xpad;
gint ypad;
if (! toggle->stock_id)
{
......@@ -301,10 +310,12 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
&toggle_rect.width,
&toggle_rect.height);
toggle_rect.x += cell_area->x + cell->xpad;
toggle_rect.y += cell_area->y + cell->ypad;
toggle_rect.width -= cell->xpad * 2;
toggle_rect.height -= cell->ypad * 2;
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
toggle_rect.x += cell_area->x + xpad;
toggle_rect.y += cell_area->y + ypad;
toggle_rect.width -= xpad * 2;
toggle_rect.height -= ypad * 2;
if (toggle_rect.width <= 0 || toggle_rect.height <= 0)
return;
......@@ -314,14 +325,14 @@ gimp_cell_renderer_toggle_render (GtkCellRenderer *cell,
if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
{
if (GTK_WIDGET_HAS_FOCUS (widget))
if (gtk_widget_has_focus (widget))
state = GTK_STATE_SELECTED;
else
state = GTK_STATE_ACTIVE;
}
else
{
if (GTK_CELL_RENDERER_TOGGLE (cell)->activatable)
if (gtk_cell_renderer_toggle_get_activatable (GTK_CELL_RENDERER_TOGGLE (cell)))
state = GTK_STATE_NORMAL;
else
state = GTK_STATE_INSENSITIVE;
......@@ -372,7 +383,7 @@ gimp_cell_renderer_toggle_activate (GtkCellRenderer *cell,
{
GtkCellRendererToggle *toggle = GTK_CELL_RENDERER_TOGGLE (cell);
if (toggle->activatable)
if (gtk_cell_renderer_toggle_get_activatable (toggle))
{
GdkModifierType state = 0;
......
......@@ -335,7 +335,7 @@ gimp_chain_line_class_init (GimpChainLineClass *klass)
static void
gimp_chain_line_init (GimpChainLine *line)
{
GTK_WIDGET_SET_FLAGS (line, GTK_NO_WINDOW);
gtk_widget_set_has_window (GTK_WIDGET (line), FALSE);
}
static GtkWidget *
......@@ -355,14 +355,17 @@ gimp_chain_line_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
GimpChainLine *line = ((GimpChainLine *) widget);
GtkAllocation allocation;
GdkPoint points[3];
GdkPoint buf;
GtkShadowType shadow;
GimpChainPosition position;
gtk_widget_get_allocation (widget, &allocation);
#define SHORT_LINE 4
points[0].x = widget->allocation.x + widget->allocation.width / 2;
points[0].y = widget->allocation.y + widget->allocation.height / 2;
points[0].x = allocation.x + allocation.width / 2;
points[0].y = allocation.y + allocation.height / 2;
position = line->position;
......@@ -392,8 +395,8 @@ gimp_chain_line_expose_event (GtkWidget *widget,
points[1].y = points[0].y;
points[2].x = points[1].x;
points[2].y = (line->which == 1 ?
widget->allocation.y + widget->allocation.height - 1 :
widget->allocation.y);
allocation.y + allocation.height - 1 :
allocation.y);
shadow = GTK_SHADOW_ETCHED_IN;
break;
......@@ -403,8 +406,8 @@ gimp_chain_line_expose_event (GtkWidget *widget,
points[1].y = points[0].y;
points[2].x = points[1].x;
points[2].y = (line->which == 1 ?
widget->allocation.y + widget->allocation.height - 1 :
widget->allocation.y);
allocation.y + allocation.height - 1 :
allocation.y);
shadow = GTK_SHADOW_ETCHED_OUT;
break;
......@@ -413,8 +416,8 @@ gimp_chain_line_expose_event (GtkWidget *widget,
points[1].x = points[0].x;
points[1].y = points[0].y - SHORT_LINE;
points[2].x = (line->which == 1 ?
widget->allocation.x + widget->allocation.width - 1 :
widget->allocation.x);
allocation.x + allocation.width - 1 :
allocation.x);
points[2].y = points[1].y;
shadow = GTK_SHADOW_ETCHED_OUT;
break;
......@@ -424,8 +427,8 @@ gimp_chain_line_expose_event (GtkWidget *widget,
points[1].x = points[0].x;
points[1].y = points[0].y + SHORT_LINE;
points[2].x = (line->which == 1 ?
widget->allocation.x + widget->allocation.width - 1 :
widget->allocation.x);
allocation.x + allocation.width - 1 :
allocation.x);
points[2].y = points[1].y;
shadow = GTK_SHADOW_ETCHED_IN;
break;
......
......@@ -289,11 +289,11 @@ gimp_color_area_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_CLASS (parent_class)->size_allocate)
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
if (widget->allocation.width != area->width ||
widget->allocation.height != area->height)
if (allocation->width != area->width ||
allocation->height != area->height)
{
area->width = widget->allocation.width;
area->height = widget->allocation.height;
area->width = allocation->width;
area->height = allocation->height;
area->rowstride = (area->width * 3 + 3) & ~0x3;
......@@ -308,7 +308,7 @@ static void
gimp_color_area_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
if (widget->state == GTK_STATE_INSENSITIVE ||
if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE ||
previous_state == GTK_STATE_INSENSITIVE)
{
GIMP_COLOR_AREA (widget)->needs_render = TRUE;
......@@ -326,7 +326,7 @@ gimp_color_area_expose (GtkWidget *widget,
GtkStyle *style = gtk_widget_get_style (widget);
guchar *buf;
if (! area->buf || ! GTK_WIDGET_DRAWABLE (widget))
if (! area->buf || ! gtk_widget_is_drawable (widget))
return FALSE;
if (area->needs_render)
......@@ -348,7 +348,7 @@ gimp_color_area_expose (GtkWidget *widget,
if (area->draw_border)
gdk_draw_rectangle (gtk_widget_get_window (widget),
style->fg_gc[widget->state],
style->fg_gc[gtk_widget_get_state (widget)],
FALSE,
0, 0,
area->width - 1, area->height - 1);
......@@ -645,7 +645,7 @@ gimp_color_area_render (GimpColorArea *area)
return;
_gimp_color_area_render_buf (GTK_WIDGET (area),
! GTK_WIDGET_IS_SENSITIVE (area),
! gtk_widget_is_sensitive (GTK_WIDGET (area)),
area->type,
area->buf,
area->width, area->height, area->rowstride,
......
......@@ -455,7 +455,7 @@ gimp_color_button_state_changed (GtkWidget *widget,
{
g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget));
if (! GTK_WIDGET_IS_SENSITIVE (widget) && GIMP_COLOR_BUTTON (widget)->dialog)
if (! gtk_widget_is_sensitive (widget) && GIMP_COLOR_BUTTON (widget)->dialog)
gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog);
if (GTK_WIDGET_CLASS (parent_class)->state_changed)
......
......@@ -24,6 +24,8 @@
#include <string.h>
#undef GSEAL_ENABLE
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
......@@ -76,12 +78,13 @@ gimp_color_scale_init (GimpColorScale *scale)
{
GtkRange *range = GTK_RANGE (scale);
GTK_SCALE (scale)->draw_value = FALSE;
range->slider_size_fixed = TRUE;
range->flippable = TRUE;
/* range->update_policy = GTK_UPDATE_DELAYED; */
gtk_range_set_flippable (GTK_RANGE (scale), TRUE);
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
scale->channel = GIMP_COLOR_SELECTOR_VALUE;
scale->needs_render = TRUE;
......@@ -124,7 +127,7 @@ gimp_color_scale_size_allocate (GtkWidget *widget,
"trough-border", &trough_border,
NULL);
if (GTK_WIDGET_CAN_FOCUS (widget))
if (gtk_widget_get_can_focus (widget))
{
gint focus_padding = 0;
......@@ -175,7 +178,7 @@ static void
gimp_color_scale_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
if (widget->state == GTK_STATE_INSENSITIVE ||
if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE ||
previous_state == GTK_STATE_INSENSITIVE)
{
GIMP_COLOR_SCALE (widget)->needs_render = TRUE;
......@@ -239,6 +242,7 @@ gimp_color_scale_expose (GtkWidget *widget,
GtkRange *range = GTK_RANGE (widget);
GtkStyle *style = gtk_widget_get_style (widget);
GdkWindow *window = gtk_widget_get_window (widget);
GtkAllocation allocation;
GdkRectangle expose_area; /* Relative to widget->allocation */
GdkRectangle area;
gint focus = 0;
......@@ -247,7 +251,7 @@ gimp_color_scale_expose (GtkWidget *widget,
gint x, y;
gint w, h;
if (! scale->buf || ! GTK_WIDGET_DRAWABLE (widget))
if (! scale->buf || ! gtk_widget_is_drawable (widget))
return FALSE;
/* This is ugly as it relies heavily on GTK+ internals, but I see no
......@@ -266,7 +270,7 @@ gimp_color_scale_expose (GtkWidget *widget,
"trough-border", &trough_border,
NULL);
if (GTK_WIDGET_CAN_FOCUS (widget))
if (gtk_widget_get_can_focus (widget))
{
gint focus_padding = 0;
......@@ -277,20 +281,22 @@ gimp_color_scale_expose (GtkWidget *widget,
focus += focus_padding;
}
x = widget->allocation.x + range->range_rect.x + focus;
y = widget->allocation.y + range->range_rect.y + focus;
gtk_widget_get_allocation (widget, &allocation);
x = allocation.x + range->range_rect.x + focus;
y = allocation.y + range->range_rect.y + focus;
w = range->range_rect.width - 2 * focus;
h = range->range_rect.height - 2 * focus;
slider_size = range->min_slider_size / 2;
expose_area = event->area;
expose_area.x -= widget->allocation.x;
expose_area.y -= widget->allocation.y;
expose_area.x -= allocation.x;
expose_area.y -= allocation.y;
if (gdk_rectangle_intersect (&expose_area, &range->range_rect, &area))
{
gboolean sensitive = (GTK_WIDGET_STATE (widget) != GTK_STATE_INSENSITIVE);
gboolean sensitive = gtk_widget_is_sensitive (widget);
if (scale->needs_render)
{
......@@ -302,8 +308,8 @@ gimp_color_scale_expose (GtkWidget *widget,
scale->needs_render = FALSE;
}
area.x += widget->allocation.x;
area.y += widget->allocation.y;
area.x += allocation.x;
area.y += allocation.y;
gtk_paint_box (style, window,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
......@@ -345,18 +351,18 @@ gimp_color_scale_expose (GtkWidget *widget,
gdk_gc_set_clip_rectangle (style->black_gc, NULL);
}
if (GTK_WIDGET_IS_SENSITIVE (widget) && GTK_WIDGET_HAS_FOCUS (range))
gtk_paint_focus (style, window, GTK_WIDGET_STATE (widget),
if (gtk_widget_has_focus (widget))
gtk_paint_focus (style, window, gtk_widget_get_state (widget),
&area, widget, "trough",
widget->allocation.x + range->range_rect.x,
widget->allocation.y + range->range_rect.y,
allocation.x + range->range_rect.x,
allocation.y + range->range_rect.y,
range->range_rect.width,
range->range_rect.height);
switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)))
{
case GTK_ORIENTATION_HORIZONTAL:
area.x = widget->allocation.x + range->slider_start;
area.x = allocation.x + range->slider_start;
area.y = y + trough_border;
area.width = 2 * slider_size + 1;
area.height = h - 2 * trough_border;
......@@ -364,7 +370,7 @@ gimp_color_scale_expose (GtkWidget *widget,
case GTK_ORIENTATION_VERTICAL:
area.x = x + trough_border;
area.y = widget->allocation.y + range->slider_start;
area.y = allocation.y + range->slider_start;
area.width = w - 2 * trough_border;
area.height = 2 * slider_size + 1;
break;
......@@ -374,7 +380,7 @@ gimp_color_scale_expose (GtkWidget *widget,
{
GdkGC *gc;
gc = (GTK_WIDGET_IS_SENSITIVE (widget) ?
gc = (gtk_widget_is_sensitive (widget) ?
style->black_gc :
style->dark_gc[GTK_STATE_INSENSITIVE]);
......@@ -396,7 +402,7 @@ gimp_color_scale_expose (GtkWidget *widget,
gdk_gc_set_clip_rectangle (gc, NULL);
gc = (GTK_WIDGET_IS_SENSITIVE (widget) ?
gc = (gtk_widget_is_sensitive (widget) ?
style->white_gc :
style->light_gc[GTK_STATE_INSENSITIVE]);
......@@ -441,7 +447,8 @@ gimp_color_scale_new (GtkOrientation orientation,
scale->channel = channel;
GTK_RANGE (scale)->flippable = (orientation == GTK_ORIENTATION_HORIZONTAL);
gtk_range_set_flippable (GTK_RANGE (scale),
orientation == GTK_ORIENTATION_HORIZONTAL);
return GTK_WIDGET (scale);
}
......@@ -496,16 +503,23 @@ gimp_color_scale_set_color (GimpColorScale *scale,
static gboolean
should_invert (GtkRange *range)
{
gboolean inverted = gtk_range_get_inverted (range);
gboolean flippable = gtk_range_get_flippable (range);
if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) ==
GTK_ORIENTATION_HORIZONTAL)
return
(range->inverted && !range->flippable) ||
(range->inverted && range->flippable &&
gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_LTR) ||
(!range->inverted && range->flippable &&
gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL);
{
return
(inverted && !flippable) ||
(inverted && flippable &&
gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_LTR) ||
(!inverted && flippable &&
gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL);
}
else
return range->inverted;
{
return inverted;
}
}
static void
......
......@@ -643,8 +643,8 @@ gimp_color_select_xy_events (GtkWidget *widget,
GdkEvent *event,
GimpColorSelect *select)
{
gint width, height;
gint x, y;
GtkAllocation allocation;
gint x, y;
switch (event->type)
{
......@@ -701,13 +701,12 @@ gimp_color_select_xy_events (GtkWidget *widget,
gimp_color_select_draw_xy_marker (select, NULL);
width = select->xy_color->allocation.width;
height = select->xy_color->allocation.height;
gtk_widget_get_allocation (select->xy_color, &allocation);
if (width > 1 && height > 1)
if (allocation.width > 1 && allocation.height > 1)
{
select->pos[0] = (x * 255) / (width - 1);
select->pos[1] = 255 - (y * 255) / (height - 1);
select->pos[0] = (x * 255) / (allocation.width - 1);
select->pos[1] = 255 - (y * 255) / (allocation.height - 1);
}
select->pos[0] = CLAMP (select->pos[0], 0, 255);
......@@ -749,8 +748,8 @@ gimp_color_select_z_events (GtkWidget *widget,
GdkEvent *event,
GimpColorSelect *select)
{
gint height;
gint z;
GtkAllocation allocation;
gint z;
switch (event->type)
{
......@@ -804,10 +803,10 @@ gimp_color_select_z_events (GtkWidget *widget,
gimp_color_select_draw_z_marker (select, NULL);
height = select->z_color->allocation.height;
gtk_widget_get_allocation (select->z_color, &allocation);
if (height > 1)
select->pos[2] = 255 - (z * 255) / (height - 1);
if (allocation.height > 1)
select->pos[2] = 255 - (z * 255) / (allocation.height - 1);
select->pos[2] = CLAMP (select->pos[2], 0, 255);
......@@ -827,12 +826,15 @@ gimp_color_select_image_fill (GtkWidget *preview,
const GimpHSV *hsv,
const GimpRGB *rgb)
{
GtkAllocation allocation;
ColorSelectFill csf;
gtk_widget_get_allocation (preview, &allocation);
csf.update = update_procs[fill_type];
csf.width = preview->allocation.width;
csf.height = preview->allocation.height;
csf.width = allocation.width;
csf.height = allocation.height;
csf.hsv = *hsv;
csf.rgb = *rgb;
......@@ -856,17 +858,20 @@ static void
gimp_color_select_draw_z_marker (GimpColorSelect *select,
GdkRectangle *clip)
{
gint width;
gint height;
gint y;
gint minx;
gint miny;
GtkAllocation allocation;
gint width;
gint height;
gint y;
gint minx;
gint miny;
if (! select->gc)
return;
width = select->z_color->allocation.width;
height = select->z_color->allocation.height;
gtk_widget_get_allocation (select->z_color, &allocation);
width = allocation.width;
height = allocation.height;
if (width < 1 || height < 1)
return;
......@@ -897,16 +902,19 @@ static void
gimp_color_select_draw_xy_marker (GimpColorSelect *select,
GdkRectangle *clip)
{
gint width;
gint height;
gint x, y;
gint minx, miny;
GtkAllocation allocation;
gint width;
gint height;
gint x, y;
gint minx, miny;
if (! select->gc)
return;
width = select->xy_color->allocation.width;
height = select->xy_color->allocation.height;
gtk_widget_get_allocation (select->xy_color, &allocation);
width = allocation.width;
height = allocation.height;
if (width < 1 || height < 1)