summaryrefslogtreecommitdiff
path: root/demos/gtk-demo
diff options
context:
space:
mode:
Diffstat (limited to 'demos/gtk-demo')
-rw-r--r--demos/gtk-demo/changedisplay.c2
-rw-r--r--demos/gtk-demo/colorsel.c7
-rw-r--r--demos/gtk-demo/drawingarea.c20
-rw-r--r--demos/gtk-demo/hypertext.c10
-rw-r--r--demos/gtk-demo/offscreen_window.c61
-rw-r--r--demos/gtk-demo/offscreen_window2.c55
-rw-r--r--demos/gtk-demo/panes.c24
-rw-r--r--demos/gtk-demo/rotated_text.c12
-rw-r--r--demos/gtk-demo/toolpalette.c23
9 files changed, 136 insertions, 78 deletions
diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c
index b178364657..42baf3bc19 100644
--- a/demos/gtk-demo/changedisplay.c
+++ b/demos/gtk-demo/changedisplay.c
@@ -128,7 +128,7 @@ query_for_toplevel (GdkScreen *screen,
gtk_widget_show_all (popup);
cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
- if (gdk_pointer_grab (popup->window, FALSE,
+ if (gdk_pointer_grab (gtk_widget_get_window (popup), FALSE,
GDK_BUTTON_RELEASE_MASK,
NULL,
cursor,
diff --git a/demos/gtk-demo/colorsel.c b/demos/gtk-demo/colorsel.c
index bb7c978796..61bdbbf615 100644
--- a/demos/gtk-demo/colorsel.c
+++ b/demos/gtk-demo/colorsel.c
@@ -19,14 +19,17 @@ expose_event_callback (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
- if (widget->window)
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
+ if (window)
{
GtkStyle *style;
cairo_t *cr;
style = gtk_widget_get_style (widget);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
gdk_cairo_rectangle (cr, &event->area);
diff --git a/demos/gtk-demo/drawingarea.c b/demos/gtk-demo/drawingarea.c
index 84f3958c73..b0fbb071e9 100644
--- a/demos/gtk-demo/drawingarea.c
+++ b/demos/gtk-demo/drawingarea.c
@@ -25,15 +25,17 @@ scribble_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer data)
{
+ GtkAllocation allocation;
cairo_t *cr;
if (surface)
cairo_surface_destroy (surface);
- surface = gdk_window_create_similar_surface (widget->window,
+ gtk_widget_get_allocation (widget, &allocation);
+ surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
CAIRO_CONTENT_COLOR,
- widget->allocation.width,
- widget->allocation.height);
+ allocation.width,
+ allocation.height);
/* Initialize the surface to white */
cr = cairo_create (surface);
@@ -55,7 +57,7 @@ scribble_expose_event (GtkWidget *widget,
{
cairo_t *cr;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_set_source_surface (cr, surface, 0, 0);
gdk_cairo_rectangle (cr, &event->area);
@@ -89,7 +91,7 @@ draw_brush (GtkWidget *widget,
cairo_destroy (cr);
/* Now invalidate the affected region of the drawing area. */
- gdk_window_invalidate_rect (widget->window,
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget),
&update_rect,
FALSE);
}
@@ -146,6 +148,7 @@ checkerboard_expose (GtkWidget *da,
GdkEventExpose *event,
gpointer data)
{
+ GtkAllocation allocation;
gint i, j, xcount, ycount;
cairo_t *cr;
@@ -159,17 +162,18 @@ checkerboard_expose (GtkWidget *da,
* works.
*/
- cr = gdk_cairo_create (da->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (da));
gdk_cairo_rectangle (cr, &event->area);
cairo_clip (cr);
+ gtk_widget_get_allocation (da, &allocation);
xcount = 0;
i = SPACING;
- while (i < da->allocation.width)
+ while (i < allocation.width)
{
j = SPACING;
ycount = xcount % 2; /* start with even/odd depending on row */
- while (j < da->allocation.height)
+ while (j < allocation.height)
{
if (ycount % 2)
cairo_set_source_rgb (cr, 0.45777, 0, 0.45777);
diff --git a/demos/gtk-demo/hypertext.c b/demos/gtk-demo/hypertext.c
index 8b67c05a3a..91eec36a1b 100644
--- a/demos/gtk-demo/hypertext.c
+++ b/demos/gtk-demo/hypertext.c
@@ -225,7 +225,8 @@ motion_notify_event (GtkWidget *text_view,
set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y);
- gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
+ gdk_window_get_pointer (gtk_widget_get_window (text_view),
+ NULL, NULL, NULL);
return FALSE;
}
@@ -237,9 +238,10 @@ visibility_notify_event (GtkWidget *text_view,
GdkEventVisibility *event)
{
gint wx, wy, bx, by;
-
- gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
-
+
+ gdk_window_get_pointer (gtk_widget_get_window (text_view),
+ &wx, &wy, NULL);
+
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
GTK_TEXT_WINDOW_WIDGET,
wx, wy, &bx, &by);
diff --git a/demos/gtk-demo/offscreen_window.c b/demos/gtk-demo/offscreen_window.c
index 9a7477667d..e4b454d3c5 100644
--- a/demos/gtk-demo/offscreen_window.c
+++ b/demos/gtk-demo/offscreen_window.c
@@ -74,7 +74,7 @@ to_child (GtkRotatedBin *bin,
s = sin (bin->angle);
c = cos (bin->angle);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
w = c * child_area.width + s * child_area.height;
h = s * child_area.width + c * child_area.height;
@@ -114,7 +114,7 @@ to_parent (GtkRotatedBin *bin,
s = sin (bin->angle);
c = cos (bin->angle);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
w = c * child_area.width + s * child_area.height;
h = s * child_area.width + c * child_area.height;
@@ -188,7 +188,7 @@ pick_offscreen_child (GdkWindow *offscreen_window,
{
to_child (bin, widget_x, widget_y, &x, &y);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
if (x >= 0 && x < child_area.width &&
y >= 0 && y < child_area.height)
@@ -224,6 +224,9 @@ static void
gtk_rotated_bin_realize (GtkWidget *widget)
{
GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
+ GtkAllocation allocation;
+ GtkStyle *style;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
guint border_width;
@@ -231,12 +234,13 @@ gtk_rotated_bin_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = widget->allocation.height - 2 * border_width;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - 2 * border_width;
+ attributes.height = allocation.height - 2 * border_width;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_EXPOSURE_MASK
@@ -253,10 +257,11 @@ gtk_rotated_bin_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
- g_signal_connect (widget->window, "pick-embedded-child",
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+ g_signal_connect (window, "pick-embedded-child",
G_CALLBACK (pick_offscreen_child), bin);
attributes.window_type = GDK_WINDOW_OFFSCREEN;
@@ -264,24 +269,27 @@ gtk_rotated_bin_realize (GtkWidget *widget)
child_requisition.width = child_requisition.height = 0;
if (bin->child && gtk_widget_get_visible (bin->child))
{
- attributes.width = bin->child->allocation.width;
- attributes.height = bin->child->allocation.height;
+ GtkAllocation child_allocation;
+
+ gtk_widget_get_allocation (bin->child, &child_allocation);
+ attributes.width = child_allocation.width;
+ attributes.height = child_allocation.height;
}
bin->offscreen_window = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (bin->offscreen_window, widget);
if (bin->child)
gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
- gdk_offscreen_window_set_embedder (bin->offscreen_window, widget->window);
+ gdk_offscreen_window_set_embedder (bin->offscreen_window, window);
g_signal_connect (bin->offscreen_window, "to-embedder",
G_CALLBACK (offscreen_window_to_parent), bin);
g_signal_connect (bin->offscreen_window, "from-embedder",
G_CALLBACK (offscreen_window_from_parent), bin);
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, bin->offscreen_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, bin->offscreen_window, GTK_STATE_NORMAL);
gdk_window_show (bin->offscreen_window);
}
@@ -405,7 +413,7 @@ gtk_rotated_bin_size_allocate (GtkWidget *widget,
gint w, h;
gdouble s, c;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -413,7 +421,7 @@ gtk_rotated_bin_size_allocate (GtkWidget *widget,
h = allocation->height - border_width * 2;
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x + border_width,
allocation->y + border_width,
w, h);
@@ -454,7 +462,8 @@ static gboolean
gtk_rotated_bin_damage (GtkWidget *widget,
GdkEventExpose *event)
{
- gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget),
+ NULL, FALSE);
return TRUE;
}
@@ -464,13 +473,15 @@ gtk_rotated_bin_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkRotatedBin *bin = GTK_ROTATED_BIN (widget);
+ GdkWindow *window;
gint width, height;
gdouble s, c;
gdouble w, h;
if (gtk_widget_is_drawable (widget))
{
- if (event->window == widget->window)
+ window = gtk_widget_get_window (widget);
+ if (event->window == window)
{
GdkPixmap *pixmap;
GtkAllocation child_area;
@@ -479,9 +490,9 @@ gtk_rotated_bin_expose (GtkWidget *widget,
if (bin->child && gtk_widget_get_visible (bin->child))
{
pixmap = gdk_offscreen_window_get_pixmap (bin->offscreen_window);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
/* transform */
s = sin (bin->angle);
@@ -507,7 +518,7 @@ gtk_rotated_bin_expose (GtkWidget *widget,
}
else if (event->window == bin->offscreen_window)
{
- gtk_paint_flat_box (widget->style, event->window,
+ gtk_paint_flat_box (gtk_widget_get_style (widget), event->window,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
&event->area, widget, "blah",
0, 0, -1, -1);
diff --git a/demos/gtk-demo/offscreen_window2.c b/demos/gtk-demo/offscreen_window2.c
index 1c9b08479f..642fc46157 100644
--- a/demos/gtk-demo/offscreen_window2.c
+++ b/demos/gtk-demo/offscreen_window2.c
@@ -126,7 +126,7 @@ pick_offscreen_child (GdkWindow *offscreen_window,
{
to_child (bin, widget_x, widget_y, &x, &y);
- child_area = bin->child->allocation;
+ gtk_widget_get_allocation (bin->child, &child_area);
if (x >= 0 && x < child_area.width &&
y >= 0 && y < child_area.height)
@@ -162,6 +162,9 @@ static void
gtk_mirror_bin_realize (GtkWidget *widget)
{
GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
+ GtkAllocation allocation;
+ GtkStyle *style;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
guint border_width;
@@ -169,12 +172,13 @@ gtk_mirror_bin_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2 * border_width;
- attributes.height = widget->allocation.height - 2 * border_width;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - 2 * border_width;
+ attributes.height = allocation.height - 2 * border_width;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_EXPOSURE_MASK
@@ -191,10 +195,11 @@ gtk_mirror_bin_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
- g_signal_connect (widget->window, "pick-embedded-child",
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+ g_signal_connect (window, "pick-embedded-child",
G_CALLBACK (pick_offscreen_child), bin);
attributes.window_type = GDK_WINDOW_OFFSCREEN;
@@ -202,24 +207,27 @@ gtk_mirror_bin_realize (GtkWidget *widget)
child_requisition.width = child_requisition.height = 0;
if (bin->child && gtk_widget_get_visible (bin->child))
{
- attributes.width = bin->child->allocation.width;
- attributes.height = bin->child->allocation.height;
+ GtkAllocation child_allocation;
+
+ gtk_widget_get_allocation (bin->child, &child_allocation);
+ attributes.width = child_allocation.width;
+ attributes.height = child_allocation.height;
}
bin->offscreen_window = gdk_window_new (gtk_widget_get_root_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (bin->offscreen_window, widget);
if (bin->child)
gtk_widget_set_parent_window (bin->child, bin->offscreen_window);
- gdk_offscreen_window_set_embedder (bin->offscreen_window, widget->window);
+ gdk_offscreen_window_set_embedder (bin->offscreen_window, window);
g_signal_connect (bin->offscreen_window, "to-embedder",
G_CALLBACK (offscreen_window_to_parent), bin);
g_signal_connect (bin->offscreen_window, "from-embedder",
G_CALLBACK (offscreen_window_from_parent), bin);
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, bin->offscreen_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, bin->offscreen_window, GTK_STATE_NORMAL);
gdk_window_show (bin->offscreen_window);
}
@@ -323,7 +331,7 @@ gtk_mirror_bin_size_allocate (GtkWidget *widget,
gint w, h;
guint border_width;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -331,7 +339,7 @@ gtk_mirror_bin_size_allocate (GtkWidget *widget,
h = allocation->height - border_width * 2;
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x + border_width,
allocation->y + border_width,
w, h);
@@ -360,7 +368,8 @@ static gboolean
gtk_mirror_bin_damage (GtkWidget *widget,
GdkEventExpose *event)
{
- gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget),
+ NULL, FALSE);
return TRUE;
}
@@ -370,11 +379,13 @@ gtk_mirror_bin_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkMirrorBin *bin = GTK_MIRROR_BIN (widget);
+ GdkWindow *window;
gint width, height;
if (gtk_widget_is_drawable (widget))
{
- if (event->window == widget->window)
+ window = gtk_widget_get_window (widget);
+ if (event->window == window)
{
GdkPixmap *pixmap;
cairo_t *cr;
@@ -386,7 +397,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
pixmap = gdk_offscreen_window_get_pixmap (bin->offscreen_window);
gdk_drawable_get_size (pixmap, &width, &height);
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
cairo_save (cr);
@@ -426,7 +437,7 @@ gtk_mirror_bin_expose (GtkWidget *widget,
}
else if (event->window == bin->offscreen_window)
{
- gtk_paint_flat_box (widget->style, event->window,
+ gtk_paint_flat_box (gtk_widget_get_style (widget), event->window,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
&event->area, widget, "blah",
0, 0, -1, -1);
diff --git a/demos/gtk-demo/panes.c b/demos/gtk-demo/panes.c
index 60ee2dd635..3399653d10 100644
--- a/demos/gtk-demo/panes.c
+++ b/demos/gtk-demo/panes.c
@@ -17,17 +17,23 @@ void
toggle_resize (GtkWidget *widget,
GtkWidget *child)
{
- GtkPaned *paned = GTK_PANED (child->parent);
- gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
+ GtkWidget *parent;
+ GtkPaned *paned;
+ gboolean is_child1;
gboolean resize, shrink;
+ parent = gtk_widget_get_parent (child);
+ paned = GTK_PANED (parent);
+
+ is_child1 = (child == gtk_paned_get_child1 (paned));
+
gtk_container_child_get (GTK_CONTAINER (paned), child,
"resize", &resize,
"shrink", &shrink,
NULL);
g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (child->parent), child);
+ gtk_container_remove (GTK_CONTAINER (parent), child);
if (is_child1)
gtk_paned_pack1 (paned, child, !resize, shrink);
else
@@ -39,17 +45,23 @@ void
toggle_shrink (GtkWidget *widget,
GtkWidget *child)
{
- GtkPaned *paned = GTK_PANED (child->parent);
- gboolean is_child1 = (child == gtk_paned_get_child1 (paned));
+ GtkWidget *parent;
+ GtkPaned *paned;
+ gboolean is_child1;
gboolean resize, shrink;
+ parent = gtk_widget_get_parent (child);
+ paned = GTK_PANED (parent);
+
+ is_child1 = (child == gtk_paned_get_child1 (paned));
+
gtk_container_child_get (GTK_CONTAINER (paned), child,
"resize", &resize,
"shrink", &shrink,
NULL);
g_object_ref (child);
- gtk_container_remove (GTK_CONTAINER (child->parent), child);
+ gtk_container_remove (GTK_CONTAINER (parent), child);
if (is_child1)
gtk_paned_pack1 (paned, child, resize, !shrink);
else
diff --git a/demos/gtk-demo/rotated_text.c b/demos/gtk-demo/rotated_text.c
index b83b2c302b..4450ab0bff 100644
--- a/demos/gtk-demo/rotated_text.c
+++ b/demos/gtk-demo/rotated_text.c
@@ -99,6 +99,8 @@ rotated_text_expose_event (GtkWidget *widget,
#define N_WORDS 5
#define FONT "Serif 18"
+ GtkAllocation allocation;
+
PangoContext *context;
PangoLayout *layout;
PangoFontDescription *desc;
@@ -108,16 +110,20 @@ rotated_text_expose_event (GtkWidget *widget,
PangoAttrList *attrs;
- int width = widget->allocation.width;
- int height = widget->allocation.height;
+ int width;
+ int height;
double device_radius;
int i;
+ gtk_widget_get_allocation (widget, &allocation);
+ width = allocation.width;
+ height = allocation.height;
+
/* Create a cairo context and set up a transformation matrix so that the user
* space coordinates for the centered square where we draw are [-RADIUS, RADIUS],
* [-RADIUS, RADIUS].
* We first center, then change the scale. */
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
device_radius = MIN (width, height) / 2.;
cairo_translate (cr,
device_radius + (width - 2 * device_radius) / 2,
diff --git a/demos/gtk-demo/toolpalette.c b/demos/gtk-demo/toolpalette.c
index e9bc926b15..b6f12283be 100644
--- a/demos/gtk-demo/toolpalette.c
+++ b/demos/gtk-demo/toolpalette.c
@@ -84,15 +84,18 @@ static gboolean
canvas_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
cairo_t *cr;
GList *iter;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
+ gtk_widget_get_allocation (widget, &allocation);
+
cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
cairo_fill (cr);
for (iter = canvas_items; iter; iter = iter->next)
@@ -173,6 +176,7 @@ palette_drag_data_received (GtkWidget *widget,
guint time,
gpointer data)
{
+ GtkAllocation allocation;
GtkToolItemGroup *drop_group = NULL;
GtkWidget *drag_palette = gtk_drag_get_source_widget (context);
GtkWidget *drag_item = NULL;
@@ -193,10 +197,13 @@ palette_drag_data_received (GtkWidget *widget,
GTK_TOOL_ITEM_GROUP (drag_item),
drop_group);
else if (GTK_IS_TOOL_ITEM (drag_item) && drop_group)
- palette_drop_item (GTK_TOOL_ITEM (drag_item),
- drop_group,
- x - GTK_WIDGET (drop_group)->allocation.x,
- y - GTK_WIDGET (drop_group)->allocation.y);
+ {
+ gtk_widget_get_allocation (GTK_WIDGET (drop_group), &allocation);
+ palette_drop_item (GTK_TOOL_ITEM (drag_item),
+ drop_group,
+ x - allocation.x,
+ y - allocation.y);
+ }
}
/********************************/
@@ -372,11 +379,13 @@ on_combo_orientation_changed (GtkComboBox *combo_box,
gpointer user_data)
{
GtkToolPalette *palette = GTK_TOOL_PALETTE (user_data);
- GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW (GTK_WIDGET (palette)->parent);
+ GtkScrolledWindow *sw;
GtkTreeModel *model = gtk_combo_box_get_model (combo_box);
GtkTreeIter iter;
gint val = 0;
+ sw = GTK_SCROLLED_WINDOW (gtk_widget_get_parent (GTK_WIDGET (palette)));
+
if (!gtk_combo_box_get_active_iter (combo_box, &iter))
return;