[gdl] Use accessor functions instead direct access. First patch
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdl] Use accessor functions instead direct access. First patch
- Date: Sun, 6 Jun 2010 03:55:07 +0000 (UTC)
commit fef8d6d96091320917b6ee59c79012f7de3636bf
Author: Andre Klapper <a9016009 gmx de>
Date: Fri Apr 9 12:25:03 2010 +0200
Use accessor functions instead direct access. First patch
Partially fixes https://bugzilla.gnome.org/show_bug.cgi?id=612497
gdl/gdl-dock-item-button-image.c | 2 +-
gdl/gdl-dock-item-grip.c | 79 ++++++++++++----------
gdl/gdl-dock-item.c | 138 +++++++++++++++++++++++---------------
gdl/gdl-dock-master.c | 14 +++--
gdl/gdl-dock-notebook.c | 2 +-
gdl/gdl-dock-object.c | 8 +-
gdl/gdl-dock-paned.c | 36 ++++++----
gdl/gdl-dock.c | 40 +++++++-----
8 files changed, 187 insertions(+), 132 deletions(-)
---
diff --git a/gdl/gdl-dock-item-button-image.c b/gdl/gdl-dock-item-button-image.c
index ce5c33e..fbf78a9 100644
--- a/gdl/gdl-dock-item-button-image.c
+++ b/gdl/gdl-dock-item-button-image.c
@@ -118,7 +118,7 @@ static void
gdl_dock_item_button_image_instance_init (
GdlDockItemButtonImage *button_image)
{
- GTK_WIDGET_SET_FLAGS (button_image, GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (button_image), FALSE);
}
static void
diff --git a/gdl/gdl-dock-item-grip.c b/gdl/gdl-dock-item-grip.c
index 728cfb6..68eae72 100644
--- a/gdl/gdl-dock-item-grip.c
+++ b/gdl/gdl-dock-item-grip.c
@@ -107,29 +107,33 @@ gdl_dock_item_grip_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GdlDockItemGrip *grip;
+ GtkAllocation allocation;
GdkRectangle handle_area;
GdkRectangle expose_area;
grip = GDL_DOCK_ITEM_GRIP (widget);
-
+
if(grip->_priv->handle_shown) {
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
- handle_area.x = widget->allocation.x;
- handle_area.y = widget->allocation.y;
+ handle_area.x = allocation.x;
+ handle_area.y = allocation.y;
handle_area.width = DRAG_HANDLE_SIZE;
- handle_area.height = widget->allocation.height;
+ handle_area.height = allocation.height;
} else {
- handle_area.x = widget->allocation.x + widget->allocation.width
- - DRAG_HANDLE_SIZE;
- handle_area.y = widget->allocation.y;
+ handle_area.x = allocation.x + allocation.width - DRAG_HANDLE_SIZE;
+ handle_area.y = allocation.y;
handle_area.width = DRAG_HANDLE_SIZE;
- handle_area.height = widget->allocation.height;
+ handle_area.height = allocation.height;
}
if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) {
- gtk_paint_handle (widget->style, widget->window, widget->state,
+ gtk_paint_handle (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget),
GTK_SHADOW_NONE, &expose_area, widget,
"handlebox", handle_area.x, handle_area.y,
handle_area.width, handle_area.height,
@@ -297,7 +301,7 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
{
GtkWidget *image;
- GTK_WIDGET_SET_FLAGS (grip, GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE);
grip->_priv = g_new0 (GdlDockItemGripPrivate, 1);
grip->_priv->label = NULL;
@@ -307,8 +311,8 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
gtk_widget_push_composite_child ();
grip->_priv->close_button = gtk_button_new ();
gtk_widget_pop_composite_child ();
-
- GTK_WIDGET_UNSET_FLAGS (grip->_priv->close_button, GTK_CAN_FOCUS);
+
+ gtk_widget_set_can_focus (grip->_priv->close_button, FALSE);
gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip));
gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE);
gtk_widget_show (grip->_priv->close_button);
@@ -324,8 +328,8 @@ gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
gtk_widget_push_composite_child ();
grip->_priv->iconify_button = gtk_button_new ();
gtk_widget_pop_composite_child ();
-
- GTK_WIDGET_UNSET_FLAGS (grip->_priv->iconify_button, GTK_CAN_FOCUS);
+
+ gtk_widget_set_can_focus (grip->_priv->iconify_button, FALSE);
gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip));
gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE);
gtk_widget_show (grip->_priv->iconify_button);
@@ -354,15 +358,18 @@ gdl_dock_item_grip_realize (GtkWidget *widget)
g_return_if_fail (grip->_priv != NULL);
if (!grip->title_window) {
+ GtkAllocation allocation;
GdkWindowAttr attributes;
GdkCursor *cursor;
g_return_if_fail (grip->_priv->label != NULL);
- attributes.x = grip->_priv->label->allocation.x;
- attributes.y = grip->_priv->label->allocation.y;
- attributes.width = grip->_priv->label->allocation.width;
- attributes.height = grip->_priv->label->allocation.height;
+ gtk_widget_get_allocation (grip->_priv->label, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = GDK_ALL_EVENTS_MASK;
@@ -373,11 +380,11 @@ gdl_dock_item_grip_realize (GtkWidget *widget)
gdk_window_set_user_data (grip->title_window, grip);
/* Unref the ref from parent realize for NO_WINDOW */
- g_object_unref (widget->window);
+ g_object_unref (gtk_widget_get_window (widget));
/* Need to ref widget->window, because parent unrealize unrefs it */
- widget->window = g_object_ref (grip->title_window);
- GTK_WIDGET_UNSET_FLAGS(widget, GTK_NO_WINDOW);
+ gtk_widget_set_window (widget, g_object_ref (grip->title_window));
+ gtk_widget_set_has_window (widget, TRUE);
/* Unset the background so as to make the colour match the parent window */
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, NULL);
@@ -400,7 +407,7 @@ gdl_dock_item_grip_unrealize (GtkWidget *widget)
GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
if (grip->title_window) {
- GTK_WIDGET_SET_FLAGS(widget, GTK_NO_WINDOW);
+ gtk_widget_set_has_window (widget, FALSE);
gdk_window_set_user_data (grip->title_window, NULL);
gdk_window_destroy (grip->title_window);
grip->title_window = NULL;
@@ -436,18 +443,18 @@ gdl_dock_item_grip_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkRequisition child_requisition;
- GtkContainer *container;
GdlDockItemGrip *grip;
gint layout_height = 0;
+ guint border_width;
g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
g_return_if_fail (requisition != NULL);
- container = GTK_CONTAINER (widget);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
grip = GDL_DOCK_ITEM_GRIP (widget);
- requisition->width = container->border_width * 2/* + ALIGN_BORDER*/;
- requisition->height = container->border_width * 2;
+ requisition->width = border_width * 2/* + ALIGN_BORDER*/;
+ requisition->height = border_width * 2;
if(grip->_priv->handle_shown)
requisition->width += DRAG_HANDLE_SIZE;
@@ -476,17 +483,17 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GdlDockItemGrip *grip;
- GtkContainer *container;
GtkRequisition close_requisition = { 0, };
GtkRequisition iconify_requisition = { 0, };
GtkAllocation child_allocation;
GdkRectangle label_area;
+ guint border_width;
g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget));
g_return_if_fail (allocation != NULL);
grip = GDL_DOCK_ITEM_GRIP (widget);
- container = GTK_CONTAINER (widget);
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation);
@@ -497,17 +504,17 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
/* Calculate the Minimum Width where buttons will fit */
int min_width = close_requisition.width + iconify_requisition.width
- + container->border_width * 2;
+ + border_width * 2;
if(grip->_priv->handle_shown)
min_width += DRAG_HANDLE_SIZE;
const gboolean space_for_buttons = (allocation->width >= min_width);
/* Set up the rolling child_allocation rectangle */
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x = container->border_width/* + ALIGN_BORDER*/;
+ child_allocation.x = border_width/* + ALIGN_BORDER*/;
else
- child_allocation.x = allocation->width - container->border_width;
- child_allocation.y = container->border_width;
+ child_allocation.x = allocation->width - border_width;
+ child_allocation.y = border_width;
/* Layout Close Button */
if (gtk_widget_get_visible (grip->_priv->close_button)) {
@@ -550,7 +557,7 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
/* Layout the Grip Handle*/
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
child_allocation.width = child_allocation.x;
- child_allocation.x = container->border_width/* + ALIGN_BORDER*/;
+ child_allocation.x = border_width/* + ALIGN_BORDER*/;
if(grip->_priv->handle_shown) {
child_allocation.x += DRAG_HANDLE_SIZE;
@@ -568,8 +575,8 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
if(child_allocation.width < 0)
child_allocation.width = 0;
- child_allocation.y = container->border_width;
- child_allocation.height = allocation->height - container->border_width * 2;
+ child_allocation.y = border_width;
+ child_allocation.height = allocation->height - border_width * 2;
if(grip->_priv->label) {
gtk_widget_size_allocate (grip->_priv->label, &child_allocation);
}
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 70f335e..2167f94 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -406,7 +406,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
static void
gdl_dock_item_instance_init (GdlDockItem *item)
{
- GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (item), GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (item), TRUE);
item->child = NULL;
@@ -732,9 +732,11 @@ static void
gdl_dock_item_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
+ GdlDockItem *item;
GtkRequisition child_requisition;
GtkRequisition grip_requisition;
- GdlDockItem *item;
+ GtkStyle *style;
+ guint border_width;
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
g_return_if_fail (requisition != NULL);
@@ -778,8 +780,11 @@ gdl_dock_item_size_request (GtkWidget *widget,
requisition->width = 0;
}
- requisition->width += (GTK_CONTAINER (widget)->border_width + widget->style->xthickness) * 2;
- requisition->height += (GTK_CONTAINER (widget)->border_width + widget->style->ythickness) * 2;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (widget);
+
+ requisition->width += (border_width + style->xthickness) * 2;
+ requisition->height += (border_width + style->ythickness) * 2;
widget->requisition = *requisition;
}
@@ -795,31 +800,33 @@ gdl_dock_item_size_allocate (GtkWidget *widget,
item = GDL_DOCK_ITEM (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
/* Once size is allocated, preferred size is no longer necessary */
item->_priv->preferred_height = -1;
item->_priv->preferred_width = -1;
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
if (item->child && gtk_widget_get_visible (item->child)) {
GtkAllocation child_allocation;
- int border_width;
+ GtkStyle *style;
+ guint border_width;
- border_width = GTK_CONTAINER (widget)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (widget);
- child_allocation.x = border_width + widget->style->xthickness;
- child_allocation.y = border_width + widget->style->ythickness;
+ child_allocation.x = border_width + style->xthickness;
+ child_allocation.y = border_width + style->ythickness;
child_allocation.width = allocation->width
- - 2 * (border_width + widget->style->xthickness);
+ - 2 * (border_width + style->xthickness);
child_allocation.height = allocation->height
- - 2 * (border_width + widget->style->ythickness);
+ - 2 * (border_width + style->ythickness);
if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) {
GtkAllocation grip_alloc = child_allocation;
@@ -856,11 +863,11 @@ gdl_dock_item_map (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, TRUE);
item = GDL_DOCK_ITEM (widget);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
if (item->child
&& gtk_widget_get_visible (item->child)
@@ -881,11 +888,11 @@ gdl_dock_item_unmap (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, FALSE);
item = GDL_DOCK_ITEM (widget);
- gdk_window_hide (widget->window);
+ gdk_window_hide (gtk_widget_get_window (widget));
if (item->_priv->grip)
gtk_widget_unmap (item->_priv->grip);
@@ -894,22 +901,25 @@ gdl_dock_item_unmap (GtkWidget *widget)
static void
gdl_dock_item_realize (GtkWidget *widget)
{
+ GdlDockItem *item;
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
- GdlDockItem *item;
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
item = GDL_DOCK_ITEM (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
/* widget window */
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -920,36 +930,41 @@ gdl_dock_item_realize (GtkWidget *widget)
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
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);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window,
+ 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);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), window,
gtk_widget_get_state (GTK_WIDGET (item)));
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ gdk_window_set_back_pixmap (window, NULL, TRUE);
if (item->child)
- gtk_widget_set_parent_window (item->child, widget->window);
-
+ gtk_widget_set_parent_window (item->child, window);
+
if (item->_priv->grip)
- gtk_widget_set_parent_window (item->_priv->grip, widget->window);
+ gtk_widget_set_parent_window (item->_priv->grip, window);
}
static void
gdl_dock_item_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
+ GdkWindow *window;
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
if (gtk_widget_get_realized (widget) &&
gtk_widget_get_has_window (widget))
{
- gtk_style_set_background (widget->style, widget->window,
- widget->state);
+ window = gtk_widget_get_window (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window,
+ gtk_widget_get_state (widget));
if (gtk_widget_is_drawable (widget))
- gdk_window_clear (widget->window);
+ gdk_window_clear (window);
}
}
@@ -961,8 +976,8 @@ gdl_dock_item_paint (GtkWidget *widget,
item = GDL_DOCK_ITEM (widget);
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
GTK_SHADOW_NONE,
&event->area, widget,
@@ -978,7 +993,8 @@ gdl_dock_item_expose (GtkWidget *widget,
g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- if (gtk_widget_is_drawable (widget) && event->window == widget->window) {
+ if (gtk_widget_is_drawable (widget) &&
+ event->window == gtk_widget_get_window (widget)) {
gdl_dock_item_paint (widget, event);
GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event));
}
@@ -997,10 +1013,11 @@ gdl_dock_item_button_changed (GtkWidget *widget,
GdkEventButton *event)
{
GdlDockItem *item;
+ GtkAllocation allocation;
+ GdkCursor *cursor;
gboolean locked;
gboolean event_handled;
gboolean in_handle;
- GdkCursor *cursor;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE);
@@ -1015,13 +1032,15 @@ gdl_dock_item_button_changed (GtkWidget *widget,
event_handled = FALSE;
+ gtk_widget_get_allocation (item->_priv->grip, &allocation);
+
/* Check if user clicked on the drag handle. */
switch (item->orientation) {
case GTK_ORIENTATION_HORIZONTAL:
- in_handle = event->x < item->_priv->grip->allocation.width;
+ in_handle = event->x < allocation.width;
break;
case GTK_ORIENTATION_VERTICAL:
- in_handle = event->y < item->_priv->grip->allocation.height;
+ in_handle = event->y < allocation.height;
break;
default:
in_handle = FALSE;
@@ -1151,7 +1170,7 @@ gdl_dock_item_dock_request (GdlDockObject *object,
/* we get (x,y) in our allocation coordinates system */
/* Get item's allocation. */
- alloc = &(GTK_WIDGET (object)->allocation);
+ gtk_widget_get_allocation (GTK_WIDGET (object), alloc);
/* Get coordinates relative to our window. */
rel_x = x - alloc->x;
@@ -1260,6 +1279,7 @@ gdl_dock_item_dock (GdlDockObject *object,
{
GdlDockObject *new_parent = NULL;
GdlDockObject *parent, *requestor_parent;
+ GtkAllocation allocation;
gboolean add_ourselves_first = FALSE;
guint available_space=0;
@@ -1274,8 +1294,9 @@ gdl_dock_item_dock (GdlDockObject *object,
gdl_dock_item_preferred_size (GDL_DOCK_ITEM (parent), &parent_req);
else
{
- parent_req.height = GTK_WIDGET (parent)->allocation.height;
- parent_req.width = GTK_WIDGET (parent)->allocation.width;
+ gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation);
+ parent_req.height = allocation.height;
+ parent_req.width = allocation.width;
}
/* If preferred size is not set on the requestor (perhaps a new item),
@@ -1563,6 +1584,7 @@ gdl_dock_item_tab_button (GtkWidget *widget,
gpointer data)
{
GdlDockItem *item;
+ GtkAllocation allocation;
item = GDL_DOCK_ITEM (data);
@@ -1575,8 +1597,9 @@ gdl_dock_item_tab_button (GtkWidget *widget,
drag handle */
switch (item->orientation) {
case GTK_ORIENTATION_HORIZONTAL:
+ gtk_widget_get_allocation (GTK_WIDGET (data), &allocation);
/*item->dragoff_x = item->_priv->grip_size / 2;*/
- item->dragoff_y = GTK_WIDGET (data)->allocation.height / 2;
+ item->dragoff_y = allocation.height / 2;
break;
case GTK_ORIENTATION_VERTICAL:
/*item->dragoff_x = GTK_WIDGET (data)->allocation.width / 2;*/
@@ -1979,6 +2002,8 @@ gdl_dock_item_unbind (GdlDockItem *item)
void
gdl_dock_item_hide_item (GdlDockItem *item)
{
+ GtkAllocation allocation;
+
g_return_if_fail (item != NULL);
if (!GDL_DOCK_OBJECT_ATTACHED (item))
@@ -2005,8 +2030,9 @@ gdl_dock_item_hide_item (GdlDockItem *item)
"floaty",&y,
NULL);
} else {
- item->_priv->preferred_width=GTK_WIDGET (item)->allocation.width;
- item->_priv->preferred_height=GTK_WIDGET (item)->allocation.height;
+ gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
+ item->_priv->preferred_width = allocation.width;
+ item->_priv->preferred_height = allocation.height;
}
item->_priv->ph = GDL_DOCK_PLACEHOLDER (
g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
@@ -2186,13 +2212,15 @@ void
gdl_dock_item_preferred_size (GdlDockItem *item,
GtkRequisition *req)
{
+ GtkAllocation allocation;
+
if (!req)
return;
- req->width = MAX (item->_priv->preferred_width,
- GTK_WIDGET (item)->allocation.width);
- req->height = MAX (item->_priv->preferred_height,
- GTK_WIDGET (item)->allocation.height);
+ gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
+
+ req->width = MAX (item->_priv->preferred_width, allocation.width);
+ req->height = MAX (item->_priv->preferred_height, allocation.height);
}
diff --git a/gdl/gdl-dock-master.c b/gdl/gdl-dock-master.c
index 3026a00..873e9ac 100644
--- a/gdl/gdl-dock-master.c
+++ b/gdl/gdl-dock-master.c
@@ -461,6 +461,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
GdlDockMaster *master;
GdlDockRequest my_request, *request;
GdkWindow *window;
+ GdkWindow *widget_window, *dock_window;
gint win_x, win_y;
gint x, y;
GdlDock *dock = NULL;
@@ -485,15 +486,17 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
if (GTK_IS_WIDGET (widget)) {
while (widget && (!GDL_IS_DOCK (widget) ||
GDL_DOCK_OBJECT_GET_MASTER (widget) != master))
- widget = widget->parent;
+ widget = gtk_widget_get_parent (widget);
if (widget) {
gint win_w, win_h;
+ widget_window = gtk_widget_get_window (widget);
+
/* verify that the pointer is still in that dock
(the user could have moved it) */
- gdk_window_get_geometry (widget->window,
+ gdk_window_get_geometry (widget_window,
NULL, NULL, &win_w, &win_h, NULL);
- gdk_window_get_origin (widget->window, &win_x, &win_y);
+ gdk_window_get_origin (widget_window, &win_x, &win_y);
if (root_x >= win_x && root_x < win_x + win_w &&
root_y >= win_y && root_y < win_y + win_h)
dock = GDL_DOCK (widget);
@@ -501,10 +504,11 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
}
}
+ dock_window = gtk_widget_get_window (GTK_WIDGET (dock));
if (dock) {
/* translate root coordinates into dock object coordinates
(i.e. widget coordinates) */
- gdk_window_get_origin (GTK_WIDGET (dock)->window, &win_x, &win_y);
+ gdk_window_get_origin (dock_window, &win_x, &win_y);
x = root_x - win_x;
y = root_y - win_y;
may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock),
@@ -518,7 +522,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item,
dock = GDL_DOCK (l->data);
/* translate root coordinates into dock object coordinates
(i.e. widget coordinates) */
- gdk_window_get_origin (GTK_WIDGET (dock)->window, &win_x, &win_y);
+ gdk_window_get_origin (dock_window, &win_x, &win_y);
x = root_x - win_x;
y = root_y - win_y;
may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock),
diff --git a/gdl/gdl-dock-notebook.c b/gdl/gdl-dock-notebook.c
index 21179de..4c3741e 100644
--- a/gdl/gdl-dock-notebook.c
+++ b/gdl/gdl-dock-notebook.c
@@ -272,7 +272,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
notebook = GDL_DOCK_NOTEBOOK (data);
/* deactivate old tablabel */
- if (nb->cur_page) {
+ if (gtk_notebook_get_current_page (nb)) {
tablabel = gtk_notebook_get_tab_label (
nb, gtk_notebook_get_nth_page (
nb, gtk_notebook_get_current_page (nb)));
diff --git a/gdl/gdl-dock-object.c b/gdl/gdl-dock-object.c
index 89897e7..ac6196c 100644
--- a/gdl/gdl-dock-object.c
+++ b/gdl/gdl-dock-object.c
@@ -360,8 +360,8 @@ gdl_dock_object_real_detach (GdlDockObject *object,
GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED);
parent = gdl_dock_object_get_parent_object (object);
widget = GTK_WIDGET (object);
- if (widget->parent)
- gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
+ if (gtk_widget_get_parent (widget))
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (parent))), widget);
if (parent)
gdl_dock_object_reduce (parent);
}
@@ -495,9 +495,9 @@ gdl_dock_object_get_parent_object (GdlDockObject *object)
g_return_val_if_fail (object != NULL, NULL);
- parent = GTK_WIDGET (object)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (object));
while (parent && !GDL_IS_DOCK_OBJECT (parent)) {
- parent = parent->parent;
+ parent = gtk_widget_get_parent (parent);
}
return parent ? GDL_DOCK_OBJECT (parent) : NULL;
diff --git a/gdl/gdl-dock-paned.c b/gdl/gdl-dock-paned.c
index 6ff98fa..3b2289c 100644
--- a/gdl/gdl-dock-paned.c
+++ b/gdl/gdl-dock-paned.c
@@ -304,8 +304,9 @@ gdl_dock_paned_add (GtkContainer *container,
GtkWidget *widget)
{
GdlDockItem *item;
- GtkPaned *paned;
GdlDockPlacement pos = GDL_DOCK_NONE;
+ GtkPaned *paned;
+ GtkWidget *child1, *child2;
g_return_if_fail (container != NULL && widget != NULL);
g_return_if_fail (GDL_IS_DOCK_PANED (container));
@@ -313,13 +314,16 @@ gdl_dock_paned_add (GtkContainer *container,
item = GDL_DOCK_ITEM (container);
g_return_if_fail (item->child != NULL);
+
paned = GTK_PANED (item->child);
- g_return_if_fail (!paned->child1 || !paned->child2);
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+ g_return_if_fail (!child1 || !child2);
- if (!paned->child1)
+ if (!child1)
pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
GDL_DOCK_LEFT : GDL_DOCK_TOP;
- else if (!paned->child2)
+ else if (!child2)
pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM;
@@ -405,8 +409,8 @@ gdl_dock_paned_dock_request (GdlDockObject *object,
item = GDL_DOCK_ITEM (object);
/* Get item's allocation. */
- alloc = &(GTK_WIDGET (object)->allocation);
- bw = GTK_CONTAINER (object)->border_width;
+ gtk_widget_get_allocation (GTK_WIDGET (object), alloc);
+ bw = gtk_container_get_border_width (GTK_CONTAINER (object));
/* Get coordinates relative to our window. */
rel_x = x - alloc->x;
@@ -533,6 +537,7 @@ gdl_dock_paned_dock (GdlDockObject *object,
GValue *other_data)
{
GtkPaned *paned;
+ GtkWidget *child1, *child2;
gboolean done = FALSE;
gboolean hresize = FALSE;
gboolean wresize = FALSE;
@@ -553,22 +558,25 @@ gdl_dock_paned_dock (GdlDockObject *object,
wresize = TRUE;
}
+ child1 = gtk_paned_get_child1 (paned);
+ child2 = gtk_paned_get_child2 (paned);
+
/* see if we can dock the item in our paned */
switch (GDL_DOCK_ITEM (object)->orientation) {
case GTK_ORIENTATION_HORIZONTAL:
- if (!paned->child1 && position == GDL_DOCK_LEFT) {
+ if (!child1 && position == GDL_DOCK_LEFT) {
gtk_paned_pack1 (paned, GTK_WIDGET (requestor), FALSE, FALSE);
done = TRUE;
- } else if (!paned->child2 && position == GDL_DOCK_RIGHT) {
+ } else if (!child2 && position == GDL_DOCK_RIGHT) {
gtk_paned_pack2 (paned, GTK_WIDGET (requestor), TRUE, FALSE);
done = TRUE;
}
break;
case GTK_ORIENTATION_VERTICAL:
- if (!paned->child1 && position == GDL_DOCK_TOP) {
+ if (!child1 && position == GDL_DOCK_TOP) {
gtk_paned_pack1 (paned, GTK_WIDGET (requestor), hresize, FALSE);
done = TRUE;
- } else if (!paned->child2 && position == GDL_DOCK_BOTTOM) {
+ } else if (!child2 && position == GDL_DOCK_BOTTOM) {
gtk_paned_pack2 (paned, GTK_WIDGET (requestor), hresize, FALSE);
done = TRUE;
}
@@ -609,8 +617,8 @@ gdl_dock_paned_set_orientation (GdlDockItem *item,
if (old_paned) {
new_paned = GTK_PANED (item->child);
- child1 = old_paned->child1;
- child2 = old_paned->child2;
+ child1 = gtk_paned_get_child1 (old_paned);
+ child2 = gtk_paned_get_child2 (old_paned);
if (child1) {
g_object_ref (child1);
@@ -640,10 +648,10 @@ gdl_dock_paned_child_placement (GdlDockObject *object,
if (item->child) {
paned = GTK_PANED (item->child);
- if (GTK_WIDGET (child) == paned->child1)
+ if (GTK_WIDGET (child) == gtk_paned_get_child1 (paned))
pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
GDL_DOCK_LEFT : GDL_DOCK_TOP;
- else if (GTK_WIDGET (child) == paned->child2)
+ else if (GTK_WIDGET (child) == gtk_paned_get_child2 (paned))
pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ?
GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM;
}
diff --git a/gdl/gdl-dock.c b/gdl/gdl-dock.c
index 4620b95..dd969dd 100644
--- a/gdl/gdl-dock.c
+++ b/gdl/gdl-dock.c
@@ -263,7 +263,7 @@ gdl_dock_class_init (GdlDockClass *klass)
static void
gdl_dock_instance_init (GdlDock *dock)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dock), GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE);
dock->root = NULL;
dock->_priv = g_new0 (GdlDockPrivate, 1);
@@ -548,7 +548,7 @@ gdl_dock_size_request (GtkWidget *widget,
dock = GDL_DOCK (widget);
container = GTK_CONTAINER (widget);
- border_width = container->border_width;
+ border_width = gtk_container_get_border_width (container);
/* make request to root */
if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root)))
@@ -577,9 +577,9 @@ gdl_dock_size_allocate (GtkWidget *widget,
dock = GDL_DOCK (widget);
container = GTK_CONTAINER (widget);
- border_width = container->border_width;
+ border_width = gtk_container_get_border_width (container);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
/* reduce allocation by border width */
allocation->x += border_width;
@@ -763,6 +763,7 @@ static void
gdl_dock_reduce (GdlDockObject *object)
{
GdlDock *dock = GDL_DOCK (object);
+ GtkWidget *parent;
if (dock->root)
return;
@@ -776,8 +777,9 @@ gdl_dock_reduce (GdlDockObject *object)
gtk_widget_hide (GTK_WIDGET (dock));
else {
GtkWidget *widget = GTK_WIDGET (object);
- if (widget->parent)
- gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
+ parent = gtk_widget_get_parent (widget);
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent), widget);
}
}
}
@@ -802,8 +804,8 @@ gdl_dock_dock_request (GdlDockObject *object,
dock = GDL_DOCK (object);
/* Get dock size. */
- alloc = &(GTK_WIDGET (dock)->allocation);
- bw = GTK_CONTAINER (dock)->border_width;
+ gtk_widget_get_allocation (GTK_WIDGET (dock), alloc);
+ bw = gtk_container_get_border_width (GTK_CONTAINER (dock));
/* Get coordinates relative to our allocation area. */
rel_x = x - alloc->x;
@@ -1057,22 +1059,25 @@ static GdlDockPlacement
gdl_dock_refine_placement (GdlDock *dock, GdlDockItem *dock_item,
GdlDockPlacement placement)
{
+ GtkAllocation allocation;
GtkRequisition object_size;
gdl_dock_item_preferred_size (dock_item, &object_size);
- g_return_val_if_fail (GTK_WIDGET (dock)->allocation.width > 0, placement);
- g_return_val_if_fail (GTK_WIDGET (dock)->allocation.height > 0, placement);
+ gtk_widget_get_allocation (GTK_WIDGET (dock), &allocation);
+
+ g_return_val_if_fail (allocation.width > 0, placement);
+ g_return_val_if_fail (allocation.height > 0, placement);
g_return_val_if_fail (object_size.width > 0, placement);
g_return_val_if_fail (object_size.height > 0, placement);
if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT) {
/* Check if dock_object touches center in terms of width */
- if (GTK_WIDGET (dock)->allocation.width/2 > object_size.width) {
+ if (allocation.width/2 > object_size.width) {
return GDL_DOCK_CENTER;
}
} else if (placement == GDL_DOCK_TOP || placement == GDL_DOCK_BOTTOM) {
/* Check if dock_object touches center in terms of height */
- if (GTK_WIDGET (dock)->allocation.height/2 > object_size.height) {
+ if (allocation.height/2 > object_size.height) {
return GDL_DOCK_CENTER;
}
}
@@ -1326,6 +1331,7 @@ gdl_dock_xor_rect (GdlDock *dock,
GdkRectangle *rect)
{
GtkWidget *widget;
+ GdkWindow *window;
gint8 dash_list [2];
widget = GTK_WIDGET (dock);
@@ -1337,7 +1343,7 @@ gdl_dock_xor_rect (GdlDock *dock,
values.function = GDK_INVERT;
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
dock->_priv->xor_gc = gdk_gc_new_with_values
- (widget->window, &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW);
+ (gtk_widget_get_window (widget), &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW);
} else
return;
};
@@ -1346,19 +1352,21 @@ gdl_dock_xor_rect (GdlDock *dock,
GDK_LINE_ON_OFF_DASH,
GDK_CAP_NOT_LAST,
GDK_JOIN_BEVEL);
-
+
+ window = gtk_widget_get_window (widget);
+
dash_list [0] = 1;
dash_list [1] = 1;
gdk_gc_set_dashes (dock->_priv->xor_gc, 1, dash_list, 2);
- gdk_draw_rectangle (widget->window, dock->_priv->xor_gc, 0,
+ gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE,
rect->x, rect->y,
rect->width, rect->height);
gdk_gc_set_dashes (dock->_priv->xor_gc, 0, dash_list, 2);
- gdk_draw_rectangle (widget->window, dock->_priv->xor_gc, 0,
+ gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE,
rect->x + 1, rect->y + 1,
rect->width - 2, rect->height - 2);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]